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

Ton Roosendaal ton at blender.org
Wed Mar 25 17:58:42 CET 2009


Revision: 19410
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19410
Author:   ton
Date:     2009-03-25 17:58:42 +0100 (Wed, 25 Mar 2009)

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

WIP commit for new system to draw widgets and use themes or styles.

Not really interesting stuff to see in code now, the current 
structure will change quite a lot, this to make it hook up well
to the existing system.

What works quite well is a new full opengl vector method to draw 
scalable and pixel-aligned anti-aliased buttons.

http://download.blender.org/institute/rt3.jpg
http://download.blender.org/institute/rt4.jpg

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    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_layout.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_subwindow.c

Added Paths:
-----------
    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-03-25 14:42:47 UTC (rev 19409)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-03-25 16:58:42 UTC (rev 19410)
@@ -86,6 +86,7 @@
 #define UI_BLOCK_MOVEMOUSE_QUIT	128
 #define UI_BLOCK_KEEP_OPEN		256
 #define UI_BLOCK_POPUP			512
+#define UI_BLOCK_2_50			1024	/* XXX 2.5 migration flag */
 
 /* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL	1       /* cancel all menus cascading */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-03-25 14:42:47 UTC (rev 19409)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-03-25 16:58:42 UTC (rev 19410)
@@ -450,8 +450,8 @@
 	
 	/* get the colour and divide up the alpha */
 	glGetFloatv(GL_CURRENT_COLOR, color);
-	alpha = color[3];
-	color[3]= alpha/(float)passes;
+	alpha = 1; //color[3];
+	color[3]= 0.5*alpha/(float)passes;
 	glColor4fv(color);
 	
 	/* set the 'jitter amount' */
@@ -630,7 +630,7 @@
 /* icons have been standardized... and this call draws in untransformed coordinates */
 #define ICON_HEIGHT		16.0f
 
