[Bf-blender-cvs] [05da610ee74] soc-2020-outliner: Outliner: Draw collection color behind icon

Nathan Craddock noreply at git.blender.org
Thu Jul 2 05:29:38 CEST 2020


Commit: 05da610ee742250d4aa266c1e9210acb1bf339e1
Author: Nathan Craddock
Date:   Wed Jul 1 17:13:29 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB05da610ee742250d4aa266c1e9210acb1bf339e1

Outliner: Draw collection color behind icon

Rather than coloring the icon itself and drawing a bar to the left, draw
a roundbox behind the collection icon. This has the benefit of being
small but still easily noticed.

Two downsides that need to be addressed:
1. The active collection highlight is not shown. This needs to be
   refactored anyway for all types because it is not always easy to tell
   which items are active.
2. Hierarchies are not colored.

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

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 83cb2b4a6d9..a740a6014ef 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2842,39 +2842,20 @@ static void tselem_draw_icon(uiBlock *block,
     }
   }
   else {
-    if (outliner_is_collection_tree_element(te)) {
-      uchar color[4];
-      float col[4];
-      float aspect = (0.8f * UI_UNIT_Y) / ICON_DEFAULT_HEIGHT;
-      x += 2.0f * aspect;
-      y += 2.0f * aspect;
-      Collection *collection = outliner_collection_from_tree_element(te);
-      if (collection->color != COLLECTION_COLOR_NONE) {
-        outliner_get_collection_color(col, collection->color);
-        rgba_float_to_uchar(color, col);
-        UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, color, true);
-      }
-      else {
-        UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, NULL, false);
-      }
-    }
-    else {
-      uiDefIconBut(block,
-                   UI_BTYPE_LABEL,
-                   0,
-                   data.icon,
-                   x,
-                   y,
-                   UI_UNIT_X,
-                   UI_UNIT_Y,
-                   NULL,
-                   0.0,
-                   0.0,
-                   1.0,
-                   alpha,
-                   (data.drag_id && ID_IS_LINKED(data.drag_id)) ? data.drag_id->lib->filepath :
-                                                                  "");
-    }
+    uiDefIconBut(block,
+                 UI_BTYPE_LABEL,
+                 0,
+                 data.icon,
+                 x,
+                 y,
+                 UI_UNIT_X,
+                 UI_UNIT_Y,
+                 NULL,
+                 0.0,
+                 0.0,
+                 1.0,
+                 alpha,
+                 (data.drag_id && ID_IS_LINKED(data.drag_id)) ? data.drag_id->lib->filepath : "");
   }
 }
 
@@ -3266,6 +3247,26 @@ static void outliner_draw_tree_element(bContext *C,
       te->flag |= TE_ACTIVE;  // for lookup in display hierarchies
     }
 
+    /* collection colors */
+    if (outliner_is_collection_tree_element(te)) {
+      Collection *collection = outliner_collection_from_tree_element(te);
+
+      if (collection->color != COLLECTION_COLOR_NONE) {
+        float color[4];
+        outliner_get_collection_color(color, collection->color);
+
+        UI_draw_roundbox_corner_set(UI_CNR_ALL);
+        UI_draw_roundbox_aa(true,
+                            (float)startx + offsx + UI_UNIT_X,
+                            (float)*starty + ufac,
+                            (float)startx + offsx + 2.0f * UI_UNIT_X,
+                            (float)*starty + UI_UNIT_Y - ufac,
+                            UI_UNIT_Y / 4.0f,
+                            color);
+        GPU_blend(true);
+      }
+    }
+
     if (tselem->type == TSE_VIEW_COLLECTION_BASE) {
       /* Scene collection in view layer can't expand/collapse. */
     }
@@ -3620,19 +3621,6 @@ static void outliner_draw_highlights_recursive(uint pos,
       }
     }
 
-    /* collection color */
-    if (outliner_is_collection_tree_element(te)) {
-      Collection *collection = outliner_collection_from_tree_element(te);
-
-      if (collection->color != COLLECTION_COLOR_NONE) {
-        float col[4];
-
-        outliner_get_collection_color(col, collection->color);
-        immUniformColor4fv(col);
-        immRecti(pos, 0, start_y, U.pixelsize * 3, start_y + UI_UNIT_Y);
-      }
-    }
-
     *io_start_y -= UI_UNIT_Y;
     if (TSELEM_OPEN(tselem, soops)) {
       outliner_draw_highlights_recursive(pos,



More information about the Bf-blender-cvs mailing list