Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_templates.c
| Show First 20 Lines • Show All 448 Lines • ▼ Show 20 Lines | for (i = 0; i < totitems; ++i) | ||||
| num++; | num++; | ||||
| for (i = 0; i < totitems; ++i) { | for (i = 0; i < totitems; ++i) { | ||||
| if (!ui_compatible_sockets(items[i].socket_type, sock->type)) | if (!ui_compatible_sockets(items[i].socket_type, sock->type)) | ||||
| continue; | continue; | ||||
| if (first) { | if (first) { | ||||
| column = uiLayoutColumn(layout, 0); | column = uiLayoutColumn(layout, 0); | ||||
| uiBlockSetCurLayout(block, column); | UI_block_layout_set_current(block, column); | ||||
| uiItemL(column, IFACE_(cname), ICON_NODE); | uiItemL(column, IFACE_(cname), ICON_NODE); | ||||
| but = block->buttons.last; | but = block->buttons.last; | ||||
| first = 0; | first = 0; | ||||
| } | } | ||||
| if (num > 1) { | if (num > 1) { | ||||
| if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) { | if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) { | ||||
| cur_node_name = items[i].node_name; | cur_node_name = items[i].node_name; | ||||
| /* XXX Do not use uiItemL here, it would add an empty icon as we are in a menu! */ | /* 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, | uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_(cur_node_name), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, ""); | 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; | icon = ICON_BLANK1; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR); | BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR); | ||||
| icon = ICON_NONE; | icon = ICON_NONE; | ||||
| } | } | ||||
| but = uiDefIconTextBut(block, BUT, 0, icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | but = uiDefIconTextBut(block, UI_BTYPE_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")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); | ||||
| argN = MEM_dupallocN(arg); | argN = MEM_dupallocN(arg); | ||||
| argN->item = items[i]; | argN->item = items[i]; | ||||
| uiButSetNFunc(but, ui_node_link, argN, NULL); | UI_but_funcN_set(but, ui_node_link, argN, NULL); | ||||
| } | } | ||||
| if (items) | if (items) | ||||
| MEM_freeN(items); | MEM_freeN(items); | ||||
| } | } | ||||
| NODE_TYPES_END | NODE_TYPES_END | ||||
| } | } | ||||
| Show All 11 Lines | static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p) | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| uiBut *but = (uiBut *)but_p; | uiBut *but = (uiBut *)but_p; | ||||
| uiLayout *split, *column; | uiLayout *split, *column; | ||||
| NodeLinkArg *arg = (NodeLinkArg *)but->func_argN; | NodeLinkArg *arg = (NodeLinkArg *)but->func_argN; | ||||
| bNodeSocket *sock = arg->sock; | bNodeSocket *sock = arg->sock; | ||||
| bNodeTreeType *ntreetype = arg->ntree->typeinfo; | bNodeTreeType *ntreetype = arg->ntree->typeinfo; | ||||
| uiBlockSetFlag(block, UI_BLOCK_NO_FLIP); | UI_block_flag_enable(block, UI_BLOCK_NO_FLIP); | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| split = uiLayoutSplit(layout, 0.0f, false); | split = uiLayoutSplit(layout, 0.0f, false); | ||||
| arg->bmain = bmain; | arg->bmain = bmain; | ||||
| arg->scene = scene; | arg->scene = scene; | ||||
| arg->layout = split; | arg->layout = split; | ||||
| if (ntreetype && ntreetype->foreach_nodeclass) | if (ntreetype && ntreetype->foreach_nodeclass) | ||||
| ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); | ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); | ||||
| column = uiLayoutColumn(split, false); | column = uiLayoutColumn(split, false); | ||||
| uiBlockSetCurLayout(block, column); | UI_block_layout_set_current(block, column); | ||||
| if (sock->link) { | if (sock->link) { | ||||
| uiItemL(column, IFACE_("Link"), ICON_NONE); | uiItemL(column, IFACE_("Link"), ICON_NONE); | ||||
| but = block->buttons.last; | but = block->buttons.last; | ||||
| but->drawflag = UI_BUT_TEXT_LEFT; | but->drawflag = UI_BUT_TEXT_LEFT; | ||||
| but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); | ||||
| uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE)); | UI_but_funcN_set(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE)); | ||||
| but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); | ||||
| uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT)); | UI_but_funcN_set(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(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, bNodeTree *ntree, bNode *node, bNodeSocket *sock) | ||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| NodeLinkArg *arg; | NodeLinkArg *arg; | ||||
| uiBut *but; | uiBut *but; | ||||
| 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; | ||||
| uiBlockSetCurLayout(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(sock, name); | ui_node_sock_name(sock, name); | ||||
| but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); | but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); | ||||
| } | } | ||||
| else | else | ||||
| but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); | ||||
| uiButSetMenuFromPulldown(but); | UI_but_type_set_menu_from_pulldown(but); | ||||
| but->flag |= UI_BUT_NODE_LINK; | 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 58 Lines • ▼ Show 20 Lines | static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) | ||||
| BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); | BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); | ||||
| /* split in label and value */ | /* split in label and value */ | ||||
| split = uiLayoutSplit(layout, 0.35f, false); | split = uiLayoutSplit(layout, 0.35f, false); | ||||
| row = uiLayoutRow(split, true); | row = uiLayoutRow(split, true); | ||||
| if (depth > 0) { | if (depth > 0) { | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| if (lnode && (lnode->inputs.first || (lnode->typeinfo->draw_buttons && lnode->type != NODE_GROUP))) { | if (lnode && (lnode->inputs.first || (lnode->typeinfo->draw_buttons && lnode->type != NODE_GROUP))) { | ||||
| int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; | int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; | ||||
| uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); | uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); | ||||
| } | } | ||||
| else | else | ||||
| uiItemL(row, "", ICON_BLANK1); | uiItemL(row, "", ICON_BLANK1); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| bt->rect.xmax = UI_UNIT_X / 2; | bt->rect.xmax = UI_UNIT_X / 2; | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| uiItemL(row, label, ICON_NONE); | uiItemL(row, label, ICON_NONE); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| bt->drawflag = UI_BUT_TEXT_LEFT; | bt->drawflag = UI_BUT_TEXT_LEFT; | ||||
| if (dependency_loop) { | if (dependency_loop) { | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||