diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/os.cpp | 11 | ||||
-rw-r--r-- | core/os/os.h | 8 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index c6e5de703c..422acf95dc 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -616,6 +616,17 @@ bool OS::has_feature(const String &p_feature) { return false; } +void OS::center_window() { + + if (is_window_fullscreen()) return; + + Size2 scr = get_screen_size(get_current_screen()); + Size2 wnd = get_real_window_size(); + int x = scr.width / 2 - wnd.width / 2; + int y = scr.height / 2 - wnd.height / 2; + set_window_position(Vector2(x, y)); +} + OS::OS() { void *volatile stack_bottom; diff --git a/core/os/os.h b/core/os/os.h index 248e1dbefa..38e55fa3b7 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -94,15 +94,17 @@ public: bool resizable; bool borderless_window; bool maximized; + bool always_on_top; bool use_vsync; float get_aspect() const { return (float)width / (float)height; } - VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_use_vsync = false) { + VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_always_on_top = false, bool p_use_vsync = false) { width = p_width; height = p_height; fullscreen = p_fullscreen; resizable = p_resizable; borderless_window = p_borderless_window; maximized = p_maximized; + always_on_top = p_always_on_top; use_vsync = p_use_vsync; } }; @@ -182,6 +184,7 @@ public: virtual Point2 get_window_position() const { return Vector2(); } virtual void set_window_position(const Point2 &p_position) {} virtual Size2 get_window_size() const = 0; + virtual Size2 get_real_window_size() const { return get_window_size(); } virtual void set_window_size(const Size2 p_size) {} virtual void set_window_fullscreen(bool p_enabled) {} virtual bool is_window_fullscreen() const { return true; } @@ -191,7 +194,10 @@ public: virtual bool is_window_minimized() const { return false; } virtual void set_window_maximized(bool p_enabled) {} virtual bool is_window_maximized() const { return true; } + virtual void set_window_always_on_top(bool p_enabled) {} + virtual bool is_window_always_on_top() const { return false; } virtual void request_attention() {} + virtual void center_window(); virtual void set_borderless_window(bool p_borderless) {} virtual bool get_borderless_window() { return 0; } |