[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17920] branches/blender2.5/blender/source /blender: View2D: More bugfixes

Joshua Leung aligorith at gmail.com
Thu Dec 18 10:20:30 CET 2008


Revision: 17920
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17920
Author:   aligorith
Date:     2008-12-18 10:20:29 +0100 (Thu, 18 Dec 2008)

Log Message:
-----------
View2D: More bugfixes

* Added flags to View2D to specify whether the view should have pixel offsets applied (this is able to be specified per axis, just in case the need arises). Currently, this is only used for headers, where the UI elements were not as smooth + round as they could be

* Fixed IPO/Action/NLA so that new instance will show channel lists by default and with scrollers

* Fixed Outliner zoom-in/out on changing windowsize. I didn't notice this on my previous custom .B.blend file, but the problem was apparent in the default setup.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
    branches/blender2.5/blender/source/blender/editors/space_nla/space_nla.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_view2d_types.h

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2008-12-18 07:22:28 UTC (rev 17919)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2008-12-18 09:20:29 UTC (rev 17920)
@@ -5079,19 +5079,21 @@
 				BLI_addtail(lb, ar);
 				ar->regiontype= RGN_TYPE_CHANNELS;
 				ar->alignment= RGN_ALIGN_LEFT; 
-				
+				ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
 				break;
 			case SPACE_ACTION:
 				ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
 				BLI_addtail(lb, ar);
 				ar->regiontype= RGN_TYPE_CHANNELS;
 				ar->alignment= RGN_ALIGN_LEFT;
+				ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
 				break;
 			case SPACE_NLA:
 				ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
 				BLI_addtail(lb, ar);
 				ar->regiontype= RGN_TYPE_CHANNELS;
 				ar->alignment= RGN_ALIGN_LEFT;
+				ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
 				break;
 		}
 	}
@@ -5117,7 +5119,7 @@
 				ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
 				ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT);
 				ar->v2d.keeptot = V2D_KEEPTOT_STRICT;
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 			}
 				break;
 			case SPACE_TIME:
@@ -5131,7 +5133,7 @@
 				ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
 				ar->v2d.tot.ymin= ar->v2d.cur.ymin= -10.0;
 				ar->v2d.min[1]= ar->v2d.max[1]= 20.0;
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 			}
 				break;
 			case SPACE_IPO:
@@ -5141,7 +5143,7 @@
 				
 				ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
 				ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 				break;
 			}
 			case SPACE_SOUND:
@@ -5151,7 +5153,7 @@
 				
 				ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
 				ar->v2d.scroll |= (V2D_SCROLL_LEFT);
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 				break;
 			}
 			case SPACE_NLA:
@@ -5161,7 +5163,7 @@
 				
 				ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
 				ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 				break;
 			}
 			case SPACE_ACTION:
@@ -5171,7 +5173,7 @@
 				
 				ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
 				ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
-				ar->v2d.flag |= V2D_IS_INITIALISED;
+				//ar->v2d.flag |= V2D_IS_INITIALISED;
 				break;
 			}
 			case SPACE_SEQ:

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-18 07:22:28 UTC (rev 17919)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-18 09:20:29 UTC (rev 17920)
@@ -64,7 +64,6 @@
  *	- this function should only be called from region init() callbacks, where it is expected that
  *	  this is called before UI_view2d_size_update(), as this one checks that the rects are properly initialised. 
  */
-// eView2D_CommonViewTypes <--- only check handle these types...
 void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
 {
 	short tot_changed= 0;
@@ -127,8 +126,8 @@
 				/* zoom + aspect ratio are locked */
 				v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
 				v2d->minzoom= v2d->maxzoom= 1.0f;
-				v2d->min[0]= v2d->max[0]= winx;
-				v2d->min[1]= v2d->max[1]= winy;
+				v2d->min[0]= v2d->max[0]= winx-1;
+				v2d->min[1]= v2d->max[1]= winy-1;
 				
 				/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
 				v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
@@ -140,6 +139,9 @@
 				
 				/* absolutely no scrollers allowed */
 				v2d->scroll= 0;
+				
+				/* pixel offsets need to be applied for smooth UI controls */
+				v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
 			}
 				break;
 			
@@ -335,8 +337,15 @@
 			}
 		}
 		else {
-			/* landscape window: correct for y */
-			height = width * winRatio;
+			if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winy != v2d->oldwiny)) {
+				/* special exception for Outliner (and later channel-lists):
+				 *	- Currently, no actions need to be taken here...
+				 */
+			}
+			else {
+				/* landscape window: correct for y */
+				height = width * winRatio;
+			}
 		}
 		
 		/* store region size for next time */
@@ -625,28 +634,30 @@
 	}
 }
 
