[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18000] branches/blender2.5/blender/source /blender/editors: View2D - View alignment flags are now taken into account in curRect_Validate ()

Joshua Leung aligorith at gmail.com
Mon Dec 22 01:11:37 CET 2008


Revision: 18000
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18000
Author:   aligorith
Date:     2008-12-22 01:11:33 +0100 (Mon, 22 Dec 2008)

Log Message:
-----------
View2D - View alignment flags are now taken into account in curRect_Validate()

Alignment flags are now checked for after keeptot settings, as these flags are of even greater importance. This is necessary for the syncing of the channels region and timeline areas in Action Editor (and later NLA Editor). 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_action/space_action.c

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-21 23:39:52 UTC (rev 17999)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-22 00:11:33 UTC (rev 18000)
@@ -235,6 +235,7 @@
 	tot= &v2d->tot;
 	
 	/* we must satisfy the following constraints (in decreasing order of importance):
+	 *	- alignment restrictions are respected
 	 *	- cur must not fall outside of tot
 	 *	- axis locks (zoom and offset) must be maintained
 	 *	- zoom must not be excessive (check either sizes or zoom values)
@@ -353,11 +354,11 @@
 		v2d->oldwiny= winy;
 	}
 	
-	/* Step 2: apply new sizes of cur rect to cur rect */
+	/* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
 	if ((width != curwidth) || (height != curheight)) {
 		float temp, dh;
 		
-		/* resize around 'center' of frame */
+		/* resize from centerpoint */
 		if (width != curwidth) {
 			temp= (cur->xmax + cur->xmin) * 0.5f;
 			dh= width * 0.5f;
@@ -374,7 +375,7 @@
 		}
 	}
 	
-	/* Step 3: adjust so that it doesn't fall outside of bounds of tot */
+	/* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */
 	if (v2d->keeptot) {
 		float temp, diff;
 		
@@ -504,6 +505,48 @@
 		}
 	}
 	
+	/* Step 4: Make sure alignment restrictions are respected */
+	if (v2d->align) {
+		/* If alignment flags are set (but keeptot is not), they must still be respected, as although
+		 * they don't specify any particular bounds to stay within, they do define ranges which are 
+		 * invalid.
+		 *
+		 * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these 
+		 * invalid zones, otherwise we offset.
+		 */
+		
+		/* handle width - posx and negx flags are mutually exclusive, so watch out */
+		if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
+			/* width is in negative-x half */
+			if (v2d->cur.xmax > 0) {
+				v2d->cur.xmin -= v2d->cur.xmax;
+				v2d->cur.xmax= 0.0f;
+			}
+		}
+		else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
+			/* width is in positive-x half */
+			if (v2d->cur.xmin < 0) {
+				v2d->cur.xmax -= v2d->cur.xmin;
+				v2d->cur.xmin = 0.0f;
+			}
+		}
+		
+		/* handle height - posx and negx flags are mutually exclusive, so watch out */
+		if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
+			/* height is in negative-y half */
+			if (v2d->cur.ymax > 0) {
+				v2d->cur.ymin -= v2d->cur.ymax;
+				v2d->cur.ymax = 0.0f;
+			}
+		}
+		else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
+			/* height is in positive-y half */
+			if (v2d->cur.ymin < 0) {
+				v2d->cur.ymax -= v2d->cur.ymin;
+				v2d->cur.ymin = 0.0f;
+			}
+		}
+	}
 }
 
 /* ------------------ */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/space_action.c	2008-12-21 23:39:52 UTC (rev 17999)
+++ branches/blender2.5/blender/source/blender/editors/space_action/space_action.c	2008-12-22 00:11:33 UTC (rev 18000)
@@ -103,9 +103,9 @@
 	ar->v2d.tot.ymax= 0.0f;
 	
 	ar->v2d.cur.xmin= -2.0f;
-	ar->v2d.cur.ymin= -200.0f;
+	ar->v2d.cur.ymin= -2000.0f; /* ideally this would be the size of the region, but since we don't know that, set for 1:1 */
 	ar->v2d.cur.xmax= 100.0f;
-	ar->v2d.cur.ymax= -20.0f;
+	ar->v2d.cur.ymax= 0.0f;
 	
 	ar->v2d.min[0]= 0.0f;
  	ar->v2d.min[1]= 0.0f;





More information about the Bf-blender-cvs mailing list