From 792ff11642c0bd0d2c2c647a2cc4d828f47d35d0 Mon Sep 17 00:00:00 2001 From: volzhs Date: Wed, 28 Dec 2016 14:27:27 +0900 Subject: [PATCH] Able to change visibility when ancestor node is hidden --- scene/2d/canvas_item.cpp | 9 ++------- tools/editor/scene_tree_editor.cpp | 13 ------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index ed1d606ba8c..995120bc995 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -261,16 +261,13 @@ void CanvasItem::show() { if (!hidden) return; - hidden=false; VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true); if (!is_inside_tree()) return; - if (is_visible()) { - _propagate_visibility_changed(true); - } + _propagate_visibility_changed(true); _change_notify("visibility/visible"); } @@ -280,15 +277,13 @@ void CanvasItem::hide() { if (hidden) return; - bool propagate=is_inside_tree() && is_visible(); hidden=true; VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false); if (!is_inside_tree()) return; - if (propagate) - _propagate_visibility_changed(false); + _propagate_visibility_changed(false); _change_notify("visibility/visible"); } diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index ebfa62528ff..ae3a465b45b 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -208,13 +208,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) if (n->is_type("Spatial")) { - Spatial *ci = n->cast_to(); - if (!ci->is_visible() && ci->get_parent_spatial() && !ci->get_parent_spatial()->is_visible()) { - error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first.")); - error->popup_centered_minsize(); - return; - } - bool v = !bool(n->call("is_hidden")); undo_redo->create_action(TTR("Toggle Spatial Visible")); undo_redo->add_do_method(n,"_set_visible_",!v); @@ -222,12 +215,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) undo_redo->commit_action(); } else if (n->is_type("CanvasItem")) { - CanvasItem *ci = n->cast_to(); - if (!ci->is_visible() && ci->get_parent_item() && !ci->get_parent_item()->is_visible()) { - error->set_text(TTR("This item cannot be made visible because the parent is hidden. Unhide the parent first.")); - error->popup_centered_minsize(); - return; - } bool v = !bool(n->call("is_hidden")); undo_redo->create_action(TTR("Toggle CanvasItem Visible")); undo_redo->add_do_method(n,v?"hide":"show");