Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-08-05 17:50:33 +0300
committerJulian Eisel <julian@blender.org>2020-08-05 17:56:24 +0300
commitadfde608311dd83585b49fb6d4f19dbd848cd252 (patch)
tree2b117ca5c6bddefe3f889c3d42cf2e67588f64a5 /source/blender/editors
parent87062d4d670c01c9c0835057aaf4164aea971e00 (diff)
Fix T79524: Button alignment broken in some cases
ad4928a1710f disabled alignment for too many cases. Still try to avoid aligning many items, to avoid thousands of redundant alignment calculations. But now we're much more picky adding an sub-row with alignment.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_layout.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b707aaa0ee9..f1d1ef589a5 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -937,7 +937,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
int h,
int flag)
{
- uiLayout *sub;
+ uiLayout *sub = layout;
uiBut *but = NULL;
PropertyType type;
PropertySubType subtype;
@@ -945,14 +945,20 @@ static uiBut *ui_item_with_label(uiLayout *layout,
#ifdef UI_PROP_DECORATE
uiLayout *layout_prop_decorate = NULL;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+ const bool use_prop_decorate = use_prop_sep && (layout->item.flag & UI_ITEM_PROP_DECORATE) &&
+ (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0;
#endif
- /* Previously 'align' was enabled to make sure the label is spaced closely to the button.
- * Set the space to zero instead as aligning a large number of labels can end up aligning
- * thousands of buttons when displaying key-map search (a heavy operation), see: T78636. */
- sub = uiLayoutRow(layout, false);
- sub->space = 0;
- UI_block_layout_set_current(block, sub);
+ UI_block_layout_set_current(block, layout);
+
+ /* Only add new row if more than 1 item will be added. */
+ if (name[0] || use_prop_decorate) {
+ /* Also avoid setting 'align' if possible. Set the space to zero instead as aligning a large
+ * number of labels can end up aligning thousands of buttons when displaying key-map search (a
+ * heavy operation), see: T78636. */
+ sub = uiLayoutRow(layout, layout->align);
+ sub->space = 0;
+ }
#ifdef UI_PROP_DECORATE
if (name[0]) {
@@ -1050,11 +1056,8 @@ static uiBut *ui_item_with_label(uiLayout *layout,
#ifdef UI_PROP_DECORATE
/* Only for alignment. */
- if (use_prop_sep) { /* Flag may have been unset meanwhile. */
- if ((layout->item.flag & UI_ITEM_PROP_DECORATE) &&
- (layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0) {
- uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
- }
+ if (use_prop_decorate) { /* Note that sep flag may have been unset meanwhile. */
+ uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
}
#endif /* UI_PROP_DECORATE */