1 #ifndef MSP_GLTK_ROOT_H_
2 #define MSP_GLTK_ROOT_H_
4 #include <sigc++/trackable.h>
5 #include <msp/gl/camera.h>
6 #include <msp/gl/program.h>
7 #include <msp/graphics/window.h>
8 #include <msp/input/keyboard.h>
9 #include <msp/input/mouse.h>
10 #include <msp/input/touchscreen.h>
11 #include <msp/time/timestamp.h>
20 A Root is a special type of Panel that covers the entire viewport and receives
21 input from keyboard and mouse.
23 class Root: public Panel, public sigc::trackable
26 sigc::signal<std::string, int, int> signal_tooltip;
29 const Resources &resources;
30 Input::Keyboard *keyboard;
31 InputMethod *input_method;
33 Input::Touchscreen *touchscreen;
38 Time::TimeStamp tooltip_timeout;
39 Widget *tooltip_target;
40 Msp::GL::Camera camera;
41 Msp::GL::Program *shprog;
44 /** Creates a Root widget for a window. The geometry is set to match the
45 window's size, and input devices are created automatically. */
46 Root(const Resources &, Graphics::Window &);
48 /** Creates a Root widget with custom input devices. If window is not null,
49 it is used to set the widget's initial geometry. */
50 Root(const Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = 0);
52 void init(Graphics::Window *);
56 virtual const char *get_class() const { return "root"; }
58 const Resources &get_resources() const { return resources; }
59 virtual unsigned get_width() const { return geom.w; }
60 virtual unsigned get_height() const { return geom.h; }
66 bool button_press_event(unsigned);
67 bool button_release_event(unsigned);
68 bool axis_motion_event(unsigned, float, float);
69 bool touch_press_event(unsigned);
70 bool touch_release_event(unsigned);
71 bool touch_motion_event(unsigned, float, float);
73 void get_pointer(int &, int &);
74 void get_touch(unsigned, int &, int &);
77 virtual void on_geometry_change();
78 virtual void on_child_added(Widget &);