1 #ifndef MSP_GLTK_ROOT_H_
2 #define MSP_GLTK_ROOT_H_
4 #include <sigc++/trackable.h>
5 #include <msp/gl/blend.h>
6 #include <msp/gl/camera.h>
7 #include <msp/gl/program.h>
8 #include <msp/gl/renderable.h>
9 #include <msp/graphics/window.h>
10 #include <msp/input/keyboard.h>
11 #include <msp/input/mouse.h>
12 #include <msp/input/touchscreen.h>
13 #include <msp/time/timestamp.h>
22 A Root is a special type of Panel that covers the entire viewport and receives
23 input from keyboard and mouse. It can be used by itself or in a GL::Pipeline.
24 Due to its specialized nature it's recommended to not use it with Scenes or
27 class Root: public Panel, public GL::Renderable, public sigc::trackable
30 sigc::signal<std::string, int, int> signal_tooltip;
34 Input::Keyboard *keyboard;
35 InputMethod *input_method;
37 Input::Touchscreen *touchscreen;
42 Time::TimeStamp tooltip_timeout;
43 Time::TimeStamp last_tick;
44 Widget *tooltip_target;
45 Msp::GL::Camera camera;
46 Msp::GL::Program *shprog;
50 /** Creates a Root widget for a window. The geometry is set to match the
51 window's size, and input devices are created automatically. */
52 Root(Resources &, Graphics::Window &);
54 /** Creates a Root widget with custom input devices. If window is not null,
55 it is used to set the widget's initial geometry. */
56 Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = 0);
58 void init(Graphics::Window *);
62 virtual const char *get_class() const { return "root"; }
64 Resources &get_resources() const { return resources; }
65 virtual unsigned get_width() const { return geom.w; }
66 virtual unsigned get_height() const { return geom.h; }
69 virtual void setup_frame(GL::Renderer &);
70 virtual void render(GL::Renderer &, GL::Tag = GL::Tag()) const;
73 bool button_press_event(unsigned);
74 bool button_release_event(unsigned);
75 bool axis_motion_event(unsigned, float, float);
76 bool touch_press_event(unsigned);
77 bool touch_release_event(unsigned);
78 bool touch_motion_event(unsigned, float, float);
80 void get_pointer(int &, int &);
81 void get_touch(unsigned, int &, int &);
84 virtual void on_size_change();
85 virtual void on_child_added(Widget &);