Collection Manager: Fix active collections. Task: T69577
Fix display of and interaction with active collections.
This commit is contained in:
parent
b734e59dd4
commit
fa71f709da
|
@ -22,7 +22,7 @@ bl_info = {
|
|||
"name": "Collection Manager",
|
||||
"description": "Manage collections and their objects",
|
||||
"author": "Ryan Inch",
|
||||
"version": (2, 7, 13),
|
||||
"version": (2, 7, 14),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D - Object Mode (Shortcut - M)",
|
||||
"warning": '', # used for warning icon and text in addons panel
|
||||
|
@ -68,7 +68,7 @@ from bpy.props import (
|
|||
|
||||
class CollectionManagerProperties(PropertyGroup):
|
||||
cm_list_collection: CollectionProperty(type=internals.CMListCollection)
|
||||
cm_list_index: IntProperty(update=ui.update_selection)
|
||||
cm_list_index: IntProperty()
|
||||
|
||||
show_exclude: BoolProperty(default=True, name="[EC] Exclude from View Layer")
|
||||
show_selectable: BoolProperty(default=True, name="[SS] Disable Selection")
|
||||
|
|
|
@ -69,13 +69,13 @@ class SetActiveCollection(Operator):
|
|||
'''Set the active collection'''
|
||||
bl_label = "Set Active Collection"
|
||||
bl_idname = "view3d.set_active_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
collection_index: IntProperty()
|
||||
collection_name: StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
if self.collection_index == 0:
|
||||
if self.collection_index == -1:
|
||||
cm = context.scene.collection_manager
|
||||
cm.cm_list_index = -1
|
||||
layer_collection = context.view_layer.layer_collection
|
||||
|
@ -86,6 +86,9 @@ class SetActiveCollection(Operator):
|
|||
|
||||
context.view_layer.active_layer_collection = layer_collection
|
||||
|
||||
if context.view_layer.active_layer_collection != layer_collection:
|
||||
self.report({'WARNING'}, "Can't set excluded collection as active")
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
@ -961,6 +964,11 @@ class CMNewCollectionOperator(Operator):
|
|||
|
||||
cm.cm_list_index = 0
|
||||
|
||||
|
||||
# set new collection to active
|
||||
layer_collection = layer_collections[new_collection.name]["ptr"]
|
||||
context.view_layer.active_layer_collection = layer_collection
|
||||
|
||||
global rename
|
||||
rename[0] = True
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class CollectionManager(Operator):
|
|||
|
||||
prop = master_collection_row.operator("view3d.set_active_collection",
|
||||
text='', icon='GROUP', depress=highlight)
|
||||
prop.collection_index = 0
|
||||
prop.collection_index = -1
|
||||
prop.collection_name = 'Master Collection'
|
||||
|
||||
master_collection_row.separator()
|
||||
|
@ -471,7 +471,17 @@ class CM_UL_items(UIList):
|
|||
row.label(icon='BLANK1')
|
||||
|
||||
|
||||
row.label(icon='GROUP')
|
||||
# collection icon
|
||||
c_icon = row.row()
|
||||
highlight = False
|
||||
if (context.view_layer.active_layer_collection == laycol["ptr"]):
|
||||
highlight = True
|
||||
|
||||
prop = c_icon.operator("view3d.set_active_collection", text='', icon='GROUP',
|
||||
emboss=highlight, depress=highlight)
|
||||
|
||||
prop.collection_index = laycol["row_index"]
|
||||
prop.collection_name = item.name
|
||||
|
||||
if context.preferences.addons[__package__].preferences.enable_qcd:
|
||||
QCD = row.row()
|
||||
|
@ -792,18 +802,6 @@ def update_icon(base, icon, theme_color):
|
|||
icon.icon_pixels_float = colored_icon
|
||||
|
||||
|
||||
def update_selection(self, context):
|
||||
cm = context.scene.collection_manager
|
||||
|
||||
if cm.cm_list_index == -1:
|
||||
return
|
||||
|
||||
selected_item = cm.cm_list_collection[cm.cm_list_index]
|
||||
layer_collection = layer_collections[selected_item.name]["ptr"]
|
||||
|
||||
context.view_layer.active_layer_collection = layer_collection
|
||||
|
||||
|
||||
def filter_items_by_name_insensitive(pattern, bitflag, items, propname="name", flags=None, reverse=False):
|
||||
"""
|
||||
Set FILTER_ITEM for items which name matches filter_name one (case-insensitive).
|
||||
|
|
Loading…
Reference in New Issue