Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_buttons/buttons_context.c
| Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | |||||
| static int buttons_context_path_workspace(ButsContextPath *path) | static int buttons_context_path_workspace(ButsContextPath *path) | ||||
| { | { | ||||
| PointerRNA *ptr = &path->ptr[path->len - 1]; | PointerRNA *ptr = &path->ptr[path->len - 1]; | ||||
| /* This one just verifies. */ | /* This one just verifies. */ | ||||
| return RNA_struct_is_a(ptr->type, &RNA_WorkSpace); | return RNA_struct_is_a(ptr->type, &RNA_WorkSpace); | ||||
| } | } | ||||
| static int buttons_context_path_collection(ButsContextPath *path, eSpaceButtons_Collection_Context collection_context) | |||||
| { | |||||
| PointerRNA *ptr = &path->ptr[path->len - 1]; | |||||
| /* if we already have a (pinned) Collection, we're done */ | |||||
| if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { | |||||
| return 1; | |||||
| } | |||||
| else if (RNA_struct_is_a(ptr->type, &RNA_ViewLayer)) { | |||||
| ViewLayer *view_layer = ptr->data; | |||||
| if (collection_context == SB_COLLECTION_CTX_GROUP) { | |||||
| Object *ob = OBACT(view_layer); | |||||
| if (ob && ob->dup_group) { | |||||
| view_layer = ob->dup_group->view_layer; | |||||
| /* Replace the view layer by the group in the context path. */ | |||||
| RNA_pointer_create(NULL, &RNA_Group, ob->dup_group, &path->ptr[path->len - 1]); | |||||
| } | |||||
| } | |||||
| LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer); | |||||
| if (layer_collection) { | |||||
| RNA_pointer_create(NULL, &RNA_LayerCollection, layer_collection, &path->ptr[path->len]); | |||||
| path->len++; | |||||
| return 1; | |||||
| } | |||||
| } | |||||
| /* no path to a collection possible */ | |||||
| return 0; | |||||
| } | |||||
| static int buttons_context_path_object(ButsContextPath *path) | static int buttons_context_path_object(ButsContextPath *path) | ||||
| { | { | ||||
| PointerRNA *ptr = &path->ptr[path->len - 1]; | PointerRNA *ptr = &path->ptr[path->len - 1]; | ||||
| /* if we already have a (pinned) object, we're done */ | /* if we already have a (pinned) object, we're done */ | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_Object)) { | if (RNA_struct_is_a(ptr->type, &RNA_Object)) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | #endif | ||||
| found = buttons_context_path_view_layer(path, workspace); | found = buttons_context_path_view_layer(path, workspace); | ||||
| break; | break; | ||||
| case BCONTEXT_WORLD: | case BCONTEXT_WORLD: | ||||
| found = buttons_context_path_world(path); | found = buttons_context_path_world(path); | ||||
| break; | break; | ||||
| case BCONTEXT_WORKSPACE: | case BCONTEXT_WORKSPACE: | ||||
| found = buttons_context_path_workspace(path); | found = buttons_context_path_workspace(path); | ||||
| break; | break; | ||||
| case BCONTEXT_COLLECTION: | |||||
| found = buttons_context_path_collection(path, sbuts->collection_context); | |||||
| break; | |||||
| case BCONTEXT_OBJECT: | case BCONTEXT_OBJECT: | ||||
| case BCONTEXT_PHYSICS: | case BCONTEXT_PHYSICS: | ||||
| case BCONTEXT_CONSTRAINT: | case BCONTEXT_CONSTRAINT: | ||||
| found = buttons_context_path_object(path); | found = buttons_context_path_object(path); | ||||
| break; | break; | ||||
| case BCONTEXT_MODIFIER: | case BCONTEXT_MODIFIER: | ||||
| found = buttons_context_path_modifier(path); | found = buttons_context_path_modifier(path); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | if (ptr && ptr->data) { | ||||
| CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); | CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "line_style")) { | else if (CTX_data_equals(member, "line_style")) { | ||||
| set_pointer_type(path, result, &RNA_FreestyleLineStyle); | set_pointer_type(path, result, &RNA_FreestyleLineStyle); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "collection")) { | |||||
| set_pointer_type(path, result, &RNA_LayerCollection); | |||||
| return 1; | |||||
| } | |||||
| else { | else { | ||||
| return 0; /* not found */ | return 0; /* not found */ | ||||
| } | } | ||||
| return -1; /* found but not available */ | return -1; /* found but not available */ | ||||
| } | } | ||||
| /************************* Drawing the Path ************************/ | /************************* Drawing the Path ************************/ | ||||
| ▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines | |||||