diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-02-22 07:13:29 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-02-22 07:13:29 +0300 |
commit | 874f8008a2c179859e6786d6ea210cad2b0cb416 (patch) | |
tree | 7f7b11fb5f785e257540a59d44b514414b27bd30 /source/blender/editors/animation/anim_channels.c | |
parent | f2f734c9a5668e370253ff550de9a240bb142466 (diff) |
Animation Editors: Bugfixes for channel selection tools
* Ctrl-Shift select for Action Groups works again
* Clicking on a channel's data will select it, and also make it the active one in the list now
* Selecting keyframes in F-Curves will select the F-Curve channel too now (+ make it active)
Diffstat (limited to 'source/blender/editors/animation/anim_channels.c')
-rw-r--r-- | source/blender/editors/animation/anim_channels.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c index ca385333d7a..e0ba8d15a98 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels.c @@ -101,45 +101,56 @@ else (channel)->flag &= ~(sflag); \ } -/* -------------------------- Internal Tools -------------------------------- */ +/* -------------------------- Exposed API ----------------------------------- */ -/* set the given Action Group to be the 'active' one in its Action */ -static void action_set_active_agrp (bAction *act, bActionGroup *agrp) +/* Set the given animation-channel as the active one for the active context */ +void ANIM_set_active_channel (void *data, short datatype, int filter, void *channel_data, short channel_type) { - bActionGroup *grp; + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + short smode; - /* sanity check */ - if (act == NULL) + /* try to build list of filtered items */ + // XXX we don't need/supply animcontext for now, since in this case, there's nothing really essential there that isn't already covered + ANIM_animdata_filter(NULL, &anim_data, filter, data, datatype); + if (anim_data.first == NULL) return; - /* clear active flag on all others */ - for (grp= act->groups.first; grp; grp= grp->next) - grp->flag &= ~AGRP_ACTIVE; + /* only clear the 'active' flag for the channels of the same type */ + for (ale= anim_data.first; ale; ale= ale->next) { + /* skip if types don't match */ + if (channel_type != ale->type) + continue; - /* set the given group to be the active one */ - if (agrp) - agrp->flag |= AGRP_ACTIVE; -} - -/* -------------------------- Exposed API ----------------------------------- */ - -/* Set the given ActionChannel or ActionGroup as the active one in the given action - * - data: should be bAction... - * - datatype: should be ANIMCONT_ACTION - * - channel_data: bActionChannel or bActionGroup - * - channel_type: eAnim_ChannelType - */ -void ANIM_action_set_active_channel (void *data, short datatype, void *channel_data, short channel_type) -{ - /* sanity checks */ - if ((data == NULL) || (datatype != ANIMCONT_ACTION)) - return; + /* flag setting mode + * - depends on whether the provided channel is encountered + */ + if (ale->data == channel_data) + smode= ACHANNEL_SETFLAG_ADD; + else + smode= ACHANNEL_SETFLAG_CLEAR; - switch (channel_type) { - case ANIMTYPE_GROUP: - action_set_active_agrp((bAction *)data, (bActionGroup *)channel_data); - break; + /* flag to set depends on type */ + switch (ale->type) { + case ANIMTYPE_GROUP: + { + bActionGroup *agrp= (bActionGroup *)ale->data; + + ACHANNEL_SET_FLAG(agrp, smode, AGRP_ACTIVE); + } + break; + case ANIMTYPE_FCURVE: + { + FCurve *fcu= (FCurve *)ale->data; + + ACHANNEL_SET_FLAG(fcu, smode, FCURVE_ACTIVE); + } + break; + } } + + /* clean up */ + BLI_freelistN(&anim_data); } /* Deselect all animation channels @@ -1192,14 +1203,14 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s } else if (selectmode == -1) { /* select all in group (and deselect everthing else) */ - bActionChannel *achan; + FCurve *fcu; /* deselect all other channels */ ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* only select channels in group and group itself */ - for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) - achan->flag |= ACHAN_SELECTED; + for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + fcu->flag |= FCURVE_SELECTED; agrp->flag |= AGRP_SELECTED; } else { @@ -1208,12 +1219,9 @@ static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, s agrp->flag |= AGRP_SELECTED; } - /* if group is selected now, and we're in Action Editor mode (so that we have pointer to active action), - * we can make this group the 'active' one in that action - */ - // TODO: we should be able to do this through dopesheet + f-curves editor too... - if ((agrp->flag & AGRP_SELECTED) && (ac->datatype == ANIMCONT_ACTION)) - action_set_active_agrp((bAction *)ac->data, agrp); + /* if group is selected now, make group the 'active' one in the visible list */ + if ((agrp->flag & AGRP_SELECTED) && (selectmode != SELECT_INVERT)) + ANIM_set_active_channel(ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); } } break; |