diff options
author | Ryan Inch <mythologylover75@gmail.com> | 2020-04-17 11:20:13 +0300 |
---|---|---|
committer | Ryan Inch <mythologylover75@gmail.com> | 2020-04-17 11:24:26 +0300 |
commit | ab7daecbb2dfe5fe8b0110bb92cd195d98c29649 (patch) | |
tree | 7e95ac252c26d64b36ed38a159ab017743c3ccc9 | |
parent | 968da083b882d51dc1daa803c8e2a3e9a25ea8ad (diff) |
Collection Manager: Expander fixes. Task: T69577
Fix expanded not getting properly updated on collection name change.
Fix expand history not getting updated on collection name change.
Fix expand history not getting cleared on collapse all.
Fix isolate tree restoring no matter what expander you click on.
Fix UI not showing isolated status when expander not expanded.
-rw-r--r-- | object_collection_manager/__init__.py | 2 | ||||
-rw-r--r-- | object_collection_manager/internals.py | 28 | ||||
-rw-r--r-- | object_collection_manager/operators.py | 19 | ||||
-rw-r--r-- | object_collection_manager/ui.py | 8 |
4 files changed, 42 insertions, 15 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 0a5eed5d..d750342f 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,9), + "version": (2,7,10), "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/internals.py b/object_collection_manager/internals.py index 0b5b4333..3244866d 100644 --- a/object_collection_manager/internals.py +++ b/object_collection_manager/internals.py @@ -228,6 +228,7 @@ def update_col_name(self, context): global layer_collections global qcd_slots global rto_history + global expand_history if self.name != self.last_name: if self.name == '': @@ -242,7 +243,9 @@ def update_col_name(self, context): layer_collections[self.last_name]["ptr"].collection.name = self.name # update expanded - if self.last_name in expanded: + orig_expanded = {x for x in expanded} + + if self.last_name in orig_expanded: expanded.remove(self.last_name) expanded.add(self.name) @@ -277,6 +280,17 @@ def update_col_name(self, context): if history and orig_targets[rto] == self.last_name: history["target"] = self.name + # update expand history + orig_expand_target = expand_history["target"] + orig_expand_history = [x for x in expand_history["history"]] + + if orig_expand_target == self.last_name: + expand_history["target"] = self.name + + for x, name in enumerate(orig_expand_history): + if name == self.last_name: + expand_history["history"][x] = self.name + # update names in expanded, qcd slots, and rto_history for any other # collection names that changed as a result of this name change cm_list_collection = context.scene.collection_manager.cm_list_collection @@ -289,8 +303,8 @@ def update_col_name(self, context): if cm_list_item.name != layer_collection.name: # update expanded - if cm_list_item.name in expanded: - if not cm_list_item.name in layer_collections: + if cm_list_item.last_name in orig_expanded: + if not cm_list_item.last_name in layer_collections: expanded.remove(cm_list_item.name) expanded.add(layer_collection.name) @@ -314,6 +328,14 @@ def update_col_name(self, context): if history and orig_targets[rto] == cm_list_item.last_name: history["target"] = layer_collection.name + # update expand history + if orig_expand_target == cm_list_item.last_name: + expand_history["target"] = layer_collection.name + + for x, name in enumerate(orig_expand_history): + if name == cm_list_item.last_name: + expand_history["history"][x] = layer_collection.name + if layer_collection.children: laycol_iter_list[0:0] = list(layer_collection.children) diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py index 11d75171..b1d4d4ca 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -96,6 +96,8 @@ class ExpandAllOperator(Operator): bl_options = {'REGISTER', 'UNDO'} def execute(self, context): + global expand_history + if len(expanded) > 0: expanded.clear() else: @@ -103,6 +105,10 @@ class ExpandAllOperator(Operator): if laycol["ptr"].children: expanded.add(laycol["name"]) + # clear expand history + expand_history["target"] = "" + expand_history["history"].clear() + # update tree view update_property_group(context) @@ -124,9 +130,6 @@ class ExpandSublevelOperator(Operator): name: StringProperty() index: IntProperty() - # static class var - isolated = False - def invoke(self, context, event): global expand_history cls = ExpandSublevelOperator @@ -136,7 +139,6 @@ class ExpandSublevelOperator(Operator): if modifiers == {"alt"}: expand_history["target"] = "" expand_history["history"].clear() - cls.isolated = False elif modifiers == {"ctrl"}: # expand/collapse all subcollections @@ -161,7 +163,6 @@ class ExpandSublevelOperator(Operator): expand_history["target"] = "" expand_history["history"].clear() - cls.isolated = False elif modifiers == {"shift"}: def isolate_tree(current_laycol): @@ -175,18 +176,19 @@ class ExpandSublevelOperator(Operator): if parent["parent"]: isolate_tree(parent) - if cls.isolated: + if self.name == expand_history["target"]: for item in expand_history["history"]: expanded.add(item) expand_history["target"] = "" expand_history["history"].clear() - cls.isolated = False else: + expand_history["target"] = "" + expand_history["history"].clear() + isolate_tree(layer_collections[self.name]) expand_history["target"] = self.name - cls.isolated = True else: # expand/collapse collection @@ -197,7 +199,6 @@ class ExpandSublevelOperator(Operator): expand_history["target"] = "" expand_history["history"].clear() - cls.isolated = False # set selected row to the collection you're expanding/collapsing and update tree view diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py index 1b675165..d4a4f49e 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -440,15 +440,19 @@ class CM_UL_items(UIList): if laycol["expanded"]: highlight = True if expand_history["target"] == item.name else False - prop = row.operator("view3d.expand_sublevel", text="", icon='DISCLOSURE_TRI_DOWN', + prop = row.operator("view3d.expand_sublevel", text="", + icon='DISCLOSURE_TRI_DOWN', emboss=highlight, depress=highlight) prop.expand = False prop.name = item.name prop.index = index else: + highlight = True if expand_history["target"] == item.name else False + prop = row.operator("view3d.expand_sublevel", text="", - icon='DISCLOSURE_TRI_RIGHT', emboss=False) + icon='DISCLOSURE_TRI_RIGHT', + emboss=highlight, depress=highlight) prop.expand = True prop.name = item.name prop.index = index |