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.
This commit is contained in:
parent
e0a324e87b
commit
8378eccbc9
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue