Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_buttons/buttons_context.c
| Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | |||||
| static int buttons_context_path_modifier(ButsContextPath *path) | static int buttons_context_path_modifier(ButsContextPath *path) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| if (buttons_context_path_object(path)) { | if (buttons_context_path_object(path)) { | ||||
| ob = path->ptr[path->len - 1].data; | ob = path->ptr[path->len - 1].data; | ||||
| if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) | if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int buttons_context_path_material(ButsContextPath *path) | static int buttons_context_path_material(ButsContextPath *path) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
| static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) | static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) | ||||
| { | { | ||||
| SpaceButs *sbuts = CTX_wm_space_buts(C); | SpaceButs *sbuts = CTX_wm_space_buts(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); | ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); | ||||
| ID *id; | ID *id; | ||||
| int found; | int found; | ||||
| Object *ob = CTX_data_active_object(C); | |||||
| memset(path, 0, sizeof(*path)); | memset(path, 0, sizeof(*path)); | ||||
| path->flag = flag; | path->flag = flag; | ||||
| /* If some ID datablock is pinned, set the root pointer. */ | /* If some ID datablock is pinned, set the root pointer. */ | ||||
| if (sbuts->pinid) { | if (sbuts->pinid) { | ||||
| id = sbuts->pinid; | id = sbuts->pinid; | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | case BCONTEXT_MODIFIER: | ||||
| break; | break; | ||||
| case BCONTEXT_DATA: | case BCONTEXT_DATA: | ||||
| found = buttons_context_path_data(path, -1); | found = buttons_context_path_data(path, -1); | ||||
| break; | break; | ||||
| case BCONTEXT_PARTICLE: | case BCONTEXT_PARTICLE: | ||||
| found = buttons_context_path_particle(path); | found = buttons_context_path_particle(path); | ||||
| break; | break; | ||||
| case BCONTEXT_MATERIAL: | case BCONTEXT_MATERIAL: | ||||
| /* the colors of grease pencil are not real materials, but to keep UI consistency, we | |||||
| simulate and generate a path */ | |||||
| if (ob && ob->type == OB_GPENCIL) { | |||||
| found = buttons_context_path_data(path, -1); | |||||
| break; | |||||
| } | |||||
| found = buttons_context_path_material(path); | found = buttons_context_path_material(path); | ||||
| break; | break; | ||||
| case BCONTEXT_TEXTURE: | case BCONTEXT_TEXTURE: | ||||
| found = buttons_context_path_texture(C, path, sbuts->texuser); | found = buttons_context_path_texture(C, path, sbuts->texuser); | ||||
| break; | break; | ||||
| case BCONTEXT_BONE: | case BCONTEXT_BONE: | ||||
| found = buttons_context_path_bone(path); | found = buttons_context_path_bone(path); | ||||
| if (!found) | if (!found) | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | void buttons_context_compute(const bContext *C, SpaceButs *sbuts) | ||||
| for (a = 0; a < BCONTEXT_TOT; a++) { | for (a = 0; a < BCONTEXT_TOT; a++) { | ||||
| if (buttons_context_path(C, path, a, pflag)) { | if (buttons_context_path(C, path, a, pflag)) { | ||||
| flag |= (1 << a); | flag |= (1 << a); | ||||
| /* setting icon for data context */ | /* setting icon for data context */ | ||||
| if (a == BCONTEXT_DATA) { | if (a == BCONTEXT_DATA) { | ||||
| ptr = &path->ptr[path->len - 1]; | ptr = &path->ptr[path->len - 1]; | ||||
| if (ptr->type) | if (ptr->type) { | ||||
| sbuts->dataicon = RNA_struct_ui_icon(ptr->type); | sbuts->dataicon = RNA_struct_ui_icon(ptr->type); | ||||
| else | } | ||||
| else { | |||||
| Object *ob = CTX_data_active_object(C); | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| sbuts->dataicon = ICON_GREASEPENCIL; | |||||
| } | |||||
| else { | |||||
| sbuts->dataicon = ICON_EMPTY_DATA; | sbuts->dataicon = ICON_EMPTY_DATA; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| /* always try to use the tab that was explicitly | /* always try to use the tab that was explicitly | ||||
| * set to the user, so that once that context comes | * set to the user, so that once that context comes | ||||
| * back, the tab is activated again */ | * back, the tab is activated again */ | ||||
| sbuts->mainb = sbuts->mainbuser; | sbuts->mainb = sbuts->mainbuser; | ||||
| /* in case something becomes invalid, change */ | /* in case something becomes invalid, change */ | ||||
| if ((flag & (1 << sbuts->mainb)) == 0) { | if ((flag & (1 << sbuts->mainb)) == 0) { | ||||
| ▲ Show 20 Lines • Show All 435 Lines • Show Last 20 Lines | |||||