[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23806] trunk/blender/source/blender: DopeSheet: DopeSheet Summary Channel

Joshua Leung aligorith at gmail.com
Tue Oct 13 13:21:02 CEST 2009


Revision: 23806
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23806
Author:   aligorith
Date:     2009-10-13 13:21:02 +0200 (Tue, 13 Oct 2009)

Log Message:
-----------
DopeSheet: DopeSheet Summary Channel

Added a summary channel that appears as the first channel in the DopeSheet. For now, this is disabled by default, but can be enabled using the 'Summary' toggle in the header between the mode selector and the standard filtering options. This has been done, since there is a possibility that it will make the DopeSheet run a bit slower.

In this channel you can do everything that you can normally do with DopeSheet channels (i.e. select, transform, edit, etc). It might be worth noting though that care probably needs to be taken when trying to use Copy/Paste, since that is still a bit fidgety...

In the process, I've fixed a few bugs, mostly with selection:
- Selecting keyframes in scene summaries wouldn't work
- Border select only worked in F-Curve and Group channels

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/animation/keyframes_draw.c
    trunk/blender/source/blender/editors/animation/keyframes_edit.c
    trunk/blender/source/blender/editors/include/ED_anim_api.h
    trunk/blender/source/blender/editors/include/ED_keyframes_draw.h
    trunk/blender/source/blender/editors/space_action/action_draw.c
    trunk/blender/source/blender/editors/space_action/action_header.c
    trunk/blender/source/blender/editors/space_action/action_select.c
    trunk/blender/source/blender/makesdna/DNA_action_types.h

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-10-13 10:52:18 UTC (rev 23805)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-10-13 11:21:02 UTC (rev 23806)
@@ -280,6 +280,12 @@
 
 /* Settings ------------------------------------------- */
 
+/* channel type has no settings */
+static short acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+{
+	return 0;
+}
+
 /* check if some setting exists for this object-based data-expander (category only) */
 static short acf_generic_dsexpand_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
 {
@@ -335,6 +341,52 @@
 /* *********************************************** */
 /* Type Specific Functions + Defines */
 
+/* Animation Summary ----------------------------------- */
+
+/* backdrop for summary widget */
+static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc)
+{
+	View2D *v2d= &ac->ar->v2d;
+	
+	// FIXME: hardcoded color - same as the 'action' line in NLA
+	glColor3f(0.8f, 0.2f, 0.0f);	// reddish color 
+	
+	/* rounded corners on LHS only 
+	 *	- top and bottom 
+	 *	- special hack: make the top a bit higher, since we are first... 
+	 */
+	uiSetRoundBox((1|8));
+	gl_round_box(GL_POLYGON, 0,  yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8);
+}
+
+/* name for summary entries */
+static void acf_summary_name(bAnimListElem *ale, char *name)
+{
+	if (name)
+		strcpy(name, "DopeSheet Summary");
+}
+
+// TODO: this is really a temp icon I think
+static int acf_summary_icon(bAnimListElem *ale)
+{
+	return ICON_BORDERMOVE;
+}
+
+/* all animation summary (DopeSheet only) type define */
+static bAnimChannelType ACF_SUMMARY = 
+{
+	acf_summary_backdrop,				/* backdrop */
+	acf_generic_indention_0,			/* indent level */
+	NULL,								/* offset */
+	
+	acf_summary_name,					/* name */
+	acf_summary_icon,					/* icon */
+	
+	acf_generic_none_setting_valid,		/* has setting */
+	NULL,								/* flag for setting */
+	NULL								/* pointer for setting */
+};
+
 /* Scene ------------------------------------------- */
 
 // TODO: just get this from RNA?
@@ -1803,6 +1855,8 @@
 		animchannelTypeInfo[type++]= NULL; 				/* AnimData */
 		animchannelTypeInfo[type++]= NULL; 				/* Special */
 		
+		animchannelTypeInfo[type++]= &ACF_SUMMARY;		/* Motion Summary */
+		
 		animchannelTypeInfo[type++]= &ACF_SCENE; 		/* Scene */
 		animchannelTypeInfo[type++]= &ACF_OBJECT; 		/* Object */
 		animchannelTypeInfo[type++]= &ACF_GROUP; 		/* Group */

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c	2009-10-13 10:52:18 UTC (rev 23805)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c	2009-10-13 11:21:02 UTC (rev 23806)
@@ -458,6 +458,16 @@
 		
 		/* do specifics */
 		switch (datatype) {
+			case ANIMTYPE_SUMMARY:
+			{
+				/* nothing to include for now... this is just a dummy wrappy around all the other channels 
+				 * in the DopeSheet, and gets included at the start of the list
+				 */
+				ale->key_data= NULL;
+				ale->datatype= ALE_ALL;
+			}
+				break;
+			
 			case ANIMTYPE_SCENE:
 			{
 				Scene *sce= (Scene *)data;
@@ -1497,7 +1507,7 @@
 }
 
 // TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted)
-static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int filter_mode)
+static int animdata_filter_dopesheet (ListBase *anim_data, bAnimContext *ac, bDopeSheet *ads, int filter_mode)
 {
 	Scene *sce= (Scene *)ads->source;
 	Base *base;
@@ -1510,6 +1520,21 @@
 		return 0;
 	}
 	
+	/* dopesheet summary 
+	 *	- only for drawing and/or selecting keyframes in channels, but not for real editing 
+	 *	- only useful for DopeSheet Editor, where the summary is useful
+	 */
+	// TODO: we should really check if some other prohibited filters are also active, but that can be for later
+	if ((filter_mode & ANIMFILTER_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) {
+		ale= make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL, ANIMTYPE_NONE, NULL);
+		if (ale) {
+			BLI_addtail(anim_data, ale);
+			items++;
+		}
+		
+		// TODO: if the summary gets a collapse widget, then we could make the other stuff not get shown... 
+	}
+	
 	/* scene-linked animation */
 	// TODO: sequencer, composite nodes - are we to include those here too?
 	{
@@ -1898,7 +1923,7 @@
 			case ANIMCONT_FCURVES:
 			case ANIMCONT_DRIVERS:
 			case ANIMCONT_NLA:
-				items= animdata_filter_dopesheet(anim_data, data, filter_mode);
+				items= animdata_filter_dopesheet(anim_data, ac, data, filter_mode);
 				break;
 		}
 			

Modified: trunk/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_draw.c	2009-10-13 10:52:18 UTC (rev 23805)
+++ trunk/blender/source/blender/editors/animation/keyframes_draw.c	2009-10-13 11:21:02 UTC (rev 23806)
@@ -515,6 +515,24 @@
 
 /* *************************** Channel Drawing Funcs *************************** */
 
+void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos)
+{
+	DLRBT_Tree keys, blocks;
+	
+	BLI_dlrbTree_init(&keys);
+	BLI_dlrbTree_init(&blocks);
+	
+		summary_to_keylist(ac, &keys, &blocks);
+	
+	BLI_dlrbTree_linkedlist_sync(&keys);
+	BLI_dlrbTree_linkedlist_sync(&blocks);
+	
+		draw_keylist(v2d, &keys, &blocks, ypos);
+	
+	BLI_dlrbTree_free(&keys);
+	BLI_dlrbTree_free(&blocks);
+}
+
 void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos)
 {
 	DLRBT_Tree keys, blocks;
@@ -622,6 +640,25 @@
 
 /* *************************** Keyframe List Conversions *************************** */
 
+void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks)
+{
+	if (ac) {
+		ListBase anim_data = {NULL, NULL};
+		bAnimListElem *ale;
+		int filter;
+		
+		/* get F-Curves to take keyframes from */
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
+		ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+		
+		/* loop through each F-Curve, grabbing the keyframes */
+		for (ale= anim_data.first; ale; ale= ale->next)
+			fcurve_to_keylist(ale->adt, ale->data, keys, blocks);
+		
+		BLI_freelistN(&anim_data);
+	}
+}
+
 void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree *blocks)
 {
 	if (sce) {

Modified: trunk/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_edit.c	2009-10-13 10:52:18 UTC (rev 23805)
+++ trunk/blender/source/blender/editors/animation/keyframes_edit.c	2009-10-13 11:21:02 UTC (rev 23806)
@@ -310,16 +310,48 @@
 		return 0;
 	
 	/* Scene's own animation */
-	if (sce->adt)
-		adt_keys_bezier_loop(bed, sce->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+	if (sce->adt) {
+		if (adt_keys_bezier_loop(bed, sce->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+			return 1;
+	}
 	
 	/* World */
-	if (wo && wo->adt)
-		adt_keys_bezier_loop(bed, wo->adt, bezt_ok, bezt_cb, fcu_cb, filterflag);
+	if (wo && wo->adt) {
+		if (adt_keys_bezier_loop(bed, wo->adt, bezt_ok, bezt_cb, fcu_cb, filterflag))
+			return 1;
+	}
 	
 	return 0;
 }
 
+/* This function is used to loop over the keyframe data in a DopeSheet summary */
+static short summary_keys_bezier_loop(BeztEditData *bed, bAnimContext *ac, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int filterflag)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter, ret_code=0;
+	
+	/* sanity check */
+	if (ac == NULL)
+		return 0;
+	
+	/* get F-Curves to take keyframes from */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
+	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+	
+	/* loop through each F-Curve, working on the keyframes until the first curve aborts */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		ret_code= ANIM_fcurve_keys_bezier_loop(bed, ale->data, bezt_ok, bezt_cb, fcu_cb);
+		
+		if (ret_code)
+			break;
+	}
+	
+	BLI_freelistN(&anim_data);
+	
+	return ret_code;
+}
+
 /* --- */
 
 /* This function is used to apply operation to all keyframes, regardless of the type */
@@ -347,6 +379,8 @@
 			return ob_keys_bezier_loop(bed, (Object *)ale->key_data, bezt_ok, bezt_cb, fcu_cb, filterflag);
 		case ALE_SCE: /* scene */
 			return scene_keys_bezier_loop(bed, (Scene *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
+		case ALE_ALL: /* 'all' (DopeSheet summary) */
+			return summary_keys_bezier_loop(bed, (bAnimContext *)ale->data, bezt_ok, bezt_cb, fcu_cb, filterflag);
 	}
 	
 	return 0;
@@ -377,6 +411,8 @@
 			return ob_keys_bezier_loop(bed, (Object *)data, bezt_ok, bezt_cb, fcu_cb, filterflag);
 		case ALE_SCE: /* scene */
 			return scene_keys_bezier_loop(bed, (Scene *)data, bezt_ok, bezt_cb, fcu_cb, filterflag);
+		case ALE_ALL: /* 'all' (DopeSheet summary) */
+			return summary_keys_bezier_loop(bed, (bAnimContext *)data, bezt_ok, bezt_cb, fcu_cb, filterflag);
 	}
 	
 	return 0;

Modified: trunk/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_anim_api.h	2009-10-13 10:52:18 UTC (rev 23805)
+++ trunk/blender/source/blender/editors/include/ED_anim_api.h	2009-10-13 11:21:02 UTC (rev 23806)
@@ -122,6 +122,8 @@
 	ANIMTYPE_ANIMDATA,
 	ANIMTYPE_SPECIALDATA,
 	
+	ANIMTYPE_SUMMARY,
+	
 	ANIMTYPE_SCENE,
 	ANIMTYPE_OBJECT,
 	ANIMTYPE_GROUP,
@@ -161,6 +163,7 @@
 	ALE_GPFRAME,		/* Grease Pencil Frames */
 	ALE_NLASTRIP,		/* NLA Strips */
 	
+	ALE_ALL,			/* All channels summary */
 	ALE_SCE,			/* Scene summary */
 	ALE_OB,				/* Object summary */
 	ALE_ACT,			/* Action summary */
@@ -184,6 +187,9 @@
 	ANIMFILTER_ANIMDATA		= (1<<9),	/* only return the underlying AnimData blocks (not the tracks, etc.) data comes from */
 	ANIMFILTER_NLATRACKS	= (1<<10),	/* only include NLA-tracks */
 	ANIMFILTER_SELEDIT		= (1<<11),	/* link editability with selected status */
+	
+	/* all filters - the power inside the bracket must be the last power for left-shifts + 1 */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list