Follow up: Move BUTTON_SETICON to THEME_CHANGED

This commit is contained in:
Alexander Montag 2024-09-28 17:31:20 +00:00
parent 62460496e4
commit a31b8b7520
1 changed files with 6 additions and 11 deletions

View File

@ -78,7 +78,6 @@ void TreeSearchPanel::_add_spacer(float p_width_multiplier) {
void TreeSearchPanel::_notification(int p_what) { void TreeSearchPanel::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
BUTTON_SET_ICON(close_button, get_theme_icon(LW_NAME(Close), LW_NAME(EditorIcons)));
// close callbacks // close callbacks
close_button->connect("pressed", Callable(this, "set_visible").bind(false)); close_button->connect("pressed", Callable(this, "set_visible").bind(false));
@ -94,6 +93,7 @@ void TreeSearchPanel::_notification(int p_what) {
break; break;
} }
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
BUTTON_SET_ICON(close_button, get_theme_icon(LW_NAME(Close), LW_NAME(EditorIcons)));
label_filter->set_text(TTR("Filter")); label_filter->set_text(TTR("Filter"));
} }
} }
@ -397,7 +397,6 @@ void TreeSearch::_select_first_match() {
if (!_vector_has_bsearch(matching_entries, item)) { if (!_vector_has_bsearch(matching_entries, item)) {
continue; continue;
} }
String debug_string = "[";
_select_item(item); _select_item(item);
return; return;
} }
@ -422,14 +421,12 @@ void TreeSearch::_select_next_match() {
} }
// find the best fitting entry. // find the best fitting entry.
for (int i = 0; i < ordered_tree_items.size(); i++) { for (int i = MAX(0, selected_idx) + 1; i < ordered_tree_items.size(); i++) {
TreeItem *item = ordered_tree_items[i]; TreeItem *item = ordered_tree_items[i];
if (!_vector_has_bsearch(matching_entries, item) || selected_idx >= i) { if (_vector_has_bsearch(matching_entries, item)) {
continue; _select_item(item);
return;
} }
_select_item(item);
return;
} }
_select_first_match(); // wrap around. _select_first_match(); // wrap around.
} }
@ -473,9 +470,6 @@ void TreeSearch::update_search(Tree *p_tree) {
_update_number_matches(); _update_number_matches();
_highlight_tree(search_mask); _highlight_tree(search_mask);
if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) {
search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match));
}
if (search_mode == TreeSearchMode::FILTER) { if (search_mode == TreeSearchMode::FILTER) {
_filter_tree(search_mask); _filter_tree(search_mask);
@ -484,6 +478,7 @@ void TreeSearch::update_search(Tree *p_tree) {
TreeSearch::TreeSearch(TreeSearchPanel *p_search_panel) { TreeSearch::TreeSearch(TreeSearchPanel *p_search_panel) {
search_panel = p_search_panel; search_panel = p_search_panel;
search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match));
} }
/* !TreeSearch */ /* !TreeSearch */