[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21309] branches/soc-2009-aligorith/source /blender/editors: NLA SoC: F-Modifiers working on NLA Strips

Joshua Leung aligorith at gmail.com
Thu Jul 2 08:41:10 CEST 2009


Revision: 21309
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21309
Author:   aligorith
Date:     2009-07-02 08:41:10 +0200 (Thu, 02 Jul 2009)

Log Message:
-----------
NLA SoC: F-Modifiers working on NLA Strips 

* Using the Ctrl-Shift-M hotkey, F-Modifiers can be added to all the selected strips.

* F-Modifiers can also be added/tweaked from the NLA N-Key properties. The UI now uses the same code as for the graph editor ones.

The UI drawing here is currently messed up from the NLA side, since it seems combining normal layout stuff and old-style uiBlocks doesn't seem to work too well (BUT! the buttons are at least functional).
Next up, I'll need to recode the buttons panel for the Graph Editor so that all of the drawing can be migrated over to use the new layout engine.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
    branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c

Modified: branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -585,10 +585,9 @@
 /* --------------- */
 
 // FIXME: remove dependency for F-Curve
-void ANIM_uiTemplate_fmodifier_draw (uiBlock *block, FCurve *fcu, FModifier *fcm, int *yco)
+void ANIM_uiTemplate_fmodifier_draw (uiBlock *block, ListBase *modifiers, FModifier *fcm, int *yco)
 {
 	FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
-	ListBase *modifiers= &fcu->modifiers; // XXX fixme... should be arg
 	uiBut *but;
 	short active= (fcm->flag & FMODIFIER_FLAG_ACTIVE);
 	short width= 314;

Modified: branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h	2009-07-02 06:41:10 UTC (rev 21309)
@@ -41,7 +41,7 @@
 struct Object;
 struct bActionGroup;
 struct FCurve;
-struct IpoCurve; // xxx
+struct FModifier;
 
 /* ************************************************ */
 /* ANIMATION CHANNEL FILTERING */
@@ -300,7 +300,7 @@
 
 /* draw a given F-Modifier for some layout/UI-Block */
 // XXX not quite complete yet
-void ANIM_uiTemplate_fmodifier_draw(struct uiBlock *block, struct FCurve *fcu, struct FModifier *fcm, int *yco);
+void ANIM_uiTemplate_fmodifier_draw(struct uiBlock *block, ListBase *modifiers, struct FModifier *fcm, int *yco);
 
 /* ************************************************* */
 /* ASSORTED TOOLS */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_buttons.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -381,7 +381,7 @@
 	
 	/* draw each modifier */
 	for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next)
-		ANIM_uiTemplate_fmodifier_draw(block, fcu, fcm, &yco);
+		ANIM_uiTemplate_fmodifier_draw(block, &fcu->modifiers, fcm, &yco);
 
 	MEM_freeN(ale);
 }

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-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_edit.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -1741,7 +1741,7 @@
 /* ************************************************************************** */
 /* F-CURVE MODIFIERS */
 
-/* ******************** Add F-Curve Modifier Operator *********************** */
+/* ******************** Add F-Modifier Operator *********************** */
 
 static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
 {

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-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_graph/graph_ops.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -221,8 +221,7 @@
 	WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
 	WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
 	
-		/* F-Curve Modifiers */
-		// XXX these are temporary? operators...
+		/* F-Modifiers */
 	WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
 	
 	

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -309,18 +309,28 @@
 static void nla_panel_modifiers(const bContext *C, Panel *pa)
 {
 	PointerRNA strip_ptr;
+	NlaStrip *strip;
+	FModifier *fcm;
 	uiLayout *layout= pa->layout;
-	//uiLayout *column, *row, *subcol;
 	uiBlock *block;
+	int yco = 190; // xxx old
 
 	/* check context and also validity of pointer */
 	if (!nla_panel_context(C, NULL, &strip_ptr))
 		return;
+	strip= strip_ptr.data;
 		
 	block= uiLayoutGetBlock(layout);
 	uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL);
-		
-	// TODO...
+	
+	/* 'add modifier' button at top of panel */
+	// XXX for now, this will be a operator button which calls a temporary 'add modifier' operator
+	// FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected)
+	uiDefButO(block, BUT, "NLA_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, "Add Modifier", 10, 225, 150, 20, "Adds a new F-Modifier for the active NLA Strip");
+	
+	/* draw each modifier */
+	for (fcm= strip->modifiers.first; fcm; fcm= fcm->next)
+		ANIM_uiTemplate_fmodifier_draw(block, &strip->modifiers, fcm, &yco);
 }
 
 /* ******************* general ******************************** */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -66,6 +66,7 @@
 
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -1021,3 +1022,83 @@
 }
 
 /* *********************************************** */
