[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22980] branches/blender2.5/blender/source /blender: 2.5 - Keyframe Types for DopeSheet

Joshua Leung aligorith at gmail.com
Fri Sep 4 04:44:57 CEST 2009


Revision: 22980
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22980
Author:   aligorith
Date:     2009-09-04 04:44:56 +0200 (Fri, 04 Sep 2009)

Log Message:
-----------
2.5 - Keyframe Types for DopeSheet

It is now possible to tag certain keyframes as being 'breakdowns' in the DopeSheet. Breakdown keyframes are drawn as slightly smaller blue diamonds.

Simply select the relevant keyframes and use the RKEY hotkey (or from the menus, Key->Keyframe Type) to choose between tagging the keyframe as a 'proper' keyframe and a 'breakdown' keyframe. 

Notes:
* Please note that this feature does not currently imply anything about breakdowns moving around keyframes or behaving any differently from any other type of keyframe
* In future, if there is any such need, more keyframe types could be added, though this is not really likely at all

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_draw.h
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_header.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_curve_types.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_enum_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_curve.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-09-04 02:44:56 UTC (rev 22980)
@@ -98,10 +98,8 @@
 	/* store settings based on state of BezTriple */
 	ak->cfra= bezt->vec[1][0];
 	ak->sel= BEZSELECTED(bezt) ? SELECT : 0;
+	ak->key_type= BEZKEYTYPE(bezt); 
 	
-	// TODO: handle type = bezt->h1 or bezt->h2
-	ak->handle_type= 0; 
-	
 	/* set 'modified', since this is used to identify long keyframes */
 	ak->modified = 1;
 	
@@ -134,6 +132,10 @@
 				if (BEZSELECTED(bezt)) ak->sel = SELECT;
 				ak->modified += 1;
 				
+				/* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */
+				if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
+					ak->key_type= BEZT_KEYTYPE_KEYFRAME;
+				
 				/* done... no need to insert */
 				return;
 			}
@@ -340,7 +342,7 @@
 }; 
 
 /* draw a simple diamond shape with OpenGL */
-void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode)
+void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short key_type, short mode)
 {
 	static GLuint displist1=0;
 	static GLuint displist2=0;
@@ -371,6 +373,11 @@
 		glEndList();
 	}
 	
+	/* tweak size of keyframe shape according to type of keyframe 
+	 * 	- 'proper' keyframes have key_type=0, so get drawn at full size
+	 */
+	hsize -= 0.5f*key_type;
+	
 	/* adjust view transform before starting */
 	glTranslatef(x, y, 0.0f);
 	glScalef(1.0f/xscale*hsize, hsize, 1.0f);
@@ -381,8 +388,22 @@
 	/* draw! */
 	if ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH) {
 		/* interior - hardcoded colors (for selected and unselected only) */
-		if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50);
-		else glColor3ub(0xE9, 0xE9, 0xE9);
+		switch (key_type) {
+			case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames for now */
+			{
+				if (sel) glColor3f(0.33f, 0.75f, 0.93f);
+				else glColor3f(0.70f, 0.86f, 0.91f);
+			}
+				break;
+				
+			case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames for now */
+			default:
+			{
+				if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50);
+				else glColor3f(0.91f, 0.91f, 0.91f);
+			}
+				break;
+		}
 		
 		glCallList(displist2);
 	}
@@ -454,7 +475,7 @@
 			/* draw using OpenGL - uglier but faster */
 			// NOTE1: a previous version of this didn't work nice for some intel cards
 			// NOTE2: if we wanted to go back to icons, these are  icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3;
-			draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), KEYFRAME_SHAPE_BOTH);
+			draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH);
 		}	
 	}
 	
@@ -695,7 +716,7 @@
 			
 			ak->cfra= (float)gpf->framenum;
 			ak->modified = 1;
-			ak->handle_type= 0; 
+			ak->key_type= 0; 
 			
 			if (gpf->flag & GP_FRAME_SELECT)
 				ak->sel = SELECT;

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-09-04 02:44:56 UTC (rev 22980)
@@ -655,7 +655,7 @@
 	return 0;
 }
 
-/* Set the interpolation type of the selected BezTriples in each IPO curve to the specified one */
+/* Set the interpolation type of the selected BezTriples in each F-Curve to the specified one */
 // ANIM_editkeyframes_ipocurve_ipotype() !
 BeztEditFunc ANIM_editkeyframes_ipo(short code)
 {
@@ -669,6 +669,35 @@
 	}
 }
 
