[Bf-blender-cvs] [4c3813fb325] master: UI: Show color tagged collection icons in menus

Nathan Craddock noreply at git.blender.org
Tue Sep 15 20:47:59 CEST 2020


Commit: 4c3813fb32567805ef6eac708e3602c2d367cc58
Author: Nathan Craddock
Date:   Tue Sep 15 12:22:03 2020 -0600
Branches: master
https://developer.blender.org/rB4c3813fb32567805ef6eac708e3602c2d367cc58

UI: Show color tagged collection icons in menus

Draw color tagged collection icons in the link to collection, add
collection instance, collection instance search, and remove collection
menus.

Manifest Task: https://developer.blender.org/T77777

Differential Revision: https://developer.blender.org/D8622

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

M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/object/object_collection.c
M	source/blender/editors/object/object_edit.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 7008d22becc..951321b93e6 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -2170,6 +2170,9 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big)
     case ID_SCR:
       iconid = ui_id_screen_get_icon(C, id);
       break;
+    case ID_GR:
+      iconid = UI_collection_color_icon_get((Collection *)id);
+      break;
     default:
       break;
   }
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 24f6d8c79f9..5f14cdcd299 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -50,6 +50,8 @@
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "UI_interface_icons.h"
+
 #include "object_intern.h"
 
 /********************* 3d view operators ***********************/
@@ -94,7 +96,7 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C,
     collection = NULL;
     while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
       item_tmp.identifier = item_tmp.name = collection->id.name + 2;
-      /* item_tmp.icon = ICON_ARMATURE_DATA; */
+      item_tmp.icon = UI_collection_color_icon_get(collection);
       item_tmp.value = i;
       RNA_enum_item_add(&item, &totitem, &item_tmp);
       i++;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 6dcb7e2a1b0..7a17cdc30e4 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -100,6 +100,8 @@
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
+#include "UI_interface_icons.h"
+
 #include "CLG_log.h"
 
 /* for menu/popup icons etc etc*/
@@ -1832,7 +1834,7 @@ static void move_to_collection_menus_free(MoveToCollectionData **menu)
   *menu = NULL;
 }
 
-static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout, void *menu_v)
+static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *menu_v)
 {
   MoveToCollectionData *menu = menu_v;
   const char *name = BKE_collection_ui_name_get(menu->collection);
@@ -1848,7 +1850,11 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
 
   uiItemS(layout);
 
-  uiItemIntO(layout, name, ICON_SCENE_DATA, menu->ot->idname, "collection_index", menu->index);
+  Scene *scene = CTX_data_scene(C);
+  const int icon = (menu->collection == scene->master_collection) ?
+                       ICON_SCENE_DATA :
+                       UI_collection_color_icon_get(menu->collection);
+  uiItemIntO(layout, name, icon, menu->ot->idname, "collection_index", menu->index);
 
   for (MoveToCollectionData *submenu = menu->submenus.first; submenu != NULL;
        submenu = submenu->next) {
@@ -1858,17 +1864,18 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
 
 static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu)
 {
+  const int icon = UI_collection_color_icon_get(menu->collection);
+
   if (BLI_listbase_is_empty(&menu->submenus)) {
     uiItemIntO(layout,
                menu->collection->id.name + 2,
-               ICON_NONE,
+               icon,
                menu->ot->idname,
                "collection_index",
                menu->index);
   }
   else {
-    uiItemMenuF(
-        layout, menu->collection->id.name + 2, ICON_NONE, move_to_collection_menu_create, menu);
+    uiItemMenuF(layout, menu->collection->id.name + 2, icon, move_to_collection_menu_create, menu);
   }
 }
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index ffe2ffac3a2..0f3409af3d3 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3991,6 +3991,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 = UI_collection_color_icon_get((Collection *)id);
+      }
+
       RNA_enum_item_add(&item, &totitem, &item_tmp);
     }
   }



More information about the Bf-blender-cvs mailing list