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

Ton Roosendaal ton at blender.org
Fri Apr 3 18:26:03 CEST 2009


Revision: 19522
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19522
Author:   ton
Date:     2009-04-03 18:26:03 +0200 (Fri, 03 Apr 2009)

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

Next part of UI drawing migration coding.

Now all calls go via the new wrapper; apart from some special types
(Colorband, HSV picking, Curve, Normal) they draw OK.

Also added new menu system, nicer shadow, and using same AA code.
Used dark theme suggestion from William btw. Don't get afraid, it'll all
be tweakable. :)

Next steps:
- move over all special button types
- make external calls for AA draw (nodes for example)
- remove old draw code
- make new colors save in theme

I also have to check on how to treat icons in buttons; this is a bit
cumbersome in cases.

Then the layout system comes back on agenda, will go over this with 
Brecht tomorrow.

So; all WIP, be patient!

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-03 15:08:38 UTC (rev 19521)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-03 16:26:03 UTC (rev 19522)
@@ -656,7 +656,7 @@
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	
 	if(block->flag & UI_BLOCK_LOOP)
-		uiDrawMenuBox(block->minx, block->miny, block->maxx, block->maxy, block->flag, block->direction);
+		ui_draw_menu_back(block);
 	else if(block->panel)
 		ui_draw_panel(ar, block);
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-04-03 15:08:38 UTC (rev 19521)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-04-03 16:26:03 UTC (rev 19522)
@@ -2423,122 +2423,7 @@
 	}
 }
 
