[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24135] trunk/blender/source/blender/ editors/interface: UI Icon Toggles Fix:

Joshua Leung aligorith at gmail.com
Wed Oct 28 11:16:49 CET 2009


Revision: 24135
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24135
Author:   aligorith
Date:     2009-10-28 11:16:49 +0100 (Wed, 28 Oct 2009)

Log Message:
-----------
UI Icon Toggles Fix:

Boolean settings now use TOG instead of ICONTOG when they have icons, since ICONTOG was causing too much trouble with icons changing when they shouldn't be. Perhaps in future there should be some flag for specifying from RNA/UI-Layouts which one you want, but for now, this will do. 

Reverting r23936 since that fix depended on ICONTOG behaviour. 

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

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2009-10-28 10:04:09 UTC (rev 24134)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2009-10-28 10:16:49 UTC (rev 24135)
@@ -893,13 +893,10 @@
 		name= ui_item_name_add_colon(name, namestr);
 
 	if(layout->root->type == UI_LAYOUT_MENU) {
-		/* whether the property is actually enabled doesn't matter, 
-		 * since the widget code for drawing toggles takes care of the 
-		 * rest (i.e. given the deactivated icon, it finds the active one
-		 * based on the state of the setting)
-		 */
-		if ( (type == PROP_BOOLEAN) || (type==PROP_ENUM && index==RNA_ENUM_VALUE) )
-			icon= ICON_CHECKBOX_DEHLT; /* ICON_CHECKBOX_HLT when on... */
+		if(type == PROP_BOOLEAN)
+			icon= (RNA_property_boolean_get(ptr, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+		else if(type == PROP_ENUM && index == RNA_ENUM_VALUE)
+			icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
 	}
 
 	slider= (flag & UI_ITEM_R_SLIDER);

Modified: trunk/blender/source/blender/editors/interface/interface_utils.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_utils.c	2009-10-28 10:04:09 UTC (rev 24134)
+++ trunk/blender/source/blender/editors/interface/interface_utils.c	2009-10-28 10:16:49 UTC (rev 24135)
@@ -61,11 +61,12 @@
 				value= RNA_property_boolean_get_index(ptr, prop, index);
 			else
 				value= RNA_property_boolean_get(ptr, prop);
-
+			
+			// XXX: when to do TOG, and when to do ICONTOG? for now, let's just do TOG, since ICONTOG causes too much trouble everywhere else
 			if(icon && name && strcmp(name, "") == 0)
-				but= uiDefIconButR(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+				but= uiDefIconButR(block, TOG, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
 			else if(icon)
-				but= uiDefIconTextButR(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+				but= uiDefIconTextButR(block, TOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
 			else
 				but= uiDefButR(block, OPTION, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
 			break;





More information about the Bf-blender-cvs mailing list