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.
This commit is contained in:
@@ -90,11 +90,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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -85,6 +85,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 */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user