diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index b8699b308fb..42bad2b50af 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3756,7 +3756,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans } CanvasItem *canvas_item = Object::cast_to(p_node); - if (canvas_item && !canvas_item->is_visible_in_tree()) { + if (canvas_item && !canvas_item->is_visible()) { return; } diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index d81ade31042..833b39eb191 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -353,18 +353,16 @@ bool CanvasItem::is_visible_in_tree() const { return visible && parent_visible_in_tree; } -void CanvasItem::_propagate_visibility_changed(bool p_visible, bool p_is_source) { +void CanvasItem::_propagate_visibility_changed(bool p_visible, bool p_was_visible) { if (p_visible && first_draw) { //avoid propagating it twice first_draw = false; } - if (!p_is_source) { - parent_visible_in_tree = p_visible; - } + parent_visible_in_tree = p_visible; notification(NOTIFICATION_VISIBILITY_CHANGED); if (visible && p_visible) { update(); - } else if (!p_visible && (visible || p_is_source)) { + } else if (!p_visible && (visible || p_was_visible)) { emit_signal(SceneStringNames::get_singleton()->hide); } _block(); @@ -372,12 +370,8 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible, bool p_is_source) for (int i = 0; i < get_child_count(); i++) { CanvasItem *c = Object::cast_to(get_child(i)); - if (c) { // Should the top_levels stop propagation? I think so, but... - if (c->visible) { - c->_propagate_visibility_changed(p_visible); - } else { - c->parent_visible_in_tree = p_visible; - } + if (c && c->visible) { //should the toplevels stop propagation? i think so but.. + c->_propagate_visibility_changed(p_visible); } } @@ -392,14 +386,11 @@ void CanvasItem::set_visible(bool p_visible) { visible = p_visible; VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, p_visible); - if (!parent_visible_in_tree) { - if (is_inside_tree()) { - notification(NOTIFICATION_VISIBILITY_CHANGED); - } + if (!is_inside_tree()) { return; } - _propagate_visibility_changed(p_visible, true); + _propagate_visibility_changed(p_visible, !p_visible); _change_notify("visible"); } diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index f1271d6d870..a9f69e7710e 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -210,7 +210,7 @@ private: void _toplevel_raise_self(); - void _propagate_visibility_changed(bool p_visible, bool p_is_source = false); + void _propagate_visibility_changed(bool p_visible, bool p_was_visible = false); void _update_callback(); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 1f59d5c8bfe..3ae191d0bb7 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -59,7 +59,7 @@ void CanvasLayer::set_visible(bool p_visible) { if (c->is_visible()) { c->_propagate_visibility_changed(p_visible); } else { - c->parent_visible_in_tree = p_visible; + c->notification(CanvasItem::NOTIFICATION_VISIBILITY_CHANGED); } } }