diff options
author | MinusKube <minuskube@gmail.com> | 2023-01-27 21:03:45 +0100 |
---|---|---|
committer | MinusKube <minuskube@gmail.com> | 2023-01-28 20:09:24 +0100 |
commit | 0f512a68dd51b827cf2f3ed6280784d91184b915 (patch) | |
tree | 0c16c115e0dce82bae8e6bbdc4a5aea15dc462cd | |
parent | 56fdef281ecc40e8ce10d4e17aa1357b150aca18 (diff) |
Fix get_parent_anchorable_rect() not returning the correct size in some cases
-rw-r--r-- | scene/gui/control.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fead0878fb..9de3fb7fa6 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -644,8 +644,10 @@ Rect2 Control::get_parent_anchorable_rect() const { parent_rect = data.parent_canvas_item->get_anchorable_rect(); } else { #ifdef TOOLS_ENABLED - Node *edited_root = get_tree()->get_edited_scene_root(); - if (edited_root && (this == edited_root || edited_root->is_ancestor_of(this))) { + Node *edited_scene_root = get_tree()->get_edited_scene_root(); + Node *scene_root_parent = edited_scene_root ? edited_scene_root->get_parent() : nullptr; + + if (scene_root_parent && get_viewport() == scene_root_parent->get_viewport()) { parent_rect.size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height")); } else { parent_rect = get_viewport()->get_visible_rect(); |