1 #ifndef MSP_GLTK_PANEL_H_
2 #define MSP_GLTK_PANEL_H_
4 #include <msp/core/typeregistry.h>
7 #include "mspgltk_api.h"
13 Panels are containers for other widgets. Panel styles should have a special
14 part "children" to render the child widgets. All properties of this part are
17 class MSPGLTK_API Panel: public Container
20 class Loader: public DataFile::DerivedObjectLoader<Panel, Widget::Loader>
23 typedef std::map<std::string, Widget *> WidgetMap;
29 void operator()(const std::string &, Loader &) const;
36 Loader(Panel &, WidgetMap &);
39 Widget &get_last_widget();
43 void child(const std::string &);
44 void constraint(Layout::ConstraintType, const std::string &);
45 void expand(bool, bool);
47 void gravity(int, int);
48 void grid(std::size_t);
58 class ArrangedLoader: public DataFile::Loader
61 typename T::Loader arr_loader;
64 ArrangedLoader(Loader &, T &);
68 std::vector<Widget *> nav_order;
69 Layout *layout = nullptr;
71 static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
72 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 RefPtr<T> chl = new T();
121 last_widget = chl.release();
126 void Panel::Loader::AddChildType<T>::operator()(const std::string &kwd, Loader &ldr) const
128 ldr.add(kwd, &Loader::child<T>);
129 ldr.add(kwd, &Loader::unnamed_child<T>);