diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-01-01 04:47:36 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-01-01 04:47:36 +0300 |
commit | c0621a1b7eca3310320e2df02094e828eda2cd37 (patch) | |
tree | c90cf5beae4919feca3cec977b56ac7ad111acbd /source/blender/editors | |
parent | c2de1373d1c61815e3030f88c196e6c42cb1c5fc (diff) |
2.5 - Action Editor
* Fixed 'mute' icons for IPO-Curve channels. Added define for icon-button widths instead of magic numbers there too.
* Restored View All (HomeKey) and Auto-Set Preview Range (Ctrl-Alt-P). These tools both use the max extents of the keyframes to determine their (time)range.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_channels.c | 18 | ||||
-rw-r--r-- | source/blender/editors/include/ED_anim_api.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 145 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_ops.c | 9 |
5 files changed, 169 insertions, 11 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c index c213e2d9a10..d60394d720f 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels.c @@ -91,11 +91,6 @@ /* -------------------------- Exposed API ----------------------------------- */ /* ************************************************************************** */ -/* Channel Drawing */ -// XXX should these get their own file or go in anim_draw instead??? - - -/* ************************************************************************** */ /* Operators */ @@ -232,7 +227,7 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s /* toggle expand */ agrp->flag ^= AGRP_EXPANDED; } - else if (x >= (ACHANNEL_NAMEWIDTH-16)) { + else if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { /* toggle protection/locking */ agrp->flag ^= AGRP_PROTECTED; } @@ -253,6 +248,9 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s //deselect_actionchannels(act, ANIMCONT_ACTION, 0); //select_action_group(act, agrp, SELECT_ADD); } + + // XXX + agrp->flag ^= AGRP_SELECTED; } } break; @@ -261,11 +259,11 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s bActionChannel *achan= (bActionChannel *)ale->data; short offset= (ac->datatype == ANIMCONT_DOPESHEET)? 21 : 0; - if (x >= (ACHANNEL_NAMEWIDTH-16)) { + if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { /* toggle protect */ achan->flag ^= ACHAN_PROTECTED; } - else if ((x >= (ACHANNEL_NAMEWIDTH-32)) && (achan->ipo)) { + else if ((x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) && (achan->ipo)) { /* toggle mute */ achan->ipo->muteipo = (achan->ipo->muteipo)? 0: 1; } @@ -333,11 +331,11 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s { IpoCurve *icu= (IpoCurve *)ale->data; - if (x >= (ACHANNEL_NAMEWIDTH-16)) { + if (x >= (ACHANNEL_NAMEWIDTH-ACHANNEL_BUTTON_WIDTH)) { /* toggle protection */ icu->flag ^= IPO_PROTECT; } - else if (x >= (ACHANNEL_NAMEWIDTH-16)) { + else if (x >= (ACHANNEL_NAMEWIDTH-2*ACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ icu->flag ^= IPO_MUTE; } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 27079c7aa63..8c4891e79f8 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -216,8 +216,13 @@ typedef enum eAnimFilter_Flags { #define ACHANNEL_HEIGHT_HALF 8 #define ACHANNEL_SKIP 2 #define ACHANNEL_STEP (ACHANNEL_HEIGHT + ACHANNEL_SKIP) + +/* channel widths */ #define ACHANNEL_NAMEWIDTH 200 +/* channel toggle-buttons */ +#define ACHANNEL_BUTTON_WIDTH 16 + /* ---------------- API -------------------- */ /* Obtain list of filtered Animation channels to operate on. diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 958c79167bb..d6c0fdcef37 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -86,6 +86,151 @@ #include "action_intern.h" /* ************************************************************************** */ +/* KEYFRAME-RANGE STUFF */ + +/* *************************** Calculate Range ************************** */ + +/* Get the min/max keyframes*/ +static void get_keyframe_extents (bAnimContext *ac, float *min, float *max) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + /* get data to filter, from Action or Dopesheet */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_IPOKEYS); + ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype); + + /* set large values to try to override */ + *min= 999999999.0f; + *max= -999999999.0f; + + /* check if any channels to set range with */ + if (anim_data.first) { + /* go through channels, finding max extents*/ + for (ale= anim_data.first; ale; ale= ale->next) { + Object *nob= ANIM_nla_mapping_get(ac, ale); + Ipo *ipo= (Ipo *)ale->key_data; + float tmin, tmax; + + /* get range and apply necessary scaling before */ + calc_ipo_range(ipo, &tmin, &tmax); + + if (nob) { + tmin= get_action_frame_inv(nob, tmin); + tmax= get_action_frame_inv(nob, tmax); + } + + /* try to set cur using these values, if they're more extreme than previously set values */ + *min= MIN2(*min, tmin); + *max= MAX2(*max, tmax); + } + + /* free memory */ + BLI_freelistN(&anim_data); + } + else { + /* set default range */ + if (ac->scene) { + *min= (float)ac->scene->r.sfra; + *max= (float)ac->scene->r.efra; + } + else { + *min= -5; + *max= 100; + } + } +} + +/* ****************** Automatic Preview-Range Operator ****************** */ + +static int actkeys_previewrange_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + Scene *scene; + float min, max; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + if (ac.scene == NULL) + return OPERATOR_CANCELLED; + else + scene= ac.scene; + + /* set the range directly */ + get_keyframe_extents(&ac, &min, &max); + scene->r.psfra= (int)floor(min + 0.5f); + scene->r.pefra= (int)floor(max + 0.5f); + + /* 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_set_previewrange (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Auto-Set Preview Range"; + ot->idname= "ACT_OT_set_previewrange"; + + /* api callbacks */ + ot->exec= actkeys_previewrange_exec; + ot->poll= ED_operator_areaactive; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; +} + +/* ****************** View-All Operator ****************** */ + +static int actkeys_viewall_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + View2D *v2d; + float extra; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + v2d= &ac.ar->v2d; + + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ + get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax); + + extra= 0.05f * (v2d->cur.xmax - v2d->cur.xmin); + v2d->cur.xmin -= extra; + v2d->cur.xmax += extra; + + /* set vertical range */ + v2d->cur.ymax= 0.0f; + v2d->cur.ymin= -(v2d->mask.ymax - v2d->mask.ymin); + + /* do View2D syncing */ + UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); + + /* 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_view_all (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "View All"; + ot->idname= "ACT_OT_view_all"; + + /* api callbacks */ + ot->exec= actkeys_viewall_exec; + ot->poll= ED_operator_areaactive; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; +} + +/* ************************************************************************** */ /* GENERAL STUFF */ // TODO: diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 572a7aa0ae5..d78e34416f0 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -73,6 +73,9 @@ enum { /* ***************************************** */ /* action_edit.c */ +void ACT_OT_set_previewrange(struct wmOperatorType *ot); +void ACT_OT_view_all(struct wmOperatorType *ot); + void ACT_OT_keyframes_copy(struct wmOperatorType *ot); void ACT_OT_keyframes_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index b68cd145e1c..c5c40626904 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -80,6 +80,9 @@ void action_operatortypes(void) WM_operatortype_append(ACT_OT_keyframes_delete); WM_operatortype_append(ACT_OT_keyframes_copy); WM_operatortype_append(ACT_OT_keyframes_paste); + + WM_operatortype_append(ACT_OT_set_previewrange); + WM_operatortype_append(ACT_OT_view_all); } /* ************************** registration - keymaps **********************************/ @@ -107,7 +110,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) RNA_enum_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "ACT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); - /* action_edit_keyframes.c */ + /* action_edit.c */ /* snap - current frame to selected keys */ WM_keymap_add_item(keymap, "ACT_OT_keyframes_cfrasnap", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); @@ -131,6 +134,10 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) // XXX - should we keep these? WM_keymap_add_item(keymap, "ACT_OT_keyframes_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACT_OT_keyframes_paste", VKEY, KM_PRESS, KM_CTRL, 0); + + /* auto-set range */ + WM_keymap_add_item(keymap, "ACT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "ACT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); /* transform system */ transform_keymap_for_space(wm, keymap, SPACE_ACTION); |