Fix T38809: regression, text cursor offset in number buttons
Use the same offset for all edit-buttons now.
This commit is contained in:
@@ -1795,6 +1795,21 @@ int ui_get_but_string_max_length(uiBut *but)
|
|||||||
return UI_MAX_DRAW_STR;
|
return UI_MAX_DRAW_STR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiBut *ui_get_but_drag_multi_edit(uiBut *but)
|
||||||
|
{
|
||||||
|
uiBut *but_iter;
|
||||||
|
|
||||||
|
BLI_assert(but->flag & UI_BUT_DRAG_MULTI);
|
||||||
|
|
||||||
|
for (but_iter = but->block->buttons.first; but_iter; but_iter = but_iter->next) {
|
||||||
|
if (but_iter->editstr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return but_iter;
|
||||||
|
}
|
||||||
|
|
||||||
static double ui_get_but_scale_unit(uiBut *but, double value)
|
static double ui_get_but_scale_unit(uiBut *but, double value)
|
||||||
{
|
{
|
||||||
UnitSettings *unit = but->block->unit;
|
UnitSettings *unit = but->block->unit;
|
||||||
|
@@ -394,6 +394,7 @@ extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) AT
|
|||||||
extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str) ATTR_NONNULL();
|
extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str) ATTR_NONNULL();
|
||||||
extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value) ATTR_NONNULL();
|
extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value) ATTR_NONNULL();
|
||||||
extern int ui_get_but_string_max_length(uiBut *but);
|
extern int ui_get_but_string_max_length(uiBut *but);
|
||||||
|
extern uiBut *ui_get_but_drag_multi_edit(uiBut *but);
|
||||||
|
|
||||||
extern void ui_set_but_default(struct bContext *C, const bool all, const bool use_afterfunc);
|
extern void ui_set_but_default(struct bContext *C, const bool all, const bool use_afterfunc);
|
||||||
|
|
||||||
|
@@ -1190,7 +1190,6 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
|
|||||||
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
|
static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
|
||||||
{
|
{
|
||||||
int drawstr_left_len = UI_MAX_DRAW_STR;
|
int drawstr_left_len = UI_MAX_DRAW_STR;
|
||||||
@@ -1214,13 +1213,10 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
|||||||
/* Special case: when we're entering text for multiple buttons,
|
/* Special case: when we're entering text for multiple buttons,
|
||||||
* don't draw the text for any of the multi-editing buttons */
|
* don't draw the text for any of the multi-editing buttons */
|
||||||
if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) {
|
if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) {
|
||||||
uiBut *but_iter;
|
uiBut *but_edit = ui_get_but_drag_multi_edit(but);
|
||||||
for (but_iter = but->block->buttons.first; but_iter; but_iter = but_iter->next) {
|
if (but_edit) {
|
||||||
if (but_iter->editstr) {
|
drawstr = but_edit->editstr;
|
||||||
drawstr = but_iter->editstr;
|
fstyle->align = UI_STYLE_TEXT_LEFT;
|
||||||
fstyle->align = UI_STYLE_TEXT_LEFT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2417,9 +2413,11 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
|
|||||||
|
|
||||||
widgetbase_draw(&wtb, wcol);
|
widgetbase_draw(&wtb, wcol);
|
||||||
|
|
||||||
/* text space */
|
if (!(state & UI_TEXTINPUT)) {
|
||||||
rect->xmin += textofs;
|
/* text space */
|
||||||
rect->xmax -= textofs;
|
rect->xmin += textofs;
|
||||||
|
rect->xmax -= textofs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||||
@@ -2735,8 +2733,10 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
|
|||||||
widgetbase_draw(&wtb, wcol);
|
widgetbase_draw(&wtb, wcol);
|
||||||
|
|
||||||
/* add space at either side of the button so text aligns with numbuttons (which have arrow icons) */
|
/* add space at either side of the button so text aligns with numbuttons (which have arrow icons) */
|
||||||
rect->xmax -= toffs;
|
if (!(state & UI_TEXTINPUT)) {
|
||||||
rect->xmin += toffs;
|
rect->xmax -= toffs;
|
||||||
|
rect->xmin += toffs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3539,7 +3539,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
|||||||
roundboxalign = widget_roundbox_set(but, rect);
|
roundboxalign = widget_roundbox_set(but, rect);
|
||||||
|
|
||||||
state = but->flag;
|
state = but->flag;
|
||||||
if (but->editstr) state |= UI_TEXTINPUT;
|
|
||||||
|
if ((but->editstr) ||
|
||||||
|
(UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_get_but_drag_multi_edit(but)))
|
||||||
|
{
|
||||||
|
state |= UI_TEXTINPUT;
|
||||||
|
}
|
||||||
|
|
||||||
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
||||||
if (but->dt != UI_EMBOSSP)
|
if (but->dt != UI_EMBOSSP)
|
||||||
|
Reference in New Issue
Block a user