[Bf-blender-cvs] [d20886e98d7] temp-checkbox-layout-tweaks: Fix more cases of recursive property splitting

Julian Eisel noreply at git.blender.org
Sat Apr 11 22:59:50 CEST 2020


Commit: d20886e98d7e2410901dba076546b69597026f28
Author: Julian Eisel
Date:   Sat Apr 11 21:57:45 2020 +0200
Branches: temp-checkbox-layout-tweaks
https://developer.blender.org/rBd20886e98d7e2410901dba076546b69597026f28

Fix more cases of recursive property splitting

A bit hacky, but we have to disable the `use_property_split` flag for a
row after adding the split layout to prevent it from further splitting
when adding more items. If these new items actually add multiple buttons
(vector items), these should be placed in a column like before (by
accident?). E.g. that's how the translate buttons (a vector item) is
aligned with the lock icons (another vector item).

===================================================================

M	source/blender/editors/interface/interface_layout.c

===================================================================

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index f23db374831..dcc138da8b3 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -135,10 +135,11 @@ enum {
 
   UI_ITEM_BOX_ITEM = 1 << 2, /* The item is "inside" a box item */
   UI_ITEM_PROP_SEP = 1 << 3,
+  UI_ITEM_INSIDE_PROP_SEP = 1 << 4,
   /* Show an icon button next to each property (to set keyframes, show status).
    * Enabled by default, depends on 'UI_ITEM_PROP_SEP'. */
-  UI_ITEM_PROP_DECORATE = 1 << 4,
-  UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 5,
+  UI_ITEM_PROP_DECORATE = 1 << 5,
+  UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 6,
 };
 
 typedef struct uiButtonItem {
@@ -1903,7 +1904,14 @@ static void ui_layout_heading_label_add(uiLayout *layout, char *heading, bool ri
  */
 static uiLayout *ui_item_prop_split_layout_hack(uiLayout *layout_parent, uiLayout *layout_split)
 {
+  /* Tag item as using property split layout, this is inherited to children so they can get special
+   * treatment if needed. */
+  layout_parent->item.flag |= UI_ITEM_INSIDE_PROP_SEP;
+
   if (layout_parent->item.type == ITEM_LAYOUT_ROW) {
+    /* Prevent further splits within the row. */
+    uiLayoutSetPropSep(layout_parent, false);
+
     layout_parent->child_items_layout = uiLayoutRow(layout_split, true);
     return layout_parent->child_items_layout;
   }
@@ -1922,6 +1930,7 @@ void uiItemFullR(uiLayout *layout,
   uiBlock *block = layout->root->block;
   char namestr[UI_MAX_NAME_STR];
   const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+  const bool inside_prop_sep = ((layout->item.flag & UI_ITEM_INSIDE_PROP_SEP) != 0);
   /* Columns can define a heading to insert. If the first item added to a split layout doesn't have
    * a label to display in the first column, the heading is inserted there. Otherwise it's inserted
    * as a new row before the first item. */
@@ -2193,6 +2202,12 @@ void uiItemFullR(uiLayout *layout,
     layout = uiLayoutColumn(layout_parent, true);
     ui_layout_heading_label_add(layout, heading, false);
   }
+  else if (inside_prop_sep) {
+    /* When placing further items in a split row, add them to a column so they match the column
+     * layout of previous items (e.g. transform vector with lock icon for each item). */
+    layout = uiLayoutColumn(layout_parent, true);
+    layout->space = 0;
+  }
 
   /* array property */
   if (index == RNA_NO_INDEX && is_array) {
@@ -3108,11 +3123,6 @@ uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int
   if (layout->item.flag & UI_ITEM_PROP_SEP) {
     uiBlock *block = uiLayoutGetBlock(layout);
 
-    /* Don't do further splits of the layout. */
-    if (layout->item.type == ITEM_LAYOUT_ROW) {
-      uiLayoutSetPropSep(layout, false);
-    }
-
     uiLayout *layout_row = uiLayoutRow(layout, true);
     uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
     uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
@@ -4568,7 +4578,8 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali
   litem->redalert = layout->redalert;
   litem->w = layout->w;
   litem->emboss = layout->emboss;
-  litem->item.flag = (layout->item.flag & (UI_ITEM_PROP_SEP | UI_ITEM_PROP_DECORATE));
+  litem->item.flag = (layout->item.flag &
+                      (UI_ITEM_PROP_SEP | UI_ITEM_PROP_DECORATE | UI_ITEM_INSIDE_PROP_SEP));
 
   if (layout->child_items_layout) {
     BLI_addtail(&layout->child_items_layout->items, litem);



More information about the Bf-blender-cvs mailing list