Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_buttons/buttons_texture.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | |||||
| #include "../interface/interface_intern.h" | #include "../interface/interface_intern.h" | ||||
| #include "buttons_intern.h" /* own include */ | #include "buttons_intern.h" /* own include */ | ||||
| static ScrArea *find_area_properties(const bContext *C); | |||||
| static SpaceProperties *find_space_properties(const bContext *C); | |||||
| /************************* Texture User **************************/ | /************************* Texture User **************************/ | ||||
| static void buttons_texture_user_property_add(ListBase *users, | static void buttons_texture_user_property_add(ListBase *users, | ||||
| ID *id, | ID *id, | ||||
| PointerRNA ptr, | PointerRNA ptr, | ||||
| PropertyRNA *prop, | PropertyRNA *prop, | ||||
| const char *category, | const char *category, | ||||
| int icon, | int icon, | ||||
| ▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | if (ct->user) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)) | static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg)) | ||||
| { | { | ||||
| /* callback when selecting a texture user in the menu */ | /* callback when selecting a texture user in the menu */ | ||||
| SpaceProperties *sbuts = CTX_wm_space_properties(C); | SpaceProperties *sbuts = find_space_properties(C); | ||||
| ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ||||
| ButsTextureUser *user = (ButsTextureUser *)user_p; | ButsTextureUser *user = (ButsTextureUser *)user_p; | ||||
| PointerRNA texptr; | PointerRNA texptr; | ||||
| Tex *tex; | Tex *tex; | ||||
| if (!ct) { | if (!ct) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | void uiTemplateTextureUser(uiLayout *layout, bContext *C) | ||||
| /* some cosmetic tweaks */ | /* some cosmetic tweaks */ | ||||
| UI_but_type_set_menu_from_pulldown(but); | UI_but_type_set_menu_from_pulldown(but); | ||||
| but->flag &= ~UI_BUT_ICON_SUBMENU; | but->flag &= ~UI_BUT_ICON_SUBMENU; | ||||
| } | } | ||||
| /************************* Texture Show **************************/ | /************************* Texture Show **************************/ | ||||
| static ScrArea *find_area_properties(const bContext *C) | |||||
| { | |||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| ScrArea *area; | |||||
| for (area = screen->areabase.first; area; area = area->next) { | |||||
HooglyBoogly: This should use the `LISTBASE_FOREACH` macro. | |||||
| if (area->spacetype == SPACE_PROPERTIES) { | |||||
| return area; | |||||
| } | |||||
| } | |||||
| return NULL; | |||||
| } | |||||
| static SpaceProperties *find_space_properties(const bContext *C) | |||||
| { | |||||
| ScrArea *area = find_area_properties(C); | |||||
| if (area != NULL) { | |||||
| return area->spacedata.first; | |||||
| } | |||||
| return NULL; | |||||
| } | |||||
| static void template_texture_show(bContext *C, void *data_p, void *prop_p) | static void template_texture_show(bContext *C, void *data_p, void *prop_p) | ||||
| { | { | ||||
| SpaceProperties *sbuts = CTX_wm_space_properties(C); | ScrArea *area = find_area_properties(C); | ||||
| SpaceProperties *sbuts = (SpaceProperties *)area->spacedata.first; | |||||
| ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ||||
| ButsTextureUser *user; | ButsTextureUser *user; | ||||
| if (!ct) { | if (!ct) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (user = ct->users.first; user; user = user->next) { | for (user = ct->users.first; user; user = user->next) { | ||||
| if (user->ptr.data == data_p && user->prop == prop_p) { | if (user->ptr.data == data_p && user->prop == prop_p) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (user) { | if (user) { | ||||
| /* select texture */ | /* select texture */ | ||||
| template_texture_select(C, user, NULL); | template_texture_select(C, user, NULL); | ||||
| /* change context */ | /* change context */ | ||||
| sbuts->mainb = BCONTEXT_TEXTURE; | sbuts->mainb = BCONTEXT_TEXTURE; | ||||
| sbuts->mainbuser = sbuts->mainb; | sbuts->mainbuser = sbuts->mainb; | ||||
| sbuts->preview = 1; | sbuts->preview = 1; | ||||
| /* redraw editor */ | /* redraw editor */ | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(area); | ||||
| } | } | ||||
| } | } | ||||
| void uiTemplateTextureShow(uiLayout *layout, const bContext *C, PointerRNA *ptr, PropertyRNA *prop) | void uiTemplateTextureShow(uiLayout *layout, const bContext *C, PointerRNA *ptr, PropertyRNA *prop) | ||||
| { | { | ||||
| /* button to quickly show texture in texture tab */ | /* button to quickly show texture in texture tab */ | ||||
| SpaceProperties *sbuts = CTX_wm_space_properties(C); | SpaceProperties *sbuts = find_space_properties(C); | ||||
| ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; | ||||
| ButsTextureUser *user; | ButsTextureUser *user; | ||||
| /* only show button in other tabs in properties editor */ | /* only show button in other tabs in properties editor */ | ||||
| if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) { | if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 29 Lines | |||||
This should use the LISTBASE_FOREACH macro.