[Bf-committers] Added HSV color selection to texture buttons

Desoto bf-committers@blender.org
Sat, 25 Oct 2003 01:45:21 -0400


This is a multi-part message in MIME format.
--------------040809030802060507020602
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I decided I go another step and see if I can implement HSV color 
selection everywhere RGB color selection is available just for 
consistency and flexibility.  I hope nobody minds me doing this work. 
If you take a look at this image:

http://blender.spaceisbig.com/tex_HSV.png

You'll see on the left the old state of the texture color buttons 
(slightly modified to accommodate the new RGB and HSV toggles), and on 
the right you see the HSV settings to match.  All is function in the 
patch file I've attached.  I hope you guys like it!  And I hope someone 
commits it!  :D  Thanks!

-Desoto

--------------040809030802060507020602
Content-Type: text/plain;
 name="desoto_HSV_texture.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="desoto_HSV_texture.txt"

? desoto_HSV_VPaint.txt
? desoto_HSV_texture.txt
? user-def.mk
? obj/windows
Index: source/blender/blenkernel/intern/texture.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/texture.c,v
retrieving revision 1.7
diff -u -r1.7 texture.c
--- source/blender/blenkernel/intern/texture.c	23 Oct 2003 09:38:10 -0000	1.7
+++ source/blender/blenkernel/intern/texture.c	25 Oct 2003 05:32:41 -0000
@@ -343,6 +343,7 @@
 	tex->rfac= 1.0;
 	tex->gfac= 1.0;
 	tex->bfac= 1.0;
+	tex->colmode= MA_RGB;
 
 }
 
Index: source/blender/include/BSE_trans_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BSE_trans_types.h,v
retrieving revision 1.5
diff -u -r1.5 BSE_trans_types.h
--- source/blender/include/BSE_trans_types.h	27 Dec 2002 13:10:20 -0000	1.5
+++ source/blender/include/BSE_trans_types.h	25 Oct 2003 05:32:41 -0000
@@ -82,7 +82,7 @@
 	float r, g, b, a;
 	float size;		/* van brush */
 	float gamma, mul;
-	short mode, flag;
+	short mode, flag, colmode;
 } VPaint;
 
 #endif /* BSE_TRANS_TYPES_H */
Index: source/blender/makesdna/DNA_texture_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_texture_types.h,v
retrieving revision 1.7
diff -u -r1.7 DNA_texture_types.h
--- source/blender/makesdna/DNA_texture_types.h	23 Sep 2003 21:05:51 -0000	1.7
+++ source/blender/makesdna/DNA_texture_types.h	25 Oct 2003 05:32:41 -0000
@@ -102,7 +102,7 @@
 typedef struct ColorBand {
 	short flag, tot, cur, ipotype;
 	CBData data[16];
-	
+
 } ColorBand;
 
 typedef struct EnvMap {
@@ -143,6 +143,8 @@
 	struct EnvMap *env;
 	
 	short fradur[4][2];
+	
+	short colmode;
 	
 } Tex;
 
