[Bf-blender-cvs] [0ff70d9] master: Code cleanup - Reduce duplication of layer number calculations here

Joshua Leung noreply at git.blender.org
Mon Nov 18 04:07:43 CET 2013


Commit: 0ff70d942fa6a27ef416e59199a5c5590307dba2
Author: Joshua Leung
Date:   Mon Nov 18 15:53:46 2013 +1300
http://developer.blender.org/rB0ff70d942fa6a27ef416e59199a5c5590307dba2

Code cleanup - Reduce duplication of layer number calculations here

===================================================================

M	source/blender/editors/interface/interface_layout.c

===================================================================

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index e5bcc3d..b23d701 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -391,20 +391,26 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
 			uiBlockBeginAlign(block);
 
 			for (a = 0; a < colbuts; a++) {
-				if (layer_used & (1 << (a + b * colbuts))) icon = ICON_LAYER_USED;
+				int layer_num  = a + b * colbuts;
+				int layer_flag = 1 << layer_num;
+				
+				if (layer_used & layer_flag) icon = ICON_LAYER_USED;
 				else icon = ICON_BLANK1;
 
-				but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth);
+				but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
 				if (subtype == PROP_LAYER_MEMBER)
-					uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts));
+					uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
 			}
 			for (a = 0; a < colbuts; a++) {
-				if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED;
+				int layer_num  = a + len / 2 + b * colbuts;
+				int layer_flag = 1 << layer_num;
+				
+				if (layer_used & layer_flag) icon = ICON_LAYER_USED;
 				else icon = ICON_BLANK1;
 
-				but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth);
+				but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
 				if (subtype == PROP_LAYER_MEMBER)
-					uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts));
+					uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
 			}
 			uiBlockEndAlign(block);




More information about the Bf-blender-cvs mailing list