[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18719] branches/blender2.5/blender/source /blender: 2.5

Ton Roosendaal ton at blender.org
Wed Jan 28 19:26:48 CET 2009


Revision: 18719
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18719
Author:   ton
Date:     2009-01-28 19:26:47 +0100 (Wed, 28 Jan 2009)

Log Message:
-----------
2.5

Some drawing tweaks for animsys:

- added notifier ND_KEYS type, to send proper notes around.
  now insert-key redraws fcurve/action view
- made slider-draggers disappear when view is total or bigger.

Also experimented with making sliders go away entirely, but
this conflicts too much with current code for channel lists.

Ali: I think you have to make call that calculates the 'tot'
for channels, and run this in region listener, including the
totRect update for view2d.

The 'minsize' for channels also fails when there's a slider,
it always doesn't fit then :)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.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_ipo/ipo_draw.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/space_ipo.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_view2d_types.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_types.h

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c	2009-01-28 18:02:15 UTC (rev 18718)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c	2009-01-28 18:26:47 UTC (rev 18719)
@@ -2117,9 +2117,9 @@
 	ED_undo_push(C, "Insert Keyframe");
 	
 	if (mode == 3) // material color requires different notifiers
-		WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+		WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, NULL);
 	else
-		WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+		WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
 	
 	return OPERATOR_FINISHED;
 }
@@ -2184,7 +2184,7 @@
 	ED_undo_push(C, "Delete Keyframe");
 	
 		// XXX what if it was a material keyframe?
-	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+	WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
 	
 	return OPERATOR_FINISHED;
 }

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2009-01-28 18:02:15 UTC (rev 18718)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2009-01-28 18:26:47 UTC (rev 18719)
@@ -57,6 +57,91 @@
 #include "interface_intern.h"
 
 /* *********************************************************************** */
+
+/* helper to allow scrollbars to dynamically hide */
+static int view2d_scroll_mapped(int scroll)
+{
+	if(scroll & V2D_SCROLL_HORIZONTAL_HIDE)
+		scroll &= ~(V2D_SCROLL_HORIZONTAL);
+	if(scroll & V2D_SCROLL_VERTICAL_HIDE)
+		scroll &= ~(V2D_SCROLL_VERTICAL);
+	return scroll;
+}
+
+/* called each time cur changes, to dynamically update masks */
+static void view2_masks(View2D *v2d)
+{
+	int scroll;
+	
+	/* mask - view frame */
+	v2d->mask.xmin= v2d->mask.ymin= 0;
+	v2d->mask.xmax= v2d->winx - 1;	/* -1 yes! masks are pixels */
+	v2d->mask.ymax= v2d->winy - 1;
+
+#if 0
+	v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_VERTICAL_HIDE);
+	/* check size if: */
+	if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
+		if(!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
+			if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin)
+				v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
+	if (v2d->scroll & V2D_SCROLL_VERTICAL)
+		if(!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
+			if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin)
+				v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
+#endif
+	scroll= view2d_scroll_mapped(v2d->scroll);
+	
+	/* scrollers shrink mask area, but should be based off regionsize 
+		*	- they can only be on one to two edges of the region they define
+		*	- if they overlap, they must not occupy the corners (which are reserved for other widgets)
+		*/
+	if (scroll) {
+		/* vertical scroller */
+		if (scroll & V2D_SCROLL_LEFT) {
+			/* on left-hand edge of region */
+			v2d->vert= v2d->mask;
+			v2d->vert.xmax= V2D_SCROLL_WIDTH;
+			v2d->mask.xmin= v2d->vert.xmax + 1;
+		}
+		else if (scroll & V2D_SCROLL_RIGHT) {
+			/* on right-hand edge of region */
+			v2d->vert= v2d->mask;
+			v2d->vert.xmax++; /* one pixel extra... was having leaving a minor gap... */
+			v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
+			v2d->mask.xmax= v2d->vert.xmin - 1;
+		}
+		
+		/* horizontal scroller */
+		if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
+			/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
+			v2d->hor= v2d->mask;
+			v2d->hor.ymax= V2D_SCROLL_HEIGHT;
+			v2d->mask.ymin= v2d->hor.ymax + 1;
+		}
+		else if (scroll & V2D_SCROLL_TOP) {
+			/* on upper edge of region */
+			v2d->hor= v2d->mask;
+			v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
+			v2d->mask.ymax= v2d->hor.ymin - 1;
+		}
+		
+		/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
+		if (scroll & V2D_SCROLL_VERTICAL) {
+			/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
+			if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
+				/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
+				v2d->vert.ymin= v2d->mask.ymin;
+			}
+			else if (scroll & V2D_SCROLL_TOP) {
+				/* on upper edge of region */
+				v2d->vert.ymax= v2d->mask.ymax;
+			}
+		}
+	}
+	
+}
+
 /* Refresh and Validation */
 
 /* Initialise all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
@@ -153,69 +238,19 @@
 		}
 	}
 	
-	
 	/* store view size */
 	v2d->winx= winx;
 	v2d->winy= winy;
 	
