1 #ifndef MSP_GLTK_CONTAINER_H_
2 #define MSP_GLTK_CONTAINER_H_
6 #include <sigc++/trackable.h>
7 #include "mspgltk_api.h"
13 class MSPGLTK_API hierarchy_error: public std::logic_error
16 hierarchy_error(const std::string &);
20 class MSPGLTK_API Container: virtual public Widget
23 struct Child: public sigc::trackable
26 Widget *widget = nullptr;
27 Time::TimeDelta time_since_animate;
29 Child(Container &, Widget *);
32 void visibility_changed(bool);
35 void ungrab_pointer();
36 void request_animation(const Time::TimeDelta &);
37 void rebuild_needed();
40 std::vector<Child *> children;
41 Widget *click_focus = nullptr;
42 unsigned click_button = 0;
43 Widget *pointer_focus = nullptr;
44 bool pointer_grabbed = false;
45 Widget *input_focus = nullptr;
46 Widget *saved_input_focus = nullptr;
47 Widget *touch_focus = nullptr;
48 bool children_rebuild_needed = false;
50 Container() = default;
55 void remove(Widget &);
57 virtual Child *create_child(Widget *);
58 Geometry determine_child_geometry(const Widget &, const Part &) const;
59 void autosize_child(const Widget &, const Part &, Geometry &) const;
60 void reposition_child(Widget &, const Part &) const;
62 std::vector<Widget *> get_children() const;
63 Widget *find_child_at(int, int) const;
64 Widget *find_descendant_at(int, int) const;
68 void set_pointer_focus(Widget *, bool = false);
69 void set_input_focus(Widget *);
71 Widget *get_input_focus() const { return input_focus; }
72 Widget *get_final_input_focus() const;
75 void check_animation_interval();
78 void rebuild_hierarchy() override;
81 void button_press(int, int, unsigned) override;
82 void button_release(int, int, unsigned) override;
83 void pointer_motion(int, int) override;
85 Widget *get_pointer_target(int, int, bool) const;
87 void pointer_leave() override;
88 void touch_press(int, int, unsigned) override;
89 void touch_release(int, int, unsigned) override;
90 void touch_motion(int, int, unsigned) override;
91 bool key_press(unsigned, unsigned) override;
92 bool key_release(unsigned, unsigned) override;
93 bool character(wchar_t) override;
94 void focus_in() override;
95 void focus_out() override;
96 bool navigate(Navigation) override;
97 void animate(const Time::TimeDelta &) override;
99 void on_reparent() override;
100 virtual void on_child_added(Widget &) { }
101 virtual void on_child_removed(Widget &) { }
102 virtual void on_input_focus_changed(Widget *);