[Bf-blender-cvs] [382b2a9c66a] master: GPencil: Implement custom channel color in Dopesheet

Antonioya noreply at git.blender.org
Wed Apr 3 10:26:16 CEST 2019


Commit: 382b2a9c66a9f8b64581dc2a360dffbbbe706e21
Author: Antonioya
Date:   Wed Apr 3 10:25:49 2019 +0200
Branches: master
https://developer.blender.org/rB382b2a9c66a9f8b64581dc2a360dffbbbe706e21

GPencil: Implement custom channel color in Dopesheet

A new parameter in the layer adjustment panel allows to define the color of the channel in Dopesheet.

This is needed when there are a lot of layers.

See D4623 for more details.

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 2374faa0da8..0348b2452da 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -224,6 +224,23 @@ class DATA_PT_gpencil_layer_relations(LayerDataButtonsPanel, Panel):
             col.prop_search(gpl, "parent_bone", parent.data, "bones", text="Bone")
 
 
+class DATA_PT_gpencil_layer_display(LayerDataButtonsPanel, Panel):
+    bl_label = "Display"
+    bl_parent_id = 'DATA_PT_gpencil_layers'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        gpd = context.gpencil
+        gpl = gpd.layers.active
+
+        col = layout.row(align=True)
+        col.prop(gpl, "channel_color")
+
+
 class DATA_PT_gpencil_onion_skinning(DataButtonsPanel, Panel):
     bl_label = "Onion Skinning"
     bl_options = {'DEFAULT_CLOSED'}
@@ -449,6 +466,7 @@ classes = (
     DATA_PT_gpencil_onion_skinning_display,
     DATA_PT_gpencil_layer_adjustments,
     DATA_PT_gpencil_layer_relations,
+    DATA_PT_gpencil_layer_display,
     DATA_PT_gpencil_vertex_groups,
     DATA_PT_gpencil_strokes,
     DATA_PT_gpencil_display,
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 6981d70019a..2ef8568e308 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -374,6 +374,8 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
 		/* thickness parameter represents "thickness change", not absolute thickness */
 		gpl->thickness = 0;
 		gpl->opacity = 1.0f;
+		/* default channel color */
+		ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
 	}
 
 	/* auto-name */
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 4173bb9d99a..a1087caf40c 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2952,6 +2952,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 				mat->blend_shadow = MA_BS_SOLID;
 			}
 		}
+
+		/* grease pencil default animation channel color */
+		{
+			for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+				if (gpd->flag & GP_DATA_ANNOTATIONS) {
+					continue;
+				}
+				for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+					/* default channel color */
+					ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
+				}
+			}
+		}
 	}
 
 	{
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 997b3c22e51..618ac8f6f13 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -220,6 +220,23 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
 	}
 }
 
+/* get backdrop color for grease pencil channels */
+static void acf_gpencil_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3])
+{
+	const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+	short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0;
+	bool showGroupColors = acf_show_channel_colors(ac);
+	
+	if ((showGroupColors) && (ale->type == ANIMTYPE_GPLAYER)) {
+		bGPDlayer *gpl = (bGPDlayer *)ale->data;
+		copy_v3_v3(r_color, gpl->color);
+	}
+	else {
+		int colOfs = 10 - 10 * indent;
+		UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
+	}
+}
+
 /* backdrop for generic channels */
 static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
 {
@@ -3058,7 +3075,7 @@ static bAnimChannelType ACF_GPL =
 	"GPencil Layer",                /* type name */
 	ACHANNEL_ROLE_CHANNEL,          /* role */
 
-	acf_generic_channel_color,      /* backdrop color */
+	acf_gpencil_channel_color,      /* backdrop color */
 	acf_generic_channel_backdrop,   /* backdrop */
 	acf_generic_indention_flexible, /* indent level */
 	acf_generic_group_offset,       /* offset */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index eefac818abe..73203beb3e2 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1145,6 +1145,15 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
+	/* layer channel color (grease pencil)  */
+	prop = RNA_def_property(srna, "channel_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_float_sdna(prop, NULL, "color");
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_ui_text(prop, "Custom Channel Color",
+		"Custom color for animation channel in Dopesheet");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
 	/* Stroke Drawing Color (Annotations) */
 	prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);



More information about the Bf-blender-cvs mailing list