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.
This commit is contained in:
2009-07-02 06:41:10 +00:00
parent f3c47a66b0
commit 6b784a80f0
9 changed files with 107 additions and 11 deletions

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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 ******************************** */

View File

@@ -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.");
}
/* *********************************************** */

View File

@@ -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 */

View File

@@ -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);
}