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
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')
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c16
-rw-r--r--source/blender/editors/space_nla/nla_edit.c81
-rw-r--r--source/blender/editors/space_nla/nla_intern.h2
-rw-r--r--source/blender/editors/space_nla/nla_ops.c5
4 files changed, 101 insertions, 3 deletions
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 003eba64ed9..1ef72760bfc 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -309,18 +309,28 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
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 ******************************** */
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.");
+}
+
+/* *********************************************** */
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index f8df41d6225..5921b8a75ce 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -105,6 +105,8 @@ void NLA_OT_move_down(wmOperatorType *ot);
void NLA_OT_apply_scale(wmOperatorType *ot);
void NLA_OT_clear_scale(wmOperatorType *ot);
+void NLA_OT_fmodifier_add(wmOperatorType *ot);
+
/* **************************************** */
/* nla_channels.c */
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index d7bd894ce4d..7caab02d6a0 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -155,6 +155,8 @@ void nla_operatortypes(void)
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 @@ static void nla_keymap_main (wmWindowManager *wm, ListBase *keymap)
/* 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);
}