[Bf-blender-cvs] [b134a0c491f] soc-2020-outliner: Outliner: Fix collection hierarchy lines

Nathan Craddock noreply at git.blender.org
Fri Jul 3 23:17:18 CEST 2020


Commit: b134a0c491fe31dd9ee02ce7db6d41424880bbb0
Author: Nathan Craddock
Date:   Fri Jul 3 14:42:32 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBb134a0c491fe31dd9ee02ce7db6d41424880bbb0

Outliner: Fix collection hierarchy lines

There were a couple of cases where the hierarchy lines didn't draw. This
refactors the code to be simpler and cover all the cases.

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

M	source/blender/editors/space_outliner/outliner_draw.c

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index c0ff88ee9af..b077ad3d300 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -3349,6 +3349,8 @@ static void outliner_draw_tree_element(bContext *C,
   }
 }
 
+#if 0
+
 static void outliner_draw_hierarchy_lines_recursive_old(uint pos,
                                                         SpaceOutliner *soops,
                                                         ListBase *lb,
@@ -3450,6 +3452,8 @@ static void outliner_draw_hierarchy_lines_recursive_old(uint pos,
   }
 }
 
+#endif /* if 0 */
+
 static void outliner_draw_hierarchy_lines_recursive(uint pos,
                                                     SpaceOutliner *soops,
                                                     ListBase *lb,
@@ -3459,71 +3463,44 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
                                                     int *starty)
 {
   bTheme *btheme = UI_GetTheme();
-  TreeElement *line_start = NULL, *line_end = NULL;
   int y = *starty;
-  short color_start;
-  const short line_offset = UI_UNIT_Y / 4.0;
+  short color;
 
-  if (BLI_listbase_is_empty(lb)) {
-    return;
-  }
-
-  immUniformColor4ubv(col);
+  /* Small vertical padding */
+  const short line_padding = UI_UNIT_Y / 4.0f;
 
   /* Draw vertical lines between collections */
+  bool draw_hierarchy_line;
   LISTBASE_FOREACH (TreeElement *, te, lb) {
     TreeStoreElem *tselem = TREESTORE(te);
+    draw_hierarchy_line = false;
     *starty -= UI_UNIT_Y;
 
-    if (tselem->type == TSE_LAYER_COLLECTION) {
-      if (line_end) {
-        if (color_start != COLLECTION_COLOR_NONE) {
-          immUniformColor4ubv(btheme->collection_color[color_start - 1].color);
-        }
-        else {
-          immUniformColor4ubv(col);
-        }
+    /* Only draw hierarchy lines for open collections. */
+    if (TSELEM_OPEN(tselem, soops) && !BLI_listbase_is_empty(&te->subtree)) {
+      if (tselem->type == TSE_LAYER_COLLECTION) {
+        draw_hierarchy_line = true;
 
-        immRecti(pos,
-                 startx,
-                 y - line_offset,
-                 startx + (U.pixelsize * 1),
-                 *starty + UI_UNIT_Y + line_offset);
-        line_end = NULL;
-      }
+        Collection *collection = outliner_collection_from_tree_element(te);
+        color = collection->color;
 
-      Collection *collection = outliner_collection_from_tree_element(te);
-      color_start = collection->color;
-      line_start = te;
-      y = *starty;
-    }
+        y = *starty;
+      }
 
-    /* No lines under closed items */
-    if (!TSELEM_OPEN(tselem, soops)) {
-      line_start = NULL;
-      line_end = NULL;
-      continue;
+      outliner_draw_hierarchy_lines_recursive(
+          pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_grayed_out, starty);
     }
-    else if (BLI_listbase_is_empty(&te->subtree)) {
-      line_start = NULL;
-      line_end = NULL;
-      continue;
-    }
-
-    outliner_draw_hierarchy_lines_recursive(
-        pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_grayed_out, starty);
 
-    line_end = te;
-  }
+    if (draw_hierarchy_line) {
+      if (color != COLLECTION_COLOR_NONE) {
+        immUniformColor4ubv(btheme->collection_color[color - 1].color);
+      }
+      else {
+        immUniformColor4ubv(col);
+      }
 
-  if (line_start) {
-    if (color_start != COLLECTION_COLOR_NONE) {
-      immUniformColor4ubv(btheme->collection_color[color_start - 1].color);
-    }
-    else {
-      immUniformColor4ubv(col);
+      immRecti(pos, startx, y - line_padding, startx + (U.pixelsize * 1), *starty + line_padding);
     }
-    immRecti(pos, startx, y - line_offset, startx + (U.pixelsize * 1), *starty + line_offset);
   }
 }



More information about the Bf-blender-cvs mailing list