]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Support loading Buttons from datafiles
[libs/gltk.git] / source / widget.cpp
index d1f21bc9408113c1d65fb78ca711d1f5d51f6adf..e1538dec221bedc9a190c5904421ce6e1d16d87c 100644 (file)
@@ -47,7 +47,8 @@ void Widget::render() const
 Widget::Widget(const Resources &r):
        res(r),
        style(0),
-       state(NORMAL)
+       state(NORMAL),
+       visible(true)
 { }
 
 void Widget::update_style()
@@ -58,7 +59,7 @@ void Widget::update_style()
                sname+='-';
                sname+=style_name;
        }
-       style=&res.get<Style>(sname);
+       style=res.get<Style>(sname);
 }
 
 void Widget::render_part(const Part &part) const
@@ -93,5 +94,30 @@ void Widget::render_text(const Part &part, const string &text) const
        GL::pop_matrix();
 }
 
+
+Widget::Loader::Loader(Widget &w):
+       wdg(w)
+{
+       add("position", &Loader::position);
+       add("size",     &Loader::size);
+       add("style",    &Loader::style);
+       add("visible",  &Widget::visible);
+}
+
+void Widget::Loader::position(int x, int y)
+{
+       wdg.set_position(x, y);
+}
+
+void Widget::Loader::size(unsigned w, unsigned h)
+{
+       wdg.set_size(w, h);
+}
+
+void Widget::Loader::style(const string &s)
+{
+       wdg.set_style(s);
+}
+
 } // namespace GLtk
 } // namespace Msp