diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-02 10:41:10 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-02 10:41:10 +0400 |
commit | 6b784a80f02deaca05e347dc2626dc92826f0944 (patch) | |
tree | c479db7ceb1b8a317f3bed9b8a199bbea1236f18 | |
parent | f3c47a66b0cb3bb70505ed46522e6c557769eaa5 (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.
-rw-r--r-- | source/blender/editors/animation/fmodifier_ui.c | 3 | ||||
-rw-r--r-- | source/blender/editors/include/ED_anim_api.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_buttons.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 81 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_ops.c | 5 |
9 files changed, 107 insertions, 11 deletions
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index b5a99877247..dfac380f595 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -585,10 +585,9 @@ static void draw_modifier__limits(uiBlock *block, FModifier *fcm, int *yco, shor /* --------------- */ // 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; diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 4d75a73a327..87f05c8a76a 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -41,7 +41,7 @@ struct gla2DDrawInfo; struct Object; struct bActionGroup; struct FCurve; -struct IpoCurve; // xxx +struct FModifier; /* ************************************************ */ /* ANIMATION CHANNEL FILTERING */ @@ -300,7 +300,7 @@ struct uiBlock; /* 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 */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 9d4a1a8b3cb..5616ffc8002 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -381,7 +381,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) /* 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); } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index a82699ac1e5..9a50c5cc203 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1741,7 +1741,7 @@ void GRAPH_OT_smooth (wmOperatorType *ot) /* ************************************************************************** */ /* F-CURVE MODIFIERS */ -/* ******************** Add F-Curve Modifier Operator *********************** */ +/* ******************** Add F-Modifier Operator *********************** */ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index d5e93dafaf0..38bde61a46c 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -221,8 +221,7 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) 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); 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); } |