[Bf-blender-cvs] [093294e1675] soc-2020-outliner: Collections: Add color tagging & use in outliner

Nathan Craddock noreply at git.blender.org
Thu Aug 20 19:55:00 CEST 2020


Commit: 093294e167508ff04362030350e05e9921683ca2
Author: Nathan Craddock
Date:   Tue Aug 18 21:22:43 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB093294e167508ff04362030350e05e9921683ca2

Collections: Add color tagging & use in outliner

Add a color tag to collections and allow tagging from the outliner
context menu.

Show the colored icon in UI menus.

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

M	release/datafiles/userdef/userdef_default_theme.c
M	release/scripts/startup/bl_ui/space_outliner.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/animation/keyingsets.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/include/UI_icons.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_region_menu_pie.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/object/object_collection.c
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_info/info_ops.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_utils.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/makesdna/DNA_collection_types.h
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 4d48bb8eaac..1fbde066ef6 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -1101,6 +1101,32 @@ const bTheme U_theme_default = {
       .active = RGBA(0x000000ff),
     },
   },
+  .collection_color = {
+    {
+      .color = RGBA(0xe4312bff),
+    },
+    {
+      .color = RGBA(0xef7e42ff),
+    },
+    {
+      .color = RGBA(0xe4dd52ff),
+    },
+    {
+      .color = RGBA(0x9ac546ff),
+    },
+    {
+      .color = RGBA(0x46bcc2ff),
+    },
+    {
+      .color = RGBA(0x8b65dcff),
+    },
+    {
+      .color = RGBA(0x999999ff),
+    },
+    {
+      .color = RGBA(0x06d4432ff),
+    },
+  },
 };
 
 /* clang-format on */
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 5a54d4ca2d8..0c8c4df0c51 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -239,6 +239,10 @@ class OUTLINER_MT_collection(Menu):
         if space.display_mode == 'VIEW_LAYER':
             layout.separator()
             layout.menu("OUTLINER_MT_collection_view_layer", icon='RENDERLAYERS')
+            layout.separator()
+
+            row = layout.row(align=True)
+            row.operator_enum("outliner.collection_color_tag_set", "color", icon_only=True)
 
         layout.separator()
 
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 9548de20752..61b2489bb4a 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1019,6 +1019,24 @@ class USERPREF_PT_theme_bone_color_sets(ThemePanel, CenterAlignMixIn, Panel):
             flow.prop(ui, "active")
             flow.prop(ui, "show_colored_constraints")
 
+class USERPREF_PT_theme_collection_colors(ThemePanel, CenterAlignMixIn, Panel):
+    bl_label = "Collection Colors"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw_header(self, _context):
+        layout = self.layout
+
+        layout.label(icon='GROUP')
+
+    def draw_centered(self, context, layout):
+        theme = context.preferences.themes[0]
+
+        layout.use_property_split = True
+
+        flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
+        for i, ui in enumerate(theme.collection_color, 1):
+            flow.prop(ui, "color", text=iface_(f"Color {i:d}"), translate=False)
+
 
 # Base class for dynamically defined theme-space panels.
 # This is not registered.
@@ -2254,6 +2272,7 @@ classes = (
     USERPREF_PT_theme_interface_icons,
     USERPREF_PT_theme_text_style,
     USERPREF_PT_theme_bone_color_sets,
+    USERPREF_PT_theme_collection_colors,
 
     USERPREF_PT_file_paths_data,
     USERPREF_PT_file_paths_render,
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 0b116804481..475f618b1f4 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -217,6 +217,15 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
     btheme->tui.transparent_checker_size = U_theme_default.tui.transparent_checker_size;
   }
 
+  FROM_DEFAULT_V4_UCHAR(collection_color[0].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[1].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[2].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[3].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[4].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[5].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[6].color);
+  FROM_DEFAULT_V4_UCHAR(collection_color[7].color);
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 66d4882cf9d..e671a5b18f7 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1971,7 +1971,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN
     /* call the menu, which will call this operator again, hence the canceled */
     pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
     layout = UI_popup_menu_layout(pup);
-    uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type");
+    uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type", false);
     UI_popup_menu_end(C, pup);
 
     return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 876740b889a..558a7be1df8 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -479,7 +479,7 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve
   /* call the menu, which will call this operator again, hence the canceled */
   pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
   layout = UI_popup_menu_layout(pup);
