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; }
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. */ SpaceButs *sbuts = CTX_wm_space_buts(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, "No textures in context.", ICON_NONE); return; } /* create button */ BLI_snprintf(name, UI_MAX_NAME_STR, "%s", user->name); 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 */ but->type= MENU; but->flag |= UI_TEXT_LEFT; but->flag &= ~UI_ICON_SUBMENU; }
void action_header_buttons(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); SpaceAction *saction= CTX_wm_space_action(C); bAnimContext ac; uiBlock *block; int xco, yco= 3, xmax; block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); uiBlockSetHandleFunc(block, do_action_buttons, NULL); xco= ED_area_header_standardbuttons(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSS); /* get context... (also syncs data) */ ANIM_animdata_get_context(C, &ac); if ((sa->flag & HEADER_NO_PULLDOWN)==0) { xmax= GetButStringLength("View"); uiDefMenuBut(block, act_viewmenu, NULL, "View", xco, yco, xmax-3, 20, ""); xco+= xmax; xmax= GetButStringLength("Select"); uiDefMenuBut(block, act_selectmenu, NULL, "Select", xco, yco, xmax-3, 20, ""); xco+= xmax; if ( (saction->mode == SACTCONT_DOPESHEET) || ((saction->action) && (saction->mode==SACTCONT_ACTION)) ) { xmax= GetButStringLength("Channel"); uiDefMenuBut(block, act_channelmenu, NULL, "Channel", xco, yco, xmax-3, 20, ""); xco+= xmax; } else if (saction->mode==SACTCONT_GPENCIL) { xmax= GetButStringLength("Channel"); uiDefMenuBut(block, act_gplayermenu, NULL, "Channel", xco, yco, xmax-3, 20, ""); xco+= xmax; } //xmax= GetButStringLength("Marker"); //uiDefMenuBut(block, act_markermenu, NULL, "Marker", xco, yco, xmax-3, 20, ""); //xco+= xmax; if (saction->mode == SACTCONT_GPENCIL) { //xmax= GetButStringLength("Frame"); //uiDefMenuBut(block, act_selectmenu, NULL, "Frame", xco, yco, xmax-3, 20, ""); //xco+= xmax; } else { xmax= GetButStringLength("Key"); uiDefMenuBut(block, act_editmenu, NULL, "Key", xco, yco, xmax-3, 20, ""); xco+= xmax; } } uiBlockSetEmboss(block, UI_EMBOSS); /* MODE SELECTOR */ uiDefButC(block, MENU, B_MODECHANGE, "Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2", xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0, "Editing modes for this editor"); xco += (90 + 8); /* SUMMARY CHANNEL */ uiDefIconTextButBitI(block, TOG, ADS_FILTER_SUMMARY, B_REDR, ICON_BORDERMOVE, "Summary", xco,yco,XIC*4,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Include DopeSheet summary row"); // TODO: needs a better icon xco += (XIC*4.5); /*if (ac.data)*/ { /* MODE-DEPENDENT DRAWING */ if (saction->mode == SACTCONT_DOPESHEET) { /* FILTERING OPTIONS */ xco -= XIC; // XXX first button incurs this offset... xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco); } else if (saction->mode == SACTCONT_ACTION) { uiLayout *layout; bScreen *sc= CTX_wm_screen(C); PointerRNA ptr; RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, saction, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first); uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACT_OT_new", NULL, NULL); uiBlockLayoutResolve(block, &xco, NULL); xco += 8; } /* draw AUTOSNAP */ if (saction->mode != SACTCONT_GPENCIL) { if (saction->flag & SACTION_DRAWTIME) { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } else { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } xco += (90 + 8); } /* COPY PASTE */ uiBlockBeginAlign(block); uiDefIconButO(block, BUT, "ACT_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Copies the selected keyframes to the buffer."); xco += XIC; uiDefIconButO(block, BUT, "ACT_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_PASTEDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels."); uiBlockEndAlign(block); xco += (XIC + 8); } /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); uiEndBlock(C, block); uiDrawBlock(C, block); }