[Bf-blender-cvs] [fab4b90] master: NLA: Indicate position of action-local markers on strips

Joshua Leung noreply at git.blender.org
Thu Jul 7 15:53:41 CEST 2016


Commit: fab4b907f6ba35f204fa25891024d1a2bdcaeda2
Author: Joshua Leung
Date:   Wed Jun 29 03:16:07 2016 +1200
Branches: master
https://developer.blender.org/rBfab4b907f6ba35f204fa25891024d1a2bdcaeda2

NLA: Indicate position of action-local markers on strips

To make it easier to synchronise timing across multiple strips, if you add
markers locally to an action, these will show up in the NLA strip in the
NLA Editor. These markings can then be used to line up the start/end of
another strip, or even to make sure that the markers from two different
strips end up lining up.

By default, this is turned on, but it can be disabled (via the View menu)
if it adds too much visual noise.

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

M	release/scripts/startup/bl_ui/space_nla.py
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index f6f010e..8fbf9bf 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -77,6 +77,7 @@ class NLA_MT_view(Menu):
         layout.prop(st, "show_locked_time")
 
         layout.prop(st, "show_strip_curves")
+        layout.prop(st, "show_local_markers")
 
         layout.separator()
         layout.operator("anim.previewrange_set")
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index b0adabe..5b3c062 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -62,7 +62,7 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
-
+#include "nla_private.h"
 #include "nla_intern.h" /* own include */
 
 
@@ -145,6 +145,62 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d,
 	BLI_dlrbTree_free(&keys);
 }
 
+/* Strip Markers ------------------------ */
+
+/* Markers inside an action strip */
+static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
+{
+	bAction *act = strip->act;
+	TimeMarker *marker;
+	
+	if (ELEM(NULL, strip->act, strip->act->markers.first))
+		return;
+	
+	for (marker = act->markers.first; marker; marker = marker->next) {
+		if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
+			float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
+			
+			/* just a simple line for now */
+			// XXX: draw a triangle instead...
+			fdrawline(frame, yminc + 1, frame, ymaxc - 1);
+		}
+	}
+}
+
+/* Markers inside a NLA-Strip */
+static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
+{
+	glLineWidth(2.0);
+	
+	if (strip->type == NLASTRIP_TYPE_CLIP) {
+		/* try not to be too conspicuous, while being visible enough when transforming */
+		if (strip->flag & NLASTRIP_FLAG_SELECT)
+			UI_ThemeColorShade(TH_STRIP_SELECT, -60);
+		else
+			UI_ThemeColorShade(TH_STRIP_SELECT, -40);
+		
+		setlinestyle(3);
+		
+		/* just draw the markers in this clip */
+		nla_actionclip_draw_markers(strip, yminc, ymaxc);
+		
+		setlinestyle(0);
+	}
+	else if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
+		/* just a solid color, so that it is very easy to spot */
+		UI_ThemeColorShade(TH_STRIP_SELECT, 20);
+		
+		/* draw the markers in the first level of strips only (if they are actions) */
+		for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) {
+			if (nls->type == NLASTRIP_TYPE_CLIP) {
+				nla_actionclip_draw_markers(nls, yminc, ymaxc);
+			}
+		}
+	}
+	
+	glLineWidth(1.0);
+}
+
 /* Strips (Proper) ---------------------- */
 
 /* get colors for drawing NLA-Strips */
@@ -361,6 +417,10 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
 		nla_draw_strip_curves(strip, yminc, ymaxc);
 	
 	
+	/* draw markings indicating locations of local markers (useful for lining up different actions) */
+	if ((snla->flag & SNLA_NOLOCALMARKERS) == 0)
+		nla_strip_draw_markers(strip, yminc, ymaxc);
+	
 	/* draw strip outline 
 	 *	- color used here is to indicate active vs non-active
 	 */
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 629e69d..4ce0f36 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -412,6 +412,8 @@ typedef enum eSpaceNla_Flag {
 	SNLA_NOSTRIPCURVES     = (1 << 5),
 	/* don't perform realtime updates */
 	SNLA_NOREALTIMEUPDATES = (1 << 6),
+	/* don't show local strip marker indications */
+	SNLA_NOLOCALMARKERS    = (1 << 7),
 } eSpaceNla_Flag;
 
 
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 3586393..df589bb 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3613,6 +3613,12 @@ static void rna_def_space_nla(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Show Control F-Curves", "Show influence F-Curves on strips");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL);
 	
+	prop = RNA_def_property(srna, "show_local_markers", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SNLA_NOLOCALMARKERS);
+	RNA_def_property_ui_text(prop, "Show Local Markers",
+	                         "Show action-local markers on the strips, useful when synchronising timing across strips");
+	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL);
+	
 	/* editing */
 	prop = RNA_def_property(srna, "use_realtime_update", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SNLA_NOREALTIMEUPDATES);




More information about the Bf-blender-cvs mailing list