[Bf-blender-cvs] [16d0ded] GPencil_EditStrokes: Animation Editor support for animating Grease Pencil settings

Joshua Leung noreply at git.blender.org
Thu Nov 27 14:49:23 CET 2014


Commit: 16d0ded827f21a914aca16e67d3bd710acccc496
Author: Joshua Leung
Date:   Fri Nov 28 02:49:02 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rB16d0ded827f21a914aca16e67d3bd710acccc496

Animation Editor support for animating Grease Pencil settings

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

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesrna/intern/rna_action.c

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

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 2daf787..0458ffe 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -91,6 +91,8 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
                 row.prop(dopesheet, "show_speakers", text="")
             if bpy.data.linestyles:
                 row.prop(dopesheet, "show_linestyles", text="")
+            if bpy.data.grease_pencil:
+                row.prop(dopesheet, "show_gpencil", text="")
 
 
 #######################################
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 05af147..4106853 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5737,6 +5737,21 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
 
 /* ****************** READ GREASE PENCIL ***************** */
 
+/* relink's grease pencil data's refs */
+static void lib_link_gpencil(FileData *fd, Main *main)
+{
+	bGPdata *gpd;
+	
+	for (gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+		if (gpd->id.flag & LIB_NEED_LINK) {
+			gpd->id.flag -= LIB_NEED_LINK;
+			
+			if (gpd->adt)
+				lib_link_animdata(fd, &gpd->id, gpd->adt);
+		}
+	}
+}
+
 /* relinks grease-pencil data - used for direct_link and old file linkage */
 static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 {
@@ -5748,6 +5763,10 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 	if (gpd == NULL)
 		return;
 	
+	/* relink animdata */
+	gpd->adt = newdataadr(fd, gpd->adt);
+	direct_link_animdata(fd, gpd->adt);
+	
 	/* relink layers */
 	link_list(fd, &gpd->layers);
 	
@@ -7719,6 +7738,7 @@ static void lib_link_all(FileData *fd, Main *main)
 	lib_link_movieclip(fd, main);
 	lib_link_mask(fd, main);
 	lib_link_linestyle(fd, main);
+	lib_link_gpencil(fd, main);
 
 	lib_link_mesh(fd, main);		/* as last: tpage images with users at zero */
 	
@@ -8824,6 +8844,12 @@ static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *li
 	}
 }
 
+static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
+{
+	if (gpd->adt)
+		expand_animdata(fd, mainvar, gpd->adt);
+}
+
 void BLO_main_expander(void (*expand_doit_func)(void *, Main *, void *))
 {
 	expand_doit = expand_doit_func;
@@ -8918,6 +8944,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
 					case ID_LS:
 						expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
 						break;
+					case ID_GD:
+						expand_gpencil(fd, mainvar, (bGPdata *)id);
+						break;
 					}
 					
 					do_it = true;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 13cceb9..a278020 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2469,6 +2469,8 @@ static void write_gpencils(WriteData *wd, ListBase *lb)
 			/* write gpd data block to file */
 			writestruct(wd, ID_GD, "bGPdata", 1, gpd);
 			
+			if (gpd->adt) write_animdata(wd, gpd->adt);
+			
 			/* write grease-pencil layers to file */
 			writelist(wd, DATA, "bGPDlayer", &gpd->layers);
 			for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 7e72da4..aa4ab8c 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -2365,6 +2365,83 @@ static bAnimChannelType ACF_DSSPK =
 	acf_dsspk_setting_ptr                   /* pointer for setting */
 };
 
+/* GPencil Expander  ------------------------------------------- */
+
+// TODO: just get this from RNA?
+static int acf_dsgpencil_icon(bAnimListElem *UNUSED(ale))
+{
+	return ICON_GREASEPENCIL;
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
+{
+	/* clear extra return data first */
+	*neg = false;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return GP_DATA_EXPAND;
+		
+		case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
+			return ADT_NLA_EVAL_OFF;
+		
+		case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
+			*neg = true;
+			return ADT_CURVES_NOT_VISIBLE;
+		
+		case ACHANNEL_SETTING_SELECT: /* selected */
+			return ADT_UI_SELECTED;
+		
+		default: /* unsupported */
+			return 0;
+	}
+}
+
+/* get pointer to the setting */
+static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type)
+{
+	bGPdata *gpd = (bGPdata *)ale->data;
+	
+	/* clear extra return data first */
+	*type = 0;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_EXPAND: /* expanded */
+			return GET_ACF_FLAG_PTR(gpd->flag, type);
+		
+		case ACHANNEL_SETTING_SELECT: /* selected */
+		case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
+		case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
+			if (gpd->adt)
+				return GET_ACF_FLAG_PTR(gpd->adt->flag, type);
+			return NULL;
+		
+		default: /* unsupported */
+			return NULL;
+	}
+}
+
+/* grease pencil expander type define */
+static bAnimChannelType ACF_DSGPENCIL =
+{
+	"GPencil DS Expander",          /* type name */
+	ACHANNEL_ROLE_EXPANDER,         /* role */
+	
+	acf_generic_dataexpand_color,   /* backdrop color */
+	acf_generic_dataexpand_backdrop, /* backdrop */
+	acf_generic_indention_1,        /* indent level */
+	acf_generic_basic_offset,       /* offset */
+
+	acf_generic_idblock_name,       /* name */
+	acf_generic_idblock_name_prop,  /* name prop */
+	acf_dsgpencil_icon,             /* icon */
+
+	acf_generic_dataexpand_setting_valid,   /* has setting */
+	acf_dsgpencil_setting_flag,             /* flag for setting */
+	acf_dsgpencil_setting_ptr               /* pointer for setting */
+};
+
 /* ShapeKey Entry  ------------------------------------------- */
 
 /* name for ShapeKey */
@@ -3162,6 +3239,7 @@ static void ANIM_init_channel_typeinfo_data(void)
 		animchannelTypeInfo[type++] = &ACF_DSLAT;        /* Lattice Channel */
 		animchannelTypeInfo[type++] = &ACF_DSLINESTYLE;  /* LineStyle Channel */
 		animchannelTypeInfo[type++] = &ACF_DSSPK;        /* Speaker Channel */
+		animchannelTypeInfo[type++] = &ACF_DSGPENCIL;    /* GreasePencil Channel */
 		
 		animchannelTypeInfo[type++] = &ACF_SHAPEKEY;     /* ShapeKey */
 		
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 9691ef9..d8ad650 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -129,6 +129,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
 			case ANIMTYPE_DSLAT:
 			case ANIMTYPE_DSLINESTYLE:
 			case ANIMTYPE_DSSPK:
+			case ANIMTYPE_DSGPENCIL:
 			{
 				/* need to verify that this data is valid for now */
 				if (ale->adt) {
@@ -183,6 +184,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat
 			case ANIMTYPE_DSSPK:
 			case ANIMTYPE_DSNTREE:
 			case ANIMTYPE_DSTEX:
+			case ANIMTYPE_DSGPENCIL:
 			{
 				/* need to verify that this data is valid for now */
 				if (ale && ale->adt) {
@@ -281,6 +283,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
 				case ANIMTYPE_DSLAT:
 				case ANIMTYPE_DSLINESTYLE:
 				case ANIMTYPE_DSSPK:
+				case ANIMTYPE_DSGPENCIL:
 				{
 					if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
 						sel = ACHANNEL_SETFLAG_CLEAR;
@@ -374,6 +377,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d
 			case ANIMTYPE_DSLAT:
 			case ANIMTYPE_DSLINESTYLE:
 			case ANIMTYPE_DSSPK:
+			case ANIMTYPE_DSGPENCIL:
 			{
 				/* need to verify that this data is valid for now */
 				if (ale->adt) {
@@ -2628,6 +2632,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
 		case ANIMTYPE_DSLAT:
 		case ANIMTYPE_DSLINESTYLE:
 		case ANIMTYPE_DSSPK:
+		case ANIMTYPE_DSGPENCIL:
 		{
 			/* sanity checking... */
 			if (ale->adt) {
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 2717a7e..d6daa64 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -771,6 +771,21 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne
 				ale->adt = BKE_animdata_from_id(data);
 				break;
 			}
+			case ANIMTYPE_DSGPENCIL:
+			{
+				bGPdata *gpd = (bGPdata *)data;
+				AnimData *adt = gpd->adt;
+				
+				/* NOTE: we just reuse the same expand filter for this case */
+				ale->flag = EXPANDED_GPD(gpd);
+				
+				// XXX: currently, this is only used for access to its animation data
+				ale->key_data = (adt) ? adt->action : NULL;
+				ale->datatype = ALE_ACT;
+				
+				ale->adt = BKE_animdata_from_id(data);
+				break;
+			}
 			case ANIMTYPE_GROUP:
 			{
 				bActionGroup *agrp = (bActionGroup *)data;
@@ -1450,6 +1465,46 @@ static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), i
 	return items;
 }
 
+/* Helper for Grease Pencil data integrated with main DopeSheet */
+static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bGPdata *gpd, int filter_mode)
+{
+	ListBase tmp_data = {NULL, NULL};
+	size_t tmp_items = 0;
+	size_t items = 0;
+	
+	/* add relevant animation channels for Grease Pencil */
+	BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd))
+	{
+		/* add animation channels */
+		tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode);
+		
+		/* add Grease Pencil layers */
+		// TODO: do these need a separate expander?
+		// XXX:  what order should these go in?
+	}
+	END_ANIMFILTER_SUBCHANNELS;
+	
+	/* did we find anything? */
+	if (tmp_items) {
+		/* include data-expand widget first */
+		if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
+			/* check if filtering by active stat

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list