+/* ------- */
+
+static short set_keytype_keyframe(BeztEditData *bed, BezTriple *bezt) 
+{
+	if (bezt->f2 & SELECT) 
+		BEZKEYTYPE(bezt)= BEZT_KEYTYPE_KEYFRAME;
+	return 0;
+}
+
+static short set_keytype_breakdown(BeztEditData *bed, BezTriple *bezt) 
+{
+	if (bezt->f2 & SELECT) 
+		BEZKEYTYPE(bezt)= BEZT_KEYTYPE_BREAKDOWN;
+	return 0;
+}
+
+/* Set the interpolation type of the selected BezTriples in each F-Curve to the specified one */
+BeztEditFunc ANIM_editkeyframes_keytype(short code)
+{
+	switch (code) {
+		case BEZT_KEYTYPE_BREAKDOWN: /* breakdown */
+			return set_keytype_breakdown;
+			
+		case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */	
+		default:
+			return set_keytype_keyframe;
+	}
+}
+
 /* ******************************************* */
 /* Selection */
 

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-09-04 02:44:56 UTC (rev 22980)
@@ -434,8 +434,13 @@
 /* ------------- Utility macros ----------------------- */
 
 /* checks if the given BezTriple is selected */
-#define BEZSELECTED(bezt) ((bezt->f2 & SELECT) || (bezt->f1 & SELECT) || (bezt->f3 & SELECT))
+#define BEZSELECTED(bezt) (((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
 
+/* provide access to Keyframe Type info in BezTriple
+ * NOTE: this is so that we can change it from being stored in 'hide'
+ */
+#define BEZKEYTYPE(bezt) ((bezt)->hide)
+
 /* set/clear/toggle macro 
  *	- channel - channel with a 'flag' member that we're setting
  *	- smode - 0=clear, 1=set, 2=toggle

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_draw.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_draw.h	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_draw.h	2009-09-04 02:44:56 UTC (rev 22980)
@@ -56,8 +56,8 @@
 	char tree_col;						/* DLRB_BLACK or DLRB_RED */
 	
 		/* keyframe info */
-	char sel;
-	short handle_type;
+	char key_type;						/* eBezTripe_KeyframeType */
+	short sel;
 	float cfra;
 	
 	/* only while drawing - used to determine if long-keyframe needs to be drawn */
@@ -99,7 +99,7 @@
 } eKeyframeShapeDrawOpts;
 
 /* draw simple diamond-shape keyframe (with OpenGL) */
-void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode);
+void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short key_type, short mode);
 
 /* ******************************* Methods ****************************** */
 

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-09-04 02:44:56 UTC (rev 22980)
@@ -40,8 +40,6 @@
 
 /* --------- BezTriple Selection ------------- */
 
-#define BEZSELECTED(bezt) ((bezt->f2 & SELECT) || (bezt->f1 & SELECT) || (bezt->f3 & SELECT))
-
 #define BEZ_SEL(bezt)		{ (bezt)->f1 |=  SELECT; (bezt)->f2 |=  SELECT; (bezt)->f3 |=  SELECT; }
 #define BEZ_DESEL(bezt)		{ (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; }
 #define BEZ_INVSEL(bezt)	{ (bezt)->f1 ^=  SELECT; (bezt)->f2 ^=  SELECT; (bezt)->f3 ^=  SELECT; }
@@ -133,6 +131,7 @@
 BeztEditFunc ANIM_editkeyframes_select(short mode);
 BeztEditFunc ANIM_editkeyframes_handles(short mode);
 BeztEditFunc ANIM_editkeyframes_ipo(short mode);
+BeztEditFunc ANIM_editkeyframes_keytype(short mode);
 
 /* ----------- BezTriple Callback (Assorted Utilities) ---------- */
 

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-09-04 02:16:08 UTC (rev 22979)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-09-04 02:44:56 UTC (rev 22980)
@@ -1038,6 +1038,77 @@
 	RNA_def_enum(ot->srna, "type", beztriple_handle_type_items, 0, "Type", "");
 }
 
+/* ******************** Set Keyframe-Type Operator *********************** */
+
+/* this function is responsible for setting interpolation mode for keyframes */
+static void setkeytype_action_keys(bAnimContext *ac, short mode) 
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	BeztEditFunc set_cb= ANIM_editkeyframes_keytype(mode);
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+	
+	/* loop through setting BezTriple interpolation
+	 * Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here...
+	 */
+	for (ale= anim_data.first; ale; ale= ale->next)
+		ANIM_fcurve_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, NULL);
+	
+	/* cleanup */
+	BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int actkeys_keytype_exec(bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	short mode;
+	
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+	if (ac.datatype == ANIMCONT_GPENCIL) 
+		return OPERATOR_PASS_THROUGH;
+		
+	/* get handle setting mode */
+	mode= RNA_enum_get(op->ptr, "type");
+	
+	/* set handle type */
+	setkeytype_action_keys(&ac, mode);
+	
+	/* validate keyframes after editing */
+	ANIM_editkeyframes_refresh(&ac);
+	
+	/* set notifier that keyframe properties have changed */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
+	
+	return OPERATOR_FINISHED;
+}
+ 
+void ACT_OT_keyframe_type (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Set Keyframe Type";
+	ot->idname= "ACT_OT_keyframe_type";
+	ot->description= "Set type of keyframe for the seleced keyframes.";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= actkeys_keytype_exec;
+	ot->poll= ED_operator_action_active;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* id-props */
+	RNA_def_enum(ot->srna, "type", beztriple_keyframe_type_items, 0, "Type", "");
+}
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list