Ported from godot 4: Fix Viewport root order after Node2D raise

- Sauermann
022d24a9ae
This commit is contained in:
Relintai 2023-04-10 11:42:15 +02:00
parent 4b2ec37826
commit 7d2667830d
6 changed files with 16 additions and 4 deletions

View File

@ -377,6 +377,16 @@ Point2 Node2D::to_global(Point2 p_local) const {
return get_global_transform().xform(p_local);
}
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

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

View File

@ -608,7 +608,7 @@ void Control::_notification(int p_notification) {
get_viewport()->_gui_set_subwindow_order_dirty();
}
if (data.RI) {
get_viewport()->_gui_set_root_order_dirty();
get_viewport()->gui_set_root_order_dirty();
}
} break;

View File

@ -37,7 +37,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_position_in_parent());
vp->_gui_set_root_order_dirty();
vp->gui_set_root_order_dirty();
}
}

View File

@ -2480,7 +2480,7 @@ void Viewport::_gui_set_subwindow_order_dirty() {
gui.subwindow_order_dirty = true;
}
void Viewport::_gui_set_root_order_dirty() {
void Viewport::gui_set_root_order_dirty() {
gui.roots_order_dirty = true;
}

View File

@ -195,6 +195,8 @@ public:
Transform2D get_final_transform() const;
void assign_next_enabled_camera_2d(const StringName &p_camera_group);
void gui_set_root_order_dirty();
void set_transparent_background(bool p_enable);
bool has_transparent_background() const;
@ -510,7 +512,6 @@ private:
List<Control *>::Element *_gui_add_subwindow_control(Control *p_control);
void _gui_set_subwindow_order_dirty();
void _gui_set_root_order_dirty();
void _gui_remove_modal_control(List<Control *>::Element *MI);
void _gui_remove_from_modal_stack(List<Control *>::Element *MI, ObjectID p_prev_focus_owner);