diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2018-07-04 23:32:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-04 23:32:29 +0200 |
commit | 9986b64b7683a224cc16192bf54c619dc2cac9be (patch) | |
tree | c0ec37e977d73f020aa8ec05f5efb6f113899456 | |
parent | 293a96c22d9e7cd68dc18b7d1dec9448d9f28e0f (diff) | |
parent | 560deda2076fd1d63b461cf74f65f90f1472b109 (diff) |
Merge pull request #19960 from groud/fix_control_size
Fixes control nodes size not updated when outside the tree
-rw-r--r-- | scene/gui/control.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fb0cec5212..3808b788c7 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1295,9 +1295,6 @@ Size2 Control::get_parent_area_size() const { void Control::_size_changed() { - if (!is_inside_tree()) - return; - Rect2 parent_rect = get_parent_anchorable_rect(); float margin_pos[4]; @@ -1334,7 +1331,7 @@ void Control::_size_changed() { } // We use a little workaround to avoid flickering when moving the pivot with _edit_set_pivot() - if (Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { + if (is_inside_tree() && Math::abs(Math::sin(data.rotation * 4.0f)) < 0.00001f && get_viewport()->is_snap_controls_to_pixels_enabled()) { new_size_cache = new_size_cache.round(); new_pos_cache = new_pos_cache.round(); } @@ -1344,17 +1341,19 @@ void Control::_size_changed() { data.pos_cache = new_pos_cache; data.size_cache = new_size_cache; - if (size_changed) { - notification(NOTIFICATION_RESIZED); - } - if (pos_changed || size_changed) { - item_rect_changed(size_changed); - _change_notify_margins(); - _notify_transform(); - } + if (is_inside_tree()) { + if (size_changed) { + notification(NOTIFICATION_RESIZED); + } + if (pos_changed || size_changed) { + item_rect_changed(size_changed); + _change_notify_margins(); + _notify_transform(); + } - if (pos_changed && !size_changed) { - _update_canvas_item_transform(); //move because it won't be updated + if (pos_changed && !size_changed) { + _update_canvas_item_transform(); //move because it won't be updated + } } } |