forked from bartvdbraak/blender
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.
This commit is contained in:
parent
a813e259d6
commit
382b2a9c66
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user