diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/window.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 8b1a4680d2..6feccb7eec 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1045,7 +1045,9 @@ void Window::popup_centered_clamped(const Size2i &p_size, float p_fallback_ratio Rect2i popup_rect; popup_rect.size = Vector2i(MIN(size_ratio.x, p_size.x), MIN(size_ratio.y, p_size.y)); - popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + if (parent_rect != Rect2()) { + popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + } popup(popup_rect); } @@ -1069,7 +1071,10 @@ void Window::popup_centered(const Size2i &p_minsize) { Size2 contents_minsize = _get_contents_minimum_size(); popup_rect.size.x = MAX(p_minsize.x, contents_minsize.x); popup_rect.size.y = MAX(p_minsize.y, contents_minsize.y); - popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + + if (parent_rect != Rect2()) { + popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + } popup(popup_rect); } @@ -1091,8 +1096,10 @@ void Window::popup_centered_ratio(float p_ratio) { } Rect2i popup_rect; - popup_rect.size = parent_rect.size * p_ratio; - popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + if (parent_rect != Rect2()) { + popup_rect.size = parent_rect.size * p_ratio; + popup_rect.position = parent_rect.position + (parent_rect.size - popup_rect.size) / 2; + } popup(popup_rect); } |