diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index e7f233cd196..c54d85e6fc5 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4920,20 +4920,16 @@ class VIEW3D_PT_collections(Panel): bl_label = "Collections" bl_options = {'DEFAULT_CLOSED'} - def _draw_collection(self, layout, view_layer, collection, index): - need_separator = index + def _draw_collection(self, layout, view_layer, depth_limit, collection, index, depth): + depth = depth + 1 + if depth > depth_limit: + return index + for child in collection.children: index += 1 - if child.exclude: - continue - - if child.collection.hide_viewport: - continue - - if need_separator: - layout.separator() - need_separator = False + if child.exclude or child.collection.hide_viewport: + index = self._draw_collection(layout, view_layer, depth_limit, child, index, depth) icon = 'BLANK1' # has_objects = True @@ -4949,6 +4945,8 @@ class VIEW3D_PT_collections(Panel): sub = row.split(factor=0.98) subrow = sub.row() subrow.alignment = 'LEFT' + for i in range(depth - 1): + subrow.label(text="", icon='BLANK1') subrow.operator( "object.hide_collection", text=child.name, icon=icon, emboss=False, ).collection_index = index @@ -4959,8 +4957,7 @@ class VIEW3D_PT_collections(Panel): subrow.active = collection.is_visible # Parent collection runtime visibility subrow.prop(child, "hide_viewport", text="", emboss=False) - for child in collection.children: - index = self._draw_collection(layout, view_layer, child, index) + index = self._draw_collection(layout, view_layer, depth_limit, child, index, depth) return index @@ -4968,11 +4965,16 @@ class VIEW3D_PT_collections(Panel): layout = self.layout layout.use_property_split = False + view = context.space_data + view_layer = context.view_layer + layout.prop(view, "collections_depth", text="Display Depth") + depth_limit = view.collections_depth + # We pass index 0 here beause the index is increased # so the first real index is 1 # And we start with index as 1 because we skip the master collection - self._draw_collection(layout, view_layer, view_layer.layer_collection, 0) + self._draw_collection(layout, view_layer, depth_limit, view_layer.layer_collection, 0, 0) class VIEW3D_PT_object_type_visibility(Panel): diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 4b55364f0b1..10cd3e1a634 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3510,5 +3510,18 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) { arm->flag &= ~(ARM_FLAG_UNUSED_6); } + + if (!DNA_struct_elem_find(fd->filesdna, "View3D", "int", "collections_depth")) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->collections_depth = 2; + } + } + } + } + } } } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a390cf67cf5..045c664fe20 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -297,17 +297,11 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op) #define COLLECTION_INVALID_INDEX -1 -void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) +static void collection_hide_menu_draw(ViewLayer *view_layer, + uiLayout *layout, + ListBase *layer_collections) { - ViewLayer *view_layer = CTX_data_view_layer(C); - LayerCollection *lc_scene = view_layer->layer_collections.first; - - uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - - for (LayerCollection *lc = lc_scene->layer_collections.first; lc; lc = lc->next) { - int index = BKE_layer_collection_findindex(view_layer, lc); - uiLayout *row = uiLayoutRow(layout, false); - + for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) { if (lc->flag & LAYER_COLLECTION_EXCLUDE) { continue; } @@ -316,6 +310,9 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) continue; } + const int index = BKE_layer_collection_findindex(view_layer, lc); + uiLayout *row = uiLayoutRow(layout, false); + int icon = ICON_NONE; if (BKE_layer_collection_has_selected_objects(view_layer, lc)) { icon = ICON_LAYER_ACTIVE; @@ -331,6 +328,19 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) "collection_index", index); } + + for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) { + collection_hide_menu_draw(view_layer, layout, &lc->layer_collections); + } +} + +void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + LayerCollection *lc_scene = view_layer->layer_collections.first; + + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); + collection_hide_menu_draw(view_layer, layout, &lc_scene->layer_collections); } static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index c1891865d6d..1427b4c822b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -286,6 +286,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->bundle_size = 0.2f; v3d->bundle_drawtype = OB_PLAINAXES; + v3d->collections_depth = 2; /* stereo */ v3d->stereo3d_camera = STEREO_3D_ID; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 31ffb3efebd..76337413497 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -268,7 +268,7 @@ typedef struct View3D { unsigned short local_view_uuid; char _pad6[2]; - int layact DNA_DEPRECATED; + int collections_depth; /** Optional bool for 3d cursor to define center. */ short ob_centre_cursor; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 2b51b1eee97..f4c0164af84 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3959,6 +3959,14 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Volume Alpha", "Opacity (alpha) of the cameras' frustum volume"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "collections_depth", PROP_INT, PROP_UNSIGNED); + RNA_def_property_ui_text( + prop, "Collections Depth", "Shows the collections panel in more or less detail"); + RNA_def_property_int_default(prop, 2); + RNA_def_property_range(prop, 1, INT_MAX); + RNA_def_property_ui_range(prop, 1, 10, 1, 1); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + { struct { const char *name;