fix narrow text entry fields
widget_draw_text was calculating wrong display length when field is too narrow to show entire input string. Gawain assert caught this 11 function calls away! Thanks to @ianwill for reporting.
This commit is contained in:
@@ -1461,14 +1461,16 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
|||||||
/* for underline drawing */
|
/* for underline drawing */
|
||||||
float font_xofs, font_yofs;
|
float font_xofs, font_yofs;
|
||||||
|
|
||||||
UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs,
|
int drawlen = (drawstr_left_len == INT_MAX) ? strlen(drawstr + but->ofs) : (drawstr_left_len - but->ofs);
|
||||||
drawstr_left_len - but->ofs, &font_xofs, &font_yofs);
|
|
||||||
|
if (drawlen > 0) {
|
||||||
|
UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, drawlen, &font_xofs, &font_yofs);
|
||||||
|
|
||||||
if (but->menu_key != '\0') {
|
if (but->menu_key != '\0') {
|
||||||
char fixedbuf[128];
|
char fixedbuf[128];
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len));
|
BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawlen));
|
||||||
|
|
||||||
str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
|
str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
@@ -1496,6 +1498,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* part text right aligned */
|
/* part text right aligned */
|
||||||
if (drawstr_right) {
|
if (drawstr_right) {
|
||||||
|
|||||||
Reference in New Issue
Block a user