diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-25 03:28:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-25 03:31:04 +0400 |
commit | d0ec83c1a24f0cc64588741f7a4758b80af8296c (patch) | |
tree | 7bbbc78d9f6ca4044a2f43e7687830f129adcc04 /source | |
parent | e643d2c2114ecff443890456ff5c1d03338a45e3 (diff) |
Fix T38809: regression, text cursor offset in number buttons
Use the same offset for all edit-buttons now.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface.c | 15 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 35 |
3 files changed, 36 insertions, 15 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d2a4dab21d7..99d97e9d500 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1795,6 +1795,21 @@ int ui_get_but_string_max_length(uiBut *but) 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) { UnitSettings *unit = but->block->unit; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 29f56192eb2..e0185d82925 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -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_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 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); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ce25c6af340..a05c9d49b6d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -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); } - static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { 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, * don't draw the text for any of the multi-editing buttons */ if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) { - uiBut *but_iter; - for (but_iter = but->block->buttons.first; but_iter; but_iter = but_iter->next) { - if (but_iter->editstr) { - drawstr = but_iter->editstr; - fstyle->align = UI_STYLE_TEXT_LEFT; - break; - } + uiBut *but_edit = ui_get_but_drag_multi_edit(but); + if (but_edit) { + drawstr = but_edit->editstr; + fstyle->align = UI_STYLE_TEXT_LEFT; } } @@ -2417,9 +2413,11 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int widgetbase_draw(&wtb, wcol); - /* text space */ - rect->xmin += textofs; - rect->xmax -= textofs; + if (!(state & UI_TEXTINPUT)) { + /* text space */ + rect->xmin += textofs; + rect->xmax -= textofs; + } } 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); /* add space at either side of the button so text aligns with numbuttons (which have arrow icons) */ - rect->xmax -= toffs; - rect->xmin += toffs; + if (!(state & UI_TEXTINPUT)) { + rect->xmax -= toffs; + rect->xmin += toffs; + } } @@ -3539,8 +3539,13 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct roundboxalign = widget_roundbox_set(but, rect); 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 (but->dt != UI_EMBOSSP) disabled = true; |