diff options
Diffstat (limited to 'editor/gui/scene_tree_editor.cpp')
-rw-r--r-- | editor/gui/scene_tree_editor.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index 2e36b66025..c11da5dfdb 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -369,16 +369,14 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { msg_temp += String::utf8("• ") + String(E.name) + "\n"; } } - } - if (num_connections >= 1 || num_groups >= 1) { - if (num_groups < 1) { - msg_temp += "\n"; - } - msg_temp += TTR("Click to show signals dock."); + } else { + msg_temp += "\n"; } Ref<Texture2D> icon_temp; SceneTreeEditorButton signal_temp = BUTTON_SIGNALS; + String msg_temp_end = TTR("Click to show signals dock."); + if (num_connections >= 1 && num_groups >= 1) { icon_temp = get_editor_theme_icon(SNAME("SignalsAndGroups")); } else if (num_connections >= 1) { @@ -386,9 +384,11 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } else if (num_groups >= 1) { icon_temp = get_editor_theme_icon(SNAME("Groups")); signal_temp = BUTTON_GROUPS; + msg_temp_end = TTR("Click to show groups dock."); } if (num_connections >= 1 || num_groups >= 1) { + msg_temp += msg_temp_end; item->add_button(0, icon_temp, signal_temp, false, msg_temp); } } @@ -1684,24 +1684,30 @@ void SceneTreeDialog::_show_all_nodes_changed(bool p_button_pressed) { } void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) { - if (p_valid.is_empty()) { - return; + if (allowed_types_hbox) { + allowed_types_hbox->queue_free(); + allowed_types_hbox = nullptr; + valid_type_icons.clear(); } tree->set_valid_types(p_valid); - HBoxContainer *hbox = memnew(HBoxContainer); - content->add_child(hbox); - content->move_child(hbox, 0); + if (p_valid.is_empty()) { + return; + } + + allowed_types_hbox = memnew(HBoxContainer); + content->add_child(allowed_types_hbox); + content->move_child(allowed_types_hbox, 0); { Label *label = memnew(Label); - hbox->add_child(label); + allowed_types_hbox->add_child(label); label->set_text(TTR("Allowed:")); } HFlowContainer *hflow = memnew(HFlowContainer); - hbox->add_child(hflow); + allowed_types_hbox->add_child(hflow); hflow->set_h_size_flags(Control::SIZE_EXPAND_FILL); for (const StringName &type : p_valid) { @@ -1735,6 +1741,9 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) { } show_all_nodes->show(); + if (is_inside_tree()) { + _update_valid_type_icons(); + } } void SceneTreeDialog::_notification(int p_what) { @@ -1753,11 +1762,7 @@ void SceneTreeDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - filter->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - for (TextureRect *trect : valid_type_icons) { - trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)), 0)); - trect->set_texture(trect->get_meta("icon")); - } + _update_valid_type_icons(); } break; case NOTIFICATION_EXIT_TREE: { @@ -1766,6 +1771,14 @@ void SceneTreeDialog::_notification(int p_what) { } } +void SceneTreeDialog::_update_valid_type_icons() { + filter->set_right_icon(get_editor_theme_icon(SNAME("Search"))); + for (TextureRect *trect : valid_type_icons) { + trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)), 0)); + trect->set_texture(trect->get_meta("icon")); + } +} + void SceneTreeDialog::_cancel() { hide(); } |