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

Ton Roosendaal ton at blender.org
Thu Jul 2 20:12:46 CEST 2009


Revision: 21321
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21321
Author:   ton
Date:     2009-07-02 20:12:46 +0200 (Thu, 02 Jul 2009)

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

Cleanup of scroller drawing in 2D windows.

Before:
http://download.blender.org/institute/rt11.jpg
After:
http://download.blender.org/institute/rt12.jpg

Will add 'zoom' widget circles later, as mockupped here:
http://www.reynish.com/files/blender25/fcurve_scrollbar.png

Also note the scale values are inside scroller; drawing it
on top conflicts with current frame item and markers.

Currently scroller disappear entirely when view is total.

For Joshua:
To make sliders behave nicely, the boundbox (v2d->tot) has to
be refreshed on each change. I've added it in graph drawing
now, but it could be notifier based I guess... not sure what
the correct anim api call would be. Can discuss tomorrow!

On todo:
Layout config hints so people can make scroller positions swap.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
    branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_edit.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_intern.h
    branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_view2d_types.h

Modified: branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/BLF_api.h	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/blenfont/BLF_api.h	2009-07-02 18:12:46 UTC (rev 21321)
@@ -79,6 +79,11 @@
 float BLF_height_default(char *str);
 
 /*
+ * set rotation for default font
+ */
+void BLF_default_rotation(float angle);
+
+/*
  * By default, rotation and clipping are disable and
  * have to be enable/disable using BLF_enable/disable.
  */

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf.c	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf.c	2009-07-02 18:12:46 UTC (rev 21321)
@@ -321,6 +321,19 @@
 	}
 }
 
+void BLF_default_rotation(float angle)
+{
+	
+	if (global_font_default>=0) {
+		global_font[global_font_default]->angle= angle;
+		if(angle)
+			global_font[global_font_default]->flags |= BLF_ROTATION;
+		else
+			global_font[global_font_default]->flags &= ~BLF_ROTATION;
+	}
+}
+
+
 void BLF_draw(char *str)
 {
 	FontBLF *font;

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c	2009-07-02 18:12:46 UTC (rev 21321)
@@ -165,7 +165,7 @@
 	glLineWidth(2.0);
 	
 	glBegin(GL_LINE_STRIP);
-		vec[1]= v2d->cur.ymin;
+		vec[1]= v2d->cur.ymin-500.0f;	/* XXX arbitrary... want it go to bottom */
 		glVertex2fv(vec);
 		
 		vec[1]= v2d->cur.ymax;

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2009-07-02 18:12:46 UTC (rev 21321)
@@ -97,9 +97,9 @@
 
 /* ------ Defines for Scrollers ----- */
 
-/* scroller thickness */
-#define V2D_SCROLL_HEIGHT	16
-#define V2D_SCROLL_WIDTH	16
+/* scroller area */
+#define V2D_SCROLL_HEIGHT	17
+#define V2D_SCROLL_WIDTH	17
 
 /* half the size (in pixels) of scroller 'handles' */
 #define V2D_SCROLLER_HANDLE_SIZE	5

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-07-02 18:12:46 UTC (rev 21321)
@@ -420,6 +420,7 @@
 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
 void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
 void ui_draw_link_bezier(rcti *rect);
+void widget_scroll_draw(struct uiWidgetColors *wcol, rcti *rect, rcti *slider, int state);
 
 extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
 		/* theme color init */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-07-02 18:12:46 UTC (rev 21321)
@@ -106,7 +106,7 @@
 	}
 	else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
 		return BUT_VERTICAL;
-	else if(ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS))
+	else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
 		return BUT_VERTICAL;
 	
 	return 0;

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-07-02 18:12:46 UTC (rev 21321)
@@ -527,7 +527,7 @@
 	coldown[0]= CLAMPIS(color[0]+shadedown, 0, 255);
 	coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255);
 	coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255);
-	coldown[3]= color[3];
+	coldown[3]= color[3];	
 }
 
 static void round_box_shade_col4(char *col1, char *col2, float fac)
@@ -1106,16 +1106,16 @@
 };
 
 static struct uiWidgetColors wcol_scroll= {
-	{25, 25, 25, 255},
+	{50, 50, 50, 180},
+	{80, 80, 80, 180},
+	{100, 100, 100, 180},
 	{180, 180, 180, 255},
-	{153, 153, 153, 255},
-	{90, 90, 90, 255},
 	
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
 	1,
-	0, -20
+	10, -20
 };
 
 /* free wcol struct to play with */
@@ -1206,6 +1206,10 @@
 	
 }
 
+static void widget_state_nothing(uiWidgetType *wt, int state)
+{
+	wt->wcol= *(wt->wcol_theme);
+}	
 
 /* special case, button that calls pulldown */
 static void widget_state_pulldown(uiWidgetType *wt, int state)
@@ -1634,44 +1638,64 @@
 	}
 }
 