-/* draws in resolution of 20x4 colors */
-static void ui_draw_but_HSVCUBE(uiBut *but)
-{
-	int a;
-	float h,s,v;
-	float dx, dy, sx1, sx2, sy, x, y;
-	float col0[4][3];	// left half, rect bottom to top
-	float col1[4][3];	// right half, rect bottom to top
-	
-	h= but->hsv[0];
-	s= but->hsv[1];
-	v= but->hsv[2];
-	
-	/* draw series of gouraud rects */
-	glShadeModel(GL_SMOOTH);
-	
-	if(but->a1==0) {	// H and V vary
-		hsv_to_rgb(0.0, s, 0.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
-		hsv_to_rgb(0.0, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
-		hsv_to_rgb(0.0, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
-		hsv_to_rgb(0.0, s, 1.0,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		x= h; y= v;
-	}
-	else if(but->a1==1) {	// H and S vary
-		hsv_to_rgb(0.0, 0.0, v,   &col1[0][0], &col1[0][1], &col1[0][2]);
-		hsv_to_rgb(0.0, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
-		hsv_to_rgb(0.0, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
-		hsv_to_rgb(0.0, 1.0, v,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		x= h; y= s;
-	}
-	else if(but->a1==2) {	// S and V vary
-		hsv_to_rgb(h, 0.0, 0.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
-		hsv_to_rgb(h, 0.333, 0.0, &col1[1][0], &col1[1][1], &col1[1][2]);
-		hsv_to_rgb(h, 0.666, 0.0, &col1[2][0], &col1[2][1], &col1[2][2]);
-		hsv_to_rgb(h, 1.0, 0.0,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		x= v; y= s;
-	}
-	else {		// only hue slider
-		hsv_to_rgb(0.0, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
-		VECCOPY(col1[1], col1[0]);
-		VECCOPY(col1[2], col1[0]);
-		VECCOPY(col1[3], col1[0]);
-		x= h; y= 0.5;
-	}
-	
-	for(dx=0.0; dx<1.0; dx+= 0.05) {
-		// previous color
-		VECCOPY(col0[0], col1[0]);
-		VECCOPY(col0[1], col1[1]);
-		VECCOPY(col0[2], col1[2]);
-		VECCOPY(col0[3], col1[3]);
 
-		// new color
-		if(but->a1==0) {	// H and V vary
-			hsv_to_rgb(dx, s, 0.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
-			hsv_to_rgb(dx, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
-			hsv_to_rgb(dx, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
-			hsv_to_rgb(dx, s, 1.0,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		}
-		else if(but->a1==1) {	// H and S vary
-			hsv_to_rgb(dx, 0.0, v,   &col1[0][0], &col1[0][1], &col1[0][2]);
-			hsv_to_rgb(dx, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
-			hsv_to_rgb(dx, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
-			hsv_to_rgb(dx, 1.0, v,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		}
-		else if(but->a1==2) {	// S and V vary
-			hsv_to_rgb(h, 0.0, dx,   &col1[0][0], &col1[0][1], &col1[0][2]);
-			hsv_to_rgb(h, 0.333, dx, &col1[1][0], &col1[1][1], &col1[1][2]);
-			hsv_to_rgb(h, 0.666, dx, &col1[2][0], &col1[2][1], &col1[2][2]);
-			hsv_to_rgb(h, 1.0, dx,   &col1[3][0], &col1[3][1], &col1[3][2]);
-		}
-		else {	// only H
-			hsv_to_rgb(dx, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
-			VECCOPY(col1[1], col1[0]);
-			VECCOPY(col1[2], col1[0]);
-			VECCOPY(col1[3], col1[0]);
-		}
-		
-		// rect
-		sx1= but->x1 + dx*(but->x2-but->x1);
-		sx2= but->x1 + (dx+0.05)*(but->x2-but->x1);
-		sy= but->y1;
-		dy= (but->y2-but->y1)/3.0;
-		
-		glBegin(GL_QUADS);
-		for(a=0; a<3; a++, sy+=dy) {
-			glColor3fv(col0[a]);
-			glVertex2f(sx1, sy);
-
-			glColor3fv(col1[a]);
-			glVertex2f(sx2, sy);
-			
-			glColor3fv(col1[a+1]);
-			glVertex2f(sx2, sy+dy);
-			
-			glColor3fv(col0[a+1]);
-			glVertex2f(sx1, sy+dy);
-		}
-		glEnd();
-	}
-
-	glShadeModel(GL_FLAT);
-
-	/* cursor */
-	x= but->x1 + x*(but->x2-but->x1);
-	y= but->y1 + y*(but->y2-but->y1);
-	CLAMP(x, but->x1+3.0, but->x2-3.0);
-	CLAMP(y, but->y1+3.0, but->y2-3.0);
-	
-	fdrawXORcirc(x, y, 3.1);
-
-	/* outline */
-	glColor3ub(0,  0,  0);
-	fdrawbox((but->x1), (but->y1), (but->x2), (but->y2));
-}
-
 #ifdef INTERNATIONAL
 static void ui_draw_but_CHARTAB(uiBut *but)
 {
@@ -3243,7 +3128,7 @@
 	
 	if(but==NULL) return;
 	
-	if(but->block->flag & UI_BLOCK_2_50) {
+	if(1) {//but->block->flag & UI_BLOCK_2_50) {
 		extern void ui_draw_but_new(ARegion *ar, uiBut *but); // XXX
 
 		ui_draw_but_new(ar, but);
@@ -3278,7 +3163,7 @@
 		break;
 
 	case HSVCUBE:
-		ui_draw_but_HSVCUBE(but);  // box for colorpicker, three types
+		//ui_draw_but_HSVCUBE(but);  // box for colorpicker, three types
 		break;
 
 #ifdef INTERNATIONAL

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-04-03 15:08:38 UTC (rev 19521)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-04-03 16:26:03 UTC (rev 19522)
@@ -348,6 +348,7 @@
 
 /* interface_widgets.c */
 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
+void ui_draw_menu_back(uiBlock *block);
 
 #endif
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c	2009-04-03 15:08:38 UTC (rev 19521)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c	2009-04-03 16:26:03 UTC (rev 19522)
@@ -64,7 +64,7 @@
 #define MENU_BUTTON_HEIGHT	20
 #define MENU_SEPR_HEIGHT	6
 #define B_NOP              	-1
-#define MENU_SHADOW_LEFT	-1
+#define MENU_SHADOW_LEFT	-10
 #define MENU_SHADOW_BOTTOM	-10
 #define MENU_SHADOW_RIGHT	10
 #define MENU_SHADOW_TOP		1
@@ -701,6 +701,9 @@
 
 	/* get winmat now that we actually have the subwindow */
 	wmSubWindowSet(window, ar->swinid);
+			// XXX ton, AA pixel space...
+	wmOrtho2(0.0, (float)ar->winrct.xmax-ar->winrct.xmin+1, 0.0, (float)ar->winrct.ymax-ar->winrct.ymin+1);
+	
 	wm_subwindow_getmatrix(window, ar->swinid, block->winmat);
 	
 	/* notify change and redraw */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-04-03 15:08:38 UTC (rev 19521)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-04-03 16:26:03 UTC (rev 19522)
@@ -31,7 +31,6 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_ID.h"
-#include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
 
@@ -41,12 +40,10 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
-#include "BKE_idprop.h"
 #include "BKE_utildefines.h"
 
-#include "RNA_access.h"
-
 #include "BIF_gl.h"
+#include "BIF_glutil.h"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -56,11 +53,7 @@
 
 #include "ED_util.h"
 #include "ED_types.h"
-#include "ED_screen.h"
 
-#include "WM_api.h"
-#include "WM_types.h"
-
 #include "BMF_Api.h"
 #ifdef INTERNATIONAL
 #include "FTF_Api.h"
@@ -96,8 +89,8 @@
 
 typedef struct uiWidgetColors {
 	float outline[3];
-	float inner[3];
-	float inner_sel[3];
+	float inner[4];
+	float inner_sel[4];
 	float item[3];
 	float text[3];
 	float text_sel[3];
@@ -113,7 +106,7 @@
 	float inner_v[64][2];
 	float inner_uv[64][2];
 	
-	short inner, outline; /* set on/off */
+	short inner, outline, emboss; /* set on/off */
 	
 	uiWidgetTrias tria1;
 	uiWidgetTrias tria2;
@@ -142,6 +135,7 @@
 	
 	UI_WTYPE_PULLDOWN,
 	UI_WTYPE_MENU_ITEM,
+	UI_WTYPE_MENU_BACK,
 	
 	/* specials */
 	UI_WTYPE_ICON,
@@ -242,9 +236,93 @@
 	
 	wtb->inner= 1;
 	wtb->outline= 1;
+	wtb->emboss= 1;
 }
 
+/* helper call, makes shadow rect, with 'sun' above menu, so only shadow to left/right/bottom */
+/* return tot */
+static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int roundboxalign, int inner)
+{
+	float vec[9][2];
+	float minx, miny, maxx, maxy;
+	int a, tot= 0;
+	
+	if(inner) {
+		minx= rect->xmin;
+		miny= rect->ymin;
+		maxx= rect->xmax;
+		maxy= rect->ymax;
+	}
+	else {
+		minx= rect->xmin-rad;
+		miny= rect->ymin-rad;
+		maxx= rect->xmax+rad;
+		maxy= rect->ymax+rad;
+	}
+	
+	/* mult */
+	for(a=0; a<9; a++) {
+		vec[a][0]= rad*cornervec[a][0]; 
+		vec[a][1]= rad*cornervec[a][1]; 
+	}
+	
+	/* start with left-top, anti clockwise */
+	if(roundboxalign & 1) {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= minx+rad-vec[a][0];
+			vert[tot][1]= maxy-vec[a][1];
+		}
+	}
+	else {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= minx;
+			vert[tot][1]= maxy;
+		}
+	}
+	
+	if(roundboxalign & 8) {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= minx+vec[a][1];
+			vert[tot][1]= miny+rad-vec[a][0];
+		}
+	}
+	else {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= minx;
+			vert[tot][1]= miny;
+		}
+	}
+	
+	if(roundboxalign & 4) {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= maxx-rad+vec[a][0];
+			vert[tot][1]= miny+vec[a][1];
+		}
+	}
+	else {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= maxx;
+			vert[tot][1]= miny;
+		}
+	}
+	
+	if(roundboxalign & 2) {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= maxx-vec[a][1];
+			vert[tot][1]= maxy-rad+vec[a][0];
+		}
+	}
+	else {
+		for(a=0; a<9; a++, tot++) {
+			vert[tot][0]= maxx;
+			vert[tot][1]= maxy;
+		}
+	}
+	return tot;
+}
 
+
+
 static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad)
 {
 	float vec[9][2], veci[9][2];
@@ -422,7 +500,7 @@
 
 static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
 {
-	float centx, centy, size;
+	float centx, centy, size, asp;
 	int a;
 		
 	/* center position and size */
@@ -430,6 +508,11 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list