[Bf-blender-cvs] [097801e] master: NLA: Shift-Tab toggles tweakmode AND makes that track solo

Joshua Leung noreply at git.blender.org
Tue Apr 14 08:40:25 CEST 2015


Commit: 097801e701cec7ae1e388d201ca3426153616097
Author: Joshua Leung
Date:   Sun Apr 12 20:42:34 2015 +1200
Branches: master
https://developer.blender.org/rB097801e701cec7ae1e388d201ca3426153616097

NLA: Shift-Tab toggles tweakmode AND makes that track solo

To help make it more convenient to edit stashed actions, Shift-Tab
(i.e. holding down the Shift key, which "tabbing" into tweakmode as
usual to edit the action referenced by the active NLA strip) now flags
the NLA Track that the strip occupies as being "solo" too.

This allows you to use the NLA to select a stashed action, then Shift-Tab
to start editing it without any other actions in the NLA stack interfering.
Like the "Next/Previous Layer" tools in the Action Editor, this is designed
to help with checking on stashed actions.

===================================================================

M	release/scripts/startup/bl_ui/space_nla.py
M	source/blender/blenkernel/BKE_nla.h
M	source/blender/blenkernel/intern/nla.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_nla/nla_channels.c
M	source/blender/editors/space_nla/nla_edit.c
M	source/blender/editors/space_nla/nla_intern.h
M	source/blender/editors/space_nla/nla_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index ae432c4..c083907 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -168,8 +168,10 @@ class NLA_MT_edit(Menu):
         layout.separator()
         # TODO: names of these tools for 'tweak-mode' need changing?
         if scene.is_nla_tweakmode:
+            layout.operator("nla.tweakmode_exit", text="Stop Editing Stashed Action").isolate_action = True
             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
         else:
+            layout.operator("nla.tweakmode_enter", text="Start Editing Stashed Action").isolate_action = True
             layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
 
 
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h
index c3fc29e..3bf8bba 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 c87f378..eaa4460 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 440201b..11ccaee 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 4ed4a3f..32a8e66 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 9ae9629..19e6f5a 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/editor

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list