diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_data.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_channels.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_ops.c | 11 |
7 files changed, 94 insertions, 39 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index c3fc29e811f..3bf8bba47f5 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -76,6 +76,8 @@ void BKE_nlameta_flush_transforms(struct NlaStrip *mstrip); struct NlaTrack *BKE_nlatrack_find_active(ListBase *tracks); void BKE_nlatrack_set_active(ListBase *tracks, struct NlaTrack *nlt); +struct NlaTrack *BKE_nlatrack_find_tweaked(struct AnimData *adt); + void BKE_nlatrack_solo_toggle(struct AnimData *adt, struct NlaTrack *nlt); bool BKE_nlatrack_has_space(struct NlaTrack *nlt, float start, float end); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index c87f378d5ae..eaa4460ce70 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -926,6 +926,40 @@ NlaTrack *BKE_nlatrack_find_active(ListBase *tracks) return NULL; } +/* Get the NLA Track that the active action/action strip comes from, + * since this info is not stored in AnimData. It also isn't as simple + * as just using the active track, since multiple tracks may have been + * entered at the same time. + */ +// TODO: Store this info in AnimData... Old files would still need to use this function for version patching though +NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt) +{ + NlaTrack *nlt; + + /* sanity check */ + if (adt == NULL) + return NULL; + + /* Since the track itself gets disabled, we want the first disabled... */ + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + if (nlt->flag & (NLATRACK_ACTIVE | NLATRACK_DISABLED)) { + /* For good measure, make sure that strip actually exists there */ + if (BLI_findindex(&nlt->strips, adt->actstrip) != -1) { + return nlt; + } + else if (G.debug & G_DEBUG) { + printf("%s: Active strip (%p, %s) not in NLA track found (%p, %s)\n", + __func__, + adt->actstrip, (adt->actstrip) ? adt->actstrip->name : "<None>", + nlt, nlt->name); + } + } + } + + /* Not found! */ + return NULL; +} + /* Toggle the 'solo' setting for the given NLA-track, making sure that it is the only one * that has this status in its AnimData block. */ diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 440201bd93e..11ccaee4146 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -625,36 +625,6 @@ void ACTION_OT_unlink(wmOperatorType *ot) /* ************************************************************************** */ /* ACTION BROWSING */ -/* Get the NLA Track that the active action comes from, since this is not stored in AnimData */ -/* TODO: Move this to blenkernel/nla.c */ -static NlaTrack *nla_tweak_track_get(AnimData *adt) -{ - NlaTrack *nlt; - - /* sanity check */ - if (adt == NULL) - return NULL; - - /* Since the track itself gets disabled, we want the first disabled... */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - if (nlt->flag & (NLATRACK_ACTIVE | NLATRACK_DISABLED)) { - /* For good measure, make sure that strip actually exists there */ - if (BLI_findindex(&nlt->strips, adt->actstrip) != -1) { - return nlt; - } - else if (G.debug & G_DEBUG) { - printf("%s: Active strip (%p, %s) not in NLA track found (%p, %s)\n", - __func__, - adt->actstrip, (adt->actstrip) ? adt->actstrip->name : "<None>", - nlt, nlt->name); - } - } - } - - /* Not found! */ - return NULL; -} - /* Try to find NLA Strip to use for action layer up/down tool */ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime) { @@ -774,7 +744,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) float ctime = BKE_scene_frame_get(scene); /* Get active track */ - act_track = nla_tweak_track_get(adt); + act_track = BKE_nlatrack_find_tweaked(adt); if (act_track == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track"); @@ -891,7 +861,7 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op) } /* Get active track */ - act_track = nla_tweak_track_get(adt); + act_track = BKE_nlatrack_find_tweaked(adt); /* If there is no active track, that means we are using the active action... */ if (act_track) { diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 4ed4a3f9514..32a8e660f66 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -291,10 +291,12 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe * 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! + * - we disable "solo" flags too, to make it easier to work with stashed actions + * with less trouble */ if (nlaedit_is_tweakmode_on(ac)) { /* exit tweakmode immediately */ - nlaedit_disable_tweakmode(ac); + nlaedit_disable_tweakmode(ac, true); /* changes to NLA-Action occurred */ notifierFlags |= ND_NLA_ACTCHANGE; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 9ae96292f52..19e6f5a8100 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -111,6 +111,8 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + + const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action"); bool ok = false; /* get editor data */ @@ -133,6 +135,15 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) /* try entering tweakmode if valid */ ok |= BKE_nla_tweakmode_enter(adt); + + /* mark the active track as being "solo"? */ + if (do_solo && adt->actstrip) { + NlaTrack *nlt = BKE_nlatrack_find_tweaked(adt); + + if (nlt && !(nlt->flag & NLATRACK_SOLO)) { + BKE_nlatrack_solo_toggle(adt, nlt); + } + } } /* free temp data */ @@ -159,6 +170,8 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) void NLA_OT_tweakmode_enter(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Enter Tweak Mode"; ot->idname = "NLA_OT_tweakmode_enter"; @@ -170,16 +183,22 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action", + "Enable 'solo' on the NLA Track containing the active strip, " + "to edit it without seeing the effects of the NLA stack"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* ------------- */ /* NLA Editor internal API function for exiting tweakmode */ -bool nlaedit_disable_tweakmode(bAnimContext *ac) +bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; + int filter; /* get a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); @@ -195,7 +214,14 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac) for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - /* to be sure, just exit tweakmode... */ + /* clear solo flags */ + if ((do_solo) & (adt->flag & ADT_NLA_SOLO_TRACK) && + (adt->flag & ADT_NLA_EDIT_ON)) + { + BKE_nlatrack_solo_toggle(adt, NULL); + } + + /* to be sure that we're doing everything right, just exit tweakmode... */ BKE_nla_tweakmode_exit(adt); } @@ -218,9 +244,11 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac) } /* exit tweakmode operator callback */ -static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; + + const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action"); bool ok = false; /* get editor data */ @@ -228,7 +256,7 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* perform operation */ - ok = nlaedit_disable_tweakmode(&ac); + ok = nlaedit_disable_tweakmode(&ac, do_solo); /* success? */ if (ok) @@ -239,6 +267,8 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *UNUSED(op)) void NLA_OT_tweakmode_exit(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Exit Tweak Mode"; ot->idname = "NLA_OT_tweakmode_exit"; @@ -250,6 +280,12 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action", + "Disable 'solo' on any of the NLA Tracks after exiting tweak mode " + "to get things back to normal"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 70fdb2d478d..344580c0d15 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -83,7 +83,7 @@ enum eNlaEdit_Snap_Mode { /* --- */ -bool nlaedit_disable_tweakmode(bAnimContext *ac); +bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo); 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 43bc4b9df0f..98da10470f8 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -306,6 +306,7 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) void nla_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; + wmKeyMapItem *kmi; /* keymap for all regions ------------------------------------------- */ keymap = WM_keymap_find(keyconf, "NLA Generic", SPACE_NLA, 0); @@ -320,6 +321,16 @@ void nla_keymap(wmKeyConfig *keyconf) 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); + /* tweakmode for stashed actions + * - similar to normal tweakmode, except we mark the tracks as being "solo" + * too so that the action can be edited in isolation + */ + kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "isolate_action", true); + + kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "isolate_action", true); + /* 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); |