summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-28 08:21:10 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-28 08:21:10 +0100
commit438b2e2d02b2ce5f2dd53b9d3d6898746d4748ef (patch)
tree4d0fa69364d1469ae15b7b0f67b7b5a3ba7a9d9c
parentc7c9aa8d8bd741f5d0aaca31780ab648f5614111 (diff)
parent022d24a9aef8aabd91dbef7fa6b01687748f78b6 (diff)
Merge pull request #59801 from Sauermann/fix-node2d-viewport-root-order
Fix Viewport root order after Node2D raise
-rw-r--r--scene/2d/node_2d.cpp12
-rw-r--r--scene/2d/node_2d.h1
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/main/canvas_layer.cpp2
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/main/viewport.h4
6 files changed, 18 insertions, 5 deletions
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 2518069b78..84bfc48a43 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -30,6 +30,8 @@
#include "node_2d.h"
+#include "scene/main/viewport.h"
+
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const {
Dictionary state;
@@ -389,6 +391,16 @@ bool Node2D::is_y_sort_enabled() const {
return y_sort_enabled;
}
+void Node2D::_notification(int p_notification) {
+ switch (p_notification) {
+ case NOTIFICATION_MOVED_IN_PARENT: {
+ if (get_viewport()) {
+ get_viewport()->gui_set_root_order_dirty();
+ }
+ } break;
+ }
+}
+
void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 0d8a31e6bb..04bbdf639d 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -53,6 +53,7 @@ class Node2D : public CanvasItem {
void _update_xform_values();
protected:
+ void _notification(int p_notification);
static void _bind_methods();
public:
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 4e76f72921..92ee21a916 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2935,7 +2935,7 @@ void Control::_notification(int p_notification) {
queue_redraw();
if (data.RI) {
- get_viewport()->_gui_set_root_order_dirty();
+ get_viewport()->gui_set_root_order_dirty();
}
} break;
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index be5788739b..5fde18721a 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -38,7 +38,7 @@ void CanvasLayer::set_layer(int p_xform) {
layer = p_xform;
if (viewport.is_valid()) {
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
- vp->_gui_set_root_order_dirty();
+ vp->gui_set_root_order_dirty();
}
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index f58bf868ad..7430a0a835 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2097,7 +2097,7 @@ List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
return gui.roots.push_back(p_control);
}
-void Viewport::_gui_set_root_order_dirty() {
+void Viewport::gui_set_root_order_dirty() {
gui.roots_order_dirty = true;
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index dc69ec24d8..5659ee4000 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -456,8 +456,6 @@ private:
void _update_canvas_items(Node *p_node);
- void _gui_set_root_order_dirty();
-
friend class Window;
void _sub_window_update_order();
@@ -514,6 +512,8 @@ public:
Transform2D get_final_transform() const;
+ void gui_set_root_order_dirty();
+
void set_transparent_background(bool p_enable);
bool has_transparent_background() const;