Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_templates.c
| Show All 39 Lines | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "NOD_socket.h" | #include "NOD_socket.h" | ||||
| #include "../interface/interface_intern.h" /* XXX bad level */ | #include "../interface/interface_intern.h" /* XXX bad level */ | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "ED_node.h" /* own include */ | #include "ED_node.h" /* own include */ | ||||
| #include "node_intern.h" | |||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| /************************* Node Socket Manipulation **************************/ | /************************* Node Socket Manipulation **************************/ | ||||
| /* describes an instance of a node type and a specific socket to link */ | /* describes an instance of a node type and a specific socket to link */ | ||||
| typedef struct NodeLinkItem { | typedef struct NodeLinkItem { | ||||
| int socket_index; /* index for linking */ | int socket_index; /* index for linking */ | ||||
| ▲ Show 20 Lines • Show All 601 Lines • ▼ Show 20 Lines | but = uiDefBut(block, | ||||
| TIP_("Disconnect nodes connected to the input")); | TIP_("Disconnect nodes connected to the input")); | ||||
| UI_but_funcN_set( | UI_but_funcN_set( | ||||
| but, ui_node_link, MEM_dupallocN(arg), POINTER_FROM_INT(UI_NODE_LINK_DISCONNECT)); | but, ui_node_link, MEM_dupallocN(arg), POINTER_FROM_INT(UI_NODE_LINK_DISCONNECT)); | ||||
| } | } | ||||
| ui_node_menu_column(arg, NODE_CLASS_GROUP, N_("Group")); | ui_node_menu_column(arg, NODE_CLASS_GROUP, N_("Group")); | ||||
| } | } | ||||
| void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSocket *sock) | void uiTemplateNodeLink( | ||||
| uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *sock) | |||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| NodeLinkArg *arg; | NodeLinkArg *arg; | ||||
| uiBut *but; | uiBut *but; | ||||
| float socket_col[4]; | |||||
| arg = MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg"); | arg = MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg"); | ||||
| arg->ntree = ntree; | arg->ntree = ntree; | ||||
| arg->node = node; | arg->node = node; | ||||
| arg->sock = sock; | arg->sock = sock; | ||||
| PointerRNA node_ptr; | |||||
| RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); | |||||
| node_socket_color_get(C, ntree, &node_ptr, sock, socket_col); | |||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { | if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { | ||||
| char name[UI_MAX_NAME_STR]; | char name[UI_MAX_NAME_STR]; | ||||
| ui_node_sock_name(ntree, sock, name); | ui_node_sock_name(ntree, sock, name); | ||||
| but = uiDefMenuBut( | but = uiDefMenuBut( | ||||
| block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); | block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconMenuBut( | but = uiDefIconMenuBut( | ||||
| block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | ||||
| } | } | ||||
| UI_but_type_set_menu_from_pulldown(but); | UI_but_type_set_menu_from_pulldown(but); | ||||
| UI_but_node_link_set(but, sock, socket_col); | |||||
| UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT); | |||||
| but->flag |= UI_BUT_NODE_LINK; | |||||
| but->poin = (char *)but; | but->poin = (char *)but; | ||||
| but->func_argN = arg; | but->func_argN = arg; | ||||
| if (sock->link && sock->link->fromnode) { | if (sock->link && sock->link->fromnode) { | ||||
| if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) { | if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) { | ||||
| but->flag |= UI_BUT_NODE_ACTIVE; | but->flag |= UI_BUT_NODE_ACTIVE; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | static void ui_node_draw_input( | ||||
| bt->drawflag = UI_BUT_TEXT_RIGHT; | bt->drawflag = UI_BUT_TEXT_RIGHT; | ||||
| if (dependency_loop) { | if (dependency_loop) { | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); | uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); | ||||
| } | } | ||||
| else if (lnode) { | else if (lnode) { | ||||
| /* input linked to a node */ | /* input linked to a node */ | ||||
| uiTemplateNodeLink(split, ntree, node, input); | uiTemplateNodeLink(split, C, ntree, node, input); | ||||
| if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) { | if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) { | ||||
| if (depth == 0) { | if (depth == 0) { | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| } | } | ||||
| ui_node_draw_node(layout, C, ntree, lnode, depth); | ui_node_draw_node(layout, C, ntree, lnode, depth); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| row = uiLayoutRow(split, true); | |||||
| uiTemplateNodeLink(row, C, ntree, node, input); | |||||
| /* input not linked, show value */ | /* input not linked, show value */ | ||||
| if (!(input->flag & SOCK_HIDE_VALUE)) { | if (!(input->flag & SOCK_HIDE_VALUE)) { | ||||
| switch (input->type) { | switch (input->type) { | ||||
| case SOCK_FLOAT: | case SOCK_FLOAT: | ||||
| case SOCK_INT: | case SOCK_INT: | ||||
| case SOCK_BOOLEAN: | case SOCK_BOOLEAN: | ||||
| case SOCK_RGBA: | case SOCK_RGBA: | ||||
| case SOCK_STRING: | case SOCK_STRING: | ||||
| row = uiLayoutRow(split, true); | |||||
| uiItemR(row, &inputptr, "default_value", 0, "", ICON_NONE); | uiItemR(row, &inputptr, "default_value", 0, "", ICON_NONE); | ||||
| break; | break; | ||||
| case SOCK_VECTOR: | case SOCK_VECTOR: | ||||
| row = uiLayoutRow(split, false); | uiItemS(row); | ||||
| col = uiLayoutColumn(row, false); | col = uiLayoutColumn(row, false); | ||||
| uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); | uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); | ||||
| break; | break; | ||||
| default: | |||||
| row = uiLayoutRow(split, false); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| else { | |||||
| row = uiLayoutRow(split, false); | |||||
| } | } | ||||
| uiTemplateNodeLink(row, ntree, node, input); | |||||
| } | } | ||||
| /* clear */ | /* clear */ | ||||
| node->flag &= ~NODE_TEST; | node->flag &= ~NODE_TEST; | ||||
| } | } | ||||
| void uiTemplateNodeView( | void uiTemplateNodeView( | ||||
| uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input) | uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input) | ||||
| Show All 19 Lines | |||||