Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Craddock <nzcraddock@gmail.com>2020-09-15 21:13:03 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-09-15 21:47:09 +0300
commit452a1c7b38383fd3f51532c429912677864e4a33 (patch)
tree37481ed6eca5cc6840dee0686b24b75ba1842cbc
parentf137022f9919f4dd315ec6b325a08e1bf5aec6fb (diff)
Collections: Add color tagging
This adds color tagging to collections. There are 8 color options which are themable in the user preferences, with an additional option for no color tag by default. This adds a new filled collection icon and 8 colored variants of the icon that can be themed in the user preferences. In this commit the only interface to setting the color tags is through Python, and there is nowhere in the interface where the collections are shown colored. Setting and viewing the color tags from the outliner will follow. Manifest Task: https://developer.blender.org/T77777 Differential Revision: https://developer.blender.org/D8622
-rw-r--r--release/datafiles/blender_icons16/icon16_outliner_collection.datbin0 -> 1048 bytes
-rw-r--r--release/datafiles/blender_icons32/icon32_outliner_collection.datbin0 -> 4120 bytes
-rw-r--r--release/datafiles/userdef/userdef_default_theme.c26
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py19
-rw-r--r--source/blender/blenkernel/intern/collection.c1
-rw-r--r--source/blender/blenloader/intern/versioning_290.c6
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c3
-rw-r--r--source/blender/editors/include/UI_icons.h11
-rw-r--r--source/blender/editors/include/UI_interface_icons.h2
-rw-r--r--source/blender/editors/interface/interface_icons.c48
-rw-r--r--source/blender/makesdna/DNA_collection_types.h19
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h7
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_collection.c19
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c24
16 files changed, 186 insertions, 2 deletions
diff --git a/release/datafiles/blender_icons16/icon16_outliner_collection.dat b/release/datafiles/blender_icons16/icon16_outliner_collection.dat
new file mode 100644
index 00000000000..c46a6ce6f66
--- /dev/null
+++ b/release/datafiles/blender_icons16/icon16_outliner_collection.dat
Binary files differ
diff --git a/release/datafiles/blender_icons32/icon32_outliner_collection.dat b/release/datafiles/blender_icons32/icon32_outliner_collection.dat
new file mode 100644
index 00000000000..0fdd735553e
--- /dev/null
+++ b/release/datafiles/blender_icons32/icon32_outliner_collection.dat
Binary files differ
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 791630a1a9c..8cbb615491d 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -1103,6 +1103,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_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index faea806c6cb..40cb03acdfc 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='OUTLINER_COLLECTION')
+
+ 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.
@@ -2256,6 +2274,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/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 836ce542793..e8b29ffac3e 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -204,6 +204,7 @@ static Collection *collection_add(Main *bmain,
/* Create new collection. */
Collection *collection = BKE_libblock_alloc(bmain, ID_GR, name, 0);
+ collection->color_tag = COLLECTION_COLOR_NONE;
/* We increase collection user count when linking to Collections. */
id_us_min(&collection->id);
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 2db2bb3c29e..3bf464602bc 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -661,5 +661,11 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+ LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
+ collection->color_tag = COLLECTION_COLOR_NONE;
+ }
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ scene->master_collection->color_tag = COLLECTION_COLOR_NONE;
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index a0a60630986..d53959a1949 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -236,6 +236,9 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
*/
{
/* Keep this block, even when empty. */
+ for (int i = 0; i < COLLECTION_COLOR_TOT; ++i) {
+ FROM_DEFAULT_V4_UCHAR(collection_color[i].color);
+ }
FROM_DEFAULT_V4_UCHAR(space_properties.match);
}
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_icons.h b/source/blender/editors/include/UI_interface_icons.h
index bbe66f7fd73..9c0539d5c2f 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;
@@ -107,6 +108,7 @@ int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon,
int UI_idcode_icon_get(const int idcode);
int UI_library_icon_get(const struct ID *id);
int UI_mode_icon_get(const int mode);
+int UI_collection_color_icon_get(const struct Collection *collection);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d22ddb5f2b7..7008d22becc 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -41,6 +41,7 @@
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
+#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_gpencil_types.h"
@@ -461,6 +462,33 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19)
# undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
+static void vicon_collection_color_draw(
+ short color_tag, int x, int y, int UNUSED(w), int UNUSED(h), float UNUSED(alpha))
+{
+ bTheme *btheme = UI_GetTheme();
+ const ThemeCollectionColor *collection_color = &btheme->collection_color[color_tag];
+
+ UI_icon_draw_ex(
+ x, y, ICON_OUTLINER_COLLECTION, U.inv_dpi_fac, 1.0f, 0.0f, collection_color->color, true);
+}
+
+# define DEF_ICON_COLLECTION_COLOR_DRAW(index, color) \
+ static void vicon_collection_color_draw_##index(int x, int y, int w, int h, float alpha) \
+ { \
+ vicon_collection_color_draw(color, x, y, w, h, alpha); \
+ }
+
+DEF_ICON_COLLECTION_COLOR_DRAW(01, COLLECTION_COLOR_01);
+DEF_ICON_COLLECTION_COLOR_DRAW(02, COLLECTION_COLOR_02);
+DEF_ICON_COLLECTION_COLOR_DRAW(03, COLLECTION_COLOR_03);
+DEF_ICON_COLLECTION_COLOR_DRAW(04, COLLECTION_COLOR_04);
+DEF_ICON_COLLECTION_COLOR_DRAW(05, COLLECTION_COLOR_05);
+DEF_ICON_COLLECTION_COLOR_DRAW(06, COLLECTION_COLOR_06);
+DEF_ICON_COLLECTION_COLOR_DRAW(07, COLLECTION_COLOR_07);
+DEF_ICON_COLLECTION_COLOR_DRAW(08, COLLECTION_COLOR_08);
+
+# undef DEF_ICON_COLLECTION_COLOR_DRAW
+
/* Dynamically render icon instead of rendering a plain color to a texture/buffer
* This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
* but it works in a very similar way.
@@ -969,6 +997,15 @@ static void init_internal_icons(void)
def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18);
def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19);
def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20);
+
+ def_internal_vicon(ICON_COLLECTION_COLOR_01, vicon_collection_color_draw_01);
+ def_internal_vicon(ICON_COLLECTION_COLOR_02, vicon_collection_color_draw_02);
+ def_internal_vicon(ICON_COLLECTION_COLOR_03, vicon_collection_color_draw_03);
+ def_internal_vicon(ICON_COLLECTION_COLOR_04, vicon_collection_color_draw_04);
+ def_internal_vicon(ICON_COLLECTION_COLOR_05, vicon_collection_color_draw_05);
+ def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06);
+ def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07);
+ def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08);
}
static void init_iconfile_list(struct ListBase *list)
@@ -2324,6 +2361,17 @@ int UI_mode_icon_get(const int mode)
}
}
+int UI_collection_color_icon_get(const Collection *collection)
+{
+ int icon = ICON_OUTLINER_COLLECTION;
+
+ if (collection->color_tag != COLLECTION_COLOR_NONE) {
+ icon = ICON_COLLECTION_COLOR_01 + collection->color_tag;
+ }
+
+ return icon;
+}
+
/* draws icon with dpi scale factor */
void UI_icon_draw(float x, float y, int icon_id)
{
diff --git a/source/blender/makesdna/DNA_collection_types.h b/source/blender/makesdna/DNA_collection_types.h
index 6cf02137fa6..e188426fdda 100644
--- a/source/blender/makesdna/DNA_collection_types.h
+++ b/source/blender/makesdna/DNA_collection_types.h
@@ -58,7 +58,9 @@ typedef struct Collection {
short flag;
/* Runtime-only, always cleared on file load. */
short tag;
- char _pad[4];
+
+ int16_t color_tag;
+ char _pad[2];
/* Runtime. Cache of objects in this collection and all its
* children. This is created on demand when e.g. some physics
@@ -92,3 +94,18 @@ enum {
* Using a generic tag like LIB_TAG_DOIT for this is just impossible, we need our very own. */
COLLECTION_TAG_RELATION_REBUILD = (1 << 0),
};
+
+/* Collection->color_tag. */
+typedef enum CollectionColorTag {
+ COLLECTION_COLOR_NONE = -1,
+ COLLECTION_COLOR_01,
+ COLLECTION_COLOR_02,
+ COLLECTION_COLOR_03,
+ COLLECTION_COLOR_04,
+ COLLECTION_COLOR_05,
+ COLLECTION_COLOR_06,
+ COLLECTION_COLOR_07,
+ COLLECTION_COLOR_08,
+
+ COLLECTION_COLOR_TOT,
+} CollectionColorTag;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index b63f4529559..b60dcb67224 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -453,6 +453,10 @@ typedef enum eWireColor_Flags {
/* TH_WIRECOLOR_TEXTCOLS = (1 << 1), */ /* UNUSED */
} eWireColor_Flags;
+typedef struct ThemeCollectionColor {
+ unsigned char color[4];
+} ThemeCollectionColor;
+
/**
* A theme.
*
@@ -491,6 +495,9 @@ typedef struct bTheme {
ThemeWireColor tarm[20];
/*ThemeWireColor tobj[20];*/
+ /* See COLLECTION_COLOR_TOT for the number of collection colors. */
+ ThemeCollectionColor collection_color[8];
+
int active_theme_area;
char _pad0[4];
} bTheme;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 8ee10047750..7a72ba2dc14 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -645,6 +645,7 @@ extern StructRNA RNA_TextureNodeViewer;
extern StructRNA RNA_TextureSlot;
extern StructRNA RNA_Theme;
extern StructRNA RNA_ThemeBoneColorSet;
+extern StructRNA RNA_ThemeCollectionColor;
extern StructRNA RNA_ThemeConsole;
extern StructRNA RNA_ThemeDopeSheet;
extern StructRNA RNA_ThemeFileBrowser;
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 15b29e45053..831e8dc424d 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -236,6 +236,8 @@ extern const EnumPropertyItem rna_enum_attribute_type_items[];
extern const EnumPropertyItem rna_enum_attribute_domain_items[];
extern const EnumPropertyItem *rna_enum_attribute_domain_itemf(struct ID *id, bool *r_free);
+extern const EnumPropertyItem rna_enum_collection_color_items[];
+
/* API calls */
int rna_node_tree_type_to_enum(struct bNodeTreeType *typeinfo);
int rna_node_tree_idname_to_enum(const char *idname);
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index 9c6c95f2819..b0250897d6d 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -30,6 +30,19 @@
#include "WM_types.h"
+const EnumPropertyItem rna_enum_collection_color_items[] = {
+ {COLLECTION_COLOR_NONE, "NONE", ICON_X, "None", "Assign no color tag to the collection"},
+ {COLLECTION_COLOR_01, "COLOR_01", ICON_COLLECTION_COLOR_01, "Color 01", ""},
+ {COLLECTION_COLOR_02, "COLOR_02", ICON_COLLECTION_COLOR_02, "Color 02", ""},
+ {COLLECTION_COLOR_03, "COLOR_03", ICON_COLLECTION_COLOR_03, "Color 03", ""},
+ {COLLECTION_COLOR_04, "COLOR_04", ICON_COLLECTION_COLOR_04, "Color 04", ""},
+ {COLLECTION_COLOR_05, "COLOR_05", ICON_COLLECTION_COLOR_05, "Color 05", ""},
+ {COLLECTION_COLOR_06, "COLOR_06", ICON_COLLECTION_COLOR_06, "Color 06", ""},
+ {COLLECTION_COLOR_07, "COLOR_07", ICON_COLLECTION_COLOR_07, "Color 07", ""},
+ {COLLECTION_COLOR_08, "COLOR_08", ICON_COLLECTION_COLOR_08, "Color 08", ""},
+ {0, NULL, 0, NULL, NULL},
+};
+
#ifdef RNA_RUNTIME
# include "DNA_object_types.h"
@@ -474,6 +487,12 @@ void RNA_def_collections(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders");
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update");
+ prop = RNA_def_property(srna, "color_tag", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "color_tag");
+ RNA_def_property_enum_items(prop, rna_enum_collection_color_items);
+ RNA_def_property_ui_text(prop, "Collection Color", "Color tag for a collection");
+ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL);
+
RNA_define_lib_overridable(false);
}
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 868c804b4a3..118a512caf9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -3623,6 +3623,23 @@ static void rna_def_userdef_theme_colorset(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
}
+static void rna_def_userdef_theme_collection_color(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "ThemeCollectionColor", NULL);
+ RNA_def_struct_sdna(srna, "ThemeCollectionColor");
+ RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+ RNA_def_struct_ui_text(srna, "Theme Collection Color", "Theme settings for collection colors");
+
+ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "color");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_ui_text(prop, "Color", "Collection Color Tag");
+ RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
+}
+
static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3939,6 +3956,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "tarm", "");
RNA_def_property_struct_type(prop, "ThemeBoneColorSet");
RNA_def_property_ui_text(prop, "Bone Color Sets", "");
+
+ prop = RNA_def_property(srna, "collection_color", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NEVER_NULL);
+ RNA_def_property_collection_sdna(prop, NULL, "collection_color", "");
+ RNA_def_property_struct_type(prop, "ThemeCollectionColor");
+ RNA_def_property_ui_text(prop, "Collection Color", "");
}
static void rna_def_userdef_addon(BlenderRNA *brna)
@@ -4180,6 +4203,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
rna_def_userdef_theme_space_topbar(brna);
rna_def_userdef_theme_space_statusbar(brna);
rna_def_userdef_theme_colorset(brna);
+ rna_def_userdef_theme_collection_color(brna);
rna_def_userdef_themes(brna);
}