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/gl/renderable.h>
8 #include <msp/graphics/window.h>
9 #include <msp/input/keyboard.h>
10 #include <msp/input/mouse.h>
11 #include <msp/input/touchscreen.h>
12 #include <msp/time/timestamp.h>
21 A Root is a special type of Panel that covers the entire viewport and receives
22 input from keyboard and mouse. It can be used by itself or in a GL::Pipeline.
23 Due to its specialized nature it's recommended to not use it with Scenes or
26 class Root: public Panel, public GL::Renderable, public sigc::trackable
29 sigc::signal<std::string, int, int> signal_tooltip;
33 Input::Keyboard *keyboard;
34 InputMethod *input_method;
36 Input::Touchscreen *touchscreen;
41 Time::TimeStamp tooltip_timeout;
42 Widget *tooltip_target;
43 Msp::GL::Camera camera;
44 Msp::GL::Program *shprog;
47 /** Creates a Root widget for a window. The geometry is set to match the
48 window's size, and input devices are created automatically. */
49 Root(Resources &, Graphics::Window &);
51 /** Creates a Root widget with custom input devices. If window is not null,
52 it is used to set the widget's initial geometry. */
53 Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = 0);
55 void init(Graphics::Window *);
59 virtual const char *get_class() const { return "root"; }
61 Resources &get_resources() const { return resources; }
62 virtual unsigned get_width() const { return geom.w; }
63 virtual unsigned get_height() const { return geom.h; }
67 virtual void render(GL::Renderer &, const GL::Tag & = GL::Tag()) const;
70 bool button_press_event(unsigned);
71 bool button_release_event(unsigned);
72 bool axis_motion_event(unsigned, float, float);
73 bool touch_press_event(unsigned);
74 bool touch_release_event(unsigned);
75 bool touch_motion_event(unsigned, float, float);
77 void get_pointer(int &, int &);
78 void get_touch(unsigned, int &, int &);
81 virtual void on_geometry_change();
82 virtual void on_child_added(Widget &);