Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Inch <mythologylover75@gmail.com>2020-04-25 11:19:33 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-04-25 11:24:56 +0300
commit0618a7636e543a507102bf4b425ab6f41d2c40bc (patch)
tree61d4fd9206de346681a4164b7049215236e0cae6
parent67ef6e567b19c57720674242bb24c8d72c14e2ef (diff)
Collection Manager: Fix selection issues. Task: T69577
Make treeview selection more stable and predictable. Fix not being able to select the row from the left side with a top level expander -- adjusts window sizing to account for this.
-rw-r--r--object_collection_manager/__init__.py2
-rw-r--r--object_collection_manager/operators.py29
-rw-r--r--object_collection_manager/ui.py15
3 files changed, 27 insertions, 19 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 67300a8b..f5ff542e 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": (2, 7, 14),
+ "version": (2, 7, 15),
"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/operators.py b/object_collection_manager/operators.py
index b03370d9..3fe19660 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -76,14 +76,16 @@ class SetActiveCollection(Operator):
def execute(self, context):
if self.collection_index == -1:
- cm = context.scene.collection_manager
- cm.cm_list_index = -1
layer_collection = context.view_layer.layer_collection
else:
laycol = layer_collections[self.collection_name]
layer_collection = laycol["ptr"]
+ # set selection to this row
+ cm = context.scene.collection_manager
+ cm.cm_list_index = laycol["row_index"]
+
context.view_layer.active_layer_collection = layer_collection
if context.view_layer.active_layer_collection != layer_collection:
@@ -119,7 +121,6 @@ class ExpandAllOperator(Operator):
class ExpandSublevelOperator(Operator):
- ''''''
bl_label = "Expand Sublevel Items"
bl_description = (
" * Ctrl+LMB - Expand/Collapse all sublevels\n"
@@ -204,8 +205,7 @@ class ExpandSublevelOperator(Operator):
expand_history["history"].clear()
- # set selected row to the collection you're expanding/collapsing and update tree view
- context.scene.collection_manager.cm_list_index = self.index
+ #update tree view
update_property_group(context)
return {'FINISHED'}
@@ -862,6 +862,7 @@ class CMRemoveCollectionOperator(Operator):
laycol = layer_collections[self.collection_name]
collection = laycol["ptr"].collection
parent_collection = laycol["parent"]["ptr"].collection
+ selected_row_name = cm.cm_list_collection[cm.cm_list_index].name
# shift all objects in this collection to the parent collection
@@ -889,9 +890,21 @@ class CMRemoveCollectionOperator(Operator):
update_property_group(context)
- if len(cm.cm_list_collection) == cm.cm_list_index:
- cm.cm_list_index = len(cm.cm_list_collection) - 1
- update_property_group(context)
+ # update selected row
+ laycol = layer_collections.get(selected_row_name, None)
+ if laycol:
+ cm.cm_list_index = laycol["row_index"]
+
+ elif len(cm.cm_list_collection) == cm.cm_list_index:
+ cm.cm_list_index -= 1
+
+ if cm.cm_list_index > -1:
+ name = cm.cm_list_collection[cm.cm_list_index].name
+ laycol = layer_collections[name]
+ while not laycol["visible"]:
+ laycol = laycol["parent"]
+
+ cm.cm_list_index = laycol["row_index"]
# update qcd
diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py
index f4f0e73e..46d27e77 100644
--- a/object_collection_manager/ui.py
+++ b/object_collection_manager/ui.py
@@ -322,15 +322,6 @@ class CollectionManager(Operator):
self.view_layer = view_layer.name
- # sync selection in ui list with active layer collection
- try:
- active_laycol_name = view_layer.active_layer_collection.name
- active_laycol_row_index = layer_collections[active_laycol_name]["row_index"]
- cm.cm_list_index = active_laycol_row_index
-
- except KeyError: # Master Collection is special and not part of regular collections
- cm.cm_list_index = -1
-
# check if expanded & history/buffer state still correct
if collection_state:
new_state = generate_state()
@@ -387,11 +378,12 @@ class CollectionManager(Operator):
# handle window sizing
max_width = 960
min_width = 456
+ row_indent_width = 15
width_step = 21
scrollbar_width = 21
lvl = get_max_lvl()
- width = min_width + (width_step * lvl)
+ width = min_width + row_indent_width + (width_step * lvl)
if len(layer_collections) > 14:
width += scrollbar_width
@@ -440,6 +432,9 @@ class CM_UL_items(UIList):
row = split.row(align=True)
row.alignment = 'LEFT'
+ # allow room to select the row from the beginning
+ row.separator()
+
# indent child items
if laycol["lvl"] > 0:
for _ in range(laycol["lvl"]):