diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-02-15 20:48:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 20:48:18 +0100 |
commit | 98b97d34df7f3ab2cafc3847358c231c3d357b40 (patch) | |
tree | 431aa6f107e860aa1e1f4ae8864f9b06e8ace169 /scene/gui/subviewport_container.cpp | |
parent | 6d575873969609e6ed58dee5052d23512b104498 (diff) | |
parent | 0f5455230c8955be0c6533574bd3d5b6f50792b6 (diff) | |
download | redot-engine-98b97d34df7f3ab2cafc3847358c231c3d357b40.tar.gz |
Merge pull request #58151 from akien-mga/notification-switch-scene
Diffstat (limited to 'scene/gui/subviewport_container.cpp')
-rw-r--r-- | scene/gui/subviewport_container.cpp | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index b8baefc307..ce78c286f5 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -100,51 +100,54 @@ Vector<int> SubViewportContainer::get_allowed_size_flags_vertical() const { } void SubViewportContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_RESIZED) { - if (!stretch) { - return; - } - - for (int i = 0; i < get_child_count(); i++) { - SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); - if (!c) { - continue; + switch (p_what) { + case NOTIFICATION_RESIZED: { + if (!stretch) { + return; } - c->set_size(get_size() / shrink); - } - } - - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED) { - for (int i = 0; i < get_child_count(); i++) { - SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); - if (!c) { - continue; - } + for (int i = 0; i < get_child_count(); i++) { + SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); + if (!c) { + continue; + } - if (is_visible_in_tree()) { - c->set_update_mode(SubViewport::UPDATE_ALWAYS); - } else { - c->set_update_mode(SubViewport::UPDATE_DISABLED); + c->set_size(get_size() / shrink); } - - c->set_handle_input_locally(false); //do not handle input locally here - } - } - - if (p_what == NOTIFICATION_DRAW) { - for (int i = 0; i < get_child_count(); i++) { - SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); - if (!c) { - continue; + } break; + + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_VISIBILITY_CHANGED: { + for (int i = 0; i < get_child_count(); i++) { + SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); + if (!c) { + continue; + } + + if (is_visible_in_tree()) { + c->set_update_mode(SubViewport::UPDATE_ALWAYS); + } else { + c->set_update_mode(SubViewport::UPDATE_DISABLED); + } + + c->set_handle_input_locally(false); //do not handle input locally here } - - if (stretch) { - draw_texture_rect(c->get_texture(), Rect2(Vector2(), get_size())); - } else { - draw_texture_rect(c->get_texture(), Rect2(Vector2(), c->get_size())); + } break; + + case NOTIFICATION_DRAW: { + for (int i = 0; i < get_child_count(); i++) { + SubViewport *c = Object::cast_to<SubViewport>(get_child(i)); + if (!c) { + continue; + } + + if (stretch) { + draw_texture_rect(c->get_texture(), Rect2(Vector2(), get_size())); + } else { + draw_texture_rect(c->get_texture(), Rect2(Vector2(), c->get_size())); + } } - } + } break; } } |