diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-04 03:00:09 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-12-04 03:09:12 +0400 |
commit | 4584caa13310d89c83f67db9530f05336ed89560 (patch) | |
tree | f0ab7489399574141ac5df492f9b4fe3e154734a | |
parent | f3d13bec6dbacbf2ddfba034776175cf78d628b0 (diff) |
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.
-rw-r--r-- | source/blender/editors/space_node/node_templates.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index f8eb0ede262..b544e753965 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]; |