diff options
author | Yevgeny Makarov <jenkm> | 2020-10-29 02:01:51 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2020-10-29 02:01:51 +0300 |
commit | 6bf043ac946f39f2ac3063feb7e7cfe7b7a6ba18 (patch) | |
tree | 827e540e7dffb14aa471fbd2f6da5183e680e19a /source/blender/editors/interface/interface_widgets.c | |
parent | d32188b85bf031f316bf0ae284805c5934fdee9c (diff) |
UI: Improved alignment of labels and buttons
Improved alignment of labels with other buttons.
Differential Revision: https://developer.blender.org/D9058
Reviewed by Julian Eisel
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 415a0440be6..e2250c764b1 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2426,19 +2426,23 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, } } else if (but->drawflag & UI_BUT_TEXT_LEFT) { - - /* Reduce the left padding for labels without an icon. */ - if ((but->type == UI_BTYPE_LABEL) && !(but->flag & UI_HAS_ICON) && - !ui_block_is_menu(but->block)) { - text_padding /= 2; - } - rect->xmin += text_padding; } else if (but->drawflag & UI_BUT_TEXT_RIGHT) { rect->xmax -= text_padding; } } + else { + /* In case a separate text label and some other button are placed under each other, + and the outline of the button does not contrast with the background. + Add an offset (thickness of the outline) so that the text does not stick out visually. */ + if (but->drawflag & UI_BUT_TEXT_LEFT) { + rect->xmin += U.pixelsize; + } + else if (but->drawflag & UI_BUT_TEXT_RIGHT) { + rect->xmax -= U.pixelsize; + } + } /* Menu contains sub-menu items with triangle icon on their right. Shortcut * strings should be drawn with some padding to the right then. */ @@ -4575,6 +4579,9 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu wt->wcol_theme = &tui->wcol_menu_back; wt->state = widget_state; } + if (!(but->flag & UI_HAS_ICON)) { + but->drawflag |= UI_BUT_NO_TEXT_PADDING; + } break; case UI_BTYPE_SEPR: |