[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21231] branches/soc-2009-aligorith/source /blender/editors: NLA SoC: Insert Keyframe Operator Tweaks ( Anim Editor Versions)

Joshua Leung aligorith at gmail.com
Mon Jun 29 05:02:46 CEST 2009


Revision: 21231
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21231
Author:   aligorith
Date:     2009-06-29 05:02:41 +0200 (Mon, 29 Jun 2009)

Log Message:
-----------
NLA SoC: Insert Keyframe Operator Tweaks (Anim Editor Versions) 

* Insert Keyframe (IKEY) operator for Graph Editor 
* Renamed the DopeSheet version to make it more consistent with the other keyframing operators

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c
    branches/soc-2009-aligorith/source/blender/editors/space_action/action_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_action/action_ops.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_header.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c

Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_edit.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -433,10 +433,10 @@
 	if (ac.datatype == ANIMCONT_GPENCIL)
 		return OPERATOR_CANCELLED;
 		
-	/* get snapping mode */
+	/* what channels to affect? */
 	mode= RNA_enum_get(op->ptr, "type");
 	
-	/* snap keyframes */
+	/* insert keyframes */
 	insert_action_keys(&ac, mode);
 	
 	/* validate keyframes after editing */
@@ -448,11 +448,11 @@
 	return OPERATOR_FINISHED;
 }
 
