2.5 - Action Editor

Select Left/Right (Alt-Select) works again.
Fixed compiling errors from previous commit.
This commit is contained in:
Joshua Leung 2008-12-24 00:05:56 +00:00
parent 1062946cad
commit a65fabc553
2 changed files with 76 additions and 12 deletions

@ -32,6 +32,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "DNA_action_types.h"
#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
@ -44,6 +45,7 @@
#include "BKE_key.h"
#include "BKE_utildefines.h"
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
@ -67,6 +69,8 @@
// 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
* operation on them, and optionally applies an IPO-curve validate function afterwards.
*/
@ -111,6 +115,21 @@ short ipo_keys_bezier_loop(Scene *scene, Ipo *ipo, BeztEditFunc bezt_cb, IcuEdit
return 0;
}
/* This function is used to loop over the channels in an Action Group to modify the IPO blocks within them */
short actgroup_keys_bezier_loop(Scene *scene, bActionGroup *agrp, BeztEditFunc bezt_cb, IcuEditFunc icu_cb)
{
}
/* -------------------------------- Further Abstracted ----------------------------- */
/* this function is called to apply the same operation to all types of channels */
short animchannel_keys_bezier_loop(Scene *scene, bAnimListElem *ale, BeztEditFunc bezt_cb, IcuEditFunc icu_cb)
{
}
/* ******************************************* */
/* Transform */

@ -114,7 +114,7 @@ void *get_nearest_act_channel (short mval[], short *ret_type, void **owner)
clickmax = clickmin;
if (clickmax < 0) {
*ret_type= ACTTYPE_NONE;
*ret_type= ANIMTYPE_NONE;
return NULL;
}
@ -455,7 +455,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short in_scroller,
/* what gets selected depends on the mode (based on initial position of cursor) */
switch (in_scroller) {
case 'h': /* all in frame(s) */
case 'h': /* all in frame(s) (option 3) */
if (ale->key_data) {
if (ale->datatype == ALE_IPO)
borderselect_ipo_key(ale->key_data, rectf.xmin, rectf.xmax, selectmode);
@ -478,7 +478,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short in_scroller,
// borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
//}
break;
case 'v': /* all in channel(s) */
case 'v': /* all in channel(s) (option 2) */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
if (ale->key_data) {
if (ale->datatype == ALE_IPO)
@ -503,7 +503,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short in_scroller,
//}
}
break;
default: /* any keyframe inside region defined by region */
default: /* any keyframe inside region defined by region (option 1) */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
if (ale->key_data) {
if (ale->datatype == ALE_IPO)
@ -524,12 +524,6 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short in_scroller,
borderselect_ipo_key(conchan->ipo, rectf.xmin, rectf.xmax, selectmode);
}
}
else if (ale->type == ANIMTYPE_ACT) {
// fixme: need a nicer way of dealing with summaries!
}
else if (ale->type == ANIMTYPE_OB) {
// fixme: need a nicer way of dealing with summaries!
}
//else if (ale->type == ANIMTYPE_GPLAYER) {
//// borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode);
//}
@ -602,7 +596,7 @@ static int actkeys_borderselect_invoke(bContext *C, wmOperator *op, wmEvent *eve
void ED_ACT_OT_keyframes_borderselect(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Borderselect";
ot->name= "Border Select";
ot->idname= "ED_ACT_OT_keyframes_borderselect";
/* api callbacks */
@ -782,11 +776,61 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short selectmode)
}
}
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
static void selectkeys_leftright (bAnimContext *ac, short leftright, short select_mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
Scene *scene= ac->scene;
float min, max;
if (select_mode==SELECT_REPLACE) {
select_mode=SELECT_ADD;
deselect_action_keys(ac, 0, 0);
}
if (leftright == 1) {
min = -MAXFRAMEF;
max = (float)(CFRA + 0.1f);
}
else {
min = (float)(CFRA - 0.1f);
max = MAXFRAMEF;
}
/* filter data */
if (ac->datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE);
else
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_IPOKEYS);
ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
/* select keys on the side where most data occurs */
for (ale= anim_data.first; ale; ale= ale->next) {
Object *nob= ANIM_nla_mapping_get(ac, ale);
if (nob) {
ANIM_nla_mapping_apply(nob, ale->key_data, 0, 1);
borderselect_ipo_key(ale->key_data, min, max, SELECT_ADD);
ANIM_nla_mapping_apply(nob, ale->key_data, 1, 1);
}
//else if (ale->type == ANIMTYPE_GPLAYER)
// borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD);
else
borderselect_ipo_key(ale->key_data, min, max, SELECT_ADD);
}
/* Cleanup */
BLI_freelistN(&anim_data);
}
/* ------------------- */
static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
bAnimContext ac;
Scene *scene;
ARegion *ar;
short in_scroller, selectmode;
int mval[2];
@ -796,6 +840,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
return OPERATOR_CANCELLED;
/* get useful pointers from animation context data */
scene= ac.scene;
ar= ac.ar;
/* get mouse coordinates (in region coordinates) */
@ -822,7 +867,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even
}
else if (RNA_boolean_get(op->ptr, "left_right")) {
/* select all keys on same side of current frame as mouse */
selectkeys_leftright(&ac, (mval[0] < CFRA), selectmode);
}
else {
/* select keyframe under mouse */