Refactor: UI: Pass StringRef to more button definition functions
Similar to 9c3aa8b824. This time there is one null argument
that has to be changed. It was simple to just move the logic to that one
caller.
This commit is contained in:
@@ -1144,7 +1144,7 @@ uiBut *uiDefButO_ptr(uiBlock *block,
|
||||
int type,
|
||||
wmOperatorType *ot,
|
||||
wmOperatorCallContext opcontext,
|
||||
const char *str,
|
||||
blender::StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
@@ -1381,7 +1381,7 @@ uiBut *uiDefIconTextButO(uiBlock *block,
|
||||
const char *opname,
|
||||
wmOperatorCallContext opcontext,
|
||||
int icon,
|
||||
const char *str,
|
||||
blender::StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
@@ -1392,7 +1392,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block,
|
||||
wmOperatorType *ot,
|
||||
wmOperatorCallContext opcontext,
|
||||
int icon,
|
||||
const char *str,
|
||||
blender::StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
|
||||
@@ -4779,24 +4779,13 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block,
|
||||
int type,
|
||||
wmOperatorType *ot,
|
||||
wmOperatorCallContext opcontext,
|
||||
const char *str,
|
||||
const StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
short height,
|
||||
const char *tip)
|
||||
{
|
||||
std::string operator_name;
|
||||
if (!str) {
|
||||
if (ot && ot->srna) {
|
||||
operator_name = WM_operatortype_name(ot, nullptr);
|
||||
str = operator_name.c_str();
|
||||
}
|
||||
else {
|
||||
str = "";
|
||||
}
|
||||
}
|
||||
|
||||
if ((!tip || tip[0] == '\0') && ot && ot->srna && !ot->get_description) {
|
||||
tip = RNA_struct_ui_description(ot->srna);
|
||||
}
|
||||
@@ -4806,9 +4795,8 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block,
|
||||
but->opcontext = opcontext;
|
||||
but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_rna_undo(), we never need undo here */
|
||||
|
||||
const bool has_label = str && str[0];
|
||||
/* Enable quick tooltip label if this is a tool button without a label. */
|
||||
if (!has_label && !ui_block_is_popover(block) && UI_but_is_tool(but)) {
|
||||
if (str.is_empty() && !ui_block_is_popover(block) && UI_but_is_tool(but)) {
|
||||
UI_but_drawflag_enable(but, UI_BUT_HAS_TOOLTIP_LABEL);
|
||||
}
|
||||
|
||||
@@ -5319,7 +5307,7 @@ uiBut *uiDefButO_ptr(uiBlock *block,
|
||||
int type,
|
||||
wmOperatorType *ot,
|
||||
wmOperatorCallContext opcontext,
|
||||
const char *str,
|
||||
const StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
@@ -5774,7 +5762,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block,
|
||||
wmOperatorType *ot,
|
||||
wmOperatorCallContext opcontext,
|
||||
int icon,
|
||||
const char *str,
|
||||
const StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
@@ -5791,7 +5779,7 @@ uiBut *uiDefIconTextButO(uiBlock *block,
|
||||
const char *opname,
|
||||
wmOperatorCallContext opcontext,
|
||||
int icon,
|
||||
const char *str,
|
||||
const StringRef str,
|
||||
int x,
|
||||
int y,
|
||||
short width,
|
||||
@@ -5799,7 +5787,7 @@ uiBut *uiDefIconTextButO(uiBlock *block,
|
||||
const char *tip)
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, false);
|
||||
if (str && str[0] == '\0') {
|
||||
if (str.is_empty()) {
|
||||
return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x, y, width, height, tip);
|
||||
}
|
||||
return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x, y, width, height, tip);
|
||||
|
||||
@@ -5961,17 +5961,16 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn
|
||||
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
|
||||
uiBut *but = uiDefIconTextButO(block,
|
||||
UI_BTYPE_BUT,
|
||||
"UI_OT_eyedropper_color",
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
icon,
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
RNA_property_ui_description(prop));
|
||||
uiBut *but = uiDefIconButO(block,
|
||||
UI_BTYPE_BUT,
|
||||
"UI_OT_eyedropper_color",
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
icon,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
RNA_property_ui_description(prop));
|
||||
but->rnapoin = *ptr;
|
||||
but->rnaprop = prop;
|
||||
but->rnaindex = -1;
|
||||
|
||||
@@ -1458,17 +1458,18 @@ static void file_draw_invalid_asset_library_hint(const bContext *C,
|
||||
sx + UI_UNIT_X, sy, suggestion, width - UI_UNIT_X, line_height, text_col, nullptr, &sy);
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
|
||||
uiBut *but = uiDefIconTextButO(block,
|
||||
UI_BTYPE_BUT,
|
||||
"SCREEN_OT_userpref_show",
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
ICON_PREFERENCES,
|
||||
nullptr,
|
||||
sx + UI_UNIT_X,
|
||||
sy - line_height - UI_UNIT_Y * 1.2f,
|
||||
UI_UNIT_X * 8,
|
||||
UI_UNIT_Y,
|
||||
nullptr);
|
||||
wmOperatorType *ot = WM_operatortype_find("SCREEN_OT_userpref_show", false);
|
||||
uiBut *but = uiDefIconTextButO_ptr(block,
|
||||
UI_BTYPE_BUT,
|
||||
ot,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
ICON_PREFERENCES,
|
||||
WM_operatortype_name(ot, nullptr),
|
||||
sx + UI_UNIT_X,
|
||||
sy - line_height - UI_UNIT_Y * 1.2f,
|
||||
UI_UNIT_X * 8,
|
||||
UI_UNIT_Y,
|
||||
nullptr);
|
||||
PointerRNA *but_opptr = UI_but_operator_ptr_ensure(but);
|
||||
RNA_enum_set(but_opptr, "section", USER_SECTION_FILE_PATHS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user