void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSocket *sock) { uiBlock *block = uiLayoutGetBlock(layout); NodeLinkArg *arg; uiBut *but; arg = MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg"); arg->ntree = ntree; arg->node = node; arg->sock = sock; UI_block_layout_set_current(block, layout); if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { char name[UI_MAX_NAME_STR]; 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, ""); } else but = uiDefIconMenuBut(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); but->flag |= UI_BUT_NODE_LINK; but->poin = (char *)but; but->func_argN = arg; if (sock->link && sock->link->fromnode) if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) but->flag |= UI_BUT_NODE_ACTIVE; }
void uiTemplateTextureUser(uiLayout *layout, bContext *C) { /* texture user selection dropdown menu. the available users have been * gathered before drawing in ButsContextTexture, we merely need to * display the current item. */ SpaceProperties *sbuts = CTX_wm_space_properties(C); ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; ButsTextureUser *user; char name[UI_MAX_NAME_STR]; if (!ct) { return; } /* get current user */ user = ct->user; if (!user) { uiItemL(layout, IFACE_("No textures in context"), ICON_NONE); return; } /* create button */ BLI_strncpy(name, user->name, UI_MAX_NAME_STR); if (user->icon) { but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else { but = uiDefMenuBut( block, template_texture_user_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } /* some cosmetic tweaks */ UI_but_type_set_menu_from_pulldown(but); but->flag &= ~UI_BUT_ICON_SUBMENU; }