Cleanup: split search menu separator argument into own function

This commit is contained in:
Campbell Barton 2020-05-07 23:16:16 +10:00
parent 74c01afe22
commit daf10d17f4
8 changed files with 17 additions and 22 deletions

View File

@ -1572,15 +1572,15 @@ eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
/* use inside searchfunc to add items */
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid, int state);
/* bfunc gets search item *poin as arg2, or if NULL the old string */
void UI_but_func_search_set(uiBut *but,
uiButSearchCreateFn search_create_fn,
uiButSearchUpdateFn search_update_fn,
void *arg,
uiButSearchArgFreeFn search_arg_free_fn,
uiButHandleFunc bfunc,
const char *search_sep_string,
uiButHandleFunc handle_fn,
void *active);
void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string);
/* height in pixels, it's using hardcoded values still */
int UI_searchbox_size_y(void);
int UI_searchbox_size_x(void);

View File

@ -6362,8 +6362,7 @@ void UI_but_func_search_set(uiBut *but,
uiButSearchUpdateFn search_update_fn,
void *arg,
uiButSearchArgFreeFn search_arg_free_fn,
uiButHandleFunc bfunc,
const char *search_sep_string,
uiButHandleFunc handle_fn,
void *active)
{
/* needed since callers don't have access to internal functions
@ -6389,9 +6388,8 @@ void UI_but_func_search_set(uiBut *but,
search->arg = arg;
search->arg_free_fn = search_arg_free_fn;
search->sep_string = search_sep_string;
if (bfunc) {
if (handle_fn) {
#ifdef DEBUG
if (but->func) {
/* watch this, can be cause of much confusion, see: T47691 */
@ -6399,7 +6397,7 @@ void UI_but_func_search_set(uiBut *but,
__func__);
}
#endif
UI_but_func_set(but, bfunc, arg, active);
UI_but_func_set(but, handle_fn, search->arg, active);
}
/* search buttons show red-alert if item doesn't exist, not for menus */
@ -6411,6 +6409,12 @@ void UI_but_func_search_set(uiBut *but,
}
}
void UI_but_func_search_set_sep_string(uiBut *but, const char *search_sep_string)
{
struct uiButSearchData *search = but->search;
search->sep_string = search_sep_string;
}
/* Callbacks for operator search button. */
static void operator_enum_search_cb(const struct bContext *C,
void *but,
@ -6499,7 +6503,6 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block,
but,
NULL,
operator_enum_call_cb,
NULL,
NULL);
but->optype = ot;

View File

@ -2701,7 +2701,6 @@ void ui_but_add_search(
coll_search,
ui_rna_collection_search_free_cb,
NULL,
NULL,
NULL);
}
else if (but->type == UI_BTYPE_SEARCH_MENU) {

View File

@ -915,8 +915,8 @@ void UI_but_func_menu_search(uiBut *but)
data,
menu_items_from_ui_destroy,
menu_call_fn,
MENU_SEP,
NULL);
UI_but_func_search_set_sep_string(but, MENU_SEP);
}
void uiTemplateMenuSearch(uiLayout *layout)

View File

@ -125,14 +125,8 @@ static void operator_search_cb(const bContext *C,
void UI_but_func_operator_search(uiBut *but)
{
UI_but_func_search_set(but,
ui_searchbox_create_operator,
operator_search_cb,
NULL,
false,
operator_call_cb,
NULL,
NULL);
UI_but_func_search_set(
but, ui_searchbox_create_operator, operator_search_cb, NULL, false, operator_call_cb, NULL);
}
void uiTemplateOperatorSearch(uiLayout *layout)

View File

@ -283,7 +283,6 @@ static uiBlock *template_common_search_menu(const bContext *C,
search_arg,
NULL,
handle_func,
NULL,
active_item);
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);

View File

@ -1182,7 +1182,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
0,
0,
"");
UI_but_func_search_set(but, NULL, node_find_cb, op->type, NULL, node_find_call_cb, NULL, NULL);
UI_but_func_search_set(but, NULL, node_find_cb, op->type, NULL, node_find_call_cb, NULL);
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
/* fake button, it holds space for search items */

View File

@ -600,7 +600,7 @@ static uiBlock *merged_element_search_menu(bContext *C, ARegion *region, void *d
but = uiDefSearchBut(
block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, menu_width, UI_UNIT_Y, 0, 0, "");
UI_but_func_search_set(
but, NULL, merged_element_search_cb, data, NULL, merged_element_search_call_cb, NULL, NULL);
but, NULL, merged_element_search_cb, data, NULL, merged_element_search_call_cb, NULL);
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
/* Fake button to hold space for search items */