-  uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
+  uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type", false);
   UI_popup_menu_end(C, pup);
 
   return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index d113e0693a4..c1668080d56 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5922,7 +5922,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
         if (nu->type == CU_NURBS) {
           pup = UI_popup_menu_begin(C, IFACE_("Direction"), ICON_NONE);
           layout = UI_popup_menu_layout(pup);
-          uiItemsEnumO(layout, op->type->idname, "direction");
+          uiItemsEnumO(layout, op->type->idname, "direction", false);
           UI_popup_menu_end(C, pup);
           return OPERATOR_INTERFACE;
         }
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 348fb614977..ed78f9e81f6 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1403,7 +1403,7 @@ static int gpencil_layer_change_invoke(bContext *C, wmOperator *op, const wmEven
   /* call the menu, which will call this operator again, hence the canceled */
   pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
   layout = UI_popup_menu_layout(pup);
-  uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer");
+  uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer", false);
   UI_popup_menu_end(C, pup);
 
   return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 452a1fca111..e976aac27a2 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -320,7 +320,7 @@ DEF_ICON_OBJECT(OUTLINER_OB_GROUP_INSTANCE)
 DEF_ICON_OBJECT(OUTLINER_OB_GREASEPENCIL)
 DEF_ICON_OBJECT(OUTLINER_OB_LIGHTPROBE)
 DEF_ICON_OBJECT(OUTLINER_OB_IMAGE)
-DEF_ICON_BLANK(321)
+DEF_ICON(OUTLINER_COLLECTION)
 DEF_ICON(RESTRICT_COLOR_OFF)
 DEF_ICON(RESTRICT_COLOR_ON)
 DEF_ICON(HIDE_ON)
@@ -980,6 +980,15 @@ DEF_ICON_VECTOR(COLORSET_18_VEC)
 DEF_ICON_VECTOR(COLORSET_19_VEC)
 DEF_ICON_VECTOR(COLORSET_20_VEC)
 
+DEF_ICON_VECTOR(COLLECTION_COLOR_01)
+DEF_ICON_VECTOR(COLLECTION_COLOR_02)
+DEF_ICON_VECTOR(COLLECTION_COLOR_03)
+DEF_ICON_VECTOR(COLLECTION_COLOR_04)
+DEF_ICON_VECTOR(COLLECTION_COLOR_05)
+DEF_ICON_VECTOR(COLLECTION_COLOR_06)
+DEF_ICON_VECTOR(COLLECTION_COLOR_07)
+DEF_ICON_VECTOR(COLLECTION_COLOR_08)
+
 /* Events  */
 DEF_ICON_COLOR(EVENT_A)
 DEF_ICON_COLOR(EVENT_B)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5d936cdfaa3..f942ca8bafa 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2208,7 +2208,10 @@ void uiItemEnumO_string(uiLayout *layout,
                         const char *opname,
                         const char *propname,
                         const char *value);
-void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
+void uiItemsEnumO(uiLayout *layout,
+                  const char *opname,
+                  const char *propname,
+                  const bool icon_only);
 void uiItemBooleanO(uiLayout *layout,
                     const char *name,
                     int icon,
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 7b59d45b203..0e0891cb526 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -32,6 +32,7 @@ struct PointerRNA;
 struct PreviewImage;
 struct Scene;
 struct bContext;
+struct Collection;
 
 enum eIconSizes;
 
@@ -106,6 +107,7 @@ struct PreviewImage *UI_icon_to_preview(int icon_id);
 int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big);
 int UI_idcode_icon_get(const int idcode);
 int UI_library_icon_get(const struct ID *id);
+int UI_collection_color_icon_get(const struct Collection *collection);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e04531bb1dd..4a68d7f861c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -383,13 +383,27 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
       }
     }
 
+    /* Keep aligned buttons in the same column. */
+    if (bt->alignnr && bt->next) {
+      int width = 0;
+      for (col_bt = bt; col_bt->rect.xmin < col_bt->next->rect.xmin; col_bt = col_bt->next) {
+        width += BLI_rctf_size_x(&col_bt->rect);
+      }
+      if (width > i) {
+        i = width;
+      }
+      bt = col_bt;
+    }
+
     if (bt->next && bt->rect.xmin < bt->next->rect.xmin) {
       /* End

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list