diff options
author | groud <gilles.roudiere@gmail.com> | 2018-07-04 14:29:29 +0200 |
---|---|---|
committer | groud <gilles.roudiere@gmail.com> | 2018-07-04 15:14:42 +0200 |
commit | 560deda2076fd1d63b461cf74f65f90f1472b109 (patch) | |
tree | 8ae53d0341d72187e32b7f89ca7d6de35ddf9c68 /scene/gui/control.cpp | |
parent | 3724f1562be5caca3c5236c1cfac8d73a3303d42 (diff) |
Fixes control nodes size not updated when outside the tree
Diffstat (limited to 'scene/gui/control.cpp')
-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 + } } } |