diff options
author | Julian Eisel <julian@blender.org> | 2021-10-27 13:06:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-10-27 13:14:47 +0300 |
commit | d161b5d204a585b910a47ca432544570ea10911e (patch) | |
tree | cfc49206b2a1520f65dcabd407667f746beb923c /source/blender/editors/interface | |
parent | e16bc136f92bd166219ef6e21bcd1a303b335aa0 (diff) |
UI: Add padding to the left of tree-rows labels without icon
The label was placed right at the left border of the row highlight,
which looked weird. So add some padding to tree-row labels without icon
or collapse chevron, which makes it look more polished. As additional
benefit, it alignes the labels better with icons of other rows on the
same tree level. And the padding makes it more clear that a child is
indeed a child, not just a sibling without icon.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/tree_view.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc index 0eeb32bcc69..04d7a066b36 100644 --- a/source/blender/editors/interface/tree_view.cc +++ b/source/blender/editors/interface/tree_view.cc @@ -641,7 +641,18 @@ BasicTreeViewItem::BasicTreeViewItem(StringRef label, BIFIconID icon_) : icon(ic void BasicTreeViewItem::build_row(uiLayout &row) { - uiItemL(&row, label_.c_str(), icon); + add_label(row); +} + +void BasicTreeViewItem::add_label(uiLayout &layout, StringRefNull label_override) +{ + const StringRefNull label = label_override.is_empty() ? StringRefNull(label_) : label_override; + + /* Some padding for labels without collapse chevron and no icon. Looks weird without. */ + if (icon == ICON_NONE && !is_collapsible()) { + uiItemS_ex(&layout, 0.8f); + } + uiItemL(&layout, label.c_str(), icon); } void BasicTreeViewItem::on_activate() |