[Bf-blender-cvs] [4584caa] master: Fix UI bug with 'socket menus' (used e.g. by cycles' Material panels).

Bastien Montagne noreply at git.blender.org
Wed Dec 4 00:16:04 CET 2013


Commit: 4584caa13310d89c83f67db9530f05336ed89560
Author: Bastien Montagne
Date:   Wed Dec 4 00:00:09 2013 +0100
http://developer.blender.org/rB4584caa13310d89c83f67db9530f05336ed89560

Fix UI bug with 'socket menus' (used e.g. by cycles' Material panels).

Also tweaked a bit how nodes with more than one socket available are drawn:
* The node entry itself (a label) has no more any icon, so that it is aligned with the other single-socket nodes.
* The sub-entries (i.e. node's sockets) are more clearly indented (using a blank icon).

Details:
Another case of bad internal UI_HAS_ICON flag erasing by brutally assigning an uneeded value to but->flag.
Revealed by recent split of some button flags into but->drawflag.

Thanks to Thomas Dinge for noting the issue.

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

M	source/blender/editors/space_node/node_templates.c

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

diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index f8eb0ed..b544e75 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -436,6 +436,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
 		char name[UI_MAX_NAME_STR];
 		const char *cur_node_name = NULL;
 		int i, num = 0;
+		int icon = ICON_NONE;
 		
 		if (compatibility && !(ntype->compatibility & compatibility))
 			continue;
@@ -461,7 +462,6 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
 				
 				uiItemL(column, IFACE_(cname), ICON_NODE);
 				but = block->buttons.last;
-				but->drawflag = UI_BUT_TEXT_LEFT;
 				
 				first = 0;
 			}
@@ -469,18 +469,21 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
 			if (num > 1) {
 				if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) {
 					cur_node_name = items[i].node_name;
-					uiItemL(column, IFACE_(cur_node_name), ICON_NODE);
-					but = block->buttons.last;
-					but->drawflag = UI_BUT_TEXT_LEFT;
+					/* XXX Do not use uiItemL here, it would add an empty icon as we are in a menu! */
+					uiDefBut(block, LABEL, 0, IFACE_(cur_node_name), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
+					         NULL, 0.0, 0.0, 0.0, 0.0, "");
 				}
-				
-				BLI_snprintf(name, UI_MAX_NAME_STR, "  %s", IFACE_(items[i].socket_name));
+
+				BLI_snprintf(name, UI_MAX_NAME_STR, "%s", IFACE_(items[i].socket_name));
+				icon = ICON_BLANK1;
 			}
-			else
+			else {
 				BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR);
+				icon = ICON_NONE;
+			}
 			
-			but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
-			               NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input"));
+			but = uiDefIconTextBut(block, BUT, 0, icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y,
+			                       NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input"));
 			
 			argN = MEM_dupallocN(arg);
 			argN->item = items[i];




More information about the Bf-blender-cvs mailing list