From 95e781c6015a9a061d496e705efe878a83020c27 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 22 Mar 2008 11:06:51 +0000 Subject: [PATCH] == Action Editor - Preview Range (Ctrl-Alt-P) == Quick feature for setting Preview Range in Action Editor: the hotkey Ctrl-Alt-P sets the Preview Range so that it matches the extents of the active action. --- source/blender/include/BIF_editaction.h | 1 + source/blender/src/editaction.c | 34 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/source/blender/include/BIF_editaction.h b/source/blender/include/BIF_editaction.h index 7fb2a6b2dde..87b3f45299b 100644 --- a/source/blender/include/BIF_editaction.h +++ b/source/blender/include/BIF_editaction.h @@ -190,6 +190,7 @@ void actdata_filter(ListBase *act_data, int filter_mode, void *data, short datat void *get_action_context(short *datatype); void remake_action_ipos(struct bAction *act); +void action_previewrange_set(struct bAction *act); /* event handling */ void winqreadactionspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt); diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 1a1bb9f4fb1..cf74c04678d 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -797,6 +797,36 @@ void *get_action_context (short *datatype) } } +/* Quick-tool for preview-range functionality in Action Editor for setting Preview-Range + * bounds to extents of Action, when Ctrl-Alt-P is used. Only available for actions. + */ +void action_previewrange_set (bAction *act) +{ + float start, end; + + /* sanity check */ + if (act == NULL) + return; + + /* calculate range + make sure it is adjusted for nla-scaling */ + calc_action_range(act, &start, &end, 0); + if (NLA_ACTION_SCALED) { + start= get_action_frame_inv(OBACT, start); + end= get_action_frame_inv(OBACT, end); + } + + /* set preview range */ + G.scene->r.psfra= start; + G.scene->r.pefra= end; + + BIF_undo_push("Set anim-preview range"); + allqueue(REDRAWTIME, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWBUTSALL, 0); +} + /* **************************************************** */ /* ACTION CHANNEL GROUPS */ @@ -4454,7 +4484,9 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case PKEY: - if (G.qual & LR_CTRLKEY) /* set preview range */ + if (G.qual == (LR_CTRLKEY|LR_ALTKEY)) /* set preview range to range of action */ + action_previewrange_set(G.saction->action); + else if (G.qual & LR_CTRLKEY) /* set preview range */ anim_previewrange_set(); else if (G.qual & LR_ALTKEY) /* clear preview range */ anim_previewrange_clear();