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

Ton Roosendaal ton at blender.org
Thu Apr 2 17:01:12 CEST 2009


Revision: 19504
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19504
Author:   ton
Date:     2009-04-02 17:01:11 +0200 (Thu, 02 Apr 2009)

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

Some more work on UI drawing code, added a generic structure
for how widgets will be defined. It's still a wrapper on top
of old buttons. Docs follow still.

Some visual improvements;

- more button types supported (check render buttons)
- pressed state is shown
- better 'panel' triangle AA, and new divider style

Still a lot of work here. I expect the next days/weeks to
be much more coding too, had to catch up with a lot of other
Blender stuff. There's more (excitement) going on than code. :)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-02 14:38:40 UTC (rev 19503)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-02 15:01:11 UTC (rev 19504)
@@ -110,26 +110,28 @@
 #define UI_PNL_UNSTOW	256
 #define UI_PNL_SCALE	512
 
-/* warning the first 4 flags are internal */
+/* warning the first 6 flags are internal */
 /* but->flag */
-#define UI_TEXT_LEFT	16
-#define UI_ICON_LEFT	32
-#define UI_ICON_RIGHT	64
+#define UI_TEXT_LEFT	64
+#define UI_ICON_LEFT	128
+#define UI_ICON_RIGHT	256
 	/* control for button type block */
-#define UI_MAKE_TOP		128
-#define UI_MAKE_DOWN	256
-#define UI_MAKE_LEFT	512
-#define UI_MAKE_RIGHT	1024
-	/* dont draw hilite on mouse over */
-#define UI_NO_HILITE	2048
+#define UI_MAKE_TOP		512
+#define UI_MAKE_DOWN	1024
+#define UI_MAKE_LEFT	2048
+#define UI_MAKE_RIGHT	4096
+
 	/* button align flag, for drawing groups together */
-#define UI_BUT_ALIGN		(15<<12)
-#define UI_BUT_ALIGN_TOP	(1<<12)
-#define UI_BUT_ALIGN_LEFT	(1<<13)
-#define UI_BUT_ALIGN_RIGHT	(1<<14)
-#define UI_BUT_ALIGN_DOWN	(1<<15)
-#define UI_BUT_DISABLED		(1<<16)
+#define UI_BUT_ALIGN		(15<<14)
+#define UI_BUT_ALIGN_TOP	(1<<14)
+#define UI_BUT_ALIGN_LEFT	(1<<15)
+#define UI_BUT_ALIGN_RIGHT	(1<<16)
+#define UI_BUT_ALIGN_DOWN	(1<<17)
 
+#define UI_BUT_DISABLED		(1<<18)
+/* dont draw hilite on mouse over */
+#define UI_NO_HILITE		(1<<19)
+
 /* Button types, bits stored in 1 value... and a short even!
 - bits 0-4:  bitnr (0-31)
 - bits 5-7:  pointer type

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-02 14:38:40 UTC (rev 19503)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-04-02 15:01:11 UTC (rev 19504)
@@ -55,6 +55,8 @@
 #define UI_MOUSE_OVER	2
 #define UI_ACTIVE		4
 #define UI_HAS_ICON		8
+#define UI_TEXTINPUT	16
+
 /* warn: rest of uiBut->flag in UI_interface.h */
 
 /* internal panel drawing defines */
@@ -344,5 +346,8 @@
 /* interface_handlers.c */
 extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
 
+/* interface_widgets.c */
+void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
+
 #endif
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-04-02 14:38:40 UTC (rev 19503)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-04-02 15:01:11 UTC (rev 19504)
@@ -871,8 +871,6 @@
 	if(x) *x= layout->x;
 	if(y) *y= layout->y;
 	
-	/* XXX temp, migration flag for drawing code */
-	uiBlockSetFlag(block, UI_BLOCK_2_50);
 }
 
 void ui_layout_free(uiLayout *layout)
@@ -941,6 +939,10 @@
 
 		if(pt->draw && (!pt->poll || pt->poll(C))) {
 			block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS, UI_HELV);
