[Bf-blender-cvs] [0518c9d582e] soc-2020-outliner: Collections: Show color tags in object.collection_link

Nathan Craddock noreply at git.blender.org
Thu Aug 13 01:01:03 CEST 2020


Commit: 0518c9d582ec389cba512303f5405bef4dd6f4d6
Author: Nathan Craddock
Date:   Wed Aug 12 16:29:23 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB0518c9d582ec389cba512303f5405bef4dd6f4d6

Collections: Show color tags in object.collection_link

Add a case to rna_id_itemf to add collection color tags. It may be
better to create a separate function, but it works okay for now.

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

M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1964813fff9..51e629520d8 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3972,6 +3972,18 @@ static bool rna_id_enum_filter_single(ID *id, void *user_data)
   return (id != user_data);
 }
 
+/* TODO (Nathan): Place this in a more ideal location. */
+static int collection_color_to_icon(Collection *collection)
+{
+  int icon = ICON_NONE;
+
+  if (collection->color != COLLECTION_COLOR_NONE) {
+    icon = ICON_COLLECTION_COLOR_01 + (collection->color - 1);
+  }
+
+  return icon;
+}
+
 /* Generic itemf's for operators that take library args */
 static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C),
                                             PointerRNA *UNUSED(ptr),
@@ -3993,6 +4005,12 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C),
     if (local == false || !ID_IS_LINKED(id)) {
       item_tmp.identifier = item_tmp.name = id->name + 2;
       item_tmp.value = i++;
+
+      /* Show collection color tag icons in menus. */
+      if (GS(id->name) == ID_GR) {
+        item_tmp.icon = collection_color_to_icon((Collection *)id);
+      }
+
       RNA_enum_item_add(&item, &totitem, &item_tmp);
     }
   }



More information about the Bf-blender-cvs mailing list