[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17498] branches/blender2.5/blender/source /blender/editors: Started work on an updated UI theme
Matt Ebb
matt at mke3.net
Wed Nov 19 04:15:53 CET 2008
Revision: 17498
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17498
Author: broken
Date: 2008-11-19 04:15:52 +0100 (Wed, 19 Nov 2008)
Log Message:
-----------
Started work on an updated UI theme
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
branches/blender2.5/blender/source/blender/editors/interface/resources.c
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_resources.h 2008-11-19 02:07:23 UTC (rev 17497)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_resources.h 2008-11-19 03:15:52 UTC (rev 17498)
@@ -531,10 +531,11 @@
/* XXX WARNING: previous is saved in file, so do not change order! */
/* theme drawtypes */
-#define TH_MINIMAL 0
-#define TH_SHADED 1
-#define TH_ROUNDED 2
-#define TH_OLDSKOOL 3
+#define TH_MINIMAL 0
+#define TH_ROUNDSHADED 1
+#define TH_ROUNDED 2
+#define TH_OLDSKOOL 3
+#define TH_SHADED 4
/* specific defines per space should have higher define values */
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2008-11-19 02:07:23 UTC (rev 17497)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2008-11-19 03:15:52 UTC (rev 17498)
@@ -134,6 +134,182 @@
glEnd();
}
+static void round_box_shade_col(float *col1, float *col2, float fac)
+{
+ float col[3];
+
+ col[0]= (fac*col1[0] + (1.0-fac)*col2[0]);
+ col[1]= (fac*col1[1] + (1.0-fac)*col2[1]);
+ col[2]= (fac*col1[2] + (1.0-fac)*col2[2]);
+
+ glColor3fv(col);
+}
+
+/* linear horizontal shade within button or in outline */
+void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
+{
+ float vec[7][2]= {{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}};
+ float div= maxy-miny;
+ float coltop[3], coldown[3], color[4];
+ int a;
+
+ /* mult */
+ for(a=0; a<7; a++) {
+ vec[a][0]*= rad; vec[a][1]*= rad;
+ }
+ /* get current color, needs to be outside of glBegin/End */
+ glGetFloatv(GL_CURRENT_COLOR, color);
+
+ /* 'shade' defines strength of shading */
+ coltop[0]= color[0]+shadetop; if(coltop[0]>1.0) coltop[0]= 1.0;
+ coltop[1]= color[1]+shadetop; if(coltop[1]>1.0) coltop[1]= 1.0;
+ coltop[2]= color[2]+shadetop; if(coltop[2]>1.0) coltop[2]= 1.0;
+ coldown[0]= color[0]+shadedown; if(coldown[0]<0.0) coldown[0]= 0.0;
+ coldown[1]= color[1]+shadedown; if(coldown[1]<0.0) coldown[1]= 0.0;
+ coldown[2]= color[2]+shadedown; if(coldown[2]<0.0) coldown[2]= 0.0;
+
+ if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) {
+ glShadeModel(GL_SMOOTH);
+ glBegin(mode);
+ }
+
+ /* start with corner right-bottom */
+ if(roundboxtype & 4) {
+
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( maxx-rad, miny);
+
+ for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, vec[a][1]/div);
+ glVertex2f( maxx-rad+vec[a][0], miny+vec[a][1]);
+ }
+
+ round_box_shade_col(coltop, coldown, rad/div);
+ glVertex2f( maxx, miny+rad);
+ }
+ else {
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( maxx, miny);
+ }
+
+ /* corner right-top */
+ if(roundboxtype & 2) {
+
+ round_box_shade_col(coltop, coldown, (div-rad)/div);
+ glVertex2f( maxx, maxy-rad);
+
+ for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div);
+ glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
+ }
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( maxx-rad, maxy);
+ }
+ else {
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( maxx, maxy);
+ }
+
+ /* corner left-top */
+ if(roundboxtype & 1) {
+
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( minx+rad, maxy);
+
+ for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, (div-vec[a][1])/div);
+ glVertex2f( minx+rad-vec[a][0], maxy-vec[a][1]);
+ }
+
+ round_box_shade_col(coltop, coldown, (div-rad)/div);
+ glVertex2f( minx, maxy-rad);
+ }
+ else {
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( minx, maxy);
+ }
+
+ /* corner left-bottom */
+ if(roundboxtype & 8) {
+
+ round_box_shade_col(coltop, coldown, rad/div);
+ glVertex2f( minx, miny+rad);
+
+ for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, (rad-vec[a][1])/div);
+ glVertex2f( minx+vec[a][1], miny+rad-vec[a][0]);
+ }
+
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( minx+rad, miny);
+ }
+ else {
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( minx, miny);
+ }
+
+ glEnd();
+ glShadeModel(GL_FLAT);
+}
+
+/* plain fake antialiased unfilled round rectangle */
+void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad, float asp)
+{
+ float color[4];
+ float raddiff;
+ int i, passes=4;
+
+ /* get the colour and divide up the alpha */
+ glGetFloatv(GL_CURRENT_COLOR, color);
+ color[3]= 1/(float)passes;
+ glColor4fv(color);
+
+ /* set the 'jitter amount' */
+ raddiff = (1/(float)passes) * asp;
+
+ glEnable( GL_BLEND );
+
+ /* draw lots of lines on top of each other */
+ for (i=passes; i>=(-passes); i--) {
+ gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad+(i*raddiff));
+ }
+
+ glDisable( GL_BLEND );
+}
+
+
+void uiTriangleFakeAA(float x1, float y1, float x2, float y2, float x3, float y3)
+{
+ float color[4];
+ float jitter;
+ int i, passes=4;
+
+ /* get the colour and divide up the alpha */
+ glGetFloatv(GL_CURRENT_COLOR, color);
+ color[3]= 1/(float)passes;
+ glColor4fv(color);
+
+ /* set the 'jitter amount' */
+ jitter = 1/(float)passes;
+
+ glEnable( GL_BLEND );
+
+ /* draw lots of lines on top of each other */
+ for (i=passes; i>=(-passes); i--) {
+ glBegin(GL_TRIANGLES);
+
+ /* 'point' first, then two base vertices */
+ glVertex2f(x1+(i*jitter), y1+(i*jitter));
+ glVertex2f(x2, y2+(i*jitter));
+ glVertex2f(x3, y3+(i*jitter));
+ glEnd();
+ }
+
+ glDisable( GL_BLEND );
+}
+
+
/* ************** safe rasterpos for pixmap alignment with pixels ************* */
void ui_rasterpos_safe(float x, float y, float aspect)
@@ -281,11 +457,6 @@
* One option is to hardcode to white, with alpha, however it causes a
* weird 'building up' efect, so it's commented out for now.
*/
-
-/*
-#define MM_WHITE_OP glColor4ub(255, 255, 255, 60)
-#define MM_WHITE_TR glColor4ub(255, 255, 255, 0)
- */
#define MM_WHITE_OP UI_ThemeColorShadeAlpha(TH_BACK, 55, -100)
#define MM_WHITE_TR UI_ThemeColorShadeAlpha(TH_BACK, 55, -255)
@@ -457,6 +628,58 @@
/* END OUTER OUTLINE */
}
+/* shaded round button */
+static void round_button_shaded(int type, int colorid, float asp, float x1, float y1, float x2, float y2, int flag, int rad)
+{
+ float shadefac;
+
+ /* colour shading */
+ if (flag & UI_SELECT) {
+ shadefac = -0.05;
+ if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, -40);
+ else UI_ThemeColorShade(colorid, -30);
+ } else {
+ shadefac = 0.05;
+ if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, +30);
+ else UI_ThemeColorShade(colorid, +20);
+ }
+ /* end colour shading */
+
+
+ /* the shaded base */
+ gl_round_box_shade(GL_POLYGON, x1, y1, x2, y2, rad, shadefac, -shadefac);
+
+ /* outline */
+ UI_ThemeColorBlendShade(TH_BUT_OUTLINE, TH_BACK, 0.1, -40);
+
+ uiRoundRectFakeAA(x1, y1, x2, y2, rad, asp);
+ /* end outline */
+}
+
+/* base round flat button */
+static void round_button_flat(int colorid, float asp, float x1, float y1, float x2, float y2, int flag, float rad)
+{
+ /* colour shading */
+ if(flag & UI_SELECT) {
+ if (flag & UI_ACTIVE) UI_ThemeColorShade(colorid, -20);
+ else UI_ThemeColorShade(colorid, -45);
+ }
+ else {
+ if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, 35);
+ else UI_ThemeColorShade(colorid, 25);
+ }
+ /* end colour shading */
+
+ /* the solid base */
+ gl_round_box(GL_POLYGON, x1, y1, x2, y2, rad);
+
+ /* outline */
+ UI_ThemeColorBlendShade(TH_BUT_OUTLINE, TH_BACK, 0.1, -30);
+
+ uiRoundRectFakeAA(x1, y1, x2, y2, rad, asp);
+ /* end outline */
+}
+
/* small side double arrow for iconrow */
static void ui_default_iconrow_arrows(float x1, float y1, float x2, float y2)
{
@@ -483,24 +706,14 @@
/* side double arrow for menu */
static void ui_default_menu_arrows(float x1, float y1, float x2, float y2)
{
- glEnable( GL_POLYGON_SMOOTH );
- glEnable( GL_BLEND );
+ /* 'point' first, then two base vertices */
+ uiTriangleFakeAA(x2-9, (y2-(y2-y1)/2)+6,
+ x2-6, (y2-(y2-y1)/2)+2,
+ x2-11, (y2-(y2-y1)/2)+2);
- glShadeModel(GL_FLAT);
- glBegin(GL_TRIANGLES);
- glVertex2f((short)x2-4,(short)(y2-(y2-y1)/2)+1);
- glVertex2f((short)x2-12,(short)(y2-(y2-y1)/2)+1);
- glVertex2f((short)x2-8,(short)(y2-(y2-y1)/2)+4);
- glEnd();
-
- glBegin(GL_TRIANGLES);
- glVertex2f((short)x2-4,(short)(y2-(y2-y1)/2) -1);
- glVertex2f((short)x2-12,(short)(y2-(y2-y1)/2) -1);
- glVertex2f((short)x2-8,(short)(y2-(y2-y1)/2) -4);
- glEnd();
-
- glDisable( GL_BLEND );
- glDisable( GL_POLYGON_SMOOTH );
+ uiTriangleFakeAA(x2-8, (y2-(y2-y1)/2)-6,
+ x2-6, (y2-(y2-y1)/2)-2,
+ x2-11, (y2-(y2-y1)/2)-2);
}
/* left/right arrows for number fields */
@@ -508,59 +721,312 @@
{
if( x2-x1 > 25) { // 25 is a bit arbitrary, but small buttons cant have arrows
- glEnable( GL_POLYGON_SMOOTH );
- glEnable( GL_BLEND );
-
- glShadeModel(GL_FLAT);
- glBegin(GL_TRIANGLES);
-
- glVertex2f((short)x1+5,(short)(y2-(y2-y1)/2));
- glVertex2f((short)x1+10,(short)(y2-(y2-y1)/2)+4);
- glVertex2f((short)x1+10,(short)(y2-(y2-y1)/2)-4);
- glEnd();
+ /* 'point' first, then two base vertices */
+ uiTriangleFakeAA(x1+4, y2-(y2-y1)/2,
+ x1+9, y2-(y2-y1)/2+3,
+ x1+9, y2-(y2-y1)/2-3);
- /* right */
- glShadeModel(GL_FLAT);
- glBegin(GL_TRIANGLES);
-
- glVertex2f((short)x2-5,(short)(y2-(y2-y1)/2));
- glVertex2f((short)x2-10,(short)(y2-(y2-y1)/2)-4);
- glVertex2f((short)x2-10,(short)(y2-(y2-y1)/2)+4);
- glEnd();
-
- glDisable( GL_BLEND );
- glDisable( GL_POLYGON_SMOOTH );
+ uiTriangleFakeAA(x2-4, y2-(y2-y1)/2,
+ x2-9, y2-(y2-y1)/2+3,
+ x2-9, y2-(y2-y1)/2-3);
}
}
+
/* changing black/white for TOG3 buts */
static void ui_tog3_invert(float x1, float y1, float x2, float y2, int seltype)
{
- short alpha = 30;
-
+
if (seltype == 0) {
- glEnable(GL_BLEND);
+ UI_ThemeColorShade(TH_BUT_SETTING, -120);
- glColor4ub(0, 0, 0, alpha);
- glRectf(x2-6, y1, x2, (y1+(y2-y1)/2));
+ glEnable( GL_LINE_SMOOTH );
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ glLineWidth(1.0);
- glColor4ub(255, 255, 255, alpha);
- glRectf(x2-6, (y1+(y2-y1)/2), x2, y2);
+ fdrawline(x1+10, (y1+(y2-y1)/2+4), x1+10, (y1+(y2-y1)/2)-4);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list