diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 10 |
2 files changed, 41 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; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 07bc1d42c3f..43d45db38e2 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -206,6 +206,14 @@ int ED_buttons_tabs_list(SpaceProperties *sbuts, short *context_tabs_array) context_tabs_array[length] = -1; length++; } + if (sbuts->pathflag & (1 << BCONTEXT_VIEW_LAYER)) { + context_tabs_array[length] = BCONTEXT_COLLECTION; + length++; + } + if (length != 0) { + context_tabs_array[length] = -1; + length++; + } if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { context_tabs_array[length] = BCONTEXT_OBJECT; length++; @@ -271,6 +279,8 @@ static const char *buttons_main_region_context_string(const short mainb) return "view_layer"; case BCONTEXT_WORLD: return "world"; + case BCONTEXT_COLLECTION: + return "collection"; case BCONTEXT_OBJECT: return "object"; case BCONTEXT_DATA: |