]> git.tdb.fi Git - libs/gltk.git/blob - source/style.cpp
Make font size a property of Style
[libs/gltk.git] / source / style.cpp
1 #include "resources.h"
2 #include "style.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GLtk {
8
9 Style::Style(Resources &r):
10         font(&r.get_default_font()),
11         font_size(font->get_native_size())
12 { }
13
14 const Part *Style::get_part(const string &name) const
15 {
16         for(PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
17                 if(i->get_name()==name)
18                         return &*i;
19
20         return 0;
21 }
22
23
24 Style::Loader::Loader(Style &s, Resources &r):
25         style(s),
26         res(r)
27 {
28         add("font",       &Style::font);
29         add("font_color", &Loader::font_color);
30         add("part",       static_cast<void (Loader::*)()>(&Loader::part));
31         add("part",       static_cast<void (Loader::*)(const std::string &)>(&Loader::part));
32         // Deprecated alias
33         add("special",    static_cast<void (Loader::*)(const std::string &)>(&Loader::part));
34 }
35
36 void Style::Loader::font_color(float r, float g, float b)
37 {
38         style.font_color = GL::Color(r, g, b);
39 }
40
41 void Style::Loader::part()
42 {
43         part(string());
44 }
45
46 void Style::Loader::part(const string &n)
47 {
48         Part p(n);
49         load_sub(p, res);
50         style.parts.push_back(p);
51 }
52
53 } // namespace GLtk
54 } // namespace Msp