diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-06-19 04:38:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-06-19 04:38:06 +0300 |
commit | d80b0bdc564d773ab5adf5ccd15cb51b07359ba6 (patch) | |
tree | 94aeff861a1a7b2ad575a59559714c8b91f489df | |
parent | 74364a3928a15bf1380dc0498b3632e6354049d2 (diff) |
UI: show label in tool-tips
When button text doesn't already show the label,
include the label in the tool-tip.
Without this the descriptions for icon-only buttons
don't always make sense.
This also gives a tool-tip for icon-only popovers.
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 9d1b6fc92fc..f10702f3f3b 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -608,6 +608,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is 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}; uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL}; uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL}; @@ -623,6 +624,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) UI_but_string_info_get(C, but, + &but_label, &but_tip, &enum_label, &enum_tip, @@ -632,6 +634,17 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) &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. */ + if (but_label.strinfo && !STRPREFIX(but->drawstr, but_label.strinfo)) { + uiTooltipField *field = text_field_add(data, + &(uiTooltipFormat){ + .style = UI_TIP_STYLE_HEADER, + .color_id = UI_TIP_LC_NORMAL, + }); + field->text = BLI_sprintfN("%s.", but_label.strinfo); + } + /* Tip */ if (but_tip.strinfo) { { @@ -844,6 +857,9 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) } /* Free strinfo's... */ + if (but_label.strinfo) { + MEM_freeN(but_label.strinfo); + } if (but_tip.strinfo) { MEM_freeN(but_tip.strinfo); } |