Viewport collections visibility popover

This brings the functionality currently in the H shortcut, to hide/show
individual collections.

In order to convey hierarchy, and to make justice to the originally
intended 1-10 shortcuts, we group the collections per siblings.
This commit is contained in:
Dalai Felinto
2018-11-15 11:35:14 -02:00
parent b85886f8d5
commit 098e807f9e

View File

@@ -245,6 +245,13 @@ class VIEW3D_HT_header(Header):
layout.separator_spacer()
# Collection Visibility
layout.popover(
panel="VIEW3D_PT_collections",
icon='GROUP',
text="",
)
# Viewport Settings
layout.popover(
panel="VIEW3D_PT_object_type_visibility",
@@ -4000,6 +4007,57 @@ class VIEW3D_PT_view3d_cursor(Panel):
layout.column().prop(view, "cursor_location", text="Location")
class VIEW3D_PT_collections(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_label = "Collections Visibility"
bl_ui_units_x = 7
def _draw_collection(self, layout, view_layer, collection, index):
need_separator = 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
icon = 'BLANK1'
if child.has_selected_objects(view_layer):
icon = 'LAYER_ACTIVE'
elif child.has_objects():
icon = 'LAYER_USED'
row = layout.row()
row.alignment = 'LEFT'
row.active = child.has_visible_objects(view_layer)
row.operator("object.hide_collection", text=child.name, icon=icon, emboss=False).collection_index = index
for child in collection.children:
index = self._draw_collection(layout, view_layer, child, index)
return index
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.label(text="Collections Visibility", icon='GROUP')
col = layout.column()
view_layer = context.view_layer
# 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)
class VIEW3D_PT_object_type_visibility(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -5362,6 +5420,7 @@ classes = (
VIEW3D_PT_view3d_properties,
VIEW3D_PT_view3d_camera_lock,
VIEW3D_PT_view3d_cursor,
VIEW3D_PT_collections,
VIEW3D_PT_object_type_visibility,
VIEW3D_PT_grease_pencil,
VIEW3D_PT_gpencil_multi_frame,