diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-28 15:28:23 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-28 15:28:23 +0400 |
commit | de1f84783be75261d5a1e17859f3c902d0b5ba1b (patch) | |
tree | 0998032095ea9676d946f411e03ea1d5c6188dad | |
parent | ad3f01e1d890aa6783c17cf673c6531b3023e4e5 (diff) |
Fix #32673: long strings were wrongly clipped when modifying
It was a regression in svn revision 50676 -- button's string width
should be calculated taking button offset into account.
However, check for button offset should check string width without
offset taken into account.
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f3539af821e..87a7d1957c5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1014,42 +1014,42 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect) if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - if ((but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr)) <= okwidth) { + /* define ofs dynamically */ + if (but->ofs > but->pos) + but->ofs = but->pos; + + if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) but->ofs = 0; - } - else { - /* define ofs dynamically */ - if (but->ofs > but->pos) - but->ofs = but->pos; - - while (but->strwidth > okwidth) { - float width; - char buf[UI_MAX_DRAW_STR]; - - /* copy draw string */ - BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf)); - /* string position of cursor */ - buf[but->pos] = 0; - width = BLF_width(fstyle->uifont_id, buf + but->ofs); - - /* if cursor is at 20 pixels of right side button we clip left */ - if (width > okwidth - 20) { - ui_text_clip_give_next_off(but); - } - else { - int len, bytes; - /* shift string to the left */ - if (width < 20 && but->ofs > 0) - ui_text_clip_give_prev_off(but); - len = strlen(but->drawstr); - bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); - but->drawstr[len - bytes] = 0; - } - but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - if (but->strwidth < 10) break; + while (but->strwidth > okwidth) { + float width; + char buf[UI_MAX_DRAW_STR]; + + /* copy draw string */ + BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf)); + /* string position of cursor */ + buf[but->pos] = 0; + width = BLF_width(fstyle->uifont_id, buf + but->ofs); + + /* if cursor is at 20 pixels of right side button we clip left */ + if (width > okwidth - 20) { + ui_text_clip_give_next_off(but); + } + else { + int len, bytes; + /* shift string to the left */ + if (width < 20 && but->ofs > 0) + ui_text_clip_give_prev_off(but); + len = strlen(but->drawstr); + bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); + but->drawstr[len - bytes] = 0; } + + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + + if (but->strwidth < 10) break; } if (fstyle->kerning == 1) { |