From 454288034df37c23f43f1c05e7a9eac0da0446fb Mon Sep 17 00:00:00 2001 From: Ryan Inch <mythologylover75@gmail.com> Date: Mon, 4 Nov 2019 03:46:03 -0500 Subject: [PATCH] Collection Manager: sync list selection to active collection. Task: T69577 --- collection_manager/__init__.py | 4 ++-- collection_manager/operators.py | 3 +-- collection_manager/ui.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/collection_manager/__init__.py b/collection_manager/__init__.py index 019f4d34..bf7d2bbb 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 6f8ba5ae..3c11c70a 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 234f47e1..b71d7fe3 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 = "" -- GitLab