summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Sizov <11782833+YuriSizov@users.noreply.github.com>2023-02-06 16:28:19 +0300
committerGitHub <noreply@github.com>2023-02-06 16:28:19 +0300
commit9d3b4b0b407536347a61d473c77e3a1cce2afa07 (patch)
treec76858c47a7c24b6dc36191853f022be58276c68
parent47c3e3b781a0aacc10c589a701a23aaac198663f (diff)
parent0f512a68dd51b827cf2f3ed6280784d91184b915 (diff)
Merge pull request #72204 from MinusKube/anchorable_rect_editor_bug
Fix get_parent_anchorable_rect() not returning the correct size in some cases
-rw-r--r--scene/gui/control.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index f09e4962a9..a930b8d972 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();