diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 23 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_group.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 10 |
6 files changed, 58 insertions, 17 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 183d715a93e..8866c6b6c40 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -39,6 +39,7 @@ #include "BLT_translation.h" #include "DNA_armature_types.h" +#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -177,7 +178,7 @@ static int buttons_context_path_workspace(ButsContextPath *path) return RNA_struct_is_a(ptr->type, &RNA_WorkSpace); } -static int buttons_context_path_collection(ButsContextPath *path) +static int buttons_context_path_collection(ButsContextPath *path, eSpaceButtons_Collection_Context collection_context) { PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -187,10 +188,21 @@ static int buttons_context_path_collection(ButsContextPath *path) } ViewLayer *view_layer = ptr->data; - LayerCollection *sc = BKE_layer_collection_get_active(view_layer); - if (sc) { - RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); + 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; } @@ -650,7 +662,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_workspace(path); break; case BCONTEXT_COLLECTION: - found = buttons_context_path_collection(path); + found = buttons_context_path_collection(path, sbuts->collection_context); break; case BCONTEXT_OBJECT: case BCONTEXT_PHYSICS: diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 7fc35a6b1e7..e6d19caad47 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -65,6 +65,7 @@ typedef struct ButsContextPath { int len; int flag; int tex_ctx; + int collection_ctx; } ButsContextPath; typedef struct ButsTextureUser { diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 70d01007d89..08b5f337936 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -781,15 +781,24 @@ static eOLDrawState tree_element_active_collection( /* don't allow selecting a scene collection, it can have multiple layer collection * instances (which one would the user want to be selected then?) */ else if (tselem->type == TSE_LAYER_COLLECTION) { - ViewLayer *view_layer = CTX_data_view_layer(C); - LayerCollection *lc = te->directdata; - const int collection_index = BKE_layer_collection_findindex(view_layer, lc); + LayerCollection *layer_collection = te->directdata; + + switch (layer_collection->scene_collection->type) { + case COLLECTION_TYPE_NONE: + case COLLECTION_TYPE_GROUP_INTERNAL: + { + ViewLayer *view_layer = BKE_view_layer_find_from_collection(tselem->id, layer_collection); + const int collection_index = BKE_layer_collection_findindex(view_layer, layer_collection); - /* If the collection is part of a group we don't change active collection. */ - if (collection_index > -1) { - view_layer->active_collection = collection_index; - WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); + if (collection_index > -1) { + view_layer->active_collection = collection_index; + } + break; + } + default: + BLI_assert(!"Collection type not fully implemented"); } + WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); } return OL_DRAWSEL_NONE; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index a1db47e54f2..0e0d40a38f1 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -126,7 +126,9 @@ typedef struct SpaceButs { short preview; /* preview is signal to refresh */ /* texture context selector (material, lamp, particles, world, other) */ short texture_context, texture_context_prev; - char flag, pad[7]; + char flag; + char collection_context; + char pad[6]; void *path; /* runtime */ int pathflag, dataicon; /* runtime */ @@ -208,6 +210,12 @@ typedef enum eSpaceButtons_Texture_Context { SB_TEXC_LINESTYLE = 5, } eSpaceButtons_Texture_Context; +/* sbuts->collection_context */ +typedef enum eSpaceButtons_Collection_Context { + SB_COLLECTION_CTX_VIEW_LAYER = 0, + SB_COLLECTION_CTX_GROUP = 1, +} eSpaceButtons_Collection_Context; + /* sbuts->align */ typedef enum eSpaceButtons_Align { BUT_FREE = 0, diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index ec67370b14f..bf64bb1181f 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -132,10 +132,11 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_Group_objects_get", NULL, NULL, NULL, NULL); rna_def_group_objects(brna, prop); - prop = RNA_def_property(srna, "collections", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "view_layer->layer_collections", NULL); - RNA_def_property_struct_type(prop, "LayerCollection"); - RNA_def_property_ui_text(prop, "Layer Collections", ""); + prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ViewLayer"); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "View Layer", "Group internal view layer"); } #endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3a496d13429..aa3f159af40 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -225,6 +225,11 @@ static const EnumPropertyItem buttons_texture_context_items[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem buttons_collection_context_items[] = { + {SB_COLLECTION_CTX_VIEW_LAYER, "VIEW_LAYER", ICON_RENDERLAYERS, "", "Show material textures"}, + {SB_COLLECTION_CTX_GROUP, "GROUP", ICON_GROUP, "", "Show world textures"}, + {0, NULL, 0, NULL, NULL} +}; static const EnumPropertyItem fileselectparams_recursion_level_items[] = { {0, "NONE", 0, "None", "Only list current directory's content, with no recursion"}, @@ -2743,6 +2748,11 @@ static void rna_def_space_buttons(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Limited Texture Context", "Use the limited version of texture user (for 'old shading' mode)"); + prop = RNA_def_property(srna, "collection_context", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, buttons_collection_context_items); + RNA_def_property_ui_text(prop, "Collection Context", "Which collection we want to show"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL); + /* pinned data */ prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); |