-	/* mask - view frame */
-	v2d->mask.xmin= v2d->mask.ymin= 0;
-	v2d->mask.xmax= winx - 1;	/* -1 yes! masks are pixels */
-	v2d->mask.ymax= winy - 1;
+	/* set masks */
+	view2_masks(v2d);
 	
-	/* scrollers shrink mask area, but should be based off regionsize 
-	 *	- they can only be on one to two edges of the region they define
-	 *	- if they overlap, they must not occupy the corners (which are reserved for other widgets)
-	 */
-	if (v2d->scroll) {
-		/* vertical scroller */
-		if (v2d->scroll & V2D_SCROLL_LEFT) {
-			/* on left-hand edge of region */
-			v2d->vert= v2d->mask;
-			v2d->vert.xmax= V2D_SCROLL_WIDTH;
-			v2d->mask.xmin= v2d->vert.xmax + 1;
-		}
-		else if (v2d->scroll & V2D_SCROLL_RIGHT) {
-			/* on right-hand edge of region */
-			v2d->vert= v2d->mask;
-			v2d->vert.xmax++; /* one pixel extra... was having leaving a minor gap... */
-			v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
-			v2d->mask.xmax= v2d->vert.xmin - 1;
-		}
-		
-		/* horizontal scroller */
-		if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
-			/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
-			v2d->hor= v2d->mask;
-			v2d->hor.ymax= V2D_SCROLL_HEIGHT;
-			v2d->mask.ymin= v2d->hor.ymax + 1;
-		}
-		else if (v2d->scroll & V2D_SCROLL_TOP) {
-			/* on upper edge of region */
-			v2d->hor= v2d->mask;
-			v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
-			v2d->mask.ymax= v2d->hor.ymin - 1;
-		}
-		
-		/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
-		if (v2d->scroll & V2D_SCROLL_VERTICAL) {
-			/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
-			if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
-				/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
-				v2d->vert.ymin= v2d->mask.ymin;
-			}
-			else if (v2d->scroll & V2D_SCROLL_TOP) {
-				/* on upper edge of region */
-				v2d->vert.ymax= v2d->mask.ymax;
-			}
-		}
-	}
-	
 	/* set 'tot' rect before setting cur? */
 	if (tot_changed) 
 		UI_view2d_totRect_set(v2d, winx, winy);
 	else
 		UI_view2d_curRect_validate(v2d);
+	
 }
 
 /* Ensure View2D rects remain in a viable configuration 
@@ -549,6 +584,9 @@
 			}
 		}
 	}
+	
+	/* set masks */
+	view2_masks(v2d);
 }
 
 /* ------------------ */
