]> git.tdb.fi Git - libs/gltk.git/blob - source/style.h
Don't rebuild on state change if there are no visual changes
[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/datafile/objectloader.h>
7 #include "part.h"
8
9 namespace Msp {
10 namespace GLtk {
11
12 class Resources;
13
14 /**
15 Styles define what wigets look like.  They are made up of Parts and some
16 generic properties.
17 */
18 class Style
19 {
20 public:
21         class Loader: public DataFile::CollectionObjectLoader<Style, Resources>
22         {
23         public:
24                 Loader(Style &, Resources &);
25
26         private:
27                 void font(const std::string &);
28                 void font_color_normal(float, float, float);
29                 void font_color(State, float, float, float);
30                 void part(const std::string &);
31                 void unnamed_part();
32         };
33
34         typedef std::list<Part> PartSeq;
35
36 private:
37         const GL::Font *font;
38         unsigned font_size;
39         GL::Color font_color[N_STATES_];
40         PartSeq parts;
41
42 public:
43         Style();
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 PartSeq &get_parts() const { return parts; }
48         const Part *get_part(const std::string &) const;
49         bool compare_states(State, State) const;
50 };
51
52 } // namespace GLtk
53 } // namespace Msp
54
55 #endif