diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-12-28 14:51:41 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-12-28 14:51:41 +0300 |
commit | 1e463b22eb9172720ab5fe5a28da13d0d8dfb364 (patch) | |
tree | 5d2bf9b224be71dd4427a407d093e3376e29eaaa /source/blender | |
parent | f3fe2d0559070c31214063e1d6cf6b6207ff2f2f (diff) |
2.5 - Action Editor:
* Added set-extrapolation operator. For now, this uses the Shift-E hotkey.
* Removed some unused code from keyframes_edit.c
Diffstat (limited to 'source/blender')
5 files changed, 98 insertions, 27 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index f905496cb25..b8a3b8acb19 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -50,7 +50,7 @@ #include "ED_keyframes_edit.h" #include "ED_markers.h" -/* This file defines an API and set of callback-operators for editing keyframe data. +/* This file defines an API and set of callback-operators for non-destructive editing of keyframe data. * * Two API functions are defined for actually performing the operations on the data: * ipo_keys_bezier_loop() and icu_keys_bezier_loop() @@ -71,9 +71,6 @@ /* ************************************************************************** */ /* IPO Editing Loops - Exposed API */ -// FIXME: it would be useful to be able to supply custom properties to the bezt function... -// workaround for those callbacks that need this now, is to set globals... - /* --------------------------- Base Functions ------------------------------------ */ /* This function is used to loop over BezTriples in the given IpoCurve, applying a given @@ -524,28 +521,8 @@ BeztEditFunc ANIM_editkeyframes_ipo(short code) } } -#if 0 -void setipotype_ipo(Ipo *ipo, int code) -{ - /* Sets the type of the selected bezts in each ipo curve in the - * Ipo to a value based on the code - */ - switch (code) { - case 1: - ipo_keys_bezier_loop(ipo, set_bezt_constant, set_ipocurve_mixed); - break; - case 2: - ipo_keys_bezier_loop(ipo, set_bezt_linear, set_ipocurve_mixed); - break; - case 3: - ipo_keys_bezier_loop(ipo, set_bezt_bezier, set_ipocurve_mixed); - break; - } -} -#endif - // XXX will we keep this? -void setexprap_ipoloop(Ipo *ipo, int code) +void setexprap_ipoloop(Ipo *ipo, short code) { IpoCurve *icu; diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 787e206b434..3b553320f32 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -130,11 +130,13 @@ void ANIM_editkeyframes_ipocurve_ipotype(struct IpoCurve *icu); /* ************************************************ */ -// XXX all of these funcs will be depreceated! +// XXX all of these funcs should be depreceated or at least renamed! short is_ipo_key_selected(struct Ipo *ipo); void set_ipo_key_selection(struct Ipo *ipo, short sel); +void setexprap_ipoloop(struct Ipo *ipo, short code); + /* ************************************************ */ diff --git a/source/blender/editors/space_action/action_edit_keyframes.c b/source/blender/editors/space_action/action_edit_keyframes.c index 22603a7dc9a..4975a2cd6de 100644 --- a/source/blender/editors/space_action/action_edit_keyframes.c +++ b/source/blender/editors/space_action/action_edit_keyframes.c @@ -88,9 +88,98 @@ /* ************************************************************************** */ /* GENERAL STUFF */ +// TODO: +// - clean +// - sample +// - delete +// - insert key +// - copy/paste + /* ************************************************************************** */ /* SETTINGS STUFF */ +// TODO: +// - wkey stuff + +/* ******************** Set Extrapolation-Type Operator *********************** */ + +/* defines for set ipo-type for selected keyframes tool */ +EnumPropertyItem prop_actkeys_expo_types[] = { + {IPO_HORIZ, "CONSTANT", "Constant", ""}, + {IPO_DIR, "DIRECTIONAL", "Extrapolation", ""}, + {IPO_CYCL, "CYCLIC", "Cyclic", ""}, + {IPO_CYCLX, "CYCLIC_EXTRAPOLATION", "Cyclic Extrapolation", ""}, + {0, NULL, NULL, NULL} +}; + +/* this function is responsible for setting extrapolation mode for keyframes */ +static void setexpo_action_keys(bAnimContext *ac, short mode) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* filter data */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS); + ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); + + /* loop through setting mode per ipo-curve */ + for (ale= anim_data.first; ale; ale= ale->next) + setexprap_ipoloop(ale->key_data, mode); + + /* cleanup */ + BLI_freelistN(&anim_data); +} + +/* ------------------- */ + +static int actkeys_expo_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + short mode; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + if (ac.datatype == ANIMCONT_GPENCIL) + return OPERATOR_PASS_THROUGH; + + /* get handle setting mode */ + mode= RNA_enum_get(op->ptr, "type"); + + /* set handle type */ + setexpo_action_keys(&ac, mode); + + /* validate keyframes after editing */ + ANIM_editkeyframes_refresh(&ac); + + /* set notifier tha things have changed */ + ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead! + + return OPERATOR_FINISHED; +} + +void ACT_OT_keyframes_expotype (wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Set Keyframe Extrapolation"; + ot->idname= "ACT_OT_keyframes_expotype"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= actkeys_expo_exec; + ot->poll= ED_operator_areaactive; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + + /* id-props */ + prop= RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_actkeys_expo_types); +} + /* ******************** Set Interpolation-Type Operator *********************** */ /* defines for set ipo-type for selected keyframes tool */ @@ -113,7 +202,7 @@ static void setipo_action_keys(bAnimContext *ac, short mode) filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS); ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); - /* loop through setting flags for handles + /* loop through setting BezTriple interpolation * Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here... */ for (ale= anim_data.first; ale; ale= ale->next) diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 8655315ccfb..6f51ce49888 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -75,6 +75,7 @@ enum { void ACT_OT_keyframes_handletype(struct wmOperatorType *ot); void ACT_OT_keyframes_ipotype(struct wmOperatorType *ot); +void ACT_OT_keyframes_expotype(struct wmOperatorType *ot); void ACT_OT_keyframes_cfrasnap(struct wmOperatorType *ot); void ACT_OT_keyframes_snap(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index ad42173be41..d6a7fda2704 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -74,6 +74,7 @@ void action_operatortypes(void) WM_operatortype_append(ACT_OT_keyframes_cfrasnap); WM_operatortype_append(ACT_OT_keyframes_handletype); WM_operatortype_append(ACT_OT_keyframes_ipotype); + WM_operatortype_append(ACT_OT_keyframes_expotype); } /* ************************** registration - keymaps **********************************/ @@ -112,6 +113,7 @@ static void action_keymap_keyframes (ListBase *keymap) /* menu + set setting */ WM_keymap_add_item(keymap, "ACT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACT_OT_keyframes_ipotype", TKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ACT_OT_keyframes_expotype", EKEY, KM_PRESS, KM_SHIFT, 0); // temp... } /* --------------- */ |