-static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
+void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
 {
 	float xs=0, ys=0, aspect, height;
 
@@ -929,8 +929,8 @@
 	int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
 	
 	/* emboss */
-	glColor4f(1.0f, 1.0f, 1.0f, 0.08f);
-	uiRoundRectFakeAA(x1+1, y1-1, x2, y2-1, rad, asp);
+	//glColor4f(1.0f, 1.0f, 1.0f, 0.08f);
+	//uiRoundRectFakeAA(x1+1, y1-1, x2, y2-1, rad, asp);
 	
 	/* colour shading */
 	if(flag & UI_SELECT) {
@@ -2205,7 +2205,7 @@
 #define BUT_TEXT_NORMAL	0
 #define BUT_TEXT_SUNKEN	1
 
-static void ui_draw_text(uiBut *but, float x, float y, int sunken)
+void ui_draw_text(uiBut *but, float x, float y, int sunken)
 {
 	int alpha_offs= (but->flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
 	int transopts;
@@ -2270,7 +2270,7 @@
 }
 
 /* draws text and icons for buttons */
-static void ui_draw_text_icon(uiBut *but)
+void ui_draw_text_icon(uiBut *but)
 {
 	float x, y;
 	short t, pos, ch;
@@ -3242,13 +3242,14 @@
 	int type;
 	
 	if(but==NULL) return;
+	
+	if(but->block->flag & UI_BLOCK_2_50) {
+		extern void ui_draw_but_new(ARegion *ar, uiBut *but); // XXX
 
-	/* XXX 2.50 no frontbuffer drawing allowed */
-#if 0
-	/* signal for frontbuf flush buttons and menus, not when normal drawing */
-	if(but->block->in_use) ui_block_set_flush(but->block, but);
-#endif
-		
+		ui_draw_but_new(ar, but);
+		return;
+	}
+
 	switch (but->type) {
 
 	case NUMSLI:

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-03-25 14:42:47 UTC (rev 19409)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h	2009-03-25 16:58:42 UTC (rev 19410)
@@ -55,7 +55,7 @@
 #define UI_MOUSE_OVER	2
 #define UI_ACTIVE		4
 #define UI_HAS_ICON		8
-/* warn: rest of uiBut->flag in BIF_interface.c */
+/* warn: rest of uiBut->flag in UI_interface.h */
 
 /* internal panel drawing defines */
 #define PNL_GRID	4
@@ -334,6 +334,9 @@
 extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
 extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight);
 
+void ui_draw_icon(uiBut *but, BIFIconID icon, int blend);
+void ui_draw_text(uiBut *but, float x, float y, int sunken);
+
 /* interface_handlers.c */
 extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-03-25 14:42:47 UTC (rev 19409)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-03-25 16:58:42 UTC (rev 19410)
@@ -846,6 +846,9 @@
 
 	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)

Added: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-03-25 16:58:42 UTC (rev 19410)
@@ -0,0 +1,1046 @@
+/**
+* ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_ID.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BLI_arithb.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
+
+#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 "UI_interface.h"
+#include "UI_interface_icons.h"
+#include "UI_resources.h"
+#include "UI_text.h"
+#include "UI_view2d.h"
+
+#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"
+#endif
+
+#include "interface_intern.h"
+
+/* ************** widget base functions ************** */
+/*
+     - in: roundbox codes for corner types and radius
+     - return: array of [size][2][x,y] points, the edges of the roundbox, + UV coords
+ 
+     - draw black box with alpha 0 on exact button boundbox
+     - for ever AA step:
+        - draw the inner part for a round filled box, with color blend codes or texture coords
+        - draw outline in outline color
+        - draw outer part, bottom half, extruded 1 pixel to bottom, for emboss shadow
+        - draw extra decorations
+     - draw background color box with alpha 1 on exact button boundbox
+ 
+ */
+
+/* fill this struct with polygon info to draw AA'ed */
+/* it has outline, back, and two optional tria meshes */
+
+typedef struct uiWidgetTrias {
+	int tot;
+	
+	float vec[32][2];
+	int (*index)[3];
+	
+} uiWidgetTrias;
+
+typedef struct uiWidgetColors {
+	float outline[3];
+	float inner[3];
+	float inner_sel[3];
+	float item[3];
+	float text[3];
+	float text_sel[3];
+	short shaded;
+	float shadetop, shadedown;
+	
+} uiWidgetColors;
+
+typedef struct uiWidgetBase {
+	
+	int totvert, halfwayvert;
+	float outer_v[64][2];
+	float inner_v[64][2];
+	float inner_uv[64][2];
+	
+	uiWidgetTrias tria1;
+	uiWidgetTrias tria2;
+	
+} uiWidgetBase;
+
+
+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}};
+
+static float jit[8][2]= {{0.468813 , -0.481430}, {-0.155755 , -0.352820}, 
+{0.219306 , -0.238501},  {-0.393286 , -0.110949}, {-0.024699 , 0.013908}, 
+{0.343805 , 0.147431}, {-0.272855 , 0.269918}, {0.095909 , 0.388710}};
+
+static float num_tria_vert[19][2]= {
+{0.382684, 0.923879}, {0.000001, 1.000000}, {-0.382683, 0.923880}, {-0.707107, 0.707107},
+{-0.923879, 0.382684}, {-1.000000, 0.000000}, {-0.923880, -0.382684}, {-0.707107, -0.707107},
+{-0.382683, -0.923880}, {0.000000, -1.000000}, {0.382684, -0.923880}, {0.707107, -0.707107},
+{0.923880, -0.382684}, {1.000000, -0.000000}, {0.923880, 0.382683}, {0.707107, 0.707107}, 
+{-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.729843, -0.008353}};
+
+static int num_tria_face[19][3]= {
+{13, 14, 18}, {17, 5, 6}, {12, 13, 18}, {17, 6, 7}, {15, 18, 14}, {16, 4, 5}, {16, 5, 17}, {18, 11, 12}, 
+{18, 17, 10}, {18, 10, 11}, {17, 9, 10}, {15, 0, 18}, {18, 0, 16}, {3, 4, 16}, {8, 9, 17}, {8, 17, 7}, 
+{2, 3, 16}, {1, 2, 16}, {16, 0, 1}};
+
+static float menu_tria_vert[6][2]= {
+{-0.41, 0.16}, {0.41, 0.16}, {0, 0.82}, 
+{0, -0.82}, {-0.41, -0.16}, {0.41, -0.16}};
+
+static int menu_tria_face[2][3]= {{2, 0, 1}, {3, 5, 4}};
+
+static float check_tria_vert[6][2]= {
+{-0.578579, 0.253369}, 	{-0.392773, 0.412794}, 	{-0.004241, -0.328551}, 
+{-0.003001, 0.034320}, 	{1.055313, 0.864744}, 	{0.866408, 1.026895}};
+
+static int check_tria_face[4][3]= {
+{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}};
+
+
+
+static void widget_init(uiWidgetBase *wt)
+{
+	wt->totvert= wt->halfwayvert= 0;
+	wt->tria1.tot= 0;
+	wt->tria2.tot= 0;
+}
+
+
+static void round_box_edges(uiWidgetBase *wt, int roundboxtype, rcti *rect, float rad)
+{
+	float vec[9][2], veci[9][2];
+	float minx= rect->xmin, miny= rect->ymin, maxx= rect->xmax, maxy= rect->ymax;
+	float radi= rad - 1.0f; /* rad inner */
+	float minxi= minx + 1.0f; /* boundbox inner */
+	float maxxi= maxx - 1.0f;
+	float minyi= miny + 1.0f;
+	float maxyi= maxy - 1.0f;
+	float facxi= 1.0f/(maxxi-minxi); /* for uv */
+	float facyi= 1.0f/(maxyi-minyi);
+	int a, tot= 0;
+	
+	/* mult */
+	for(a=0; a<9; a++) {
+		veci[a][0]= radi*cornervec[a][0]; 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list