From a344f203467940cbb8fe6dde001fba5c4517619d Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 2 Mar 2021 12:43:27 -0600 Subject: UI: Rename search button variable I landed D10527 in rB1a8aee0a7cec accidentally, and the version there was missing a name change discussed in review. This commit just renames the boolean variable controlling the special behavior for attribute search. Original message meant for this change: For geometry nodes we will use search buttons to display a list of attributes available the last time the node tree was executed (D10519). Because this list is just a hint, we need to be able to enter any string, not just strings from the search items. This patch adds a boolean option to string buttons to enable this. The change is quite simple, changes to behavior are only required in two places. The type-specific button struct changes help a lot here. Differential Revision: https://developer.blender.org/D10527 --- source/blender/editors/include/UI_interface.h | 2 +- source/blender/editors/interface/interface.c | 4 ++-- source/blender/editors/interface/interface_handlers.c | 2 +- source/blender/editors/interface/interface_intern.h | 2 +- source/blender/editors/interface/interface_region_search.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 09e1a269ae1..5620d39ab16 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1606,7 +1606,7 @@ void UI_but_func_search_set(uiBut *but, void UI_but_func_search_set_context_menu(uiBut *but, uiButSearchContextMenuFn context_menu_fn); void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn); void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string); -void UI_but_func_search_set_all_strings_valid(uiBut *but, const bool value); +void UI_but_func_search_set_results_are_suggestions(uiBut *but, const bool value); /* height in pixels, it's using hardcoded values still */ int UI_searchbox_size_y(void); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ed2984e1a86..c7f5385eac3 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6661,12 +6661,12 @@ void UI_but_func_search_set_tooltip(uiBut *but, uiButSearchTooltipFn tooltip_fn) but_search->item_tooltip_fn = tooltip_fn; } -void UI_but_func_search_set_all_strings_valid(uiBut *but, const bool value) +void UI_but_func_search_set_results_are_suggestions(uiBut *but, const bool value) { uiButSearch *but_search = (uiButSearch *)but; BLI_assert(but->type == UI_BTYPE_SEARCH_MENU); - but_search->all_strings_valid = value; + but_search->results_are_suggestions = value; } /* Callbacks for operator search button. */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 40202250d9f..75ee3300e63 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3413,7 +3413,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) if ((ui_searchbox_apply(but, data->searchbox) == false) && (ui_searchbox_find_index(data->searchbox, but->editstr) == -1) && - !but_search->all_strings_valid) { + !but_search->results_are_suggestions) { data->cancel = true; /* ensure menu (popup) too is closed! */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9d0184ce487..c39e2b3ff8a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -325,7 +325,7 @@ typedef struct uiButSearch { * The search box only provides suggestions, it does not force * the string to match one of the search items when applying. */ - bool all_strings_valid; + bool results_are_suggestions; } uiButSearch; /** Derived struct for #UI_BTYPE_DECORATOR */ diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c index 9297da5307a..12044863b8c 100644 --- a/source/blender/editors/interface/interface_region_search.c +++ b/source/blender/editors/interface/interface_region_search.c @@ -1053,7 +1053,7 @@ void ui_but_search_refresh(uiButSearch *search_but) ui_searchbox_update_fn(but->block->evil_C, search_but, but->drawstr, items); - if (!search_but->all_strings_valid) { + if (!search_but->results_are_suggestions) { /* Only red-alert when we are sure of it, this can miss cases when >10 matches. */ if (items->totitem == 0) { UI_but_flag_enable(but, UI_BUT_REDALERT); -- cgit v1.2.3