[Bf-blender-cvs] [aee04d49603] master: Fix T89246: No Mnemonic Underlines in Dialogs

Harley Acheson noreply at git.blender.org
Fri Jun 18 17:33:43 CEST 2021


Commit: aee04d496035c2b11b640a91b2e7eca86e878cf2
Author: Harley Acheson
Date:   Fri Jun 18 08:32:07 2021 -0700
Branches: master
https://developer.blender.org/rBaee04d496035c2b11b640a91b2e7eca86e878cf2

Fix T89246: No Mnemonic Underlines in Dialogs

When drawing mnemonic underlines for hotkeys, use text output of
underscore character instead of direct drawing a line. Otherwise these
are not visible in dialog buttons.

Introduced in 0fcc063fd99c

Differential Revision: https://developer.blender.org/D11641

Reviewed by Campbell Barton

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

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

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

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d5714c152a3..4f24911b8f2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1949,8 +1949,8 @@ static bool widget_draw_text_underline_calc_position(const char *UNUSED(str),
     /* Full width of this glyph including both bearings. */
     const float width = glyph_bounds->xmin + BLI_rctf_size_x(glyph_bounds) + glyph_bounds->xmin;
     ul_data->r_offset_px[0] = glyph_step_bounds->xmin + ((width - ul_data->width_px) * 0.5f);
-    /* Two line-widths below the lower glyph bounds. */
-    ul_data->r_offset_px[1] = glyph_bounds->ymin - U.pixelsize - U.pixelsize;
+    /* One line-width below the lower glyph bounds. */
+    ul_data->r_offset_px[1] = glyph_bounds->ymin - U.pixelsize;
     /* Early exit. */
     return false;
   }
@@ -2221,16 +2221,13 @@ static void widget_draw_text(const uiFontStyle *fstyle,
                                      widget_draw_text_underline_calc_position,
                                      &ul_data);
 
-          GPU_blend(GPU_BLEND_ALPHA);
-          const uint pos = GPU_vertformat_attr_add(
-              immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
-          immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-          immUniformColor4ubv(wcol->text);
           const int pos_x = rect->xmin + font_xofs + ul_data.r_offset_px[0];
           const int pos_y = rect->ymin + font_yofs + ul_data.r_offset_px[1];
-          immRecti(pos, pos_x, pos_y, pos_x + ul_width, pos_y - ul_height);
-          immUnbindProgram();
-          GPU_blend(GPU_BLEND_NONE);
+
+          /* Use text output because direct drawing doesn't always work. See T89246. */
+          BLF_position(fstyle->uifont_id, pos_x, pos_y, 0.0f);
+          BLF_color4ubv(fstyle->uifont_id, wcol->text);
+          BLF_draw(fstyle->uifont_id, "_", 2);
 
           if (fstyle->kerning == 1) {
             BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);



More information about the Bf-blender-cvs mailing list