@@ -731,7 +769,7 @@
 {
 	*curmasked= v2d->cur;
 	
-	if ((v2d->scroll)) {
+	if (view2d_scroll_mapped(v2d->scroll)) {
 		float dx= (v2d->cur.xmax-v2d->cur.xmin)/((float)(v2d->mask.xmax-v2d->mask.xmin+1));
 		float dy= (v2d->cur.ymax-v2d->cur.ymin)/((float)(v2d->mask.ymax-v2d->mask.ymin+1));
 		
@@ -1116,6 +1154,7 @@
 	View2DScrollers *scrollers;
 	rcti vert, hor;
 	float fac, totsize, scrollsize;
+	int scroll= view2d_scroll_mapped(v2d->scroll);
 	
 	vert= v2d->vert;
 	hor= v2d->hor;
@@ -1129,7 +1168,7 @@
 	 */
 	
 	/* horizontal scrollers */
-	if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
+	if (scroll & V2D_SCROLL_HORIZONTAL) {
 		/* scroller 'button' extents */
 		totsize= v2d->tot.xmax - v2d->tot.xmin;
 		scrollsize= (float)(hor.xmax - hor.xmin);
@@ -1145,7 +1184,7 @@
 	}
 	
 	/* vertical scrollers */
-	if (v2d->scroll & V2D_SCROLL_VERTICAL) {
+	if (scroll & V2D_SCROLL_VERTICAL) {
 		/* scroller 'button' extents */
 		totsize= v2d->tot.ymax - v2d->tot.ymin;
 		scrollsize= (float)(vert.ymax - vert.ymin);
@@ -1161,7 +1200,7 @@
 	}
 	
 	/* grid markings on scrollbars */
-	if (v2d->scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
+	if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
 		/* store clamping */
 		scrollers->xclamp= xclamp;
 		scrollers->xunits= xunits;
@@ -1292,13 +1331,14 @@
 	Scene *scene= CTX_data_scene(C);
 	const short darker= -50, dark= -10, light= 20, lighter= 50;
 	rcti vert, hor, corner;
+	int scroll= view2d_scroll_mapped(v2d->scroll);
 	
 	/* make copies of rects for less typing */
 	vert= v2d->vert;
 	hor= v2d->hor;
 	
 	/* horizontal scrollbar */
-	if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
+	if (scroll & V2D_SCROLL_HORIZONTAL) {
 		/* scroller backdrop */
 		UI_ThemeColorShade(TH_SHADE1, light);
 		glRecti(hor.xmin,  hor.ymin,  hor.xmax,  hor.ymax);
@@ -1306,8 +1346,10 @@
 		/* scroller 'button' 
 		 *	- if view is zoomable in x, draw handles too 
 		 *	- handles are drawn darker
+		 *  - no slider when view is > total
 		 */
-		if (v2d->keepzoom & V2D_LOCKZOOM_X) {
+		if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin); 
+		else if (v2d->keepzoom & V2D_LOCKZOOM_X) {
 			/* draw base bar as rounded shape */
 			UI_ThemeColorShade(TH_SHADE1, dark);
 			uiSetRoundBox(15);
@@ -1362,7 +1404,7 @@
 		
 		/* scale indicators */
 		// XXX will need to update the font drawing when the new stuff comes in
-		if ((v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
+		if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
 			View2DGrid *grid= vs->grid;
 			float fac, dfac, fac2, val;
 			
@@ -1426,14 +1468,14 @@
 		
 		/* decoration outer bevel line */
 		UI_ThemeColorShade(TH_SHADE1, lighter);
-		if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
+		if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
 			sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
-		else if (v2d->scroll & V2D_SCROLL_TOP)
+		else if (scroll & V2D_SCROLL_TOP)
 			sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
 	}
 	
 	/* vertical scrollbar */
-	if (v2d->scroll & V2D_SCROLL_VERTICAL) {
+	if (scroll & V2D_SCROLL_VERTICAL) {
 		/* scroller backdrop  */
 		UI_ThemeColorShade(TH_SHADE1, light);
 		glRecti(vert.xmin,  vert.ymin,  vert.xmax,  vert.ymax);
@@ -1442,7 +1484,8 @@
 		 *	- if view is zoomable in y, draw handles too 
 		 *	- handles are drawn darker
 		 */
-		if (v2d->keepzoom & V2D_LOCKZOOM_Y) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list