From e7a8ab248112edffe09b574b68352160b59021db Mon Sep 17 00:00:00 2001 From: Ryan Inch <mythologylover75@gmail.com> Date: Thu, 9 Jan 2020 01:15:22 -0500 Subject: [PATCH] Collection Manager: Improve width calculation. Task: T69577 Improves the width calculation for the main window to better accommodate sub-collections and take into account the width of the scroll bar when it's present. --- object_collection_manager/__init__.py | 2 +- object_collection_manager/ui.py | 33 ++++++++++++++------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 4d19a5dae..16917ffff 100644 --- a/object_collection_manager/__init__.py +++ b/object_collection_manager/__init__.py @@ -22,7 +22,7 @@ bl_info = { "name": "Collection Manager", "description": "Manage collections and their objects", "author": "Ryan Inch", - "version": (1,8,7), + "version": (1,8,8), "blender": (2, 80, 0), "location": "View3D - Object Mode (Shortcut - M)", "warning": '', # used for warning icon and text in addons panel diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py index 604f105d3..dfdeb889c 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -152,23 +152,8 @@ class CollectionManager(Operator): def execute(self, context): wm = context.window_manager - lvl = 0 - - #expanded.clear() - - #excludeall_history.clear() - #restrictselectall_history.clear() - #hideall_history.clear() - #disableviewall_history.clear() - #disablerenderall_history.clear() update_property_group(context) - - lvl = get_max_lvl() - - if lvl > 25: - lvl = 25 - self.view_layer = context.view_layer.name # sync selection in ui list with active layer collection @@ -179,6 +164,7 @@ class CollectionManager(Operator): except: context.scene.CMListIndex = -1 + # check if in phantom mode and if it's still viable if context.scene.CM_Phantom_Mode: if set(layer_collections.keys()) != set(phantom_history["initial_state"].keys()): context.scene.CM_Phantom_Mode = False @@ -186,7 +172,22 @@ class CollectionManager(Operator): if context.view_layer.name != phantom_history["view_layer"]: context.scene.CM_Phantom_Mode = False - return wm.invoke_popup(self, width=(400+(lvl*20))) + # handle window sizing + max_width = 960 + min_width = 456 + width_step = 21 + scrollbar_width = 21 + lvl = get_max_lvl() + + width = min_width + (width_step * lvl) + + if len(layer_collections) > 14: + width += scrollbar_width + + if width > max_width: + width = max_width + + return wm.invoke_popup(self, width=width) def update_selection(self, context): -- GitLab