1 #ifndef MSP_GLTK_PANEL_H_
2 #define MSP_GLTK_PANEL_H_
5 #include <msp/core/typeregistry.h>
8 #include "mspgltk_api.h"
14 Panels are containers for other widgets. Panel styles should have a special
15 part "children" to render the child widgets. All properties of this part are
18 class MSPGLTK_API Panel: public Container
21 class Loader: public DataFile::DerivedObjectLoader<Panel, Widget::Loader>
24 typedef std::map<std::string, Widget *> WidgetMap;
30 void operator()(const std::string &, Loader &) const;
37 Loader(Panel &, WidgetMap &);
40 Widget &get_last_widget();
44 void child(const std::string &);
45 void constraint(Layout::ConstraintType, const std::string &);
46 void expand(bool, bool);
48 void gravity(int, int);
49 void grid(std::size_t);
59 class ArrangedLoader: public DataFile::Loader
62 typename T::Loader arr_loader;
65 ArrangedLoader(Loader &, T &);
69 std::vector<Widget *> nav_order;
70 std::unique_ptr<Layout> layout;
72 static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
73 static bool widget_registry_init_done;
79 static void register_child_type(const std::string &);
81 const char *get_class() const override { return "panel"; }
83 Layout &get_or_create_layout();
86 void autosize_special(const Part &, Geometry &) const override;
87 void render_special(const Part &, GL::Renderer &) const override;
90 bool navigate(Navigation) override;
92 Widget *find_next_child(int, int, int, int, int) const;
93 static int compute_delta(int, int, int, int, int);
95 void on_size_change() override;
96 void on_child_added(Widget &) override;
97 void on_child_removed(Widget &) override;
102 void Panel::register_child_type(const std::string &name)
104 widget_registry.register_type<T>(name);
109 void Panel::Loader::child(const std::string &n)
112 wdg_map[n] = last_widget;
116 void Panel::Loader::unnamed_child()
118 std::unique_ptr<T> chl = std::make_unique<T>();
120 Widget *wdg = chl.get();
127 void Panel::Loader::AddChildType<T>::operator()(const std::string &kwd, Loader &ldr) const
129 ldr.add(kwd, &Loader::child<T>);
130 ldr.add(kwd, &Loader::unnamed_child<T>);