[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38012] branches/soc-2011-pepper/source/ blender/editors: NLA Strip Drawing Tweaks

Joshua Leung aligorith at gmail.com
Fri Jul 1 14:21:13 CEST 2011


Revision: 38012
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38012
Author:   aligorith
Date:     2011-07-01 12:21:13 +0000 (Fri, 01 Jul 2011)
Log Message:
-----------
NLA Strip Drawing Tweaks

* Removed frame-number display from NLA strips. Indeed doing so makes
things look cleaner/easier to identify.
* When transforming NLA strips, the "temp-metas" (purple strips) get
their frame extents drawn on either end, like in the sequencer, which
seems to be easier to read than the ones inside the strips.

---

The downside of this tweak is that there is no longer any visual
feedback for which strips run reversed instead of forwards, as that
used to be shown using the frame extents stuff.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
    branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c

Modified: branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-07-01 11:16:42 UTC (rev 38011)
+++ branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-07-01 12:21:13 UTC (rev 38012)
@@ -197,32 +197,6 @@
 	return 0;
 }
 
-/* This function is used to loop over the keyframe data of an AnimData block */
-static short adt_keyframes_loop(KeyframeEditData *ked, AnimData *adt, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag)
-{
-	/* sanity check */
-	if (adt == NULL)
-		return 0;
-	
-	/* drivers or actions? */
-	if (filterflag & ADS_FILTER_ONLYDRIVERS) {
-		FCurve *fcu;
-		
-		/* just loop through all F-Curves acting as Drivers */
-		for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
-			if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
-				return 1;
-		}
-	}
-	else if (adt->action) {
-		/* call the function for actions */
-		if (act_keyframes_loop(ked, adt->action, key_ok, key_cb, fcu_cb))
-			return 1;
-	}
-	
-	return 0;
-}
-
 /* This function is used to loop over the keyframe data in an Object */
 static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *ob, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
 {

Modified: branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-07-01 11:16:42 UTC (rev 38011)
+++ branches/soc-2011-pepper/source/blender/editors/space_nla/nla_draw.c	2011-07-01 12:21:13 UTC (rev 38012)
@@ -420,23 +420,23 @@
 } 
 
 /* add the relevant text to the cache of text-strings to draw in pixelspace */
-static void nla_draw_strip_text (NlaTrack *UNUSED(nlt), NlaStrip *strip, int UNUSED(index), View2D *v2d, float yminc, float ymaxc)
+static void nla_draw_strip_text (NlaTrack *UNUSED(nlt), NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc)
 {
-	char str[256], dir[3];
+	char str[256];
 	char col[4];
+	float xofs;
 	rctf rect;
 	
-	/* 'dir' - direction that strip is played in */
-	if (strip->flag & NLASTRIP_FLAG_REVERSE)
-		sprintf(dir, "<-");
-	else
-		sprintf(dir, "->");
-	
 	/* just print the name and the range */
-	if (strip->flag & NLASTRIP_FLAG_TEMP_META)
-		sprintf(str, "Temp-Meta | %.2f %s %.2f", strip->start, dir, strip->end);
-	else
-		sprintf(str, "%s | %.2f %s %.2f", strip->name, strip->start, dir, strip->end);
+	if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
+		sprintf(str, "%d) Temp-Meta", index);
+	}
+	else {
+		if (strip->flag & NLASTRIP_FLAG_REVERSE)
+			sprintf(str, "%s", strip->name);
+		else
+			sprintf(str, "%s", strip->name);
+	}
 	
 	/* set text color - if colors (see above) are light, draw black text, otherwise draw white */
 	if (strip->flag & (NLASTRIP_FLAG_ACTIVE|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_TWEAKUSER)) {
@@ -445,22 +445,52 @@
 	else {
 		col[0]= col[1]= col[2]= 255;
 	}
-	col[3]= 1.0;
-
+	col[3]= 255;
+	
+	/* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */
+	if ((strip->end - strip->start) <= 5.0f)
+		xofs = 0.5f;
+	else
+		xofs = 1.0f;
+	
 	/* set bounding-box for text 
 	 *	- padding of 2 'units' on either side
 	 */
 	// TODO: make this centered?
-	rect.xmin= strip->start + 0.5f;
+	rect.xmin= strip->start + xofs;
 	rect.ymin= yminc;
-	rect.xmax= strip->end - 0.5f;
+	rect.xmax= strip->end - xofs;
 	rect.ymax= ymaxc;
 	
-	/* add this string to the cache of texts to draw*/
-
+	/* add this string to the cache of texts to draw */
 	UI_view2d_text_cache_rectf(v2d, &rect, str, col);
 }
 
+/* add frame extents to cache of text-strings to draw in pixelspace
+ * for now, only used when transforming strips
+ */
+static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc)
+{
+	const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
+	const char col[4] = {220, 220, 220, 255}; /* light grey */
+	char str[16] = "";
+	
+	
+	/* Always draw times above the strip, whereas sequencer drew below + above.
+	 * However, we should be fine having everything on top, since these tend to be 
+	 * quite spaced out. 
+	 *	- 1 dp is compromise between lack of precision (ints only, as per sequencer)
+	 *	  while also preserving some accuracy, since we do use floats
+	 */
+		/* start frame */
+	sprintf(str, "%.1f", strip->start);
+	UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col);
+	
+		/* end frame */
+	sprintf(str, "%.1f", strip->end);
+	UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col);
+}
+
 /* ---------------------- */
 
 void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
@@ -518,6 +548,12 @@
 							
 							/* add the text for this strip to the cache */
 							nla_draw_strip_text(nlt, strip, index, v2d, yminc, ymaxc);
+							
+							/* if transforming strips (only real reason for temp-metas currently), 
+							 * add to the cache the frame numbers of the strip's extents
+							 */
+							if (strip->flag & NLASTRIP_FLAG_TEMP_META)
+								nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc);
 						}
 					}
 				}




More information about the Bf-blender-cvs mailing list