Merge pull request #59801 from Sauermann/fix-node2d-viewport-root-order

Fix Viewport root order after Node2D raise
This commit is contained in:
Rémi Verschelde 2022-11-28 08:21:10 +01:00
commit 438b2e2d02
No known key found for this signature in database
GPG key ID: C3336907360768E1
6 changed files with 18 additions and 5 deletions

View file

@ -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);

View file

@ -53,6 +53,7 @@ class Node2D : public CanvasItem {
void _update_xform_values();
protected:
void _notification(int p_notification);
static void _bind_methods();
public:

View file

@ -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;

View file

@ -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();
}
}

View file

@ -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;
}

View file

@ -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;