[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18310] branches/blender2.5/blender/source /blender/editors: * Enabled disabled drawing for 'locked' buttons

Matt Ebb matt at mke3.net
Sun Jan 4 08:50:42 CET 2009


Revision: 18310
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18310
Author:   broken
Date:     2009-01-04 08:50:41 +0100 (Sun, 04 Jan 2009)

Log Message:
-----------
* Enabled disabled drawing for 'locked' buttons 
(made with uiBlockSetButLock())

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
    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/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	2009-01-04 07:47:11 UTC (rev 18309)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_resources.h	2009-01-04 07:50:41 UTC (rev 18310)
@@ -904,6 +904,7 @@
 void 	UI_ThemeColorBlend(int colorid1, int colorid2, float fac);
 // same, with shade offset
 void    UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset);
+void	UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset);
 
 // returns one value, not scaled
 float 	UI_GetThemeValuef(int colorid);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-01-04 07:47:11 UTC (rev 18309)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-01-04 07:50:41 UTC (rev 18310)
@@ -2035,6 +2035,12 @@
 	if(block->flag & UI_BLOCK_NO_HILITE)
 		but->flag |= UI_NO_HILITE;
 
+	if (but->lock) {
+		if (but->lockstr) {
+			but->flag |= UI_BUT_DISABLED;
+		}
+	}
+
 	return but;
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-01-04 07:47:11 UTC (rev 18309)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c	2009-01-04 07:50:41 UTC (rev 18310)
@@ -436,13 +436,14 @@
 /* plain fake antialiased unfilled round rectangle */
 void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad, float asp)
 {
-	float color[4];
+	float color[4], alpha;
 	float raddiff;
 	int i, passes=4;
 	
 	/* get the colour and divide up the alpha */
 	glGetFloatv(GL_CURRENT_COLOR, color);
-	color[3]= 1/(float)passes;
+	alpha = color[3];
+	color[3]= alpha/(float)passes;
 	glColor4fv(color);
 	
 	/* set the 'jitter amount' */
@@ -456,6 +457,9 @@
 	}
 	
 	glDisable( GL_BLEND );
+	
+	color[3] = alpha;
+	glColor4fv(color);
 }
 
 /* (old, used in outliner) plain antialiased filled box */
@@ -706,6 +710,8 @@
 		else if(but->flag & UI_ACTIVE);
 		else blend= -60;
 	}
+	if (but->flag & UI_BUT_DISABLED) blend = -100;
+	
 	UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
 	
 	glDisable(GL_BLEND);
@@ -909,6 +915,7 @@
 /* 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)
 {
+	int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
 	float shadefac;
 	
 	/* colour shading */
@@ -928,7 +935,7 @@
 	gl_round_box_shade(GL_POLYGON, x1, y1, x2, y2, rad, shadefac, -shadefac);
 	
 	/* outline */
-	UI_ThemeColorBlendShade(TH_BUT_OUTLINE, TH_BACK, 0.1, -40);
+	UI_ThemeColorBlendShadeAlpha(TH_BUT_OUTLINE, TH_BACK, 0.1, -40, alpha_offs);
 	
 	uiRoundRectFakeAA(x1, y1, x2, y2, rad, asp);
 	/* end outline */	
@@ -937,6 +944,8 @@
 /* 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)
 {	
+	int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
+	
 	/* colour shading */
 	if(flag & UI_SELECT) {
 		if (flag & UI_ACTIVE) UI_ThemeColorShade(colorid, -20);
@@ -952,7 +961,7 @@
 	gl_round_box(GL_POLYGON, x1, y1, x2, y2, rad);
 	
 	/* outline */
-	UI_ThemeColorBlendShade(TH_BUT_OUTLINE, TH_BACK, 0.1, -30);
+	UI_ThemeColorBlendShadeAlpha(TH_BUT_OUTLINE, TH_BACK, 0.1, -30, alpha_offs);
 	
 	uiRoundRectFakeAA(x1, y1, x2, y2, rad, asp);
 	/* end outline */

Modified: branches/blender2.5/blender/source/blender/editors/interface/resources.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/resources.c	2009-01-04 07:47:11 UTC (rev 18309)
+++ branches/blender2.5/blender/source/blender/editors/interface/resources.c	2009-01-04 07:50:41 UTC (rev 18310)
@@ -838,13 +838,37 @@
 	g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
 	b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
 	
-	r= r<0?0:(r>255?255:r);
-	g= g<0?0:(g>255?255:g);
-	b= b<0?0:(b>255?255:b);
+	CLAMP(r, 0, 255);
+	CLAMP(g, 0, 255);
+	CLAMP(b, 0, 255);
 	
 	glColor3ub(r, g, b);
 }
 
+// blend between to theme colors, shade it, and set it
+void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
+{
+	int r, g, b, a;
+	char *cp1, *cp2;
+	
+	cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+	cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+
+	if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0;
+	r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]);
+	g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]);
+	b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]);
+	a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]);
+	
+	CLAMP(r, 0, 255);
+	CLAMP(g, 0, 255);
+	CLAMP(b, 0, 255);
+	CLAMP(a, 0, 255);
+
+	glColor4ub(r, g, b, a);
+}
+
+
 // get individual values, not scaled
 float UI_GetThemeValuef(int colorid)
 {





More information about the Bf-blender-cvs mailing list