Merge pull request #63235 from kleonc/canvas-item-remove-from-canvas-group

This commit is contained in:
Rémi Verschelde 2022-07-20 22:37:32 +02:00 committed by GitHub
commit 976cb7ea9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -230,16 +230,16 @@ void CanvasItem::_enter_canvas() {
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas); RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
group = "root_canvas" + itos(canvas.get_id()); canvas_group = "root_canvas" + itos(canvas.get_id());
add_to_group(group); add_to_group(canvas_group);
if (canvas_layer) { if (canvas_layer) {
canvas_layer->reset_sort_index(); canvas_layer->reset_sort_index();
} else { } else {
get_viewport()->gui_reset_canvas_sort_index(); get_viewport()->gui_reset_canvas_sort_index();
} }
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE | SceneTree::GROUP_CALL_DEFERRED, group, SNAME("_top_level_raise_self")); get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE | SceneTree::GROUP_CALL_DEFERRED, canvas_group, SNAME("_top_level_raise_self"));
} else { } else {
CanvasItem *parent = get_parent_item(); CanvasItem *parent = get_parent_item();
@ -258,7 +258,10 @@ void CanvasItem::_exit_canvas() {
notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID()); RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID());
canvas_layer = nullptr; canvas_layer = nullptr;
group = StringName(); if (canvas_group != StringName()) {
remove_from_group(canvas_group);
canvas_group = StringName();
}
} }
void CanvasItem::_notification(int p_what) { void CanvasItem::_notification(int p_what) {
@ -319,8 +322,8 @@ void CanvasItem::_notification(int p_what) {
break; break;
} }
if (group != StringName()) { if (canvas_group != StringName()) {
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE | SceneTree::GROUP_CALL_DEFERRED, group, "_top_level_raise_self"); get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE | SceneTree::GROUP_CALL_DEFERRED, canvas_group, "_top_level_raise_self");
} else { } else {
CanvasItem *p = get_parent_item(); CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p); ERR_FAIL_COND(!p);

View File

@ -70,7 +70,7 @@ private:
mutable SelfList<Node> xform_change; mutable SelfList<Node> xform_change;
RID canvas_item; RID canvas_item;
StringName group; StringName canvas_group;
CanvasLayer *canvas_layer = nullptr; CanvasLayer *canvas_layer = nullptr;