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>
14 #include "mspgltk_api.h"
23 A Root is a special type of Panel that covers the entire viewport and receives
24 input from keyboard and mouse. It can be used by itself or in a GL::Pipeline.
25 Due to its specialized nature it's recommended to not use it with Scenes or
28 class MSPGLTK_API Root: public Panel, public GL::Renderable, public sigc::trackable
31 sigc::signal<std::string, int, int> signal_tooltip;
35 Input::Keyboard *keyboard = nullptr;
36 InputMethod *input_method = nullptr;
37 Input::Mouse *mouse = nullptr;
38 Input::Touchscreen *touchscreen = nullptr;
39 bool own_input = false;
40 Label *lbl_tooltip = nullptr;
43 Time::TimeStamp tooltip_timeout;
44 Time::TimeStamp last_tick;
45 Widget *tooltip_target = nullptr;
46 Msp::GL::Camera camera;
47 Msp::GL::Program *shprog = nullptr;
51 /** Creates a Root widget for a window. The geometry is set to match the
52 window's size, and input devices are created automatically. */
53 Root(Resources &, Graphics::Window &);
55 /** Creates a Root widget with custom input devices. If window is not null,
56 it is used to set the widget's initial geometry. */
57 Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = nullptr);
60 const char *get_class() const override { return "root"; }
62 Resources &get_resources() const { return resources; }
63 virtual unsigned get_width() const { return geom.w; }
64 virtual unsigned get_height() const { return geom.h; }
67 void setup_frame(GL::Renderer &) override;
68 void render(GL::Renderer &, GL::Tag = GL::Tag()) const override;
71 bool button_press_event(unsigned);
72 bool button_release_event(unsigned);
73 bool axis_motion_event(unsigned, float, float);
74 bool touch_press_event(unsigned);
75 bool touch_release_event(unsigned);
76 bool touch_motion_event(unsigned, float, float);
78 void get_pointer(int &, int &);
79 void get_touch(unsigned, int &, int &);
82 void on_size_change() override;
83 void on_child_added(Widget &) override;