[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17711] branches/blender2.5/blender/source /blender/editors: View2D: Scrollbar tweaks

Joshua Leung aligorith at gmail.com
Thu Dec 4 06:37:57 CET 2008


Revision: 17711
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17711
Author:   aligorith
Date:     2008-12-04 06:37:55 +0100 (Thu, 04 Dec 2008)

Log Message:
-----------
View2D: Scrollbar tweaks

* Added back vertical scale markings for vertical scrollbars. Currently untested (until IPO Editor can be put back in). Also, there was a special exception for the Sequencer, which will need to be checked when the time comes too.

* Fixed the display of frame numbers in scrollbars. Was caused by error in using an int, where a float was required (this is one place MSVC gives better warnings than GCC). 

* Outliner horizontal scrollbar now displays a more useful range. The previous range was based on screen width, not width of content. 

* Outliner horizontal scrollbar now draws with bevel-highlight line again. Was missed out in a previous commit.

* Added simple toggle Frames/Seconds operator to TimeLine to test if the View2D code is working right for this. This uses the same hotkey (TKEY) as it's counterpart (with a menu for input) did in previous incarnations of Blender. 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-12-04 02:01:42 UTC (rev 17710)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-12-04 05:37:55 UTC (rev 17711)
@@ -97,7 +97,7 @@
 
 /* scrollbar drawing */
 View2DScrollers *UI_view2d_calc_scrollers(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
-void UI_view2d_draw_scrollers(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers, int flag);
+void UI_view2d_draw_scrollers(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
 void UI_view2d_free_scrollers(View2DScrollers *scrollers);
 
 /* coordinate conversion */

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-04 02:01:42 UTC (rev 17710)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-12-04 05:37:55 UTC (rev 17711)
@@ -734,7 +734,7 @@
 
 
 /* Draw scrollbars in the given 2d-region */
-void UI_view2d_draw_scrollers(const bContext *C, View2D *v2d, View2DScrollers *scrollers, int flag)
+void UI_view2d_draw_scrollers(const bContext *C, View2D *v2d, View2DScrollers *scrollers)
 {
 	const int darker= -40, dark= 0, light= 20, lighter= 50;
 	rcti vert, hor;
@@ -766,8 +766,7 @@
 		// XXX will need to update the font drawing when the new stuff comes in
 		if (v2d->scroll & HOR_SCROLLGRID) {
 			View2DGrid *grid= scrollers->grid;
-			float fac, dfac, fac2;
-			int val;
+			float fac, dfac, fac2, val;
 			
 			/* the numbers: convert grid->startx and -dx to scroll coordinates 
 			 *	- fac is x-coordinate to draw to
@@ -777,8 +776,9 @@
 			fac= hor.xmin + fac*(hor.xmax - hor.xmin);
 			
 			dfac= (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin);
-			dfac= dfac*(hor.xmax-hor.xmin);
+			dfac= dfac * (hor.xmax - hor.xmin);
 			
+			/* set starting value, and text color */
 			UI_ThemeColor(TH_TEXT);
 			val= grid->startx;
 			
@@ -828,7 +828,7 @@
 		
 		/* decoration outer bevel line */
 		UI_ThemeColorShade(TH_SHADE1, lighter);
-		if (v2d->scroll & B_SCROLL)
+		if (v2d->scroll & (B_SCROLL|B_SCROLLO))
 			sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
 		else if (v2d->scroll & T_SCROLL)
 			sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
@@ -857,14 +857,41 @@
 		/* scale indiators */
 		// XXX will need to update the font drawing when the new stuff comes in
 		if (v2d->scroll & VERT_SCROLLGRID) {
+			View2DGrid *grid= scrollers->grid;
+			float fac, dfac, val;
 			
+			/* the numbers: convert grid->starty and dy to scroll coordinates 
+			 *	- fac is y-coordinate to draw to
+			 *	- dfac is gap between scale markings
+			 *	- these involve a correction for horizontal scrollbar
+			 *	  NOTE: it's assumed that that scrollbar is there if this is involved!
+			 */
+			fac= (grid->starty- v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+			fac= (vert.ymin + SCROLLH) + fac*(vert.ymax - vert.ymin - SCROLLH);
+			
+			dfac= (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin);
+			dfac= dfac * (vert.ymax - vert.ymin - SCROLLH);
+			
+			/* set starting value, and text color */
+			UI_ThemeColor(TH_TEXT);
+			val= grid->starty;
+			
+			/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */
+			// XXX only relevant to Sequencer, so need to review this when we port that code
+			if (scrollers->yclamp == V2D_GRID_CLAMP)
+				fac += 0.5f * dfac;
+				
+			/* draw vertical steps */
+			for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
+				scroll_printstr(scrollers, (float)(vert.xmax)-14.0, fac, val, grid->powery, scrollers->yunits, 'v');
+			}			
 		}	
 		
 		/* decoration outer bevel line */
 		UI_ThemeColorShade(TH_SHADE1, lighter);
 		if (v2d->scroll & R_SCROLL)
 			sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax);
-		else 
+		else if (v2d->scroll & L_SCROLL)
 			sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
 	}
 }

Modified: branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c	2008-12-04 02:01:42 UTC (rev 17710)
+++ branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c	2008-12-04 05:37:55 UTC (rev 17711)
@@ -348,8 +348,8 @@
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	// XXX width should be depend on max length of items (like height)...
-	awidth= width= ar->winrct.xmax - ar->winrct.xmin;
-	aheight= height= ar->winrct.ymax - ar->winrct.ymin;
+	awidth= width= ar->winrct.xmax - ar->winrct.xmin + 1;
+	aheight= height= ar->winrct.ymax - ar->winrct.ymin + 1;
 	
 	UI_view2d_update_size(v2d, awidth, aheight);
 	
@@ -394,6 +394,7 @@
 
 	if ((rows*ROW_HEIGHT) > height)
 		height= rows * ROW_HEIGHT;
+	width= (cols + 1) * COLUMN_WIDTH;
 	
 	/* need to validate view2d after updating size of tot */
 	v2d->tot.xmin= 0;
@@ -423,8 +424,8 @@
 	UI_view2d_view_restore(C);
 	
 	/* scrollers */
-	scrollers= UI_view2d_calc_scrollers(C, v2d, 0, 0, 0, 0); // XXX last two vars here are useless
-	UI_view2d_draw_scrollers(C, v2d, scrollers, (0));
+	scrollers= UI_view2d_calc_scrollers(C, v2d, 0, 0, 0, 0);
+	UI_view2d_draw_scrollers(C, v2d, scrollers);
 	UI_view2d_free_scrollers(scrollers);
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/space_time.c	2008-12-04 02:01:42 UTC (rev 17710)
+++ branches/blender2.5/blender/source/blender/editors/space_time/space_time.c	2008-12-04 05:37:55 UTC (rev 17711)
@@ -119,10 +119,11 @@
 	View2DScrollers *scrollers;
 	float col[3];
 	int unit, winx, winy;
-
-	winx= ar->winrct.xmax-ar->winrct.xmin;
-	winy= ar->winrct.ymax-ar->winrct.ymin;
 	
+	// XXX this should become stored in regions too...
+	winx= ar->winrct.xmax - ar->winrct.xmin + 1;
+	winy= ar->winrct.ymax - ar->winrct.ymin + 1;
+	
 	UI_view2d_update_size(v2d, winx, winy);
 
 	/* clear and setup matrix */
@@ -153,7 +154,7 @@
 	
 	/* scrollers */
 	scrollers= UI_view2d_calc_scrollers(C, v2d, unit, V2D_GRID_CLAMP, 0, 0);
-	UI_view2d_draw_scrollers(C, v2d, scrollers, (0));
+	UI_view2d_draw_scrollers(C, v2d, scrollers);
 	UI_view2d_free_scrollers(scrollers);
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c	2008-12-04 02:01:42 UTC (rev 17710)
+++ branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c	2008-12-04 05:37:55 UTC (rev 17711)
@@ -39,6 +39,7 @@
 #include "BLI_blenlib.h"
 
 #include "BKE_global.h"
+#include "BKE_utildefines.h"
 
 #include "UI_interface.h"
 #include "UI_view2d.h"
@@ -175,16 +176,46 @@
 	prop= RNA_def_property(ot->srna, "frame", PROP_INT, PROP_NONE);
 }
 
