Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicating the "Filters" section #79650

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,11 @@ void SceneTreeDock::_notification(int p_what) {

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")));
Copy link
Member

@KoBeWi KoBeWi Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a better way to get this item than using the text.

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...
if (button_2d) {
button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons")));
Expand Down Expand Up @@ -3030,10 +3035,6 @@ void SceneTreeDock::_update_tree_menu() {
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) {
scene_tree->set_filter(p_filter);

Expand Down Expand Up @@ -3088,14 +3089,11 @@ void SceneTreeDock::_append_filter_options_to(PopupMenu *p_menu, bool p_include_
p_menu->add_separator();

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->add_item(TTR("Filter by Type"), FILTER_BY_TYPE);
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_GROUP), TTR("Selects all Nodes belonging to the given group.\nIf empty, selects any Node belonging to any group."));
}
Expand Down Expand Up @@ -3716,8 +3714,8 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec
filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed));
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));
_append_filter_options_to(filter->get_menu());

filter_quick_menu = memnew(PopupMenu);
filter_quick_menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_filter_option_selected));
Expand Down
1 change: 0 additions & 1 deletion editor/scene_tree_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ class SceneTreeDock : public VBoxContainer {

void _tree_rmb(const Vector2 &p_menu_pos);
void _update_tree_menu();
void _update_filter_menu();

void _filter_changed(const String &p_filter);
void _filter_gui_input(const Ref<InputEvent> &p_event);
Expand Down