[Bf-blender-cvs] [bec2fad2153] soc-2020-outliner: Collections: Show correct icon for move to collection submenus

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


Commit: bec2fad2153494c9096b213ce0ce46e832fcb1bf
Author: Nathan Craddock
Date:   Wed Aug 12 16:12:00 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBbec2fad2153494c9096b213ce0ce46e832fcb1bf

Collections: Show correct icon for move to collection submenus

The submenu would show the scene data icon for the first entry in each
submenu rather than using the collection color icon.

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

M	source/blender/editors/object/object_edit.c

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

diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 3612f546dd8..4addd989034 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1761,7 +1761,19 @@ 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)
+/* 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;
+}
+
+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);
@@ -1777,7 +1789,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 :
+                       collection_color_to_icon(menu->collection);
+  uiItemIntO(layout, name, icon, menu->ot->idname, "collection_index", menu->index);
 
   for (MoveToCollectionData *submenu = menu->submenus.first; submenu != NULL;
        submenu = submenu->next) {
@@ -1785,17 +1801,6 @@ static void move_to_collection_menu_create(bContext *UNUSED(C), uiLayout *layout
   }
 }
 
-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;
-}
-
 static void move_to_collection_menus_items(uiLayout *layout, MoveToCollectionData *menu)
 {
   const int icon = collection_color_to_icon(menu->collection);



More information about the Bf-blender-cvs mailing list