diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-11-23 14:13:07 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-11-23 16:04:07 +0100 |
commit | ebd1b0089a5b732afed22247bceefd1a7ef3d4f6 (patch) | |
tree | 295300db7ea4da67e283ada9756c9c2c136d4d27 /scene | |
parent | a8a88194a5cf5849d421aaec05beddbc437ebbcd (diff) |
Fix Viewport being visible after leaving tree
When a SubViewport leaves the tree, it is still displayed in its parent
SubViewportContainer until the next redraw.
This PR makes sure, that the parent gets redrawn immediately.
This also fixes the visibility problem when a SubViewport is added as
child of a SubViewportContainer.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/subviewport_container.cpp | 12 | ||||
-rw-r--r-- | scene/gui/subviewport_container.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index 3ad84cbc6d..f3d9a22342 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -227,6 +227,18 @@ void SubViewportContainer::unhandled_input(const Ref<InputEvent> &p_event) { } } +void SubViewportContainer::add_child_notify(Node *p_child) { + if (Object::cast_to<SubViewport>(p_child)) { + queue_redraw(); + } +} + +void SubViewportContainer::remove_child_notify(Node *p_child) { + if (Object::cast_to<SubViewport>(p_child)) { + queue_redraw(); + } +} + PackedStringArray SubViewportContainer::get_configuration_warnings() const { PackedStringArray warnings = Node::get_configuration_warnings(); diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index 63a58b5f07..fdd8fe9486 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -44,6 +44,9 @@ protected: void _notification(int p_what); static void _bind_methods(); + virtual void add_child_notify(Node *p_child) override; + virtual void remove_child_notify(Node *p_child) override; + public: void set_stretch(bool p_enable); bool is_stretch_enabled() const; |