-static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+/* function in use for buttons and for view2d sliders */
+void widget_scroll_draw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int state)
 {
 	uiWidgetBase wtb;
-	rcti rect1;
-	double value;
-	char inner[3];
-	float fac, size, rad;
+	float rad;
 	int horizontal;
 
+	widget_init(&wtb);
+
 	/* determine horizontal/vertical */
 	horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
-
+	
 	if(horizontal)
 		rad= 0.5f*(rect->ymax - rect->ymin);
 	else
 		rad= 0.5f*(rect->xmax - rect->xmin);
-
-	widget_init(&wtb);
+	
 	wtb.shadedir= (horizontal)? 1: 0;
-
+	
 	/* draw back part, colors swapped and shading inverted */
-	VECCOPY(inner, wcol->inner);
-	VECCOPY(wcol->inner, wcol->item);
 	if(horizontal)
 		SWAP(short, wcol->shadetop, wcol->shadedown);
-	if(state & UI_SELECT)
-		SWAP(short, wcol->shadetop, wcol->shadedown);
 	
-	round_box_edges(&wtb, roundboxalign, rect, rad); /* XXX vertical gradient is wrong */
+	round_box_edges(&wtb, 15, rect, rad); 
 	widgetbase_draw(&wtb, wcol);
+	
+	/* slider */
+	if(slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2);
+	else {
+		
+		SWAP(short, wcol->shadetop, wcol->shadedown);
+		
+		QUATCOPY(wcol->inner, wcol->item);
+		
+		if(wcol->shadetop>wcol->shadedown)
+			wcol->shadetop+= 20;	/* XXX violates themes... */
+		else wcol->shadedown+= 20;
+		
+		if(state & UI_SELECT)
+			SWAP(short, wcol->shadetop, wcol->shadedown);
 
-	VECCOPY(wcol->inner, inner);
-	if(horizontal)
-		SWAP(short, wcol->shadetop, wcol->shadedown);
-	if(state & UI_SELECT)
-		SWAP(short, wcol->shadetop, wcol->shadedown);
-	
-	/* front part */
+		/* draw */
+		wtb.emboss= 0; /* only emboss once */
+		
+		round_box_edges(&wtb, 15, slider, rad); 
+		widgetbase_draw(&wtb, wcol);
+		
+	}	
+}
+
+static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+	rcti rect1;
+	double value;
+	float fac, size;
+	int horizontal;
+
+	/* calculate slider part */
 	value= ui_get_but_val(but);
 
 	size= (but->softmax + but->a1 - but->softmin);
@@ -1680,6 +1704,9 @@
 	/* position */
 	rect1= *rect;
 
+	/* determine horizontal/vertical */
+	horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+	
 	if(horizontal) {
 		fac= (rect->xmax - rect->xmin)/(size);
 		rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin));
@@ -1691,17 +1718,8 @@
 		rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin));
 	}
 
-	/* draw */
-	wtb.emboss= 0; /* only emboss once */
+	widget_scroll_draw(wcol, rect, &rect1, state);
 
-	if(!horizontal)
-		SWAP(short, wcol->shadetop, wcol->shadedown);
-
-	round_box_edges(&wtb, roundboxalign, &rect1, rad); /* XXX vertical gradient is wrong */
-	widgetbase_draw(&wtb, wcol);
-
-	if(!horizontal)
-		SWAP(short, wcol->shadetop, wcol->shadedown);
 }
 
 static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
@@ -2103,6 +2121,7 @@
 
 		case UI_WTYPE_SCROLL:
 			wt.wcol_theme= &btheme->tui.wcol_scroll;
+			wt.state= widget_state_nothing;
 			wt.custom= widget_scroll;
 			break;
 	}

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2009-07-02 15:45:15 UTC (rev 21320)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2009-07-02 18:12:46 UTC (rev 21321)
@@ -34,6 +34,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_view2d_types.h"
 
 #include "BLI_blenlib.h"
@@ -901,7 +902,14 @@
 /* Restore view matrices after drawing */
 void UI_view2d_view_restore(const bContext *C)
 {
-	ED_region_pixelspace(CTX_wm_region(C));
+	ARegion *ar= CTX_wm_region(C);
+	int width= ar->winrct.xmax-ar->winrct.xmin+1;
+	int height= ar->winrct.ymax-ar->winrct.ymin+1;
+	
+	wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
+	wmLoadIdentity();
+	
+	//	ED_region_pixelspace(CTX_wm_region(C));
 }
 
 /* *********************************************************************** */
@@ -1198,7 +1206,10 @@
  * WARNING: the start of this struct must not change, as view2d_ops.c uses this too. 
  * 		   For now, we don't need to have a separate (internal) header for structs like this...
  */
-struct View2DScrollers {	
+struct View2DScrollers {
+	rcti hor, vert;			/* exact size of slider backdrop */
+	int horfull, vertfull;	/* set if sliders are full, we don't draw them */
+	
 		/* focus bubbles */
 	int vert_min, vert_max;	/* vertical scrollbar */
 	int hor_min, hor_max;	/* horizontal scrollbar */
@@ -1214,15 +1225,34 @@
 {
 	View2DScrollers *scrollers;
 	rcti vert, hor;
-	float fac, totsize, scrollsize;
+	float fac1, fac2, totsize, scrollsize;
 	int scroll= view2d_scroll_mapped(v2d->scroll);
 	
+	/* scrollers is allocated here... */
+	scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+	
 	vert= v2d->vert;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list