-/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing 
-*	- this assumes viewport/scissor been set for the region, taking scrollbars into account
-*/
-
+/* Set view matrices to use 'cur' rect as viewing frame for View2D drawing */
 void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
 {
 	wmWindow *window= CTX_wm_window(C);
 	rctf curmasked;
+	float xofs, yofs;
 	
-	/* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied, 
-	 * as they were causing some unwanted offsets when drawing 
+	/* pixel offsets (-0.375f) are needed to get 1:1 correspondance with pixels for smooth UI drawing, 
+	 * but only applied where requsted
 	 */
+	xofs= (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
+	yofs= (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
+	
+	/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
 	view2d_map_cur_using_mask(v2d, &curmasked);
-	wmOrtho2(window, curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
 	
+	/* set matrix on all appropriate axes */
+	wmOrtho2(window, curmasked.xmin-xofs, curmasked.xmax-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
+	
 	/* XXX is this necessary? */
 	wmLoadIdentity(window);
 }
 
 /* Set view matrices to only use one axis of 'cur' only
- *	- this assumes viewport/scissor been set for the region, taking scrollbars into account
- *
  *	- xaxis 	= if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
  */
 void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
@@ -654,15 +665,22 @@
 	wmWindow *window= CTX_wm_window(C);
 	ARegion *ar= CTX_wm_region(C);
 	rctf curmasked;
+	float xofs, yofs;
 	
-	/* set the matrix - pixel offsets (-0.375) for 1:1 correspondance are not applied, 
-	 * as they were causing some unwanted offsets when drawing 
+	/* pixel offsets (-0.375f) are needed to get 1:1 correspondance with pixels for smooth UI drawing, 
+	 * but only applied where requsted
 	 */
+	xofs= (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
+	yofs= (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
+	
+	/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
 	view2d_map_cur_using_mask(v2d, &curmasked);
+	
+	/* only set matrix with 'cur' coordinates on relevant axes */
 	if (xaxis)
-		wmOrtho2(window, curmasked.xmin, curmasked.xmax, 0, ar->winy);
+		wmOrtho2(window, curmasked.xmin-xofs, curmasked.xmax-xofs, -yofs, ar->winy-yofs);
 	else
-		wmOrtho2(window, 0, ar->winx, curmasked.ymin, curmasked.ymax);
+		wmOrtho2(window, -xofs, ar->winx-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
 		
 	/* XXX is this necessary? */
 	wmLoadIdentity(window);
@@ -779,8 +797,6 @@
 			grid->powerx-= 2;
 			if (grid->powerx < -2) grid->powerx= -2;
 		}
-		
-		grid->startx= v2d->cur.xmin;
 	}
 	
 	/* calculate y-axis grid scale (only if both args are valid) */
@@ -795,8 +811,6 @@
 			if (grid->dy < 1.0f) grid->dy= 1.0f;
 			if (grid->powery < 1) grid->powery= 1;
 		}
-		
-		grid->starty= v2d->cur.ymin;
 	}
 	
 	/* calculate start position */
@@ -804,10 +818,15 @@
 		grid->startx= seconddiv*(v2d->cur.xmin/seconddiv - fmod(v2d->cur.xmin/seconddiv, grid->dx/seconddiv));
 		if (v2d->cur.xmin < 0.0f) grid->startx-= grid->dx;
 	}
+	else
+		grid->startx= v2d->cur.xmin;
+		
 	if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
 		grid->starty= (v2d->cur.ymin - fmod(v2d->cur.ymin, grid->dy));
 		if (v2d->cur.ymin < 0.0f) grid->starty-= grid->dy;
 	}
+	else
+		grid->starty= v2d->cur.ymin;
 	
 	return grid;
 }

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-18 07:22:28 UTC (rev 17919)
+++ branches/blender2.5/blender/source/blender/editors/space_action/space_action.c	2008-12-18 09:20:29 UTC (rev 17920)
@@ -80,42 +80,45 @@
 	ar->regiontype= RGN_TYPE_HEADER;
 	ar->alignment= RGN_ALIGN_BOTTOM;
 	
+	/* channel list region */
+	ar= MEM_callocN(sizeof(ARegion), "channel area for action");
+	BLI_addtail(&saction->regionbase, ar);
+	ar->regiontype= RGN_TYPE_CHANNELS;
+	ar->alignment= RGN_ALIGN_LEFT;
+	
+		/* only need to set scroll settings, as this will use 'listview' v2d configuration */
+	ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+	ar->v2d.flag = V2D_VIEWSYNC_Y;
+	
 	/* main area */
 	ar= MEM_callocN(sizeof(ARegion), "main area for action");
 	
 	BLI_addtail(&saction->regionbase, ar);
 	ar->regiontype= RGN_TYPE_WINDOW;
 	
-	ar->v2d.tot.xmin= 1.0f;
-	ar->v2d.tot.ymin= -1000.0f;
-	ar->v2d.tot.xmax= 1000.0f;
+	ar->v2d.tot.xmin= -5.0f;
+	ar->v2d.tot.ymin= -2000.0f;
+	ar->v2d.tot.xmax= 1000.0f; // xxx - use end frame instead?
 	ar->v2d.tot.ymax= 0.0f;
 	
-	ar->v2d.cur.xmin= -5.0f;
-	ar->v2d.cur.ymin= -75.0f;
-	ar->v2d.cur.xmax= 65.0f;
-	ar->v2d.cur.ymax= 5.0f;
+	ar->v2d.cur.xmin= -2.0f;
+	ar->v2d.cur.ymin= -200.0f;
+	ar->v2d.cur.xmax= 100.0f;
+	ar->v2d.cur.ymax= 0.0f;
 	
 	ar->v2d.min[0]= 0.0f;
  	ar->v2d.min[1]= 0.0f;
 	
 	ar->v2d.max[0]= MAXFRAMEF;
- 	ar->v2d.max[1]= 1000.0f;
+ 	ar->v2d.max[1]= 2000.0f;
  	
 	ar->v2d.minzoom= 0.01f;
 	ar->v2d.maxzoom= 50;
-	ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+	ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
 	ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
 	ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
-	ar->v2d.align= V2D_ALIGN_NO_POS_X;
+	ar->v2d.align= V2D_ALIGN_NO_POS_Y;
 	
-	/* channel list region XXX */
-	ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
-	BLI_addtail(&saction->regionbase, ar);
-	ar->regiontype= RGN_TYPE_CHANNELS;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list