Index: source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_editing.c,v
retrieving revision 1.9
diff -u -r1.9 buttons_editing.c
--- source/blender/src/buttons_editing.c	22 Oct 2003 23:20:44 -0000	1.9
+++ source/blender/src/buttons_editing.c	25 Oct 2003 05:32:41 -0000
@@ -1896,14 +1896,28 @@
 static void editing_panel_mesh_paint(void)
 {
 	extern VPaint Gvp;         /* from vpaint */
+	float *colpoin = NULL, min;
 	uiBlock *block;
 
 	block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_paint", UI_EMBOSS, UI_HELV, curarea->win);
 	if(uiNewPanel(curarea, block, "Paint", "Editing", 640, 0, 318, 204)==0) return;
 
-	uiDefButF(block, NUMSLI, 0, "R ",			979,160,194,19, &Gvp.r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting");
-	uiDefButF(block, NUMSLI, 0, "G ",			979,140,194,19, &Gvp.g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting");
-	uiDefButF(block, NUMSLI, 0, "B ",			979,120,194,19, &Gvp.b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting");
+	colpoin = &(Gvp.r);
+	
+	if(Gvp.colmode==MA_RGB) {
+		uiDefButF(block, NUMSLI, 0, "R ",			979,160,194,19, colpoin, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting");
+		uiDefButF(block, NUMSLI, 0, "G ",			979,140,194,19, colpoin+1, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting");
+		uiDefButF(block, NUMSLI, 0, "B ",			979,120,194,19, colpoin+2, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting");
+	}
+	else {
+		uiBlockSetCol(block, TH_BUT_SETTING1);
+		uiDefButF(block, HSVSLI, 0, "H ",			979,160,194,19, colpoin, 0.0, 0.9999, B_VPCOLSLI, 0, "The hue of the color used for painting");
+		uiDefButF(block, HSVSLI, 0, "S ",			979,140,194,19, colpoin, 0.0001, 1.0, B_VPCOLSLI, 0, "The saturation of the color used for painting");
+		uiDefButF(block, HSVSLI, 0, "V ",			979,120,194,19, colpoin, 0.0001, 1.0, B_VPCOLSLI, 0, "The value of the color used for painting");        
+		uiBlockSetCol(block, TH_AUTO);
+	}
+	
+	
 	uiDefButF(block, NUMSLI, 0, "Opacity ",		979,100,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
 	uiDefButF(block, NUMSLI, 0, "Size ",		979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush");
 
@@ -1915,15 +1929,18 @@
 	uiDefButS(block, ROW, B_DIFF, "Mul",			1212, 100,63,19, &Gvp.mode, 1.0, 3.0, 0, 0, "Multiply the vertex colour");
 	uiDefButS(block, ROW, B_DIFF, "Filter",		1212, 80,63,19, &Gvp.mode, 1.0, 4.0, 0, 0, "Mix the colours with an alpha factor");
 
-	uiDefButS(block, TOG|BIT|1, 0, "Area", 		980,50,80,19, &Gvp.flag, 0, 0, 0, 0, "Set the area the brush covers");
-	uiDefButS(block, TOG|BIT|2, 0, "Soft", 		1061,50,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush");
-	uiDefButS(block, TOG|BIT|3, 0, "Normals", 	1174,50,102,19, &Gvp.flag, 0, 0, 0, 0, "Use vertex normal for painting");
-
-	uiDefBut(block, BUT, B_VPGAMMA, "Set", 	980,30,80,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours");
-	uiDefButF(block, NUM, B_DIFF, "Mul:", 		1061,30,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with");
-	uiDefButF(block, NUM, B_DIFF, "Gamma:", 	1174,30,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours");
+	uiDefButS(block, ROW, REDRAWBUTSEDIT, "RGB",			980,55,70,20, &Gvp.colmode, 2.0, (float)MA_RGB, 0, 0, "Create colour by red, green and blue");
+	uiDefButS(block, ROW, REDRAWBUTSEDIT, "HSV",			1050,55,70,20, &Gvp.colmode, 2.0, (float)MA_HSV, 0, 0, "Mix colour with hue, saturation and value");
+		
+	uiDefButS(block, TOG|BIT|1, 0, "Area", 		980,30,80,19, &Gvp.flag, 0, 0, 0, 0, "Set the area the brush covers");
+	uiDefButS(block, TOG|BIT|2, 0, "Soft", 		1061,30,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush");
+	uiDefButS(block, TOG|BIT|3, 0, "Normals", 	1174,30,102,19, &Gvp.flag, 0, 0, 0, 0, "Use vertex normal for painting");
+
+	uiDefBut(block, BUT, B_VPGAMMA, "Set", 	980,10,80,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours");
+	uiDefButF(block, NUM, B_DIFF, "Mul:", 		1061,10,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with");
+	uiDefButF(block, NUM, B_DIFF, "Gamma:", 	1174,10,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours");
 	
-	uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol",	980,5,103,28, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)");
+	uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol",	980,-10,103,19, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)");
 
 }
 
Index: source/blender/src/buttons_shading.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v
retrieving revision 1.19
diff -u -r1.19 buttons_shading.c
--- source/blender/src/buttons_shading.c	23 Oct 2003 16:52:53 -0000	1.19
+++ source/blender/src/buttons_shading.c	25 Oct 2003 05:32:42 -0000
@@ -976,7 +976,7 @@
 {
 	uiBlock *block;
 	CBData *cbd;
-	
+		
 	block= uiNewBlock(&curarea->uiblocks, "texture_panel_colors", UI_EMBOSS, UI_HELV, curarea->win);
 	uiNewPanelTabbed("Texture", "Texture");
 	if(uiNewPanel(curarea, block, "Colors", "Texture", 1280, 0, 318, 204)==0) return;
@@ -1000,19 +1000,46 @@
 		uiDefButS(block, ROW, B_TEXPRV, "S",		130,120,20,20, &tex->coba->ipotype, 5.0, 2.0, 0, 0, "Interpolation type Spline");
 		uiDefButF(block, COL, B_BANDCOL, "",		150,120,30,20, &(cbd->r), 0, 0, 0, 0, "");
 		uiDefButF(block, NUMSLI, B_TEXPRV, "A ",	180,120,130,20, &cbd->a, 0.0, 1.0, 0, 0, "Set the alpha value");
+	
+		if (tex->colmode==MA_RGB) {
+			uiDefButF(block, NUMSLI, B_TEXREDR_PRV, "R ",	10,100,100,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Set the red value");
+			uiDefButF(block, NUMSLI, B_TEXREDR_PRV, "G ",	110,100,100,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Set the green value");
+			uiDefButF(block, NUMSLI, B_TEXREDR_PRV, "B ",	210,100,100,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Set the blue value");
+		}
+		else {
+			uiBlockSetCol(block, TH_BUT_SETTING1);
+			uiDefButF(block, HSVSLI, B_TEXREDR_PRV, "H ",	10,100,100,20, &(cbd->r), 0.0, 0.9999, B_BANDCOL, 0, "Set the hue");
+			uiDefButF(block, HSVSLI, B_TEXREDR_PRV, "S ",	110,100,100,20, &(cbd->r), 0.0001, 1.0, B_BANDCOL, 0, "Set the saturation");
+			uiDefButF(block, HSVSLI, B_TEXREDR_PRV, "V ",	210,100,100,20, &(cbd->r), 0.0001, 1.0, B_BANDCOL, 0, "Set the value");        
+			uiBlockSetCol(block, TH_AUTO);
+		}
 		
-		uiDefButF(block, NUMSLI, B_TEXPRV, "R ",	10,100,100,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Set the red value");
-		uiDefButF(block, NUMSLI, B_TEXPRV, "G ",	110,100,100,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Set the green value");
-		uiDefButF(block, NUMSLI, B_TEXPRV, "B ",	210,100,100,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Set the blue value");
-		
+		uiDefButS(block, ROW, REDRAWBUTSSHADING, "RGB",			10,55,70,20, &tex->colmode, 2.0, (float)MA_RGB, 0, 0, "Create colour by red, green and blue");
+		uiDefButS(block, ROW, REDRAWBUTSSHADING, "HSV",			90,55,70,20, &tex->colmode, 2.0, (float)MA_HSV, 0, 0, "Mix colour with hue, saturation and value");		
+			
 	}
 
 	/* RGB-BRICON */
 	if((tex->flag & TEX_COLORBAND)==0) {
-		uiDefButF(block, NUMSLI, B_TEXPRV, "R ",		60,80,200,20, &tex->rfac, 0.0, 2.0, 0, 0, "Set the red value");
-		uiDefButF(block, NUMSLI, B_TEXPRV, "G ",		60,60,200,20, &tex->gfac, 0.0, 2.0, 0, 0, "Set the green value");
-		uiDefButF(block, NUMSLI, B_TEXPRV, "B ",		60,40,200,20, &tex->bfac, 0.0, 2.0, 0, 0, "Set the blue value");
+		
+		if (tex->colmode==MA_RGB) {
+			uiDefButF(block, NUMSLI, B_TEXPRV, "R ",		60,150,200,20, &tex->rfac, 0.0, 2.0, 0, 0, "Set the red value");
+			uiDefButF(block, NUMSLI, B_TEXPRV, "G ",		60,120,200,20, &tex->gfac, 0.0, 2.0, 0, 0, "Set the green value");
+			uiDefButF(block, NUMSLI, B_TEXPRV, "B ",		60,90,200,20, &tex->bfac, 0.0, 2.0, 0, 0, "Set the blue value");
+		}
+		else {
+			uiBlockSetCol(block, TH_BUT_SETTING1);
+			uiDefButF(block, HSVSLI, B_TEXPRV, "H ",		60,150,200,20, &(tex->rfac), 0.0, 0.9999, B_BANDCOL, 0, "Set the hue");
+			uiDefButF(block, HSVSLI, B_TEXPRV, "S ",		60,120,200,20, &(tex->rfac), 0.0001, 1.0, B_BANDCOL, 0, "Set the saturation");
+			uiDefButF(block, HSVSLI, B_TEXPRV, "V ",		60,90,200,20, &(tex->rfac), 0.0001, 1.0, B_BANDCOL, 0, "Set the value");        
+			uiBlockSetCol(block, TH_AUTO);
+		}
+		
+		uiDefButS(block, ROW, REDRAWBUTSSHADING, "RGB",			10,55,70,20, &tex->colmode, 2.0, (float)MA_RGB, 0, 0, "Create colour by red, green and blue");
+		uiDefButS(block, ROW, REDRAWBUTSSHADING, "HSV",			90,55,70,20, &tex->colmode, 2.0, (float)MA_HSV, 0, 0, "Mix colour with hue, saturation and value");		
+	
 	}
+	
 	uiDefButF(block, NUMSLI, B_TEXPRV, "Bright",		10,10,150,20, &tex->bright, 0.0, 2.0, 0, 0, "Set the brightness of the colour or intensity of a texture");
 	uiDefButF(block, NUMSLI, B_TEXPRV, "Contr",			160,10,150,20, &tex->contrast, 0.01, 2.0, 0, 0, "Set the contrast of the colour or intensity of a texture");
 
Index: source/blender/src/drawobject.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawobject.c,v
retrieving revision 1.31
diff -u -r1.31 drawobject.c
--- source/blender/src/drawobject.c	23 Oct 2003 16:15:05 -0000	1.31
+++ source/blender/src/drawobject.c	25 Oct 2003 05:32:43 -0000
@@ -1071,7 +1071,7 @@
 	}
 	glEnd();
 
-	glPointSize(1.0);
+	glPointSize(3.0);
 }
 
 
Index: source/blender/src/vpaint.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/vpaint.c,v
retrieving revision 1.7
diff -u -r1.7 vpaint.c
--- source/blender/src/vpaint.c	7 Oct 2003 18:24:02 -0000	1.7
+++ source/blender/src/vpaint.c	25 Oct 2003 05:32:43 -0000
@@ -55,6 +55,7 @@
 
 #include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
+#include "DNA_material_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"
@@ -99,7 +100,7 @@
 
 #define MAXINDEX	65336
 
-VPaint Gvp= {1.0, 1.0, 1.0, 0.2, 25.0, 1.0, 1.0, 0, VP_AREA+VP_SOFT};
+VPaint Gvp= {1.0, 1.0, 1.0, 0.2, 25.0, 1.0, 1.0, 0, VP_AREA+VP_SOFT, MA_RGB};
 float vpimat[3][3];
 unsigned int *vpaintundobuf=0;
 int totvpaintundo;

--------------040809030802060507020602--