diff --git a/collection_manager/__init__.py b/collection_manager/__init__.py index 019f4d34dc34df37575f410a53d2c0579f29b7bc..bf7d2bbb1652272325845e9efc9c5f7792516e49 100644 --- a/collection_manager/__init__.py +++ b/collection_manager/__init__.py @@ -23,7 +23,7 @@ bl_info = { "name": "Collection Manager", "description": "Manage collections and their objects", "author": "Ryan Inch", - "version": (1,1,2), + "version": (1,2,0), "blender": (2, 80, 0), "location": "View3D - Object Mode (Shortcut - M)", "warning": '', # used for warning icon and text in addons panel @@ -79,7 +79,7 @@ def register(): bpy.utils.register_class(cls) bpy.types.Scene.CMListCollection = CollectionProperty(type=internals.CMListCollection) - bpy.types.Scene.CMListIndex = IntProperty() + bpy.types.Scene.CMListIndex = IntProperty(update=ui.update_selection) bpy.types.Scene.show_exclude = BoolProperty(default=True, name="Exclude from View Layer") bpy.types.Scene.show_selectable = BoolProperty(default=True, name="Selectable") diff --git a/collection_manager/operators.py b/collection_manager/operators.py index 6f8ba5aef66324e12edb57646b711fb833bad870..3c11c70a7de8002a3a90e2eacae05976ead28e7f 100644 --- a/collection_manager/operators.py +++ b/collection_manager/operators.py @@ -21,8 +21,7 @@ class ExpandAllOperator(bpy.types.Operator): if laycol["ptr"].children: expanded.append(laycol["name"]) - # set selected row to the first row and update tree view - context.scene.CMListIndex = 0 + # update tree view update_property_group(context) return {'FINISHED'} diff --git a/collection_manager/ui.py b/collection_manager/ui.py index 234f47e1d0b451550a2b4791e4ca18e1073737bf..b71d7fe313ff70164bc9682c479234bd4279b056 100644 --- a/collection_manager/ui.py +++ b/collection_manager/ui.py @@ -129,9 +129,21 @@ class CollectionManager(Operator): self.view_layer = context.view_layer.name + # sync selection in ui list with active layer collection + active_laycol_name = context.view_layer.active_layer_collection.name + active_laycol_row_index = layer_collections[active_laycol_name]["row_index"] + context.scene.CMListIndex = active_laycol_row_index + return wm.invoke_popup(self, width=(400+(lvl*20))) +def update_selection(self, context): + selected_item = context.scene.CMListCollection[context.scene.CMListIndex] + layer_collection = layer_collections[selected_item.name]["ptr"] + + context.view_layer.active_layer_collection = layer_collection + + class CM_UL_items(UIList): last_filter_value = ""