Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-02 10:41:10 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-02 10:41:10 +0400
commit6b784a80f02deaca05e347dc2626dc92826f0944 (patch)
treec479db7ceb1b8a317f3bed9b8a199bbea1236f18 /source/blender/editors/space_nla/nla_edit.c
parentf3c47a66b0cb3bb70505ed46522e6c557769eaa5 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_nla/nla_edit.c')
-rw-r--r--source/blender/editors/space_nla/nla_edit.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 6d82e3d4be2..9910e62b262 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -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 @@ void NLA_OT_clear_scale (wmOperatorType *ot)
}
/* *********************************************** */
+/* 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.");
+}
+
+/* *********************************************** */