]> git.tdb.fi Git - libs/gltk.git/blob - source/style.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / style.h
1 #ifndef MSP_GLTK_STYLE_H_
2 #define MSP_GLTK_STYLE_H_
3
4 #include <msp/gl/color.h>
5 #include <msp/gl/font.h>
6 #include <msp/gl/sampler.h>
7 #include <msp/datafile/objectloader.h>
8 #include "mspgltk_api.h"
9 #include "part.h"
10
11 namespace Msp {
12 namespace GLtk {
13
14 class Resources;
15
16 /**
17 Styles define what wigets look like.  They are made up of Parts and some
18 generic properties.
19 */
20 class MSPGLTK_API Style
21 {
22 public:
23         class Loader: public DataFile::CollectionObjectLoader<Style, Resources>
24         {
25         public:
26                 Loader(Style &, Resources &);
27
28         private:
29                 void font(const std::string &);
30                 void font_color_normal(float, float, float);
31                 void font_color(State, float, float, float);
32                 void part(const std::string &);
33                 void unnamed_part();
34         };
35
36 private:
37         const GL::Font *font = nullptr;
38         unsigned font_size = 0;
39         GL::Color font_color[N_STATES_];
40         const GL::Sampler *sampler = nullptr;
41         std::vector<Part> parts;
42
43 public:
44         const GL::Font &get_font() const;
45         unsigned get_font_size() const { return font_size; }
46         const GL::Color &get_font_color(State) const;
47         const GL::Sampler &get_sampler() const;
48         const std::vector<Part> &get_parts() const { return parts; }
49         const Part *find_part(const std::string &) const;
50         bool compare_states(State, State) const;
51 };
52
53 } // namespace GLtk
54 } // namespace Msp
55
56 #endif