[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18111] branches/blender2.5/blender/source /blender/editors: 2.5 - Action Editor: Bringing back more operators

Joshua Leung aligorith at gmail.com
Sun Dec 28 09:15:29 CET 2008


Revision: 18111
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18111
Author:   aligorith
Date:     2008-12-28 09:15:29 +0100 (Sun, 28 Dec 2008)

Log Message:
-----------
2.5 - Action Editor: Bringing back more operators

* Added 'set handle-type' operator. Currently, all possible handle types are all set using a menu and HKEY. This will need to be reviewed at some point, but I think it should be easier for users to remember 1 hotkey for this, rather than 4 scattered around the place.

* Added 'set interpolation' operator. This uses the Shift-T hotkey as before (for now). As in AnimSys2, this sets per-keyframe interpolation.

* Remapped toggle frames/time-codes operator to Ctrl-T key. This may still change, but the TKEY needs to be free for transform tool here.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.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

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c	2008-12-28 07:39:23 UTC (rev 18110)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c	2008-12-28 08:15:29 UTC (rev 18111)
@@ -368,7 +368,7 @@
 	ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
 	
 	WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
-	WM_keymap_verify_item(keymap, "ANIM_OT_toggle_time", TKEY, KM_PRESS, 0, 0);
+	WM_keymap_verify_item(keymap, "ANIM_OT_toggle_time", TKEY, KM_PRESS, KM_CTRL, 0);
 	
 		/* preview range */
 	WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_define", PKEY, KM_PRESS, KM_CTRL, 0);

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-28 07:39:23 UTC (rev 18110)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-28 08:15:29 UTC (rev 18111)
@@ -398,7 +398,6 @@
 /* Sets the selected bezier handles to type 'auto' */
 static short set_bezier_auto(BeztEditData *bed, BezTriple *bezt) 
 {
-	/* is a handle selected? If so set it to type auto */
 	if((bezt->f1  & SELECT) || (bezt->f3 & SELECT)) {
 		if (bezt->f1 & SELECT) bezt->h1= 1; /* the secret code for auto */
 		if (bezt->f3 & SELECT) bezt->h2= 1;
@@ -417,7 +416,6 @@
 /* Sets the selected bezier handles to type 'vector'  */
 static short set_bezier_vector(BeztEditData *bed, BezTriple *bezt) 
 {
-	/* is a handle selected? If so set it to type vector */
 	if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
 		if (bezt->f1 & SELECT) bezt->h1= HD_VECT;
 		if (bezt->f3 & SELECT) bezt->h2= HD_VECT;
@@ -433,29 +431,25 @@
 	return 0;
 }
 
-#if 0 // xxx currently not used (only used by old code as a check)
+/* Queries if the handle should be set to 'free' or 'align' */
 static short bezier_isfree(BeztEditData *bed, BezTriple *bezt) 
 {
-	/* queries whether the handle should be set
-	 * to type 'free' or 'align'
-	 */
 	if ((bezt->f1 & SELECT) && (bezt->h1)) return 1;
 	if ((bezt->f3 & SELECT) && (bezt->h2)) return 1;
 	return 0;
 }
 
+/* Sets selected bezier handles to type 'align' */
 static short set_bezier_align(BeztEditData *bed, BezTriple *bezt) 
-{
-	/* Sets selected bezier handles to type 'align' */
+{	
 	if (bezt->f1 & SELECT) bezt->h1= HD_ALIGN;
 	if (bezt->f3 & SELECT) bezt->h2= HD_ALIGN;
 	return 0;
 }
-#endif // xxx currently not used (only used by old code as a check, but can't replicate that now)
 
+/* Sets selected bezier handles to type 'free'  */
 static short set_bezier_free(BeztEditData *bed, BezTriple *bezt) 
 {
-	/* Sets selected bezier handles to type 'free'  */
 	if (bezt->f1 & SELECT) bezt->h1= HD_FREE;
 	if (bezt->f3 & SELECT) bezt->h2= HD_FREE;
 	return 0;
@@ -463,54 +457,31 @@
 
 /* Set all Bezier Handles to a single type */
 // calchandles_ipocurve
-BeztEditFunc ANIM_editkeyframes_sethandles(short code)
+BeztEditFunc ANIM_editkeyframes_handles(short code)
 {
 	switch (code) {
-		case 1: /* auto */
+		case HD_AUTO: /* auto */
 			return set_bezier_auto;
-		case 2: /* vector */
+		case HD_VECT: /* vector */
 			return set_bezier_vector;
-			
+		case HD_FREE: /* free */
+			return set_bezier_free;
+		case HD_ALIGN: /* align */
+			return set_bezier_align;
+		
 		default: /* free or align? */
-			return set_bezier_free; // err.. to set align, we need 'align' to be set
+			return bezier_isfree;
 	}
 }
 
-#if 0
-void sethandles_ipo_keys(Ipo *ipo, int code)
-{
-	/* this function lets you set bezier handles all to
-	 * one type for some Ipo's (e.g. with hotkeys through
-	 * the action window).
-	 */ 
-
-	/* code==1: set autohandle */
-	/* code==2: set vectorhandle */
-	/* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
-	
-	switch (code) {
-	case 1: /* auto */
-		ipo_keys_bezier_loop(ipo, set_bezier_auto, calchandles_ipocurve);
-		break;
-	case 2: /* vector */
-		ipo_keys_bezier_loop(ipo, set_bezier_vector, calchandles_ipocurve);
-		break;
-	default: /* free or align? */
-		if (ipo_keys_bezier_loop(ipo, bezier_isfree, NULL)) /* free */ 
-			ipo_keys_bezier_loop(ipo, set_bezier_free, calchandles_ipocurve);
-		else /* align */
-			ipo_keys_bezier_loop(ipo, set_bezier_align, calchandles_ipocurve);
-		break;
-	}
-}
-#endif
-
 /* ------- */
 
-void set_ipocurve_mixed(IpoCurve *icu)
+/* IPO-curve sanity callback - the name of this is a bit unwieldy, by is best to keep this in style... */
+// was called set_ipocurve_mixed()
+void ANIM_editkeyframes_ipocurve_ipotype(IpoCurve *icu)
 {
 	/* Sets the type of the IPO curve to mixed, as some (selected)
-	 * keyframes were set to other interpolation modes
+	 * keyframes were set to other interpolation types
 	 */
 	icu->ipo= IPO_MIXED;
 	
@@ -540,13 +511,13 @@
 }
 
 /* Set the interpolation type of the selected BezTriples in each IPO curve to the specified one */
-// set_ipocurve_mixed() !
+// ANIM_editkeyframes_ipocurve_ipotype() !
 BeztEditFunc ANIM_editkeyframes_ipo(short code)
 {
 	switch (code) {
-		case 1: /* constant */
+		case IPO_CONST: /* constant */
 			return set_bezt_constant;
-		case 2: /* linear */	
+		case IPO_LIN: /* linear */	
 			return set_bezt_linear;
 		default: /* bezier */
 			return set_bezt_bezier;

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	2008-12-28 07:39:23 UTC (rev 18110)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2008-12-28 08:15:29 UTC (rev 18111)
@@ -124,6 +124,10 @@
 BeztEditFunc ANIM_editkeyframes_handles(short mode);
 BeztEditFunc ANIM_editkeyframes_ipo(short mode);
 
+/* ---------- IpoCurve Callbacks ------------ */
+
+void ANIM_editkeyframes_ipocurve_ipotype(struct IpoCurve *icu);
+
 /* ************************************************ */
 
 // XXX all of these funcs will be depreceated!

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.c	2008-12-28 07:39:23 UTC (rev 18110)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.c	2008-12-28 08:15:29 UTC (rev 18111)
@@ -91,6 +91,188 @@
 /* ************************************************************************** */
 /* SETTINGS STUFF */
 
+/* ******************** Set Interpolation-Type Operator *********************** */
+
+/* defines for set ipo-type for selected keyframes tool */
+EnumPropertyItem prop_actkeys_ipo_types[] = {
+	{IPO_CONST, "CONSTANT", "Constant Interpolation", ""},
+	{IPO_LIN, "LINEAR", "Linear Interpolation", ""},
+	{IPO_BEZ, "BEZIER", "Bezier Interpolation", ""},
+	{0, NULL, NULL, NULL}
+};
+
+/* this function is responsible for setting interpolation mode for keyframes */
+static void setipo_action_keys(bAnimContext *ac, short mode) 
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	BeztEditFunc set_cb= ANIM_editkeyframes_ipo(mode);
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS);
+	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+	/* loop through setting flags for handles 
+	 * 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)
+		ipo_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, ANIM_editkeyframes_ipocurve_ipotype);
+	
+	/* cleanup */
+	BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int actkeys_ipo_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 */
+	setipo_action_keys(&ac, mode);
+	
+	/* validate keyframes after editing */
+	ANIM_editkeyframes_refresh(&ac);
+	
+	/* set notifier tha things have changed */
+	ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead!
+	
+	return OPERATOR_FINISHED;
+}
+ 
+void ACT_OT_keyframes_ipotype (wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+	
+	/* identifiers */
+	ot->name= "Set Keyframe Interpolation";
+	ot->idname= "ACT_OT_keyframes_ipotype";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= actkeys_ipo_exec;
+	ot->poll= ED_operator_areaactive;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+	
+	/* id-props */
+	prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, prop_actkeys_ipo_types);
+}
+
+/* ******************** Set Handle-Type Operator *********************** */
+
+/* defines for set handle-type for selected keyframes tool */
+EnumPropertyItem prop_actkeys_handletype_types[] = {
+	{HD_AUTO, "AUTO", "Auto Handles", ""},
+	{HD_VECT, "VECTOR", "Vector Handles", ""},
+	{HD_FREE, "FREE", "Free Handles", ""},
+	{HD_ALIGN, "ALIGN", "Aligned Handles", ""},
+//	{-1, "TOGGLE", "Toggle between Free and Aligned Handles", ""},
+	{0, NULL, NULL, NULL}
+};
+
+/* this function is responsible for setting handle-type of selected keyframes */
+static void sethandles_action_keys(bAnimContext *ac, short mode) 
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	BeztEditFunc set_cb= ANIM_editkeyframes_handles(mode);
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS);
+	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+	/* loop through setting flags for handles 
+	 * 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) {
+		if (mode == -1) {	
+			BeztEditFunc toggle_cb;
+			
+			/* check which type of handle to set (free or aligned) 
+			 *	- check here checks for handles with free alignment already
+			 */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list