Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_nla/nla_channels.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| /* Depending on the channel that was clicked on, the mouse click will activate whichever | /* Depending on the channel that was clicked on, the mouse click will activate whichever | ||||
| * part of the channel is relevant. | * part of the channel is relevant. | ||||
| * | * | ||||
| * NOTE: eventually, | * NOTE: eventually, | ||||
| * this should probably be phased out when many of these things are replaced with buttons | * this should probably be phased out when many of these things are replaced with buttons | ||||
| * --> Most channels are now selection only. | * --> Most channels are now selection only. | ||||
| */ | */ | ||||
| static int mouse_nla_channels( | static int mouse_nla_channels(bContext *C, bAnimContext *ac, int channel_index, short selectmode) | ||||
| bContext *C, bAnimContext *ac, float x, int channel_index, short selectmode) | |||||
| { | { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| View2D *v2d = &ac->region->v2d; | |||||
| int notifierFlags = 0; | int notifierFlags = 0; | ||||
| /* get the channel that was clicked on */ | /* get the channel that was clicked on */ | ||||
| /* filter channels */ | /* filter channels */ | ||||
| filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); | filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); | ||||
| ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); | ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); | ||||
| /* get channel from index */ | /* get channel from index */ | ||||
| ▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | case ANIMTYPE_DSSIMULATION: { | ||||
| } | } | ||||
| } | } | ||||
| notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_NLATRACK: { | case ANIMTYPE_NLATRACK: { | ||||
| NlaTrack *nlt = (NlaTrack *)ale->data; | NlaTrack *nlt = (NlaTrack *)ale->data; | ||||
| AnimData *adt = ale->adt; | |||||
| short offset; | |||||
| /* offset for start of channel (on LHS of channel-list) */ | |||||
| if (ale->id) { | |||||
| /* special exception for materials and particles */ | |||||
| if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) { | |||||
| offset = 21 + NLACHANNEL_BUTTON_WIDTH; | |||||
| } | |||||
| else { | |||||
| offset = 14; | |||||
| } | |||||
| } | |||||
| else { | |||||
| offset = 0; | |||||
| } | |||||
| if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { | |||||
| /* toggle protection (only if there's a toggle there) */ | |||||
| nlt->flag ^= NLATRACK_PROTECTED; | |||||
| /* notifier flags - channel was edited */ | |||||
| notifierFlags |= (ND_ANIMCHAN | NA_EDITED); | |||||
| } | |||||
| else if (x >= (v2d->cur.xmax - 2 * NLACHANNEL_BUTTON_WIDTH)) { | |||||
| /* toggle mute */ | |||||
| nlt->flag ^= NLATRACK_MUTED; | |||||
| /* notifier flags - channel was edited */ | |||||
| notifierFlags |= (ND_ANIMCHAN | NA_EDITED); | |||||
| ale->update |= ANIM_UPDATE_DEPS; | |||||
| } | |||||
| else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) { | |||||
| /* toggle 'solo' */ | |||||
| BKE_nlatrack_solo_toggle(adt, nlt); | |||||
| /* notifier flags - channel was edited */ | if (nlaedit_is_tweakmode_on(ac) == 0) { | ||||
| notifierFlags |= (ND_ANIMCHAN | NA_EDITED); | |||||
| ale->update |= ANIM_UPDATE_DEPS; | |||||
| } | |||||
| else if (nlaedit_is_tweakmode_on(ac) == 0) { | |||||
| /* set selection */ | /* set selection */ | ||||
| if (selectmode == SELECT_INVERT) { | if (selectmode == SELECT_INVERT) { | ||||
| /* inverse selection status of this F-Curve only */ | /* inverse selection status of this F-Curve only */ | ||||
| nlt->flag ^= NLATRACK_SELECTED; | nlt->flag ^= NLATRACK_SELECTED; | ||||
| } | } | ||||
| else { | else { | ||||
| /* select F-Curve by itself */ | /* select F-Curve by itself */ | ||||
| ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); | ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); | ||||
| Show All 9 Lines | case ANIMTYPE_NLATRACK: { | ||||
| /* notifier flags - channel was selected */ | /* notifier flags - channel was selected */ | ||||
| notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_NLAACTION: { | case ANIMTYPE_NLAACTION: { | ||||
| AnimData *adt = BKE_animdata_from_id(ale->id); | AnimData *adt = BKE_animdata_from_id(ale->id); | ||||
| /* button region... */ | |||||
| if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { | |||||
| if (nlaedit_is_tweakmode_on(ac) == 0) { | |||||
| /* 'push-down' action - only usable when not in tweak-mode */ | |||||
| /* TODO: make this use the operator instead of calling the function directly | |||||
| * however, calling the operator requires that we supply the args, | |||||
| * and that works with proper buttons only */ | |||||
| BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(ale->id)); | |||||
| } | |||||
| else { | |||||
| /* When in tweak-mode, this button becomes the toggle for mapped editing. */ | |||||
| adt->flag ^= ADT_NLA_EDIT_NOMAP; | |||||
| } | |||||
| /* changes to NLA-Action occurred */ | |||||
| notifierFlags |= ND_NLA_ACTCHANGE; | |||||
| ale->update |= ANIM_UPDATE_DEPS; | |||||
| } | |||||
| /* OR rest of name... */ | |||||
| else { | |||||
| /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block | /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block | ||||
| * - this is useful when there's no clear divider, and makes more sense in | * - this is useful when there's no clear divider, and makes more sense in | ||||
| * the case of users trying to use this to change actions | * the case of users trying to use this to change actions | ||||
| * - in tweak-mode, clicking here gets us out of tweak-mode, as changing selection | * - in tweak-mode, clicking here gets us out of tweak-mode, as changing selection | ||||
| * while in tweak-mode is really evil! | * while in tweak-mode is really evil! | ||||
| * - we disable "solo" flags too, to make it easier to work with stashed actions | * - we disable "solo" flags too, to make it easier to work with stashed actions | ||||
| * with less trouble | * with less trouble | ||||
| */ | */ | ||||
| if (nlaedit_is_tweakmode_on(ac)) { | if (nlaedit_is_tweakmode_on(ac)) { | ||||
| /* Exit tweak-mode immediately. */ | /* Exit tweak-mode immediately. */ | ||||
| nlaedit_disable_tweakmode(ac, true); | nlaedit_disable_tweakmode(ac, true); | ||||
| /* changes to NLA-Action occurred */ | /* changes to NLA-Action occurred */ | ||||
| notifierFlags |= ND_NLA_ACTCHANGE; | notifierFlags |= ND_NLA_ACTCHANGE; | ||||
| ale->update |= ANIM_UPDATE_DEPS; | ale->update |= ANIM_UPDATE_DEPS; | ||||
| } | } | ||||
| else { | else { | ||||
| /* select/deselect */ | /* select/deselect */ | ||||
| if (selectmode == SELECT_INVERT) { | if (selectmode == SELECT_INVERT) { | ||||
| /* inverse selection status of this AnimData block only */ | /* inverse selection status of this AnimData block only */ | ||||
| adt->flag ^= ADT_UI_SELECTED; | adt->flag ^= ADT_UI_SELECTED; | ||||
| } | } | ||||
| else { | else { | ||||
| /* select AnimData block by itself */ | /* select AnimData block by itself */ | ||||
| ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); | ANIM_anim_channels_select_set(ac, ACHANNEL_SETFLAG_CLEAR); | ||||
| adt->flag |= ADT_UI_SELECTED; | adt->flag |= ADT_UI_SELECTED; | ||||
| } | } | ||||
| /* set active? */ | /* set active? */ | ||||
| if (adt->flag & ADT_UI_SELECTED) { | if (adt->flag & ADT_UI_SELECTED) { | ||||
| adt->flag |= ADT_UI_ACTIVE; | adt->flag |= ADT_UI_ACTIVE; | ||||
| } | } | ||||
| notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); | ||||
| } | } | ||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("Error: Invalid channel type in mouse_nla_channels()\n"); | printf("Error: Invalid channel type in mouse_nla_channels()\n"); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH, | ||||
| 0, | 0, | ||||
| NLACHANNEL_FIRST_TOP(&ac), | NLACHANNEL_FIRST_TOP(&ac), | ||||
| x, | x, | ||||
| y, | y, | ||||
| NULL, | NULL, | ||||
| &channel_index); | &channel_index); | ||||
| /* handle mouse-click in the relevant channel then */ | /* handle mouse-click in the relevant channel then */ | ||||
| notifierFlags = mouse_nla_channels(C, &ac, x, channel_index, selectmode); | notifierFlags = mouse_nla_channels(C, &ac, channel_index, selectmode); | ||||
| /* set notifier that things have changed */ | /* set notifier that things have changed */ | ||||
| WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); | WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void NLA_OT_channels_click(wmOperatorType *ot) | void NLA_OT_channels_click(wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 489 Lines • Show Last 20 Lines | |||||