[Bf-blender-cvs] [d80b0bdc564] master: UI: show label in tool-tips

Campbell Barton noreply at git.blender.org
Wed Jun 19 04:06:51 CEST 2019


Commit: d80b0bdc564d773ab5adf5ccd15cb51b07359ba6
Author: Campbell Barton
Date:   Wed Jun 19 11:38:06 2019 +1000
Branches: master
https://developer.blender.org/rBd80b0bdc564d773ab5adf5ccd15cb51b07359ba6

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.

===================================================================

M	source/blender/editors/interface/interface_region_tooltip.c

===================================================================

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);
   }



More information about the Bf-blender-cvs mailing list