From 472f7464856dd4c6edb6885b99e57041a229e31c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 1 Jul 2013 14:58:59 +0000 Subject: NLA Bugfix: When clicking on a channel name in the channel list while still in tweakmode, this will now result in tweakmode being exited instead of going into a weird limbo-land where channel selection has changed (but tweakmode is still active but not drawn) --- source/blender/editors/space_nla/nla_channels.c | 38 ++++++++++++++-------- source/blender/editors/space_nla/nla_edit.c | 43 +++++++++++++++++-------- source/blender/editors/space_nla/nla_intern.h | 2 ++ source/blender/editors/space_nla/nla_ops.c | 36 ++++++++++++--------- 4 files changed, 75 insertions(+), 44 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index ca50ff3b545..bf914a05620 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -287,24 +287,34 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor /* 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 * the case of users trying to use this to change actions + * - in tweakmode, clicking here gets us out of tweakmode, as changing selection + * while in tweakmode is really evil! */ - - /* select/deselect */ - if (selectmode == SELECT_INVERT) { - /* inverse selection status of this AnimData block only */ - adt->flag ^= ADT_UI_SELECTED; + if (nlaedit_is_tweakmode_on(ac)) { + /* exit tweakmode immediately */ + nlaedit_disable_tweakmode(ac); + + /* changes to NLA-Action occurred */ + notifierFlags |= ND_NLA_ACTCHANGE; } else { - /* select AnimData block by itself */ - ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - adt->flag |= ADT_UI_SELECTED; + /* select/deselect */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this AnimData block only */ + adt->flag ^= ADT_UI_SELECTED; + } + else { + /* select AnimData block by itself */ + ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + adt->flag |= ADT_UI_SELECTED; + } + + /* set active? */ + if (adt->flag & ADT_UI_SELECTED) + adt->flag |= ADT_UI_ACTIVE; + + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - - /* set active? */ - if (adt->flag & ADT_UI_SELECTED) - adt->flag |= ADT_UI_ACTIVE; - - notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } break; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 159cc74af56..7347b446bce 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -173,26 +173,21 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot) /* ------------- */ -static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) +/* NLA Editor internal API function for exiting tweakmode */ +bool nlaedit_disable_tweakmode(bAnimContext *ac) { - 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 a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* if no blocks, popup error? */ if (anim_data.first == NULL) { - BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for"); - return OPERATOR_CANCELLED; + BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from"); + return false; } /* for each AnimData block with NLA-data, try exitting tweak-mode */ @@ -209,16 +204,36 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) /* if we managed to enter tweakmode on at least one AnimData block, * set the flag for this in the active scene and send notifiers */ - if (ac.scene) { + if (ac->scene) { /* clear editing flag */ - ac.scene->flag &= ~SCE_NLA_EDIT_ON; + ac->scene->flag &= ~SCE_NLA_EDIT_ON; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } /* done */ - return OPERATOR_FINISHED; + return true; +} + +/* exit tweakmode operator callback */ +static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *UNUSED(op)) +{ + bAnimContext ac; + bool ok = false; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* perform operation */ + ok = nlaedit_disable_tweakmode(&ac); + + /* success? */ + if (ok) + return OPERATOR_FINISHED; + else + return OPERATOR_CANCELLED; } void NLA_OT_tweakmode_exit(wmOperatorType *ot) diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index e78187cef39..2ad2418fc77 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -81,6 +81,8 @@ enum eNlaEdit_Snap_Mode { /* --- */ +bool nlaedit_disable_tweakmode(bAnimContext *ac); + void NLA_OT_tweakmode_enter(wmOperatorType *ot); void NLA_OT_tweakmode_exit(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index e4d5c6ef284..aa3224507bc 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -172,8 +172,9 @@ static void nla_keymap_channels(wmKeyMap *keymap) { wmKeyMapItem *kmi; - /* NLA-specific (different to standard channels keymap) -------------------------- */ - /* selection */ + /* keymappings here are NLA-specific (different to standard channels keymap) */ + + /* selection --------------------------------------------------------------------- */ /* click-select */ // XXX for now, only leftmouse.... kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); @@ -181,7 +182,7 @@ static void nla_keymap_channels(wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); - /* channel operations */ + /* channel operations ------------------------------------------------------------ */ /* add tracks */ kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", FALSE); @@ -197,7 +198,7 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; - /* selection */ + /* selection ------------------------------------------------ */ /* click select */ kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); @@ -233,20 +234,14 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - /* view*/ + /* view ---------------------------------------------------- */ /* auto-set range */ //WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - /* editing */ - /* tweakmode - * - enter and exit are separate operators with the same hotkey... - * This works as they use different poll()'s - */ - WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); - + /* editing ------------------------------------------------ */ + /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); @@ -301,11 +296,20 @@ void nla_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; - /* keymap for all regions */ + /* keymap for all regions ------------------------------------------- */ keymap = WM_keymap_find(keyconf, "NLA Generic", SPACE_NLA, 0); + + /* region management */ WM_keymap_add_item(keymap, "NLA_OT_properties", NKEY, KM_PRESS, 0, 0); - /* channels */ + /* tweakmode + * - enter and exit are separate operators with the same hotkey... + * This works as they use different poll()'s + */ + WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); + + /* channels ---------------------------------------------------------- */ /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module. * Most of the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as there * are many similarities with the other Animation Editors. @@ -315,7 +319,7 @@ void nla_keymap(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "NLA Channels", SPACE_NLA, 0); nla_keymap_channels(keymap); - /* data */ + /* data ------------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0); nla_keymap_main(keyconf, keymap); } -- cgit v1.2.3