]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
10eef5ff2ac329e4214ab33c48092d97fb8690ee
[libs/gltk.git] / source / part.h
1 #ifndef MSP_GLTK_PART_H_
2 #define MSP_GLTK_PART_H_
3
4 #include <string>
5 #include <msp/datafile/objectloader.h>
6 #include "geometry.h"
7 #include "mspgltk_api.h"
8 #include "state.h"
9
10 namespace Msp {
11 namespace GLtk {
12
13 class Graphic;
14 class PartCache;
15 class Resources;
16
17 /**
18 Defines a single graphical element of a widget style.
19 */
20 class MSPGLTK_API Part
21 {
22 public:
23         class Loader: public DataFile::CollectionObjectLoader<Part>
24         {
25         public:
26                 Loader(Part &, Resources &);
27         private:
28                 void finish() override;
29
30                 void graphic_normal(const std::string &);
31                 void graphic(State, const std::string &);
32                 void align(float, float);
33                 void fill(float, float);
34                 void margin();
35                 void size(unsigned, unsigned);
36         };
37
38 private:
39         std::string name;
40         const Graphic *graphic[N_STATES_] = { };
41         Geometry geom;
42         Sides margin;
43         Alignment align;
44
45 public:
46         Part(const std::string &);
47         const std::string &get_name() const { return name; }
48         const Graphic *get_graphic(State) const;
49         const Geometry &get_geometry() const { return geom; }
50         const Sides &get_margin() const { return margin; }
51         const Alignment &get_alignment() const { return align; }
52         void build(const Geometry &, State, PartCache &) const;
53 };
54
55 } // namespace GLtk
56 } // namespace Msp
57
58 #endif