]> git.tdb.fi Git - libs/gltk.git/blobdiff - examples/widgetdemo/widgetdemo.cpp
Refactor Panel to create Layout internally on request
[libs/gltk.git] / examples / widgetdemo / widgetdemo.cpp
index bfbcfc27c65c5ae07f511aeb9cb8c1cc6e1b41ca..52545a2b2b86c1f099a2a3bc96ff4cbb43d801cd 100644 (file)
@@ -19,10 +19,10 @@ WidgetDemo::WidgetDemo(int, char **):
        window.set_title("GLtk widget demo");
        window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &WidgetDemo::exit), 0));
 
-       root.set_layout(new GLtk::Layout);
+       GLtk::Layout &root_layout = root.get_or_create_layout();
 
        root.add(selector);
-       root.get_layout()->set_expand(selector, false, true);
+       root_layout.set_expand(selector, false, true);
 
        add_demo("Button", new ButtonDemo);
        add_demo("Dropdown", new DropdownDemo);
@@ -46,10 +46,12 @@ void WidgetDemo::tick()
 
 void WidgetDemo::add_demo(const string &title, GLtk::Panel *demo)
 {
+       GLtk::Layout &root_layout = root.get_or_create_layout();
+
        demo->set_visible(false);
        root.add(*demo);
-       root.get_layout()->add_constraint(*demo, GLtk::Layout::RIGHT_OF, selector);
-       root.get_layout()->set_expand(*demo, true, true);
+       root_layout.add_constraint(*demo, GLtk::Layout::RIGHT_OF, selector);
+       root_layout.set_expand(*demo, true, true);
 
        selector.add_demo(title, demo);
 }