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; }