diff options
author | Harley Acheson <harley> | 2020-05-03 09:52:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-05-03 10:08:05 +0300 |
commit | 5366eb89c6eb4057edfdf16eb42f31d34f6a0ba4 (patch) | |
tree | 647b79e6be46f5239f755827ec79a23f73cfc188 /source/blender/editors/interface/interface_widgets.c | |
parent | 0d65520f05ec5474e62d453aa62eb06efa3981d7 (diff) |
UI: improve widget text cursor position
Use BLF_boundbox_foreach_glyph for more accurate cursor placement.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index e927d259926..e0ea760d7bd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2097,15 +2097,16 @@ static void widget_draw_text_ime_underline(const uiFontStyle *fstyle, static bool widget_draw_text_underline_calc_center_x(const char *UNUSED(str), const size_t str_step_ofs, const rcti *glyph_step_bounds, - const int glyph_advance_x, - const rctf *UNUSED(glyph_bounds), - const float UNUSED(glyph_bearing[2]), + const int UNUSED(glyph_advance_x), + const rctf *glyph_bounds, + const float glyph_bearing[2], void *user_data) { /* The index of the character to get, set to the x-position. */ int *ul_data = user_data; if (ul_data[0] == (int)str_step_ofs) { - ul_data[1] = glyph_step_bounds->xmin + (glyph_advance_x / 2); + ul_data[1] = glyph_step_bounds->xmin + glyph_bearing[0] + + (BLI_rctf_size_x(glyph_bounds) / 2.0f); /* Early exit. */ return false; } |