Merge pull request #18894 from volzhs/fix-toggle-visibility
Respect visibility change by Scene dock when using Sync Scene Changes
This commit is contained in:
commit
3b8bd50b41
|
@ -70,8 +70,18 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
|
||||||
|
|
||||||
} else if (p_id == BUTTON_VISIBILITY) {
|
} else if (p_id == BUTTON_VISIBILITY) {
|
||||||
undo_redo->create_action(TTR("Toggle Visible"));
|
undo_redo->create_action(TTR("Toggle Visible"));
|
||||||
undo_redo->add_do_method(this, "toggle_visible", n);
|
_toggle_visible(n);
|
||||||
undo_redo->add_undo_method(this, "toggle_visible", n);
|
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||||
|
if (selection.size() > 1) {
|
||||||
|
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
|
Node *nv = E->get();
|
||||||
|
ERR_FAIL_COND(!nv);
|
||||||
|
if (nv == n) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_toggle_visible(nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
} else if (p_id == BUTTON_LOCK) {
|
} else if (p_id == BUTTON_LOCK) {
|
||||||
|
|
||||||
|
@ -118,33 +128,13 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SceneTreeEditor::_toggle_visible(Node *p_node) {
|
void SceneTreeEditor::_toggle_visible(Node *p_node) {
|
||||||
if (p_node->is_class("Spatial")) {
|
if (p_node->has_method("is_visible") && p_node->has_method("set_visible")) {
|
||||||
bool v = bool(p_node->call("is_visible"));
|
bool v = bool(p_node->call("is_visible"));
|
||||||
p_node->call("set_visible", !v);
|
undo_redo->add_do_method(p_node, "set_visible", !v);
|
||||||
} else if (p_node->is_class("CanvasItem")) {
|
undo_redo->add_undo_method(p_node, "set_visible", v);
|
||||||
bool v = bool(p_node->call("is_visible"));
|
|
||||||
if (v) {
|
|
||||||
p_node->call("hide");
|
|
||||||
} else {
|
|
||||||
p_node->call("show");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeEditor::toggle_visible(Node *p_node) {
|
|
||||||
_toggle_visible(p_node);
|
|
||||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
|
||||||
if (selection.size() > 1) {
|
|
||||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
|
||||||
Node *nv = E->get();
|
|
||||||
ERR_FAIL_COND(!nv);
|
|
||||||
if (nv == p_node) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_toggle_visible(nv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
|
bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
|
||||||
|
|
||||||
if (!p_node)
|
if (!p_node)
|
||||||
|
@ -968,8 +958,6 @@ void SceneTreeEditor::_bind_methods() {
|
||||||
ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed);
|
ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed);
|
||||||
ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select);
|
ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select);
|
||||||
ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed);
|
ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed);
|
||||||
ClassDB::bind_method("_toggle_visible", &SceneTreeEditor::_toggle_visible);
|
|
||||||
ClassDB::bind_method("toggle_visible", &SceneTreeEditor::toggle_visible);
|
|
||||||
|
|
||||||
ClassDB::bind_method("_node_script_changed", &SceneTreeEditor::_node_script_changed);
|
ClassDB::bind_method("_node_script_changed", &SceneTreeEditor::_node_script_changed);
|
||||||
ClassDB::bind_method("_node_visibility_changed", &SceneTreeEditor::_node_visibility_changed);
|
ClassDB::bind_method("_node_visibility_changed", &SceneTreeEditor::_node_visibility_changed);
|
||||||
|
|
|
@ -70,8 +70,6 @@ class SceneTreeEditor : public Control {
|
||||||
|
|
||||||
void _compute_hash(Node *p_node, uint64_t &hash);
|
void _compute_hash(Node *p_node, uint64_t &hash);
|
||||||
|
|
||||||
void toggle_visible(Node *p_node);
|
|
||||||
|
|
||||||
bool _add_nodes(Node *p_node, TreeItem *p_parent);
|
bool _add_nodes(Node *p_node, TreeItem *p_parent);
|
||||||
void _test_update_tree();
|
void _test_update_tree();
|
||||||
void _update_tree();
|
void _update_tree();
|
||||||
|
|
Loading…
Reference in New Issue