+			
+			/* XXX temp, migration flag for drawing code */
+			uiBlockSetFlag(block, UI_BLOCK_2_50);
+			
 			w= (ar->type->minsizex)? ar->type->minsizex-22: UI_PANEL_WIDTH-22;
 
 			if(uiNewPanel(C, ar, block, pt->name, pt->name, x, y, w, 0)) {

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-04-02 14:38:40 UTC (rev 19503)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-04-02 15:01:11 UTC (rev 19504)
@@ -453,37 +453,14 @@
 	return block;
 }
 
-static void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
-{
-	// we draw twice, anti polygons not widely supported...
-	glBegin(GL_POLYGON);
-	glVertex2f(x1, y1);
-	glVertex2f(x2, y2);
-	glVertex2f(x3, y3);
-	glEnd();
-	
-	/* set antialias line */
-	glEnable( GL_LINE_SMOOTH );
-	glEnable( GL_BLEND );
-
-	glBegin(GL_LINE_LOOP);
-	glVertex2f(x1, y1);
-	glVertex2f(x2, y2);
-	glVertex2f(x3, y3);
-	glEnd();
-	
-	glDisable( GL_LINE_SMOOTH );
-	glDisable( GL_BLEND );
-}
-
 /* triangle 'icon' for panel header */
 void ui_draw_tria_icon(float x, float y, float aspect, char dir)
 {
 	if(dir=='h') {
-		ui_draw_anti_tria( x, y+1, x, y+10.0, x+8, y+6.25);
+		ui_draw_anti_tria( x-1, y, x-1, y+11.0, x+9, y+6.25);
 	}
 	else {
-		ui_draw_anti_tria( x-2, y+9,  x+8-2, y+9, x+4.25-2, y+1);	
+		ui_draw_anti_tria( x-3, y+10,  x+8-1, y+10, x+4.25-2, y);	
 	}
 }
 
@@ -679,7 +656,7 @@
 	glDisable(GL_BLEND);
 }
 
-void ui_draw_panel(ARegion *ar, uiBlock *block)
+static void ui_draw_panel_old(ARegion *ar, uiBlock *block)
 {
 	Panel *panel= block->panel;
 	int ofsx;
@@ -860,6 +837,108 @@
 		ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+5, block->aspect, 'v');
 }
 
+/* XXX has follow style definitions still */
+static void ui_draw_panel_style(ARegion *ar, uiBlock *block)
+{
+	Panel *panel= block->panel;
+	int ofsx;
+	char *panelname= panel->drawname[0]?panel->drawname:panel->panelname;
+	
+	if(panel->paneltab) return;
+	
+	/* divider */
+	if(panel->prev) {
+		float minx= block->minx+10;
+		float maxx= block->maxx-10;
+		float y= block->maxy + PNL_HEADER;
+		
+		glEnable(GL_BLEND);
+		glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
+		fdrawline(minx, y, maxx, y);
+		glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
+		fdrawline(minx, y-block->aspect, maxx, y-block->aspect);
+		glDisable(GL_BLEND);
+	}
+	
+	/* title */
+	if(!(panel->flag & PNL_CLOSEDX)) {
+		ofsx= PNL_ICON+8;
+		if(panel->control & UI_PNL_CLOSE) ofsx+= PNL_ICON;
+		UI_ThemeColor(TH_TEXT);
+		ui_rasterpos_safe(4+block->minx+ofsx, block->maxy+2, block->aspect);
+		UI_DrawString(block->curfont, panelname, ui_translate_buttons());
+	}
+	
+	/* if the panel is minimized vertically:
+		* (------)
+		*/
+	if(panel->flag & PNL_CLOSEDY) {
+		
+		
+		/* if it's being overlapped by a panel being dragged */
+		if(panel->flag & PNL_OVERLAP) {
+			UI_ThemeColor(TH_TEXT_HI);
+			uiRoundRect(block->minx, block->maxy, block->maxx, block->maxy+PNL_HEADER, 8);
+		}
+		
+	}
+	else if(panel->flag & PNL_CLOSEDX) {
+		
+	}
+	/* an open panel */
+	else {
+		
+		/* in some occasions, draw a border */
+		if(panel->flag & PNL_SELECT) {
+			if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
+			else uiSetRoundBox(3);
+			
+			UI_ThemeColorShade(TH_HEADER, -120);
+			uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
+		}
+		if(panel->flag & PNL_OVERLAP) {
+			if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
+			else uiSetRoundBox(3);
+			
+			UI_ThemeColor(TH_TEXT_HI);
+			uiRoundRect(block->minx, block->miny, block->maxx, block->maxy+PNL_HEADER, 8);
+		}
+		
+		if(panel->control & UI_PNL_SCALE)
+			ui_draw_panel_scalewidget(block);
+	}
+	
+	/* draw optional close icon */
+	
+	ofsx= 6;
+	if(panel->control & UI_PNL_CLOSE) {
+		
+		ui_draw_x_icon(block->minx+2+ofsx, block->maxy+2);
+		ofsx= 22;
+	}
+	
+	/* draw collapse icon */
+	UI_ThemeColor(TH_TEXT);
+	
+	if(panel->flag & PNL_CLOSEDY)
+		ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+1, block->aspect, 'h');
+	else if(panel->flag & PNL_CLOSEDX)
+		ui_draw_tria_icon(block->minx+7, block->maxy+1, block->aspect, 'h');
+	else
+		ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+1, block->aspect, 'v');
+	
+	
+}
+
+
+void ui_draw_panel(ARegion *ar, uiBlock *block)
+{
+	if(block->flag & UI_BLOCK_2_50)
+		ui_draw_panel_style(ar, block);
+	else
+		ui_draw_panel_old(ar, block);
+}
+
 /* ------------ panel alignment ---------------- */
 
 

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-02 14:38:40 UTC (rev 19503)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-04-02 15:01:11 UTC (rev 19504)
@@ -119,6 +119,57 @@
 } uiWidgetBase;
 
 
