diff options
Diffstat (limited to 'source/blender/editors/animation/anim_channels_edit.c')
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 896 |
1 files changed, 448 insertions, 448 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index b32bbd4874d..1158145ad6b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -30,7 +30,7 @@ #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include <string.h> #include "MEM_guardedalloc.h" @@ -80,24 +80,24 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - + /* try to build list of filtered items */ ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); if (BLI_listbase_is_empty(&anim_data)) return; - + /* 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; - + /* flag to set depends on type */ switch (ale->type) { case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)ale->data; - + ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE); break; } @@ -105,14 +105,14 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - + ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE); break; } @@ -144,13 +144,13 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + ACHANNEL_SET_FLAG(gpl, ACHANNEL_SETFLAG_CLEAR, GP_LAYER_ACTIVE); break; } } } - + /* set active flag */ if (channel_data) { switch (channel_type) { @@ -199,26 +199,26 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat } break; } - + case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)channel_data; gpl->flag |= GP_LAYER_ACTIVE; break; } - + /* unhandled currently, but may be interesting */ case ANIMTYPE_MASKLAYER: case ANIMTYPE_SHAPEKEY: case ANIMTYPE_NLAACTION: break; - + /* other types */ default: break; } } - + /* clean up */ ANIM_animdata_freelist(&anim_data); } @@ -250,7 +250,7 @@ static void select_pchan_for_action_group(bAnimContext *ac, bActionGroup *agrp, } } -/* Deselect all animation channels +/* Deselect all animation channels * - data: pointer to datatype, as contained in bAnimContext * - datatype: the type of data that 'data' represents (eAnimCont_Types) * - test: check if deselecting instead of selecting @@ -261,18 +261,18 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ /* NOTE: no list visible, otherwise, we get dangling */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); - + /* See if we should be selecting or deselecting */ if (test) { for (ale = anim_data.first; ale; ale = ale->next) { - if (sel == 0) + if (sel == 0) break; - + switch (ale->type) { case ANIMTYPE_SCENE: if (ale->flag & SCE_DS_SELECTED) @@ -301,7 +301,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d if (ale->flag & NLATRACK_SELECTED) sel = ACHANNEL_SETFLAG_CLEAR; break; - + case ANIMTYPE_FILLACTD: /* Action Expander */ case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: @@ -337,16 +337,16 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d } } } - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: { Scene *scene = (Scene *)ale->data; - + ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED); - + if (scene->adt) { ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED); } @@ -379,7 +379,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED); fcu->flag &= ~FCURVE_ACTIVE; break; @@ -387,14 +387,14 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_SHAPEKEY: { KeyBlock *kb = (KeyBlock *)ale->data; - + ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - + ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED); nlt->flag &= ~NLATRACK_ACTIVE; break; @@ -429,27 +429,27 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT); break; } case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)ale->data; - + ACHANNEL_SET_FLAG(masklay, sel, MASK_LAYERFLAG_SELECT); break; } } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } /* ---------------------------- Graph Editor ------------------------------------- */ -/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting +/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting * - anim_data: list of the all the anim channels that can be chosen * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too, * then the channels under closed expanders get ignored... @@ -462,7 +462,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn { bAnimListElem *ale, *match = NULL; int prevLevel = 0, matchLevel = 0; - + /* sanity check */ if (ELEM(NULL, anim_data, anim_data->first)) return; @@ -489,23 +489,23 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn } else { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting); - + if (acf == NULL) { printf("ERROR: no channel info for the changed channel\n"); return; } - + /* get the level of the channel that was affected * - we define the level as simply being the offset for the start of the channel */ matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; prevLevel = matchLevel; } - - /* flush up? + + /* flush up? * * For Visibility: - * - only flush up if the current state is now enabled (positive 'on' state is default) + * - only flush up if the current state is now enabled (positive 'on' state is default) * (otherwise, it's too much work to force the parents to be inactive too) * * For everything else: @@ -519,25 +519,25 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn for (ale = match->prev; ale; ale = ale->prev) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; - + /* if no channel info was found, skip, since this type might not have any useful info */ if (acf == NULL) continue; - - /* get the level of the current channel traversed + + /* get the level of the current channel traversed * - we define the level as simply being the offset for the start of the channel */ level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; - + /* if the level is 'less than' (i.e. more important) the level we're matching - * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, + * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel * get updated below once the first 1st group is found)... */ if (level < prevLevel) { /* flush the new status... */ ANIM_channel_setting_set(ac, ale, setting, mode); - + /* store this level as the 'old' level now */ prevLevel = level; } @@ -549,31 +549,31 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn if (prevLevel == 0) break; /* otherwise, this level weaves into another sibling hierarchy to the previous one just - * finished, so skip until we get to the parent of this level + * finished, so skip until we get to the parent of this level */ else continue; } } } - + /* flush down (always) */ { /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */ for (ale = match->next; ale; ale = ale->next) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; - + /* if no channel info was found, skip, since this type might not have any useful info */ if (acf == NULL) continue; - - /* get the level of the current channel traversed + + /* get the level of the current channel traversed * - we define the level as simply being the offset for the start of the channel */ level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; - - /* if the level is 'greater than' (i.e. less important) the channel that was changed, + + /* if the level is 'greater than' (i.e. less important) the channel that was changed, * flush the new status... */ if (level > matchLevel) @@ -584,7 +584,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn */ else break; - + /* store this level as the 'old' level now */ // prevLevel = level; // XXX: prevLevel is unused } @@ -596,13 +596,13 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* Delete the given F-Curve from its AnimData block */ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu) { - /* - if no AnimData, we've got nowhere to remove the F-Curve from + /* - if no AnimData, we've got nowhere to remove the F-Curve from * (this doesn't guarantee that the F-Curve is in there, but at least we tried * - if no F-Curve, there is nothing to remove */ if (ELEM(NULL, adt, fcu)) return; - + /* remove from whatever list it came from * - Action Group * - Action @@ -615,15 +615,15 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f } else if (adt->action) { bAction *act = adt->action; - + /* remove from group or action, whichever one "owns" the F-Curve */ if (fcu->grp) { bActionGroup *agrp = fcu->grp; - + /* remove F-Curve from group+action */ action_groups_remove_channel(act, fcu); - - /* if group has no more channels, remove it too, + + /* if group has no more channels, remove it too, * otherwise can have many dangling groups [#33541] */ if (BLI_listbase_is_empty(&agrp->channels)) { @@ -633,7 +633,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f else { BLI_remlink(&act->curves, fcu); } - + /* if action has no more F-Curves as a result of this, unlink it from * AnimData if it did not come from a NLA Strip being tweaked. * @@ -646,7 +646,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f adt->action = NULL; } } - + /* free the F-Curve itself */ free_fcurve(fcu); } @@ -660,7 +660,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f static int animedit_poll_channels_active(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) @@ -685,13 +685,13 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C) /* animation editor test */ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0) return 0; - + /* NLA TweakMode test */ if (sa->spacetype == SPACE_NLA) { if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; } - + return 1; } @@ -720,7 +720,7 @@ static const EnumPropertyItem prop_animchannel_rearrange_types[] = { /* Island definition - just a listbase container */ typedef struct tReorderChannelIsland { struct tReorderChannelIsland *next, *prev; - + ListBase channels; /* channels within this region with the same state */ int flag; /* eReorderIslandFlag */ } tReorderChannelIsland; @@ -741,7 +741,7 @@ static bool rearrange_island_ok(tReorderChannelIsland *island) /* island must not be untouchable */ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) return 0; - + /* island should be selected to be moved */ return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED); } @@ -753,13 +753,13 @@ static bool rearrange_island_top(ListBase *list, tReorderChannelIsland *island) if (rearrange_island_ok(island)) { /* remove from current position */ BLI_remlink(list, island); - + /* make it first element */ BLI_insertlinkbefore(list, list->first, island); - + return 1; } - + return 0; } @@ -777,14 +777,14 @@ static bool rearrange_island_up(ListBase *list, tReorderChannelIsland *island) if (prev) { /* remove from current position */ BLI_remlink(list, island); - + /* push it up */ BLI_insertlinkbefore(list, prev, island); - + return 1; } } - + return 0; } @@ -804,16 +804,16 @@ static bool rearrange_island_down(ListBase *list, tReorderChannelIsland *island) if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* remove from current position */ BLI_remlink(list, island); - + /* push it down */ BLI_insertlinkafter(list, next, island); - + return true; } } /* else: no next channel, so we're at the bottom already, so can't move */ } - + return false; } @@ -821,10 +821,10 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan { if (rearrange_island_ok(island)) { tReorderChannelIsland *last = list->last; - + /* remove island from current position */ BLI_remlink(list, island); - + /* add before or after the last channel? */ if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* can add after it */ @@ -833,12 +833,12 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan else { /* can at most go just before it, since last cannot be moved */ BLI_insertlinkbefore(list, last, island); - + } - + return true; } - + return false; } @@ -879,13 +879,13 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr { tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ bool is_sel = false, is_untouchable = false; - + /* get flags - selected and untouchable from the channel */ switch (type) { case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)channel; - + is_sel = SEL_AGRP(agrp); is_untouchable = (agrp->flag & AGRP_TEMP) != 0; break; @@ -894,21 +894,21 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)channel; - + is_sel = SEL_FCU(fcu); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)channel; - + is_sel = SEL_NLT(nlt); break; } case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)channel; - + is_sel = SEL_GPL(gpl); break; } @@ -916,7 +916,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %u\n", type); return; } - + /* do we need to add to a new island? */ if (/* 1) no islands yet */ (island == NULL) || @@ -931,7 +931,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr /* create a new island now */ island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); BLI_addtail(islands, island); - + if (is_sel) island->flag |= REORDER_ISLAND_SELECTED; if (is_untouchable) @@ -949,14 +949,14 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList) { tReorderChannelIsland *island, *isn = NULL; - + /* make sure srcList is empty now */ BLI_assert(BLI_listbase_is_empty(srcList)); - + /* go through merging islands */ for (island = islands->first; island; island = isn) { isn = island->next; - + /* merge island channels back to main list, then delete the island */ BLI_movelisttolist(srcList, &island->channels); BLI_freelinkN(islands, island); @@ -971,19 +971,19 @@ static void rearrange_animchannels_filter_visible(ListBase *anim_data_visible, b ListBase anim_data = {NULL, NULL}; bAnimListElem *ale, *ale_next; int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - + /* get all visible channels */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* now, only keep the ones that are of the types we are interested in */ for (ale = anim_data.first; ale; ale = ale_next) { ale_next = ale->next; - + if (ale->type != type) { BLI_freelinkN(&anim_data, ale); } } - + /* return cleaned up list */ *anim_data_visible = anim_data; } @@ -996,11 +996,11 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re ListBase islands = {NULL, NULL}; Link *channel, *chanNext = NULL; bool done = false; - + /* don't waste effort on an empty list */ if (BLI_listbase_is_empty(list)) return 0; - + /* group channels into islands */ for (channel = list->first; channel; channel = chanNext) { /* find out whether this channel is present in anim_data_visible or not! */ @@ -1008,18 +1008,18 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re chanNext = channel->next; rearrange_animchannel_add_to_islands(&islands, list, channel, type, is_hidden); } - - /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen - * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we + + /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen + * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we * shouldn't need to encounter items we've moved already */ if (islands.first != islands.last) { tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first; tReorderChannelIsland *island, *isn = NULL; - + for (island = first; island; island = isn) { isn = (mode > 0) ? island->prev : island->next; - + /* perform rearranging */ if (rearrange_func(&islands, island)) { island->flag |= REORDER_ISLAND_MOVED; @@ -1027,10 +1027,10 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re } } } - + /* ungroup islands */ rearrange_animchannel_flatten_islands(&islands, list); - + /* did we do anything? */ return done; } @@ -1045,21 +1045,21 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn { AnimChanRearrangeFp rearrange_func; ListBase anim_data_visible = {NULL, NULL}; - + /* hack: invert mode so that functions will work in right order */ mode *= -1; - + /* get rearranging function */ rearrange_func = rearrange_get_mode_func(mode); if (rearrange_func == NULL) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK); - + /* perform rearranging on tracks list */ rearrange_animchannel_islands(&adt->nla_tracks, rearrange_func, mode, ANIMTYPE_NLATRACK, &anim_data_visible); - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1074,20 +1074,20 @@ static void rearrange_driver_channels(bAnimContext *ac, AnimData *adt, eRearrang /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); ListBase anim_data_visible = {NULL, NULL}; - + if (rearrange_func == NULL) return; - + /* only consider drivers if they're accessible */ if (EXPANDED_DRVD(adt) == 0) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE); - + /* perform rearranging on drivers list (drivers are really just F-Curves) */ rearrange_animchannel_islands(&adt->drivers, rearrange_func, mode, ANIMTYPE_FCURVE, &anim_data_visible); - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1099,29 +1099,29 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) { bActionGroup *agrp; FCurve *fcu; - + if (act == NULL) return; - + /* Separate F-Curves into lists per group */ for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->channels.first) { fcu = agrp->channels.last; act->curves.first = fcu->next; - + fcu = agrp->channels.first; fcu->prev = NULL; - + fcu = agrp->channels.last; fcu->next = NULL; } } - + /* Initialize memory for temp-group */ memset(tgrp, 0, sizeof(bActionGroup)); tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP); BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name)); - + /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { /* start of list */ @@ -1129,21 +1129,21 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) fcu->prev = NULL; tgrp->channels.first = fcu; act->curves.first = NULL; - + /* end of list */ fcu = act->curves.last; fcu->next = NULL; tgrp->channels.last = fcu; act->curves.last = NULL; - - /* ensure that all of these get their group set to this temp group + + /* ensure that all of these get their group set to this temp group * (so that visibility filtering works) */ for (fcu = tgrp->channels.first; fcu; fcu = fcu->next) { fcu->grp = tgrp; } } - + /* Add temp-group to list */ BLI_addtail(&act->groups, tgrp); } @@ -1152,36 +1152,36 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) static void join_groups_action_temp(bAction *act) { bActionGroup *agrp; - + for (agrp = act->groups.first; agrp; agrp = agrp->next) { ListBase tempGroup; - + /* add list of channels to action's channels */ tempGroup = agrp->channels; BLI_movelisttolist(&act->curves, &agrp->channels); agrp->channels = tempGroup; - + /* clear moved flag */ agrp->flag &= ~AGRP_MOVED; - + /* if group was temporary one: * - unassign all FCurves which were temporarily added to it * - remove from list (but don't free as it's on the stack!) */ if (agrp->flag & AGRP_TEMP) { FCurve *fcu; - + for (fcu = agrp->channels.first; fcu; fcu = fcu->next) { fcu->grp = NULL; } - + BLI_remlink(&act->groups, agrp); break; } } } -/* Change the order of anim-channels within action +/* Change the order of anim-channels within action * mode: REARRANGE_ANIMCHAN_* */ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrangeAnimChan_Mode mode) @@ -1189,35 +1189,35 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange bActionGroup tgrp; ListBase anim_data_visible = {NULL, NULL}; bool do_channels; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* make sure we're only operating with groups (vs a mixture of groups+curves) */ split_groups_action_temp(act, &tgrp); - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP); - - /* rearrange groups first + + /* rearrange groups first * - the group's channels will only get considered if nothing happened when rearranging the groups * i.e. the rearrange function returned 0 */ do_channels = (rearrange_animchannel_islands(&act->groups, rearrange_func, mode, ANIMTYPE_GROUP, &anim_data_visible) == 0); - + /* free temp data */ BLI_freelistN(&anim_data_visible); - + if (do_channels) { bActionGroup *agrp; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE); - + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ if (EXPANDED_AGRP(ac, agrp)) { @@ -1225,11 +1225,11 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange &anim_data_visible); } } - + /* free temp data */ BLI_freelistN(&anim_data_visible); } - + /* assemble lists into one list (and clear moved tags) */ join_groups_action_temp(act); } @@ -1239,23 +1239,23 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode) { ListBase anim_data_visible = {NULL, NULL}; - + NlaTrack *nlt; NlaStrip *strip; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* skip if these curves aren't being shown */ if (adt->flag & ADT_NLA_SKEYS_COLLAPSED) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE); - + /* we cannot rearrange between strips, but within each strip, we can rearrange those curves */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (strip = nlt->strips.first; strip; strip = strip->next) { @@ -1263,7 +1263,7 @@ static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRea &anim_data_visible); } } - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1275,36 +1275,36 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* get Grease Pencil datablocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { ListBase anim_data_visible = {NULL, NULL}; bGPdata *gpd = ale->data; - + /* only consider layers if this datablock is open */ BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK); if ((gpd->flag & GP_DATA_EXPAND) == 0) continue; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER); - + /* rearrange datablock's layers */ rearrange_animchannel_islands(&gpd->layers, rearrange_func, mode, ANIMTYPE_GPLAYER, &anim_data_visible); - + /* free visible layers data */ BLI_freelistN(&anim_data_visible); } - + /* free GPD channel data */ ANIM_animdata_freelist(&anim_data); } @@ -1315,14 +1315,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) { bAnimContext ac; eRearrangeAnimChan_Mode mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get mode */ mode = RNA_enum_get(op->ptr, "direction"); - + /* method to move channels depends on the editor */ if (ac.datatype == ANIMCONT_GPENCIL) { /* Grease Pencil channels */ @@ -1340,23 +1340,23 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - + switch (ac.datatype) { case ANIMCONT_NLA: /* NLA-tracks only */ rearrange_nla_channels(&ac, adt, mode); break; - + case ANIMCONT_DRIVERS: /* Drivers list only */ rearrange_driver_channels(&ac, adt, mode); break; - + case ANIMCONT_ACTION: /* Single Action only... */ case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME... { @@ -1366,13 +1366,13 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) printf("Animdata has no action\n"); break; } - + default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */ { /* NLA Control Curves */ if (adt->nla_tracks.first) rearrange_nla_control_channels(&ac, adt, mode); - + /* Action */ if (adt->action) rearrange_action_channels(&ac, adt->action, mode); @@ -1382,14 +1382,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); } - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1399,14 +1399,14 @@ static void ANIM_OT_channels_move(wmOperatorType *ot) ot->name = "Move Channels"; ot->idname = "ANIM_OT_channels_move"; ot->description = "Rearrange selected animation channels"; - + /* api callbacks */ ot->exec = animchannels_rearrange_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", ""); } @@ -1422,16 +1422,16 @@ static int animchannels_grouping_poll(bContext *C) /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; - + /* animation editor test - must be suitable modes only */ sl = CTX_wm_space_data(C); - + switch (sa->spacetype) { /* supported... */ case SPACE_ACTION: { SpaceAction *saction = (SpaceAction *)sl; - + /* dopesheet and action only - all others are for other datatypes or have no groups */ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) return 0; @@ -1441,7 +1441,7 @@ static int animchannels_grouping_poll(bContext *C) case SPACE_IPO: { SpaceIpo *sipo = (SpaceIpo *)sl; - + /* drivers can't have groups... */ if (sipo->mode != SIPO_MODE_ANIMATION) return 0; @@ -1452,50 +1452,50 @@ static int animchannels_grouping_poll(bContext *C) default: return 0; } - + return 1; } /* ----------------------------------------------------------- */ static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref, const char name[]) -{ +{ AnimData *adt = adt_ref->adt; bAction *act = adt->action; - + if (act) { ListBase anim_data = {NULL, NULL}; int filter; - + /* find selected F-Curves to re-group */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(ac, &anim_data, filter, adt_ref, ANIMCONT_CHANNEL); - + if (anim_data.first) { bActionGroup *agrp; bAnimListElem *ale; - + /* create new group, which should now be part of the action */ agrp = action_groups_add_new(act, name); BLI_assert(agrp != NULL); - + /* transfer selected F-Curves across to new group */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; bActionGroup *grp = fcu->grp; - + /* remove F-Curve from group, then group too if it is now empty */ action_groups_remove_channel(act, fcu); - + if ((grp) && BLI_listbase_is_empty(&grp->channels)) { BLI_freelinkN(&act->groups, grp); } - + /* add F-Curve to group */ action_groups_add_channel(act, agrp, fcu); } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -1505,35 +1505,35 @@ static int animchannels_group_exec(bContext *C, wmOperator *op) { bAnimContext ac; char name[MAX_NAME]; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get name for new group */ RNA_string_get(op->ptr, "name", name); - + /* XXX: name for group should never be empty... */ if (name[0]) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* handle each animdata block separately, so that the regrouping doesn't flow into blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { animchannels_group_channels(&ac, ale, name); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* updatss */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } - + return OPERATOR_FINISHED; } @@ -1543,18 +1543,18 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) ot->name = "Group Channels"; ot->idname = "ANIM_OT_channels_group"; ot->description = "Add selected F-Curves to a new group"; - + /* callbacks */ ot->invoke = WM_operator_props_popup; ot->exec = animchannels_group_exec; ot->poll = animchannels_grouping_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ - ot->prop = RNA_def_string(ot->srna, "name", "New Group", - sizeof(((bActionGroup *)NULL)->name), + ot->prop = RNA_def_string(ot->srna, "name", "New Group", + sizeof(((bActionGroup *)NULL)->name), "Name", "Name of newly created group"); /* RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); */ /* XXX: still not too sure about this - keeping same text is confusing... */ } @@ -1564,33 +1564,33 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* just selected F-Curves... */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* find action for this F-Curve... */ if (ale->adt && ale->adt->action) { FCurve *fcu = (FCurve *)ale->data; bAction *act = ale->adt->action; - + /* only proceed to remove if F-Curve is in a group... */ - if (fcu->grp) { + if (fcu->grp) { bActionGroup *agrp = fcu->grp; - + /* remove F-Curve from group and add at tail (ungrouped) */ action_groups_remove_channel(act, fcu); BLI_addtail(&act->curves, fcu); - + /* delete group if it is now empty */ if (BLI_listbase_is_empty(&agrp->channels)) { BLI_freelinkN(&act->groups, agrp); @@ -1598,13 +1598,13 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + /* updates */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1614,11 +1614,11 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot) ot->name = "Ungroup Channels"; ot->idname = "ANIM_OT_channels_ungroup"; ot->description = "Remove selected F-Curves from their current groups"; - + /* callbacks */ ot->exec = animchannels_ungroup_exec; ot->poll = animchannels_grouping_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1631,22 +1631,22 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* cannot delete in shapekey */ - if (ac.datatype == ANIMCONT_SHAPEKEY) + if (ac.datatype == ANIMCONT_SHAPEKEY) return OPERATOR_CANCELLED; - - + + /* do groups only first (unless in Drivers mode, where there are none) */ if (ac.datatype != ANIMCONT_DRIVERS) { /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* delete selected groups and their associated channels */ for (ale = anim_data.first; ale; ale = ale->next) { /* only groups - don't check other types yet, since they may no-longer exist */ @@ -1654,20 +1654,20 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) bActionGroup *agrp = (bActionGroup *)ale->data; AnimData *adt = ale->adt; FCurve *fcu, *fcn; - + /* skip this group if no AnimData available, as we can't safely remove the F-Curves */ if (adt == NULL) continue; - + /* delete all of the Group's F-Curves, but no others */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) { fcn = fcu->next; - + /* remove from group and action, then free */ action_groups_remove_channel(adt->action, fcu); free_fcurve(fcu); } - + /* free the group itself */ if (adt->action) BLI_freelinkN(&adt->action->groups, agrp); @@ -1675,24 +1675,24 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(agrp); } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* delete selected data channels */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { - case ANIMTYPE_FCURVE: + case ANIMTYPE_FCURVE: { /* F-Curves if we can identify its parent */ AnimData *adt = ale->adt; FCurve *fcu = (FCurve *)ale->data; - + /* try to free F-Curve */ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu); break; @@ -1702,7 +1702,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* NLA Control Curve - Deleting it should disable the corresponding setting... */ NlaStrip *strip = (NlaStrip *)ale->owner; FCurve *fcu = (FCurve *)ale->data; - + if (STREQ(fcu->rna_path, "strip_time")) { strip->flag &= ~NLASTRIP_FLAG_USR_TIME; } @@ -1712,7 +1712,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) else { printf("ERROR: Trying to delete NLA Control Curve for unknown property '%s'\n", fcu->rna_path); } - + /* unlink and free the F-Curve */ BLI_remlink(&strip->fcurves, fcu); free_fcurve(fcu); @@ -1723,7 +1723,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* Grease Pencil layer */ bGPdata *gpd = (bGPdata *)ale->id; bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* try to delete the layer's data and the layer itself */ BKE_gpencil_free_frames(gpl); BLI_freelinkN(&gpd->layers, gpl); @@ -1734,35 +1734,35 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* Mask layer */ Mask *mask = (Mask *)ale->id; MaskLayer *masklay = (MaskLayer *)ale->data; - + /* try to delete the layer's data and the layer itself */ BKE_mask_layer_remove(mask, masklay); break; } } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); DAG_relations_tag_update(CTX_data_main(C)); return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Channels"; ot->idname = "ANIM_OT_channels_delete"; ot->description = "Delete all selected animation channels"; - + /* api callbacks */ ot->exec = animchannels_delete_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1789,7 +1789,7 @@ static const EnumPropertyItem prop_animchannel_settings_types[] = { /* ------------------- */ -/* Set/clear a particular flag (setting) for all selected + visible channels +/* Set/clear a particular flag (setting) for all selected + visible channels * setting: the setting to modify * mode: eAnimChannels_SetFlag * onlysel: only selected channels get the flag set @@ -1801,20 +1801,20 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin ListBase all_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data that we need if flush is on */ if (flush) { - /* get list of all channels that selection may need to be flushed to + /* get list of all channels that selection may need to be flushed to * - hierarchy visibility needs to be ignored so that settings can get flushed * "down" inside closed containers */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype); } - - /* filter data that we're working on + + /* filter data that we're working on * - hierarchy matters if we're doing this from the channels region - * since we only want to apply this to channels we can "see", + * since we only want to apply this to channels we can "see", * and have these affect their relatives * - but for Graph Editor, this gets used also from main region * where hierarchy doesn't apply [#21276] @@ -1829,12 +1829,12 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin } if (onlysel) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* if toggling, check if disable or enable */ if (mode == ACHANNEL_SETFLAG_TOGGLE) { /* default to turn all on, unless we encounter one that's on... */ mode = ACHANNEL_SETFLAG_ADD; - + /* see if we should turn off instead... */ for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ @@ -1844,21 +1844,21 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin } } } - + /* apply the setting */ for (ale = anim_data.first; ale; ale = ale->next) { /* skip channel if setting is not available */ if (ANIM_channel_setting_get(ac, ale, setting) == -1) continue; - + /* set the setting in the appropriate way */ ANIM_channel_setting_set(ac, ale, setting, mode); - + /* if flush status... */ if (flush) ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode); } - + ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); } @@ -1871,27 +1871,27 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) eAnimChannel_Settings setting; eAnimChannels_SetFlag mode; bool flush = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */ mode = RNA_enum_get(op->ptr, "mode"); setting = RNA_enum_get(op->ptr, "type"); - + /* check if setting is flushable */ if (setting == ACHANNEL_SETTING_EXPAND) flush = false; - - /* modify setting + + /* modify setting * - only selected channels are affected */ setflag_anim_channels(&ac, setting, mode, true, flush); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1899,20 +1899,20 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Enable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_enable"; ot->description = "Enable specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); @@ -1924,20 +1924,20 @@ static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Disable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_disable"; ot->description = "Disable specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); @@ -1949,20 +1949,20 @@ static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Toggle Channel Setting"; ot->idname = "ANIM_OT_channels_setting_toggle"; ot->description = "Toggle specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); @@ -1974,19 +1974,19 @@ static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Toggle Channel Editability"; ot->idname = "ANIM_OT_channels_editable_toggle"; ot->description = "Toggle editability of selected channels"; - + /* api callbacks */ ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); @@ -2001,21 +2001,21 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op) { bAnimContext ac; bool onlysel = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) onlysel = false; - + /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2025,14 +2025,14 @@ static void ANIM_OT_channels_expand(wmOperatorType *ot) ot->name = "Expand Channels"; ot->idname = "ANIM_OT_channels_expand"; ot->description = "Expand (i.e. open) all selected expandable animation channels"; - + /* api callbacks */ ot->exec = animchannels_expand_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); } @@ -2043,21 +2043,21 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op) { bAnimContext ac; bool onlysel = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) onlysel = false; - + /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2067,14 +2067,14 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) ot->name = "Collapse Channels"; ot->idname = "ANIM_OT_channels_collapse"; ot->description = "Collapse (i.e. close) all selected expandable animation channels"; - + /* api callbacks */ ot->exec = animchannels_collapse_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)"); } @@ -2090,37 +2090,37 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) * or are no longer wanted * 3) No drivers */ - + static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { ID *id = ale->id; AnimData *adt = ale->data; - + bool action_empty = false; bool nla_empty = false; bool drivers_empty = false; - + /* sanity checks */ BLI_assert((id != NULL) && (adt != NULL)); - + /* check if this is "empty" and can be deleted */ /* (For now, there are only these 3 criteria) */ - + /* 1) Active Action is missing or empty */ if (ELEM(NULL, adt->action, adt->action->curves.first)) { action_empty = true; @@ -2128,18 +2128,18 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) else { /* TODO: check for keyframe + fmodifier data on these too */ } - + /* 2) No NLA Tracks and/or NLA Strips */ if (adt->nla_tracks.first == NULL) { nla_empty = true; } else { NlaTrack *nlt; - + /* empty tracks? */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (nlt->strips.first) { - /* stop searching, as we found one that actually had stuff we don't want lost + /* stop searching, as we found one that actually had stuff we don't want lost * NOTE: nla_empty gets reset to false, as a previous track may have been empty */ nla_empty = false; @@ -2151,23 +2151,23 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* 3) Drivers */ drivers_empty = (adt->drivers.first == NULL); - - + + /* remove AnimData? */ if (action_empty && nla_empty && drivers_empty) { BKE_animdata_free(id, true); } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2177,11 +2177,11 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) ot->name = "Remove Empty Animation Data"; ot->idname = "ANIM_OT_channels_clean_empty"; ot->description = "Delete all empty animation data containers from visible data-blocks"; - + /* api callbacks */ ot->exec = animchannels_clean_empty_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2191,56 +2191,56 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) static int animchannels_enable_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; - + /* animation editor test - Action/Dopesheet/etc. and Graph only */ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO) == 0) return 0; - + return 1; } static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through filtered data and clean curves */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + /* remove disabled flags from F-Curves */ fcu->flag &= ~FCURVE_DISABLED; - + /* for drivers, let's do the same too */ if (fcu->driver) fcu->driver->flag &= ~DRIVER_FLAG_INVALID; - + /* tag everything for updates - in particular, this is needed to get drivers working again */ ale->update |= ANIM_UPDATE_DEPS; } - + ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2250,11 +2250,11 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) ot->name = "Revive Disabled F-Curves"; ot->idname = "ANIM_OT_channels_fcurves_enable"; ot->description = "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again"; - + /* api callbacks */ ot->exec = animchannels_enable_exec; ot->poll = animchannels_enable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2265,10 +2265,10 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) static int animchannels_find_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + if (sa == NULL) return 0; - + /* animation editor with dopesheet */ return ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA); } @@ -2277,14 +2277,14 @@ static int animchannels_find_poll(bContext *C) static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *evt) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* set initial filter text, and enable filter */ RNA_string_set(op->ptr, "query", ac.ads->searchstr); - + /* defer to popup */ return WM_operator_props_popup(C, op, evt); } @@ -2293,26 +2293,26 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent * static int animchannels_find_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* update filter text, and ensure that filter is enabled if there's something there * NOTE: we turn the filter off if there's nothing (this is a quick shortcut for dismissing) */ RNA_string_get(op->ptr, "query", ac.ads->searchstr); - + if (ac.ads->searchstr[0]) { ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME; } else { ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME; } - + /* redraw */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2322,15 +2322,15 @@ static void ANIM_OT_channels_find(wmOperatorType *ot) ot->name = "Find Channels"; ot->idname = "ANIM_OT_channels_find"; ot->description = "Filter the set of channels shown to only include those with matching names"; - + /* callbacks */ ot->invoke = animchannels_find_invoke; ot->exec = animchannels_find_exec; ot->poll = animchannels_find_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_string(ot->srna, "query", "Query", sizeof(((bDopeSheet *)NULL)->searchstr), "", "Text to search for in channel names"); } @@ -2340,37 +2340,37 @@ static void ANIM_OT_channels_find(wmOperatorType *ot) static int animchannels_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); else ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ANIM_OT_channels_select_all_toggle"; ot->description = "Toggle selection of all animation channels"; - + /* api callbacks */ ot->exec = animchannels_deselectall_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); } @@ -2382,12 +2382,12 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin, ymax; - + /* set initial y extents */ if (ac->datatype == ANIMCONT_NLA) { ymin = (float)(-NLACHANNEL_HEIGHT(snla)); @@ -2397,27 +2397,27 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec ymin = 0.0f; ymax = (float)(-ACHANNEL_HEIGHT(ac)); } - + /* convert border-region to view coordinates */ UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { if (ac->datatype == ANIMCONT_NLA) ymin = ymax - NLACHANNEL_STEP(snla); else ymin = ymax - ACHANNEL_STEP(ac); - + /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { /* set selection flags only */ ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); - + /* type specific actions */ switch (ale->type) { case ANIMTYPE_GROUP: @@ -2431,20 +2431,20 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - - /* for now, it's easier just to do this here manually, as defining a new type - * currently adds complications when doing other stuff + + /* for now, it's easier just to do this here manually, as defining a new type + * currently adds complications when doing other stuff */ ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); break; } } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -2458,11 +2458,11 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) short selectmode = 0; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); @@ -2476,15 +2476,15 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) else { selectmode = ACHANNEL_SETFLAG_CLEAR; } - + /* apply borderselect animation channels */ borderselect_anim_channels(&ac, &rect, selectmode); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} static void ANIM_OT_channels_select_border(wmOperatorType *ot) { @@ -2492,18 +2492,18 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "ANIM_OT_channels_select_border"; ot->description = "Select all animation channels within the specified region"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = animchannels_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -2518,33 +2518,33 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) bAnimListElem *ale; int filter; bool success = false; - + /* get the channel that was clicked on */ /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", channel_index); - + ANIM_animdata_freelist(&anim_data); return false; } - + /* check that channel can be renamed */ acf = ANIM_channel_get_typeinfo(ale); if (acf && acf->name_prop) { PointerRNA ptr; PropertyRNA *prop; - + /* ok if we can get name property to edit from this channel */ if (acf->name_prop(ale, &ptr, &prop)) { /* actually showing the rename textfield is done on redraw, - * so here we just store the index of this channel in the + * so here we just store the index of this channel in the * dopesheet data, which will get utilized when drawing the * channel... * @@ -2556,7 +2556,7 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) } } } - + /* free temp data and tag for refresh */ ANIM_animdata_freelist(&anim_data); ED_region_tag_redraw(ac->ar); @@ -2569,18 +2569,18 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) View2D *v2d; int channel_index; float x, y; - + /* get useful pointers from animation context data */ ar = ac->ar; v2d = &ar->v2d; - - /* figure out which channel user clicked in + + /* figure out which channel user clicked in * Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use * ACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - + if (ac->datatype == ANIMCONT_NLA) { SpaceNla *snla = (SpaceNla *)ac->sl; UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); @@ -2617,7 +2617,7 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot) ot->name = "Rename Channels"; ot->idname = "ANIM_OT_channels_rename"; ot->description = "Rename animation channel under mouse"; - + /* api callbacks */ ot->invoke = animchannels_rename_invoke; ot->poll = animedit_poll_channels_active; @@ -2632,19 +2632,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, bAnimListElem *ale; int filter; int notifierFlags = 0; - + /* get the channel that was clicked on */ /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index); - + ANIM_animdata_freelist(&anim_data); return 0; } @@ -2664,7 +2664,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, { Scene *sce = (Scene *)ale->data; AnimData *adt = sce->adt; - + /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -2675,7 +2675,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, sce->flag |= SCE_DS_SELECTED; if (adt) adt->flag |= ADT_UI_SELECTED; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -2686,7 +2686,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, Base *base = (Base *)ale->data; Object *ob = base->object; AnimData *adt = ob->adt; - + /* set selection status */ if ((ob->restrictflag & OB_RESTRICT_SELECT) == 0) { if (selectmode == SELECT_INVERT) { @@ -2760,28 +2760,28 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); ale->adt->flag |= ADT_UI_SELECTED; } - + /* set active? */ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) ale->adt->flag |= ADT_UI_ACTIVE; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } - case ANIMTYPE_GROUP: + case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)ale->data; - + Object *ob = NULL; bPoseChannel *pchan = NULL; - - + + /* Armatures-Specific Feature: * Since groups are used to collect F-Curves of the same Bone by default * (via Keying Sets) so that they can be managed better, we try to make * things here easier for animators by mapping group selection to bone - * selection. + * selection. * * Only do this if "Only Selected" dopesheet filter is not active, or else it * becomes too unpredictable/tricky to manage @@ -2789,7 +2789,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) { if ((ale->id) && (GS(ale->id->name) == ID_OB)) { ob = (Object *)ale->id; - + if (ob->type == OB_ARMATURE) { /* Assume for now that any group with corresponding name is what we want * (i.e. for an armature whose location is animated, things would break @@ -2798,10 +2798,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, * TODO: check the first F-Curve or so to be sure... */ pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); - } + } } } - + /* select/deselect group */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this group only */ @@ -2810,11 +2810,11 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, else if (selectmode == -1) { /* select all in group (and deselect everthing else) */ FCurve *fcu; - + /* deselect all other channels */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); - + /* only select channels in group and group itself */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) fcu->flag |= FCURVE_SELECTED; @@ -2824,10 +2824,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* select group by itself */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); - + agrp->flag |= AGRP_SELECTED; } - + /* if group is selected now, make group the 'active' one in the visible list */ if (agrp->flag & AGRP_SELECTED) { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); @@ -2837,7 +2837,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP); if (pchan) ED_pose_bone_select(ob, pchan, false); } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -2845,7 +2845,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this F-Curve only */ @@ -2856,18 +2856,18 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); fcu->flag |= FCURVE_SELECTED; } - + /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ if (fcu->flag & FCURVE_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type); - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } - case ANIMTYPE_SHAPEKEY: + case ANIMTYPE_SHAPEKEY: { KeyBlock *kb = (KeyBlock *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this ShapeKey only */ @@ -2878,39 +2878,39 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); kb->flag |= KEYBLOCK_SEL; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } case ANIMTYPE_NLACONTROLS: { AnimData *adt = (AnimData *)ale->data; - + /* toggle expand * - Although the triangle widget already allows this, since there's nothing else that can be done here now, * let's just use it for easier expand/collapse for now */ adt->flag ^= ADT_NLA_SKEYS_COLLAPSED; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_GPDATABLOCK: { bGPdata *gpd = (bGPdata *)ale->data; - - /* toggle expand + + /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ gpd->flag ^= GP_DATA_EXPAND; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* invert selection status of this layer only */ @@ -2921,12 +2921,12 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); gpl->flag |= GP_LAYER_SELECT; } - + /* change active layer, if this is selected (since we must always have an active layer) */ if (gpl->flag & GP_LAYER_SELECT) { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER); } - + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* Grease Pencil updates */ notifierFlags |= (ND_ANIMCHAN | NA_EDITED); /* Animation Ediotrs updates */ break; @@ -2934,19 +2934,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, case ANIMTYPE_MASKDATABLOCK: { Mask *mask = (Mask *)ale->data; - + /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ mask->flag ^= MASK_ANIMF_EXPAND; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* invert selection status of this layer only */ @@ -2957,7 +2957,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); masklay->flag |= MASK_LAYERFLAG_SELECT; } - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } @@ -2966,10 +2966,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, printf("Error: Invalid channel type in mouse_anim_channels()\n"); break; } - + /* free channels */ ANIM_animdata_freelist(&anim_data); - + /* return notifier flags */ return notifierFlags; } @@ -2986,16 +2986,16 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE int notifierFlags = 0; short selectmode; float x, y; - - + + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ ar = ac.ar; v2d = &ar->v2d; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; @@ -3003,45 +3003,45 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ else selectmode = SELECT_REPLACE; - - /* figure out which channel user clicked in + + /* figure out which channel user clicked in * Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use * ACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP(&ac), 0, (float)ACHANNEL_HEIGHT_HALF(&ac), x, y, NULL, &channel_index); - + /* handle mouse-click in the relevant channel then */ notifierFlags = mouse_anim_channels(C, &ac, channel_index, selectmode); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); - + return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_click(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Click on Channels"; ot->idname = "ANIM_OT_channels_click"; ot->description = "Handle mouse-clicks over animation channels"; - + /* api callbacks */ ot->invoke = animchannels_mouseclick_invoke; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ /* NOTE: don't save settings, otherwise, can end up with some weird behaviour (sticky extend) */ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "children_only", false, "Select Children Only", ""); // CTRLKEY|SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -3152,13 +3152,13 @@ void ED_operatortypes_animchannels(void) { WM_operatortype_append(ANIM_OT_channels_select_all_toggle); WM_operatortype_append(ANIM_OT_channels_select_border); - + WM_operatortype_append(ANIM_OT_channels_click); WM_operatortype_append(ANIM_OT_channel_select_keys); WM_operatortype_append(ANIM_OT_channels_rename); WM_operatortype_append(ANIM_OT_channels_find); - + WM_operatortype_append(ANIM_OT_channels_setting_enable); WM_operatortype_append(ANIM_OT_channels_setting_disable); WM_operatortype_append(ANIM_OT_channels_setting_toggle); @@ -3167,16 +3167,16 @@ void ED_operatortypes_animchannels(void) /* XXX does this need to be a separate operator? */ WM_operatortype_append(ANIM_OT_channels_editable_toggle); - + WM_operatortype_append(ANIM_OT_channels_move); - + WM_operatortype_append(ANIM_OT_channels_expand); WM_operatortype_append(ANIM_OT_channels_collapse); - + WM_operatortype_append(ANIM_OT_channels_fcurves_enable); - + WM_operatortype_append(ANIM_OT_channels_clean_empty); - + WM_operatortype_append(ANIM_OT_channels_group); WM_operatortype_append(ANIM_OT_channels_ungroup); } @@ -3186,7 +3186,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0); wmKeyMapItem *kmi; - + /* click-select */ /* XXX for now, only leftmouse.... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); @@ -3201,31 +3201,31 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* deselect all */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true); - + /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); - + /* delete */ WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", DELKEY, KM_PRESS, 0, 0); - + /* settings */ WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0); - + /* settings - specialized hotkeys */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); - + /* expand/collapse */ WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "all", false); kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0); @@ -3236,7 +3236,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN); RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM); - + /* grouping */ WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0); |