Cleanup: Use common define for menu separator arrow

This commit is contained in:
Hans Goudey 2021-10-21 12:50:55 -05:00
parent 7b9319adf9
commit 3858bf5c6f
3 changed files with 10 additions and 15 deletions

View File

@ -96,6 +96,9 @@ typedef struct uiTreeViewItemHandle uiTreeViewItemHandle;
#define UI_SEP_CHAR '|'
#define UI_SEP_CHAR_S "|"
/* Separator for text in search menus. */
#define UI_MENU_ARROW_SEP "▶"
/* names */
#define UI_MAX_DRAW_STR 400
#define UI_MAX_NAME_STR 128

View File

@ -69,9 +69,6 @@
/** \name Menu Search Template Implementation
* \{ */
/* Unicode arrow. */
#define MENU_SEP "\xe2\x96\xb6"
/**
* Use when #menu_items_from_ui_create is called with `include_all_areas`.
* so we can run the menu item in the area it was extracted from.
@ -415,7 +412,7 @@ static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *d
char uiname[256];
WM_operator_py_idname(idname_as_py, ot->idname);
SNPRINTF(uiname, "%s " MENU_SEP "%s", idname_as_py, ot_ui_name);
SNPRINTF(uiname, "%s " UI_MENU_ARROW_SEP "%s", idname_as_py, ot_ui_name);
item->drawwstr_full = strdup_memarena(memarena, uiname);
item->drawstr = ot_ui_name;
@ -841,7 +838,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
while (menu_parent) {
BLI_dynstr_append(dyn_str, menu_parent->drawstr);
BLI_dynstr_append(dyn_str, " " MENU_SEP " ");
BLI_dynstr_append(dyn_str, " " UI_MENU_ARROW_SEP " ");
menu_parent = menu_parent->temp_child;
}
}
@ -859,13 +856,13 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
BLI_dynstr_appendf(dyn_str, " (%s)", kmi_str);
}
BLI_dynstr_append(dyn_str, " " MENU_SEP " ");
BLI_dynstr_append(dyn_str, " " UI_MENU_ARROW_SEP " ");
}
/* Optional nested menu. */
if (item->drawstr_submenu != NULL) {
BLI_dynstr_append(dyn_str, item->drawstr_submenu);
BLI_dynstr_append(dyn_str, " " MENU_SEP " ");
BLI_dynstr_append(dyn_str, " " UI_MENU_ARROW_SEP " ");
}
BLI_dynstr_append(dyn_str, item->drawstr);
@ -1160,7 +1157,7 @@ void UI_but_func_menu_search(uiBut *but)
UI_but_func_search_set_context_menu(but, ui_search_menu_create_context_menu);
UI_but_func_search_set_tooltip(but, ui_search_menu_create_tooltip);
UI_but_func_search_set_sep_string(but, MENU_SEP);
UI_but_func_search_set_sep_string(but, UI_MENU_ARROW_SEP);
}
void uiTemplateMenuSearch(uiLayout *layout)
@ -1177,6 +1174,4 @@ void uiTemplateMenuSearch(uiLayout *layout)
UI_but_func_menu_search(but);
}
#undef MENU_SEP
/** \} */

View File

@ -74,14 +74,11 @@ static StringRef attribute_domain_string(const AttributeDomain domain)
return StringRef(IFACE_(name));
}
/* Unicode arrow. */
#define MENU_SEP "\xe2\x96\xb6"
static bool attribute_search_item_add(uiSearchItems *items, const GeometryAttributeInfo &item)
{
const StringRef data_type_name = attribute_data_type_string(item.data_type);
const StringRef domain_name = attribute_domain_string(item.domain);
std::string search_item_text = domain_name + " " + MENU_SEP + item.name + UI_SEP_CHAR +
std::string search_item_text = domain_name + " " + UI_MENU_ARROW_SEP + item.name + UI_SEP_CHAR +
data_type_name;
return UI_search_item_add(
@ -198,7 +195,7 @@ void node_geometry_add_attribute_search_button(const bContext *UNUSED(C),
AttributeSearchData, {node_tree, node, (bNodeSocket *)socket_ptr->data});
UI_but_func_search_set_results_are_suggestions(but, true);
UI_but_func_search_set_sep_string(but, MENU_SEP);
UI_but_func_search_set_sep_string(but, UI_MENU_ARROW_SEP);
UI_but_func_search_set(but,
nullptr,
attribute_search_update_fn,