Groups and collection: editing group collections

Allow users to edit either the object group active collection or view layer one

We can't support users selecting the group collections from the outliner group
because that would be imply having an active group for the scene or workspace.

But the way it is now allows to see and edit the collection values after the
group is instanced.
This commit is contained in:
Dalai Felinto
2017-11-30 18:38:07 -02:00
parent aeaf87bbeb
commit f91e057786
7 changed files with 80 additions and 23 deletions

View File

@@ -27,6 +27,16 @@ class CollectionButtonsPanel:
bl_context = "collection"
def get_collection_from_context(context):
active_object = context.active_object
if active_object and active_object.dupli_group and context.space_data.collection_context == 'GROUP':
group = active_object.dupli_group
return group.view_layer.collections.active
else:
return context.layer_collection
class COLLECTION_PT_context_collection(CollectionButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
@@ -34,8 +44,14 @@ class COLLECTION_PT_context_collection(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
space = context.space_data
active_object = context.active_object
collection = context.layer_collection
if active_object and active_object.dupli_group:
split = layout.split(percentage=0.2)
split.row().prop(space, "collection_context", expand=True)
layout = split
collection = get_collection_from_context(context)
name = collection.name
if name == 'Master Collection':
layout.label(text=name, icon='COLLAPSEMENU')
@@ -54,7 +70,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['BLENDER_CLAY']
collection = context.layer_collection
collection = get_collection_from_context(context)
collection_props = collection.engine_overrides['BLENDER_CLAY']
col = layout.column()
@@ -81,7 +97,7 @@ class COLLECTION_PT_object_mode_settings(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['ObjectMode']
collection = context.layer_collection
collection = get_collection_from_context(context)
collection_props = collection.engine_overrides['ObjectMode']
col = layout.column()
@@ -100,7 +116,7 @@ class COLLECTION_PT_edit_mode_settings(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['EditMode']
collection = context.layer_collection
collection = get_collection_from_context(context)
collection_props = collection.engine_overrides['EditMode']
col = layout.column()
@@ -124,7 +140,7 @@ class COLLECTION_PT_paint_weight_mode_settings(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['WeightPaintMode']
collection = context.layer_collection
collection = get_collection_from_context(context)
collection_props = collection.engine_overrides['WeightPaintMode']
col = layout.column()
@@ -143,7 +159,7 @@ class COLLECTION_PT_paint_vertex_mode_settings(CollectionButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
scene_props = context.scene.collection_properties['VertexPaintMode']
collection = context.layer_collection
collection = get_collection_from_context(context)
collection_props = collection.engine_overrides['VertexPaintMode']
col = layout.column()