diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 5 | ||||
-rw-r--r-- | core/bind/core_bind.h | 1 | ||||
-rw-r--r-- | core/os/os.h | 12 |
3 files changed, 18 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index a977fd3da4..85793f127d 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -288,6 +288,10 @@ void _OS::set_window_size(const Size2 &p_size) { OS::get_singleton()->set_window_size(p_size); } +Rect2 _OS::get_window_safe_area() const { + return OS::get_singleton()->get_window_safe_area(); +} + void _OS::set_window_fullscreen(bool p_enabled) { OS::get_singleton()->set_window_fullscreen(p_enabled); } @@ -1046,6 +1050,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position); ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size); ClassDB::bind_method(D_METHOD("set_window_size", "size"), &_OS::set_window_size); + ClassDB::bind_method(D_METHOD("get_window_safe_area"), &_OS::get_window_safe_area); ClassDB::bind_method(D_METHOD("set_window_fullscreen", "enabled"), &_OS::set_window_fullscreen); ClassDB::bind_method(D_METHOD("is_window_fullscreen"), &_OS::is_window_fullscreen); ClassDB::bind_method(D_METHOD("set_window_resizable", "enabled"), &_OS::set_window_resizable); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index c40abd51f6..1790c68757 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -162,6 +162,7 @@ public: virtual void set_window_position(const Point2 &p_position); virtual Size2 get_window_size() const; virtual Size2 get_real_window_size() const; + virtual Rect2 get_window_safe_area() const; virtual void set_window_size(const Size2 &p_size); virtual void set_window_fullscreen(bool p_enabled); virtual bool is_window_fullscreen() const; diff --git a/core/os/os.h b/core/os/os.h index 5a2c998782..943c0498f1 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -205,6 +205,18 @@ public: virtual void request_attention() {} virtual void center_window(); + // Returns window area free of hardware controls and other obstacles. + // The application should use this to determine where to place UI elements. + // + // Keep in mind the area returned is in window coordinates rather than + // viewport coordinates - you should perform the conversion on your own. + // + // The maximum size of the area is Rect2(0, 0, window_size.width, window_size.height). + virtual Rect2 get_window_safe_area() const { + Size2 window_size = get_window_size(); + return Rect2(0, 0, window_size.width, window_size.height); + } + virtual void set_borderless_window(bool p_borderless) {} virtual bool get_borderless_window() { return 0; } |