| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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 |
}; |