[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18120] branches/blender2.5/blender/source /blender/editors: 2.5 - Action Editor:

Joshua Leung aligorith at gmail.com
Sun Dec 28 12:51:42 CET 2008


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

Log Message:
-----------
2.5 - Action Editor: 

* Added set-extrapolation operator. For now, this uses the Shift-E hotkey.
* Removed some unused code from keyframes_edit.c

Modified Paths:
--------------
    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/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-28 11:28:44 UTC (rev 18119)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2008-12-28 11:51:41 UTC (rev 18120)
@@ -50,7 +50,7 @@
 #include "ED_keyframes_edit.h"
 #include "ED_markers.h"
 
-/* This file defines an API and set of callback-operators for editing keyframe data.
+/* This file defines an API and set of callback-operators for non-destructive editing of keyframe data.
  *
  * Two API functions are defined for actually performing the operations on the data:
  *			ipo_keys_bezier_loop() and icu_keys_bezier_loop()
@@ -71,9 +71,6 @@
 /* ************************************************************************** */
 /* IPO Editing Loops - Exposed API */
 
-// FIXME: it would be useful to be able to supply custom properties to the bezt function...
-// workaround for those callbacks that need this now, is to set globals...
-
 /* --------------------------- Base Functions ------------------------------------ */
 
 /* This function is used to loop over BezTriples in the given IpoCurve, applying a given 
@@ -524,28 +521,8 @@
 	}
 }
 
-#if 0
-void setipotype_ipo(Ipo *ipo, int code)
-{
-	/* Sets the type of the selected bezts in each ipo curve in the
-	 * Ipo to a value based on the code
-	 */
-	switch (code) {
-	case 1:
-		ipo_keys_bezier_loop(ipo, set_bezt_constant, set_ipocurve_mixed);
-		break;
-	case 2:
-		ipo_keys_bezier_loop(ipo, set_bezt_linear, set_ipocurve_mixed);
-		break;
-	case 3:
-		ipo_keys_bezier_loop(ipo, set_bezt_bezier, set_ipocurve_mixed);
-		break;
-	}
-}
-#endif
-
 // XXX will we keep this?
-void setexprap_ipoloop(Ipo *ipo, int code)
+void setexprap_ipoloop(Ipo *ipo, short code)
 {
 	IpoCurve *icu;
 	

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 11:28:44 UTC (rev 18119)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2008-12-28 11:51:41 UTC (rev 18120)
@@ -130,12 +130,14 @@
 
 /* ************************************************ */
 
-// XXX all of these funcs will be depreceated!
+// XXX all of these funcs should be depreceated or at least renamed!
 
 short is_ipo_key_selected(struct Ipo *ipo);
 void set_ipo_key_selection(struct Ipo *ipo, short sel);
 
+void setexprap_ipoloop(struct Ipo *ipo, short code);
 
+
 /* ************************************************ */
 
 #endif /* ED_KEYFRAMES_EDIT_H */

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 11:28:44 UTC (rev 18119)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.c	2008-12-28 11:51:41 UTC (rev 18120)
@@ -88,9 +88,98 @@
 /* ************************************************************************** */
 /* GENERAL STUFF */
 
+// TODO:
+//	- clean
+//	- sample
+//	- delete
+//	- insert key
+// 	- copy/paste
+
 /* ************************************************************************** */
 /* SETTINGS STUFF */
 
+// TODO: 
+// 	- wkey stuff
+
+/* ******************** Set Extrapolation-Type Operator *********************** */
+
+/* defines for set ipo-type for selected keyframes tool */
+EnumPropertyItem prop_actkeys_expo_types[] = {
+	{IPO_HORIZ, "CONSTANT", "Constant", ""},
+	{IPO_DIR, "DIRECTIONAL", "Extrapolation", ""},
+	{IPO_CYCL, "CYCLIC", "Cyclic", ""},
+	{IPO_CYCLX, "CYCLIC_EXTRAPOLATION", "Cyclic Extrapolation", ""},
+	{0, NULL, NULL, NULL}
+};
+
+/* this function is responsible for setting extrapolation mode for keyframes */
+static void setexpo_action_keys(bAnimContext *ac, short mode) 
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS);
+	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+	/* loop through setting mode per ipo-curve */
+	for (ale= anim_data.first; ale; ale= ale->next)
+		setexprap_ipoloop(ale->key_data, mode);
+	
+	/* cleanup */
+	BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int actkeys_expo_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 */
+	setexpo_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_expotype (wmOperatorType *ot)
+{
+	PropertyRNA *prop;
+	
+	/* identifiers */
+	ot->name= "Set Keyframe Extrapolation";
+	ot->idname= "ACT_OT_keyframes_expotype";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= actkeys_expo_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_expo_types);
+}
+
 /* ******************** Set Interpolation-Type Operator *********************** */
 
 /* defines for set ipo-type for selected keyframes tool */
@@ -113,7 +202,7 @@
 	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS);
 	ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
 	
-	/* loop through setting flags for handles 
+	/* 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)

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2008-12-28 11:28:44 UTC (rev 18119)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2008-12-28 11:51:41 UTC (rev 18120)
@@ -75,6 +75,7 @@
 
 void ACT_OT_keyframes_handletype(struct wmOperatorType *ot);
 void ACT_OT_keyframes_ipotype(struct wmOperatorType *ot);
+void ACT_OT_keyframes_expotype(struct wmOperatorType *ot);
 
 void ACT_OT_keyframes_cfrasnap(struct wmOperatorType *ot);
 void ACT_OT_keyframes_snap(struct wmOperatorType *ot);

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2008-12-28 11:28:44 UTC (rev 18119)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2008-12-28 11:51:41 UTC (rev 18120)
@@ -74,6 +74,7 @@
 	WM_operatortype_append(ACT_OT_keyframes_cfrasnap);
 	WM_operatortype_append(ACT_OT_keyframes_handletype);
 	WM_operatortype_append(ACT_OT_keyframes_ipotype);
+	WM_operatortype_append(ACT_OT_keyframes_expotype);
 }
 
 /* ************************** registration - keymaps **********************************/
@@ -112,6 +113,7 @@
 		/* menu + set setting */
 	WM_keymap_add_item(keymap, "ACT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "ACT_OT_keyframes_ipotype", TKEY, KM_PRESS, KM_SHIFT, 0);
+	WM_keymap_add_item(keymap, "ACT_OT_keyframes_expotype", EKEY, KM_PRESS, KM_SHIFT, 0); // temp...
 }
 
 /* --------------- */





More information about the Bf-blender-cvs mailing list