+typedef enum {
+	/* standard set */
+	UI_WTYPE_TOGGLE,
+	UI_WTYPE_OPTION,
+	UI_WTYPE_RADIO,
+	UI_WTYPE_NUMBER,
+	UI_WTYPE_SLIDER,
+	UI_WTYPE_EXEC,
+	
+	/* strings */
+	UI_WTYPE_NAME,
+	UI_WTYPE_NAME_LINK,
+	UI_WTYPE_POINTER_LINK,
+	UI_WTYPE_FILENAME,
+	
+	/* menus */
+	UI_WTYPE_MENU_RADIO,
+	UI_WTYPE_MENU_POINTER_LINK,
+	
+	UI_WTYPE_PULLDOWN,
+	UI_WTYPE_MENU_ITEM,
+	
+	/* specials */
+	UI_WTYPE_ICON,
+	UI_WTYPE_SWATCH,
+	UI_WTYPE_RGB_PICKER,
+	UI_WTYPE_NORMAL
+	
+} uiWidgetTypeEnum;
+
+
+/* uiWidgetType: for time being only for visual appearance,
+   later, a handling callback can be added too 
+*/
+typedef struct uiWidgetType {
+	
+	/* pointer to theme color definition */
+	uiWidgetColors *wcol_theme;
+	
+	/* converted colors for state */
+	uiWidgetColors wcol;
+	
+	void (*state)(struct uiWidgetType *, int state);
+	void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
+	void (*text)(uiBut *, rcti *, float *col);
+	
+} uiWidgetType;
+
+
+/* *********************** draw data ************************** */
+
 static float cornervec[9][2]= {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, 
 {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}};
 
@@ -151,8 +202,35 @@
 static int check_tria_face[4][3]= {
 {3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}};
 
+/* ************************************************* */
 
+void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
+{
+	float color[4];
+	int j;
+	
+	glEnable(GL_BLEND);
+	glGetFloatv(GL_CURRENT_COLOR, color);
+	color[3]= 0.125;
+	glColor4fv(color);
+	
+	/* for each AA step */
+	for(j=0; j<8; j++) {
+		glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f);
 
+		glBegin(GL_POLYGON);
+		glVertex2f(x1, y1);
+		glVertex2f(x2, y2);
+		glVertex2f(x3, y3);
+		glEnd();
+		
+		glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f);
+	}
+
+	glDisable(GL_BLEND);
+	
+}
+
 static void widget_init(uiWidgetBase *wt)
 {
 	wt->totvert= wt->halfwayvert= 0;
@@ -161,7 +239,7 @@
 }
 
 
-static void round_box_edges(uiWidgetBase *wt, int roundboxtype, rcti *rect, float rad)
+static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad)
 {
 	float vec[9][2], veci[9][2];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list