-void ACT_OT_insert (wmOperatorType *ot)
+void ACT_OT_insert_keyframe (wmOperatorType *ot)
 {
 	/* identifiers */
 	ot->name= "Insert Keyframes";
-	ot->idname= "ACT_OT_insert";
+	ot->idname= "ACT_OT_insert_keyframe";
 	
 	/* api callbacks */
 	ot->invoke= WM_menu_invoke;

Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_header.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -211,7 +211,7 @@
 	
 	uiItemS(layout);
 	
-	uiItemO(layout, NULL, 0, "ACT_OT_insert");
+	uiItemO(layout, NULL, 0, "ACT_OT_insert_keyframe");
 	
 	uiItemS(layout);
 	

Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_intern.h	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_intern.h	2009-06-29 03:02:41 UTC (rev 21231)
@@ -83,7 +83,7 @@
 void ACT_OT_copy(struct wmOperatorType *ot);
 void ACT_OT_paste(struct wmOperatorType *ot);
 
-void ACT_OT_insert(struct wmOperatorType *ot);
+void ACT_OT_insert_keyframe(struct wmOperatorType *ot);
 void ACT_OT_duplicate(struct wmOperatorType *ot);
 void ACT_OT_delete(struct wmOperatorType *ot);
 void ACT_OT_clean(struct wmOperatorType *ot);

Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_ops.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_ops.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -79,7 +79,7 @@
 	WM_operatortype_append(ACT_OT_clean);
 	WM_operatortype_append(ACT_OT_delete);
 	WM_operatortype_append(ACT_OT_duplicate);
-	WM_operatortype_append(ACT_OT_insert);
+	WM_operatortype_append(ACT_OT_insert_keyframe);
 	WM_operatortype_append(ACT_OT_copy);
 	WM_operatortype_append(ACT_OT_paste);
 	
@@ -142,7 +142,7 @@
 	WM_keymap_add_item(keymap, "ACT_OT_delete", DELKEY, KM_PRESS, 0, 0);
 	
 	WM_keymap_add_item(keymap, "ACT_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
-	WM_keymap_add_item(keymap, "ACT_OT_insert", IKEY, KM_PRESS, 0, 0);
+	WM_keymap_add_item(keymap, "ACT_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
 	
 		/* copy/paste */
 	WM_keymap_add_item(keymap, "ACT_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -399,8 +399,104 @@
 /* ************************************************************************** */
 /* GENERAL STUFF */
 
-// TODO: insertkey
+/* ******************** Insert Keyframes Operator ************************* */
 
+/* defines for insert keyframes tool */
+EnumPropertyItem prop_graphkeys_insertkey_types[] = {
+	{1, "ALL", 0, "All Channels", ""},
+	{2, "SEL", 0, "Only Selected Channels", ""},
+	{0, NULL, 0, NULL, NULL}
+};
+
+/* this function is responsible for snapping keyframes to frame-times */
+static void insert_graph_keys(bAnimContext *ac, short mode) 
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	Scene *scene= ac->scene;
+	float cfra= (float)CFRA;
+	short flag = 0;
+	
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+	if (mode == 2) filter |= ANIMFILTER_SEL;
+	
+	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+	
+	/* init keyframing flag */
+	if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
+	if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+	// if (IS_AUTOKEY_MODE(EDITKEYS)) flag |= INSERTKEY_REPLACE;
+	
+	/* insert keyframes */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		AnimData *adt= ANIM_nla_mapping_get(ac, ale);
+		FCurve *fcu= (FCurve *)ale->key_data;
+		
+		/* adjust current frame for NLA-mapping */
+		if (adt)
+			cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
+		else 
+			cfra= (float)CFRA;
+			
+		/* if there's an id */
+		if (ale->id)
+			insert_keyframe(ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+		else
+			insert_vert_fcurve(fcu, cfra, fcu->curval, 0);
+	}
+	
+	BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+static int graphkeys_insertkey_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_CANCELLED;
+		
+	/* which channels to affect? */
+	mode= RNA_enum_get(op->ptr, "type");
+	
+	/* insert keyframes */
+	insert_graph_keys(&ac, mode);
+	
+	/* validate keyframes after editing */
+	ANIM_editkeyframes_refresh(&ac);
+	
+	/* set notifier that things have changed */
+	ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_KEYFRAMES_VALUES);
+	
+	return OPERATOR_FINISHED;
+}
+
+void GRAPH_OT_insert_keyframe (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Insert Keyframes";
+	ot->idname= "GRAPH_OT_insert_keyframe";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= graphkeys_insertkey_exec;
+	ot->poll= ED_operator_ipo_active; // xxx
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* id-props */
+	RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", "");
+}
+
 /* ******************** Click-Insert Keyframes Operator ************************* */
 
 static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_header.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_header.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -201,7 +201,7 @@
 	
 	uiItemS(layout);
 	
-	//uiItemO(layout, NULL, 0, "GRAPH_OT_insert");
+	uiItemO(layout, NULL, 0, "GRAPH_OT_insert_keyframe");
 	uiItemO(layout, NULL, 0, "GRAPH_OT_fmodifier_add");
 	
 	uiItemS(layout);

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_intern.h	2009-06-29 03:02:41 UTC (rev 21231)
@@ -86,6 +86,7 @@
 void GRAPH_OT_view_all(struct wmOperatorType *ot);
 
 void GRAPH_OT_click_insert(struct wmOperatorType *ot);
+void GRAPH_OT_insert_keyframe(struct wmOperatorType *ot);
 
 void GRAPH_OT_copy(struct wmOperatorType *ot);
 void GRAPH_OT_paste(struct wmOperatorType *ot);

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c	2009-06-29 02:37:44 UTC (rev 21230)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c	2009-06-29 03:02:41 UTC (rev 21231)
@@ -132,6 +132,7 @@
 	WM_operatortype_append(GRAPH_OT_copy);
 	WM_operatortype_append(GRAPH_OT_paste);
 	
+	WM_operatortype_append(GRAPH_OT_insert_keyframe);
 	WM_operatortype_append(GRAPH_OT_click_insert);
 	
 	/* F-Curve Modifiers */
@@ -209,6 +210,7 @@
 	WM_keymap_add_item(keymap, "GRAPH_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
 	
 		/* insertkey */
+	WM_keymap_add_item(keymap, "GRAPH_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
 	
 		/* copy/paste */





More information about the Bf-blender-cvs mailing list