]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/window.h
de8a3d0beaccf79c2bc7bf9e42c3535840636fbf
[libs/gui.git] / source / graphics / window.h
1 #ifndef MSP_GRAPHICS_WINDOW_H_
2 #define MSP_GRAPHICS_WINDOW_H_
3
4 #include <string>
5 #include <sigc++/signal.h>
6
7 namespace Msp {
8 namespace Graphics {
9
10 class Display;
11 struct Monitor;
12
13 struct WindowOptions
14 {
15         int x = 0;
16         int y = 0;
17         bool user_position = false;
18         unsigned width = 640;
19         unsigned height = 480;
20         bool fullscreen = false;
21         const Monitor *fullscreen_monitor = nullptr;
22         bool fullscreen_exclusive = true;
23         bool resizable = false;
24 };
25
26 class Window
27 {
28 public:
29         struct Private;
30         struct Event;
31
32         /** Provides input events.  The event structure contents are platform-
33         specific.  Applications will want to use the enclosed Keyboard and Mouse
34         objects instead. */
35         sigc::signal<void, const Event &> signal_input_event;
36
37         sigc::signal<void> signal_got_focus;
38         sigc::signal<void> signal_lost_focus;
39
40         sigc::signal<void, int, int> signal_move;
41         sigc::signal<void, unsigned, unsigned> signal_resize;
42         sigc::signal<void, unsigned, unsigned, unsigned, unsigned, const Event &> signal_expose;
43         sigc::signal<void> signal_close;
44
45 protected:
46         Display &display;
47         WindowOptions options;
48         bool visible = false;
49         bool kbd_autorepeat = true;
50         bool touch_input = false;
51         bool resizing = false;
52         bool moving = false;
53         Private *priv = nullptr;
54
55 public:
56         Window(Display &, unsigned w, unsigned h, bool fs = false);
57         Window(Display &, const WindowOptions &);
58 private:
59         void init();
60         void platform_init();
61         void platform_cleanup();
62 public:
63         ~Window();
64
65         void set_title(const std::string &);
66         void reconfigure(const WindowOptions &);
67 private:
68         void set_fullscreen_mode();
69         void platform_reconfigure(bool);
70 public:
71         void set_keyboard_autorepeat(bool);
72         bool get_keyboard_autorepeat() const { return kbd_autorepeat; }
73         void show_cursor(bool);
74         void warp_pointer(int, int);
75         void set_touch_input(bool);
76 private:
77         void platform_set_touch_input();
78 public:
79         bool get_touch_input() const { return touch_input; }
80
81         Display &get_display() const { return display; }
82         const WindowOptions &get_options() const { return options; }
83         unsigned get_width() const { return options.width; }
84         unsigned get_height() const { return options.height; }
85         const Private &get_private() const { return *priv; }
86
87         void show();
88         void hide();
89 private:
90         void platform_show();
91         void platform_hide();
92
93 public:
94         bool event(const Event &evnt);
95 };
96
97 } // namespace Graphics
98 } // namespace Msp
99
100 #endif