+/* ****************** time display toggle operator ****************************/
+
+static int toggle_time_exec(bContext *C, wmOperator *op)
+{
+	SpaceTime *stime;
+	
+	if (ELEM(NULL, C->area, C->area->spacedata.first))
+		return OPERATOR_CANCELLED;
+	
+	/* simply toggle draw frames flag for now */
+	// XXX in past, this displayed menu to choose... (for later!)
+	stime= C->area->spacedata.first;
+	stime->flag ^= TIME_DRAWFRAMES;
+	
+	return OPERATOR_FINISHED;
+}
+
+void ED_TIME_OT_toggle_time(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Toggle Frames/Seconds";
+	ot->idname= "ED_TIME_OT_toggle_time";
+	
+	/* api callbacks */
+	ot->exec= toggle_time_exec;
+}
+
 /* ************************** registration **********************************/
 
 void time_operatortypes(void)
 {
 	WM_operatortype_append(ED_TIME_OT_change_frame);
+	WM_operatortype_append(ED_TIME_OT_toggle_time);
 }
 
 void time_keymap(wmWindowManager *wm)
 {
 	WM_keymap_verify_item(&wm->timekeymap, "ED_TIME_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
+	WM_keymap_verify_item(&wm->timekeymap, "ED_TIME_OT_toggle_time", TKEY, KM_PRESS, 0, 0);
+	
 
 	/* markers (XXX move to function?) */
 	WM_keymap_verify_item(&wm->timekeymap, "ED_MARKER_OT_add", MKEY, KM_PRESS, 0, 0);




More information about the Bf-blender-cvs mailing list