From 6bf043ac946f39f2ac3063feb7e7cfe7b7a6ba18 Mon Sep 17 00:00:00 2001 From: Yevgeny Makarov Date: Wed, 28 Oct 2020 16:01:51 -0700 Subject: 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 --- release/scripts/modules/rna_prop_ui.py | 4 ++-- source/blender/editors/interface/interface_layout.c | 2 -- .../blender/editors/interface/interface_widgets.c | 21 ++++++++++++++------- source/blender/editors/space_node/node_intern.h | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 98722ea322b..8fdd66dff9f 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -282,10 +282,10 @@ def draw(layout, context, context_member, property_type, use_edit=True): if use_edit: split = box.split(factor=0.75) - row = split.row(align=True) + row = split.row() else: split = box.split(factor=1.00) - row = split.row(align=True) + row = split.row() row.alignment = 'RIGHT' diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index ad260274e78..cf589e43858 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2148,7 +2148,6 @@ void uiItemFullR(uiLayout *layout, uiLayout *layout_split = uiLayoutSplit( layout_row ? layout_row : layout, UI_ITEM_PROP_SEP_DIVIDE, true); bool label_added = false; - layout_split->space = 0; uiLayout *layout_sub = uiLayoutColumn(layout_split, true); layout_sub->space = 0; @@ -3186,7 +3185,6 @@ uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout) uiLayout *layout_row = uiLayoutRow(parent_layout, true); uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true); - layout_split->space = 0; split_wrapper.label_column = uiLayoutColumn(layout_split, true); split_wrapper.label_column->alignment = UI_LAYOUT_ALIGN_RIGHT; split_wrapper.property_row = ui_item_prop_split_layout_hack(parent_layout, layout_split); 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: diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 04e452d5270..aa59b7293a3 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -266,7 +266,7 @@ extern const char *node_context_dir[]; #define NODE_SOCKDY (0.08f * U.widget_unit) #define NODE_WIDTH(node) (node->width * UI_DPI_FAC) #define NODE_HEIGHT(node) (node->height * UI_DPI_FAC) -#define NODE_MARGIN_X (0.95f * U.widget_unit) +#define NODE_MARGIN_X (1.10f * U.widget_unit) #define NODE_SOCKSIZE (0.25f * U.widget_unit) #define NODE_RESIZE_MARGIN (0.20f * U.widget_unit) #define NODE_LINK_RESOL 12 -- cgit v1.2.3