diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-07-01 18:58:59 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-07-01 18:58:59 +0400 |
commit | 472f7464856dd4c6edb6885b99e57041a229e31c (patch) | |
tree | a15125b84f1f92b77b6c2619b3dd9dfc3574c474 /source/blender/editors/space_nla/nla_edit.c | |
parent | e6830300b7fbc03f72fbc35cafd35a147bf590dd (diff) |
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)
Diffstat (limited to 'source/blender/editors/space_nla/nla_edit.c')
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 43 |
1 files changed, 29 insertions, 14 deletions
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) |