diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2021-06-18 18:32:07 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2021-06-18 18:32:07 +0300 |
commit | aee04d496035c2b11b640a91b2e7eca86e878cf2 (patch) | |
tree | a781f055bd2bf868d3ca06136771e526843fa73b /source | |
parent | 4c19fe470785c0377eead723dc0c9c93a1613537 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 17 |
1 files changed, 7 insertions, 10 deletions
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); |