diff options
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 3efaff72637..13762b348c2 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -33,6 +33,7 @@ #include "DNA_armature_types.h" #include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -153,6 +154,29 @@ static bool buttons_context_path_world(ButsContextPath *path) return false; } +static bool buttons_context_path_collection(ButsContextPath *path, wmWindow *window) +{ + 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_Collection)) { + return true; + } + /* if we have a view layer, use the view layer's active collection */ + if (buttons_context_path_view_layer(path, window)) { + ViewLayer *view_layer = path->ptr[path->len - 1].data; + Collection *c = view_layer->active_collection->collection; + if (c) { + RNA_id_pointer_create(&c->id, &path->ptr[path->len]); + path->len++; + return true; + } + } + + /* no path to a collection possible */ + return false; +} + static bool buttons_context_path_linestyle(ButsContextPath *path, wmWindow *window) { PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -575,6 +599,9 @@ static bool buttons_context_path( case BCONTEXT_WORLD: found = buttons_context_path_world(path); break; + case BCONTEXT_COLLECTION: /* This is for Line Art collection flags */ + found = buttons_context_path_collection(path, window); + break; case BCONTEXT_TOOL: found = true; break; @@ -858,6 +885,10 @@ int /*eContextResult*/ buttons_context(const bContext *C, set_pointer_type(path, result, &RNA_World); return CTX_RESULT_OK; } + if (CTX_data_equals(member, "collection")) { + set_pointer_type(path, result, &RNA_Collection); + return 1; + } if (CTX_data_equals(member, "object")) { set_pointer_type(path, result, &RNA_Object); return CTX_RESULT_OK; |