[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29160] trunk/blender/source/blender/ editors/interface/interface_regions.c: Avoid reset the H and S value in the color picker when V is equal to zero!

Diego Borghetti bdiego at gmail.com
Wed Jun 2 18:02:28 CEST 2010


Revision: 29160
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29160
Author:   bdiego
Date:     2010-06-02 18:02:28 +0200 (Wed, 02 Jun 2010)

Log Message:
-----------
Avoid reset the H and S value in the color picker when V is equal to zero!

Small change to keep the value of H and S when V come to zero, take care
that only work if you keep the color picker open.

When the color picker is closed, the H and S value are reset to zero
this is because the color picker is used in a lot of different place
and this value need to be reset.

(BTW reset to zero only when V is equal to zero!)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_regions.c

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2010-06-02 14:40:58 UTC (rev 29159)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2010-06-02 16:02:28 UTC (rev 29160)
@@ -1559,12 +1559,21 @@
 }
 
 /* also used by small picker, be careful with name checks below... */
-void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
+void ui_update_block_buts_rgb(uiBlock *block, float *rgb, float *rhsv)
 {
 	uiBut *bt;
 	float hsv[3];
 	
-	rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+	/* this is to keep the H and S value when V is equal to zero
+	 * and we are working in HSV mode, of course!
+	 */
+	if (rhsv) {
+		hsv[0]= rhsv[0];
+		hsv[1]= rhsv[1];
+		hsv[2]= rhsv[2];
+	}
+	else
+		rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
 	
 	// this updates button strings, is hackish... but button pointers are on stack of caller function
 	for(bt= block->buttons.first; bt; bt= bt->next) {
@@ -1630,7 +1639,7 @@
 	
 	if (prop) {
 		RNA_property_float_get_array(&ptr, prop, rgb);
-		ui_update_block_buts_rgb(but->block, rgb);
+		ui_update_block_buts_rgb(but->block, rgb, NULL);
 	}
 	
 	if(popup)
@@ -1646,7 +1655,7 @@
 	
 	hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
 	
-	ui_update_block_buts_rgb(but->block, rgb);
+	ui_update_block_buts_rgb(but->block, rgb, hsv);
 	
 	if(popup)
 		popup->menuretval= UI_RETURN_UPDATE;
@@ -1667,7 +1676,7 @@
 		srgb_to_linearrgb_v3_v3(rgb, rgb);
 	}
 	
-	ui_update_block_buts_rgb(but->block, rgb);
+	ui_update_block_buts_rgb(but->block, rgb, NULL);
 	
 	if(popup)
 		popup->menuretval= UI_RETURN_UPDATE;
@@ -1876,7 +1885,7 @@
 
 				ui_set_but_vectorf(but, col);
 				
-				ui_update_block_buts_rgb(block, col);
+				ui_update_block_buts_rgb(block, col, NULL);
 				if(popup)
 					popup->menuretval= UI_RETURN_UPDATE;
 				





More information about the Bf-blender-cvs mailing list