Debian Codegraph @

editor/gui/window_wrapper.h

raw symbols SCIP
1 /**************************************************************************/
2 /* window_wrapper.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/math/rect2.h"
34 #include "scene/gui/margin_container.h"
35 #include "scene/gui/menu_button.h"
36
37 class Window;
38 class HBoxContainer;
39
40 class WindowWrapper : public MarginContainer {
41 GDCLASS(WindowWrapper, MarginContainer);
42
43 Control *wrapped_control = nullptr;
44 MarginContainer *margins = nullptr;
45 Window *window = nullptr;
46 ObjectID window_id;
47
48 Panel *window_background = nullptr;
49
50 Ref<Shortcut> enable_shortcut;
51
52 bool override_close_request = false;
53
54 Rect2 _get_default_window_rect() const;
55 Node *_get_wrapped_control_parent() const;
56
57 void _set_window_enabled_with_rect(bool p_visible, const Rect2 p_rect);
58 void _set_window_rect(const Rect2 p_rect);
59 void _window_size_changed();
60 void _window_close_request();
61
62 protected:
63 static void _bind_methods();
64 void _notification(int p_what);
65
66 virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
67
68 public:
69 void set_wrapped_control(Control *p_control, const Ref<Shortcut> &p_enable_shortcut = Ref<Shortcut>());
70 Control *get_wrapped_control() const;
71 Control *release_wrapped_control();
72
73 bool is_window_available() const;
74
75 bool get_window_enabled() const;
76 void set_window_enabled(bool p_enabled);
77
78 Rect2i get_window_rect() const;
79 int get_window_screen() const;
80
81 void restore_window(const Rect2i &p_rect, int p_screen = -1);
82 void restore_window_from_saved_position(const Rect2 p_window_rect, int p_screen, const Rect2 p_screen_rect);
83 void enable_window_on_screen(int p_screen = -1, bool p_auto_scale = false);
84
85 void set_window_title(const String &p_title);
86 void set_margins_enabled(bool p_enabled);
87 Size2 get_margins_size();
88 Size2 get_margins_top_left();
89 void grab_window_focus();
90
91 void set_override_close_request(bool p_enabled);
92
93 WindowWrapper();
94 ~WindowWrapper();
95 };
96
97 class ScreenSelect : public Button {
98 GDCLASS(ScreenSelect, Button);
99
100 Popup *popup = nullptr;
101 HBoxContainer *screen_list = nullptr;
102
103 void _build_advanced_menu();
104
105 void _emit_screen_signal(int p_screen_idx);
106 void _handle_mouse_shortcut(const Ref<InputEvent> &p_event);
107 void _show_popup();
108
109 protected:
110 virtual void pressed() override;
111 static void _bind_methods();
112
113 void _notification(int p_what);
114
115 public:
116 ScreenSelect();
117 };