diff options
Diffstat (limited to 'source/blender/editors/interface/interface_region_tooltip.c')
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index d88e4283553..2bf63955855 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -531,7 +531,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is { uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL}; - UI_but_string_info_get(C, but, NULL, &op_keymap, NULL); + UI_but_string_info_get(C, but, &op_keymap, NULL); shortcut = op_keymap.strinfo; } @@ -761,9 +761,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is return data; } -static uiTooltipData *ui_tooltip_data_from_button(bContext *C, - uiBut *but, - uiButExtraOpIcon *extra_icon) +static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) { uiStringInfo but_label = {BUT_GET_LABEL, NULL}; uiStringInfo but_tip = {BUT_GET_TIP, NULL}; @@ -776,29 +774,20 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, char buf[512]; - wmOperatorType *extra_icon_optype = UI_but_extra_operator_icon_optype_get(extra_icon); - wmOperatorType *optype = extra_icon ? extra_icon_optype : but->optype; - /* create tooltip data */ uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); - if (extra_icon) { - UI_but_string_info_get(C, but, extra_icon, &but_label, &but_tip, &op_keymap, NULL); - } - else { - UI_but_string_info_get(C, - but, - NULL, - &but_label, - &but_tip, - &enum_label, - &enum_tip, - &op_keymap, - &prop_keymap, - &rna_struct, - &rna_prop, - NULL); - } + UI_but_string_info_get(C, + but, + &but_label, + &but_tip, + &enum_label, + &enum_tip, + &op_keymap, + &prop_keymap, + &rna_struct, + &rna_prop, + NULL); /* Tip Label (only for buttons not already showing the label). * Check prefix instead of comparing because the button may include the shortcut. */ @@ -931,16 +920,15 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, } } } - else if (optype) { - PointerRNA *opptr = extra_icon_optype ? - UI_but_extra_operator_icon_opptr_get(extra_icon) : - UI_but_operator_ptr_get( - but); /* allocated when needed, the button owns it */ + else if (but->optype) { + PointerRNA *opptr; + char *str; + opptr = UI_but_operator_ptr_get(but); /* allocated when needed, the button owns it */ /* so the context is passed to fieldf functions (some py fieldf functions use it) */ WM_operator_properties_sanitize(opptr, false); - char *str = ui_tooltip_text_python_from_op(C, optype, opptr); + str = ui_tooltip_text_python_from_op(C, but->optype, opptr); /* operator info */ if (U.flag & USER_TOOLTIPS_PYTHON) { @@ -967,7 +955,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, disabled_msg = CTX_wm_operator_poll_msg_get(C); } /* alternatively, buttons can store some reasoning too */ - if (!disabled_msg && but->disabled_info) { + else if (but->disabled_info) { disabled_msg = TIP_(but->disabled_info); } @@ -1405,8 +1393,11 @@ static ARegion *ui_tooltip_create_with_data(bContext *C, /** \name ToolTip Public API * \{ */ -ARegion *UI_tooltip_create_from_button_or_extra_icon( - bContext *C, ARegion *butregion, uiBut *but, uiButExtraOpIcon *extra_icon, bool is_label) +/** + * \param is_label: When true, show a small tip that only shows the name, + * otherwise show the full tooltip. + */ +ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *but, bool is_label) { wmWindow *win = CTX_wm_window(C); /* aspect values that shrink text are likely unreadable */ @@ -1423,7 +1414,7 @@ ARegion *UI_tooltip_create_from_button_or_extra_icon( } if (data == NULL) { - data = ui_tooltip_data_from_button(C, but, extra_icon); + data = ui_tooltip_data_from_button(C, but); } if (data == NULL) { @@ -1461,15 +1452,6 @@ ARegion *UI_tooltip_create_from_button_or_extra_icon( return region; } -/** - * \param is_label: When true, show a small tip that only shows the name, - * otherwise show the full tooltip. - */ -ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *but, bool is_label) -{ - return UI_tooltip_create_from_button_or_extra_icon(C, butregion, but, NULL, is_label); -} - ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) { wmWindow *win = CTX_wm_window(C); |