Merge pull request #79650 from garychia/filters_section

Avoid duplicating the "Filters" section
This commit is contained in:
Rémi Verschelde 2023-08-02 12:18:21 +02:00
commit 1cc377b4e0
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 6 additions and 9 deletions

View File

@ -1386,6 +1386,11 @@ void SceneTreeDock::_notification(int p_what) {
filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
PopupMenu *filter_menu = filter->get_menu();
filter_menu->set_item_icon(filter_menu->get_item_idx_from_text(TTR("Filters")), get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_TYPE), get_theme_icon(SNAME("Node"), SNAME("EditorIcons")));
filter_menu->set_item_icon(filter_menu->get_item_index(FILTER_BY_GROUP), get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")));
// These buttons are created on READY, because reasons... // These buttons are created on READY, because reasons...
if (button_2d) { if (button_2d) {
button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons")));
@ -3030,10 +3035,6 @@ void SceneTreeDock::_update_tree_menu() {
tree_menu->add_submenu_item(TTR("All Scene Sub-Resources"), "AllResources"); tree_menu->add_submenu_item(TTR("All Scene Sub-Resources"), "AllResources");
} }
void SceneTreeDock::_update_filter_menu() {
_append_filter_options_to(filter->get_menu());
}
void SceneTreeDock::_filter_changed(const String &p_filter) { void SceneTreeDock::_filter_changed(const String &p_filter) {
scene_tree->set_filter(p_filter); scene_tree->set_filter(p_filter);
@ -3088,14 +3089,11 @@ void SceneTreeDock::_append_filter_options_to(PopupMenu *p_menu, bool p_include_
p_menu->add_separator(); p_menu->add_separator();
p_menu->set_item_text(-1, TTR("Filters")); p_menu->set_item_text(-1, TTR("Filters"));
p_menu->set_item_icon(-1, get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
p_menu->set_item_indent(-1, -2); p_menu->set_item_indent(-1, -2);
} }
p_menu->add_item(TTR("Filter by Type"), FILTER_BY_TYPE); p_menu->add_item(TTR("Filter by Type"), FILTER_BY_TYPE);
p_menu->add_item(TTR("Filter by Group"), FILTER_BY_GROUP); p_menu->add_item(TTR("Filter by Group"), FILTER_BY_GROUP);
p_menu->set_item_icon(p_menu->get_item_index(FILTER_BY_TYPE), get_theme_icon(SNAME("Node"), SNAME("EditorIcons")));
p_menu->set_item_icon(p_menu->get_item_index(FILTER_BY_GROUP), get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")));
p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_TYPE), TTR("Selects all Nodes of the given type.")); p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_TYPE), TTR("Selects all Nodes of the given type."));
p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_GROUP), TTR("Selects all Nodes belonging to the given group.\nIf empty, selects any Node belonging to any group.")); p_menu->set_item_tooltip(p_menu->get_item_index(FILTER_BY_GROUP), TTR("Selects all Nodes belonging to the given group.\nIf empty, selects any Node belonging to any group."));
} }
@ -3716,8 +3714,8 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
filter->add_theme_constant_override("minimum_character_width", 0); filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed)); filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed));
filter->connect("gui_input", callable_mp(this, &SceneTreeDock::_filter_gui_input)); filter->connect("gui_input", callable_mp(this, &SceneTreeDock::_filter_gui_input));
filter->get_menu()->connect("about_to_popup", callable_mp(this, &SceneTreeDock::_update_filter_menu));
filter->get_menu()->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected)); filter->get_menu()->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected));
_append_filter_options_to(filter->get_menu());
filter_quick_menu = memnew(PopupMenu); filter_quick_menu = memnew(PopupMenu);
filter_quick_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected)); filter_quick_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected));

View File

@ -249,7 +249,6 @@ class SceneTreeDock : public VBoxContainer {
void _tree_rmb(const Vector2 &p_menu_pos); void _tree_rmb(const Vector2 &p_menu_pos);
void _update_tree_menu(); void _update_tree_menu();
void _update_filter_menu();
void _filter_changed(const String &p_filter); void _filter_changed(const String &p_filter);
void _filter_gui_input(const Ref<InputEvent> &p_event); void _filter_gui_input(const Ref<InputEvent> &p_event);