+/* NLA Modifiers */
+
+/* ******************** Add F-Modifier Operator *********************** */
+
+static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	FModifier *fcm;
+	int type= RNA_enum_get(op->ptr, "type");
+	short onlyActive = RNA_boolean_get(op->ptr, "only_active");
+	
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+		
+	/* get a list of the editable tracks being shown in the NLA */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+	
+	/* for each NLA-Track, add the specified modifier to all selected strips */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		NlaTrack *nlt= (NlaTrack *)ale->data;
+		NlaStrip *strip;
+		int i = 1;
+		
+		for (strip= nlt->strips.first; strip; strip=strip->next, i++) {
+			/* only add F-Modifier if on active strip? */
+			if ((onlyActive) && (strip->flag & NLASTRIP_FLAG_ACTIVE)==0)
+				continue;
+			
+			/* add F-Modifier of specified type to selected, and make it the active one */
+			fcm= add_fmodifier(&strip->modifiers, type);
+			
+			if (fcm)
+				set_active_fmodifier(&strip->modifiers, fcm);
+			else {
+				char errormsg[128];
+				sprintf(errormsg, "Modifier couldn't be added to (%s : %d). See console for details.", nlt->name, i);
+				
+				BKE_report(op->reports, RPT_ERROR, errormsg);
+			}
+		}
+	}
+	
+	/* free temp data */
+	BLI_freelistN(&anim_data);
+	
+	/* set notifier that things have changed */
+	ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
+	WM_event_add_notifier(C, NC_SCENE, NULL);
+	
+	/* done */
+	return OPERATOR_FINISHED;
+}
+ 
+void NLA_OT_fmodifier_add (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Add F-Modifier";
+	ot->idname= "NLA_OT_fmodifier_add";
+	
+	/* api callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= nla_fmodifier_add_exec;
+	ot->poll= nlaop_poll_tweakmode_off; 
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* id-props */
+	RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", "");
+	RNA_def_boolean(ot->srna, "only_active", 0, "Only Active", "Only add F-Modifier of the specified type to the active strip.");
+}
+
+/* *********************************************** */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-07-02 06:41:10 UTC (rev 21309)
@@ -105,7 +105,9 @@
 void NLA_OT_apply_scale(wmOperatorType *ot);
 void NLA_OT_clear_scale(wmOperatorType *ot);
 
+void NLA_OT_fmodifier_add(wmOperatorType *ot);
 
+
 /* **************************************** */
 /* nla_channels.c */
 

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c	2009-07-02 05:43:14 UTC (rev 21308)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c	2009-07-02 06:41:10 UTC (rev 21309)
@@ -155,6 +155,8 @@
 	
 	WM_operatortype_append(NLA_OT_apply_scale);
 	WM_operatortype_append(NLA_OT_clear_scale);
+	
+	WM_operatortype_append(NLA_OT_fmodifier_add);
 }
 
 /* ************************** registration - keymaps **********************************/
@@ -255,6 +257,9 @@
 		/* clear scale */
 	WM_keymap_add_item(keymap, "NLA_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0);
 	
+		/* add f-modifier */
+	WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+	
 	/* transform system */
 	transform_keymap_for_space(wm, keymap, SPACE_NLA);
 }





More information about the Bf-blender-cvs mailing list