diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-25 16:27:31 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-28 19:46:52 +0300 |
commit | 9bcdb19a3e0270a0e8727290111e4a1d6e15a944 (patch) | |
tree | f390e678329570613be33fd6be41ad8615ba975c /source | |
parent | 41a284212a65e1590dc28bee83dcd72ef5e0a6f3 (diff) |
Fix label misalignment when there are multiple buttons on the right side.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index cfc47e65a26..89b08d83b44 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -158,6 +158,9 @@ struct uiLayout { bContextStore *context; ListBase items; + /* Sub layout to add child items, if not the layout itself. */ + uiLayout *child_items_layout; + int x, y, w, h; float scale[2]; short space; @@ -1628,6 +1631,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } /* Split the label / property. */ + uiLayout *layout_parent = layout; if (use_prop_sep) { uiLayout *layout_row = NULL; #ifdef UI_PROP_DECORATE @@ -1693,6 +1697,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index } } + /* Hack to add further items in a row into the second part of + * the split layout, so the label part keeps a fixed size. */ + if (layout_parent && layout_parent->item.type == ITEM_LAYOUT_ROW) { + layout_split = uiLayoutRow(layout_split, true); + layout_parent->child_items_layout = layout_split; + } + /* Watch out! We can only write into the new layout now. */ if ((type == PROP_ENUM) && (flag & UI_ITEM_R_EXPAND)) { /* Expanded enums each have their own name. */ @@ -3608,7 +3619,13 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali litem->w = layout->w; litem->emboss = layout->emboss; litem->item.flag = (layout->item.flag & (UI_ITEM_PROP_SEP | UI_ITEM_PROP_DECORATE)); - BLI_addtail(&layout->items, litem); + + if (layout->child_items_layout) { + BLI_addtail(&layout->child_items_layout->items, litem); + } + else { + BLI_addtail(&layout->items, litem); + } } /* layout create functions */ @@ -4286,7 +4303,12 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but) bitem->item.flag |= UI_ITEM_MIN; } - BLI_addtail(&layout->items, bitem); + if (layout->child_items_layout) { + BLI_addtail(&layout->child_items_layout->items, bitem); + } + else { + BLI_addtail(&layout->items, bitem); + } if (layout->context) { but->context = layout->context; |