[Bf-blender-cvs] [b485592901b] soc-2020-outliner: Theme: Add theming for collection colors
Nathan Craddock
noreply at git.blender.org
Fri Jul 3 05:42:16 CEST 2020
Commit: b485592901b197279b34cd714a687d70003b90eb
Author: Nathan Craddock
Date: Thu Jul 2 21:27:04 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBb485592901b197279b34cd714a687d70003b90eb
Theme: Add theming for collection colors
Add a new panel similar to the Bone Color Sets panel to set the
collection colors. These draw in the outliner and outliner context menu.
===================================================================
M release/datafiles/userdef/userdef_default_theme.c
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/blenloader/intern/versioning_userdef.c
M source/blender/editors/interface/interface_icons.c
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/makesdna/DNA_userdef_types.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 4d48bb8eaac..0fd262f0c14 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -1101,6 +1101,26 @@ 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),
+ },
+ },
};
/* clang-format on */
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index e5171df597a..a6d48fba0a1 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1003,6 +1003,27 @@ 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
+
+ for i, ui in enumerate(theme.collection_color, 1):
+ layout.label(text=iface_(f"Color {i:d}"), translate=False)
+
+ flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
+
+ flow.prop(ui, "color")
+
# Base class for dynamically defined theme-space panels.
# This is not registered.
@@ -2226,6 +2247,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 1b0e41ec54a..d983adfeea5 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -216,6 +216,13 @@ 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);
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index c7e75913cff..8d6cef0e9e9 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -460,54 +460,11 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19)
# undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
-static void get_collection_color(float col[4], short color)
-{
- switch (color) {
- case COLLECTION_COLOR_RED:
- col[0] = 0.945f;
- col[1] = 0.568f;
- col[2] = 0.560f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_ORANGE:
- col[0] = 0.945f;
- col[1] = 0.580f;
- col[2] = 0.384f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_YELLOW:
- col[0] = 0.752f;
- col[1] = 0.674f;
- col[2] = 0.309f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_GREEN:
- col[0] = 0.576f;
- col[1] = 0.717f;
- col[2] = 0.305f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_BLUE:
- col[0] = 0.329f;
- col[1] = 0.733f;
- col[2] = 0.705f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_PURPLE:
- col[0] = 0.721f;
- col[1] = 0.619f;
- col[2] = 0.929f;
- col[3] = 1.0f;
- break;
- }
-}
-
static void vicon_collection_color_draw(
short color, int x, int y, int w, int h, float UNUSED(alpha))
{
bTheme *btheme = UI_GetTheme();
- float col[4];
- get_collection_color(col, color);
+ const ThemeCollectionColor *collection_color = &btheme->collection_color[color - 1];
const int c = x + w;
uint pos = GPU_vertformat_attr_add(
@@ -516,7 +473,7 @@ static void vicon_collection_color_draw(
/* XXX: Include alpha into this... */
/* normal */
- immUniformColor3fv(col);
+ immUniformColor3ubv(collection_color->color);
immRecti(pos, x, y, c, y + h);
immUnbindProgram();
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 0a872abda06..2708eb84639 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -87,48 +87,6 @@
/* ****************************************************** */
/* Tree Size Functions */
-static void outliner_get_collection_color(float col[4], short color)
-{
- switch (color) {
- case COLLECTION_COLOR_RED:
- col[0] = 0.945f;
- col[1] = 0.568f;
- col[2] = 0.560f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_ORANGE:
- col[0] = 0.945f;
- col[1] = 0.580f;
- col[2] = 0.384f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_YELLOW:
- col[0] = 0.752f;
- col[1] = 0.674f;
- col[2] = 0.309f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_GREEN:
- col[0] = 0.576f;
- col[1] = 0.717f;
- col[2] = 0.305f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_BLUE:
- col[0] = 0.329f;
- col[1] = 0.733f;
- col[2] = 0.705f;
- col[3] = 1.0f;
- break;
- case COLLECTION_COLOR_PURPLE:
- col[0] = 0.721f;
- col[1] = 0.619f;
- col[2] = 0.929f;
- col[3] = 1.0f;
- break;
- }
-}
-
static void outliner_tree_dimensions_impl(SpaceOutliner *soops,
ListBase *lb,
int *width,
@@ -3254,8 +3212,9 @@ static void outliner_draw_tree_element(bContext *C,
Collection *collection = outliner_collection_from_tree_element(te);
if (collection->color != COLLECTION_COLOR_NONE) {
+ bTheme *btheme = UI_GetTheme();
float color[4];
- outliner_get_collection_color(color, collection->color);
+ rgba_uchar_to_float(color, btheme->collection_color[collection->color - 1].color);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(true,
@@ -3501,6 +3460,7 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
bool draw_grayed_out,
int *starty)
{
+ bTheme *btheme = UI_GetTheme();
TreeElement *line_start = NULL, *line_end = NULL;
int y = *starty;
short color_start;
@@ -3520,10 +3480,7 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
if (tselem->type == TSE_LAYER_COLLECTION) {
if (line_end) {
if (color_start != COLLECTION_COLOR_NONE) {
- float c[4];
- outliner_get_collection_color(c, color_start);
-
- immUniformColor4fv(c);
+ immUniformColor4ubv(btheme->collection_color[color_start - 1].color);
}
else {
immUniformColor4ubv(col);
@@ -3563,10 +3520,7 @@ static void outliner_draw_hierarchy_lines_recursive(uint pos,
if (line_start) {
if (color_start != COLLECTION_COLOR_NONE) {
- float c[4];
- outliner_get_collection_color(c, color_start);
-
- immUniformColor4fv(c);
+ immUniformColor4ubv(btheme->collection_color[color_start - 1].color);
}
else {
immUniformColor4ubv(col);
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index d751ad9ac47..3680475b8a6 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -456,6 +456,10 @@ typedef enum eWireColor_Flags {
/* TH_WIRECOLOR_TEXTCOLS = (1 << 1), */ /* UNUSED */
} eWireColor_Flags;
+typedef struct ThemeCollectionColor {
+ unsigned char color[4];
+} ThemeCollectionColor;
+
/**
* A theme.
*
@@ -494,6 +498,8 @@ typedef struct bTheme {
ThemeWireColor tarm[20];
/*ThemeWireColor tobj[20];*/
+ ThemeCollectionColor collection_color[6];
+
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 53bb8899855..9be84d6b5be 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -633,6 +633,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/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index c31b313d827..691ff89c42a 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -3608,6 +3608,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 Collecti
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list