Collection Manager: Add discard state feature. Task: T69577
Adds feature to discard histories for RTOs and the expand operator, and to discard copy/swap buffers.
This commit is contained in:
parent
57462fb093
commit
61f1c0aef5
|
@ -22,7 +22,7 @@ bl_info = {
|
|||
"name": "Collection Manager",
|
||||
"description": "Manage collections and their objects",
|
||||
"author": "Ryan Inch",
|
||||
"version": (2,2,1),
|
||||
"version": (2,3,2),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D - Object Mode (Shortcut - M)",
|
||||
"warning": '', # used for warning icon and text in addons panel
|
||||
|
|
|
@ -79,7 +79,7 @@ class ExpandAllOperator(Operator):
|
|||
|
||||
expand_history = {"target": "", "history": []}
|
||||
class ExpandSublevelOperator(Operator):
|
||||
''' * Ctrl-Click to expand/collapse all sublevels\n * Shift-Click to isolate/restore tree'''
|
||||
''' * Ctrl-Click to expand/collapse all sublevels\n * Shift-Click to isolate/restore tree\n * Alt-Click to discard history'''
|
||||
bl_label = "Expand Sublevel Items"
|
||||
bl_idname = "view3d.expand_sublevel"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -97,7 +97,12 @@ class ExpandSublevelOperator(Operator):
|
|||
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if modifiers == {"alt"}:
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"ctrl"}:
|
||||
# expand/collapse all subcollections
|
||||
expand = None
|
||||
|
||||
|
@ -211,7 +216,7 @@ class CMSetCollectionOperator(Operator):
|
|||
|
||||
|
||||
class CMExcludeOperator(Operator):
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation'''
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation\n * Alt-Click to discard history'''
|
||||
bl_label = "Exclude Collection from View Layer"
|
||||
bl_idname = "view3d.exclude_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -235,7 +240,11 @@ class CMExcludeOperator(Operator):
|
|||
target = rto_history["exclude"][view_layer]["target"]
|
||||
exclude_history = rto_history["exclude"][view_layer]["history"]
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["exclude"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
# isolate/de-isolate exclusion of collections
|
||||
|
||||
active_layer_collections = [x["ptr"] for x in layer_collections.values()
|
||||
|
@ -408,13 +417,15 @@ class CMExcludeOperator(Operator):
|
|||
|
||||
|
||||
class CMUnExcludeAllOperator(Operator):
|
||||
''' * Click to toggle between current excluded state and all included.\n * Shift-Click to invert excluded status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs'''
|
||||
''' * Click to toggle between current excluded state and all included.\n * Shift-Click to invert excluded status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs\n * Alt-Click to discard history and copy/swap actions'''
|
||||
bl_label = "Toggle Excluded Status Of All Collections"
|
||||
bl_idname = "view3d.un_exclude_all_collections"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
global copy_buffer
|
||||
global swap_buffer
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -424,9 +435,25 @@ class CMUnExcludeAllOperator(Operator):
|
|||
|
||||
exclude_all_history = rto_history["exclude_all"][view_layer]
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
global copy_buffer
|
||||
if modifiers == {"alt"}:
|
||||
# clear RTO history
|
||||
del rto_history["exclude_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
if copy_buffer["RTO"] == "exclude":
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
|
||||
# clear swap buffer
|
||||
if swap_buffer["A"]["RTO"] == "exclude":
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if not copy_buffer["values"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = "exclude"
|
||||
|
@ -448,8 +475,6 @@ class CMUnExcludeAllOperator(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl", "alt"}:
|
||||
global swap_buffer
|
||||
|
||||
if not swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = "exclude"
|
||||
|
@ -528,7 +553,7 @@ class CMUnExcludeAllOperator(Operator):
|
|||
|
||||
|
||||
class CMRestrictSelectOperator(Operator):
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation'''
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation\n * Alt-Click to discard history'''
|
||||
bl_label = "Disable Selection of Collection"
|
||||
bl_idname = "view3d.restrict_select_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -552,7 +577,11 @@ class CMRestrictSelectOperator(Operator):
|
|||
target = rto_history["select"][view_layer]["target"]
|
||||
select_history = rto_history["select"][view_layer]["history"]
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["select"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
# isolate/de-isolate selectability of collections
|
||||
|
||||
laycol = layer_collections[self.name]
|
||||
|
@ -720,13 +749,15 @@ class CMRestrictSelectOperator(Operator):
|
|||
|
||||
|
||||
class CMUnRestrictSelectAllOperator(Operator):
|
||||
''' * Click to toggle between current selectable state and all selectable.\n * Shift-Click to invert selectable status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs'''
|
||||
''' * Click to toggle between current selectable state and all selectable.\n * Shift-Click to invert selectable status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs\n * Alt-Click to discard history and copy/swap actions'''
|
||||
bl_label = "Toggle Selectable Status Of All Collections"
|
||||
bl_idname = "view3d.un_restrict_select_all_collections"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
global copy_buffer
|
||||
global swap_buffer
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -736,9 +767,25 @@ class CMUnRestrictSelectAllOperator(Operator):
|
|||
|
||||
select_all_history = rto_history["select_all"][view_layer]
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
global copy_buffer
|
||||
if modifiers == {"alt"}:
|
||||
# clear RTO history
|
||||
del rto_history["select_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
if copy_buffer["RTO"] == "collection.hide_select":
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
|
||||
# clear swap buffer
|
||||
if swap_buffer["A"]["RTO"] == "collection.hide_select":
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if not copy_buffer["values"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = "collection.hide_select"
|
||||
|
@ -760,8 +807,6 @@ class CMUnRestrictSelectAllOperator(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl", "alt"}:
|
||||
global swap_buffer
|
||||
|
||||
if not swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = "collection.hide_select"
|
||||
|
@ -836,7 +881,7 @@ class CMUnRestrictSelectAllOperator(Operator):
|
|||
|
||||
|
||||
class CMHideOperator(Operator):
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation'''
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation\n * Alt-Click to discard history'''
|
||||
bl_label = "Hide Collection"
|
||||
bl_idname = "view3d.hide_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -860,7 +905,11 @@ class CMHideOperator(Operator):
|
|||
target = rto_history["hide"][view_layer]["target"]
|
||||
hide_history = rto_history["hide"][view_layer]["history"]
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["hide"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
# isolate/de-isolate view of collections
|
||||
|
||||
laycol = layer_collections[self.name]
|
||||
|
@ -1028,13 +1077,15 @@ class CMHideOperator(Operator):
|
|||
|
||||
|
||||
class CMUnHideAllOperator(Operator):
|
||||
''' * Click to toggle between current visibility state and all visible.\n * Shift-Click to invert visibility status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs'''
|
||||
''' * Click to toggle between current visibility state and all visible.\n * Shift-Click to invert visibility status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs\n * Alt-Click to discard history and copy/swap actions'''
|
||||
bl_label = "Toggle Hidden Status Of All Collections"
|
||||
bl_idname = "view3d.un_hide_all_collections"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
global copy_buffer
|
||||
global swap_buffer
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -1044,9 +1095,25 @@ class CMUnHideAllOperator(Operator):
|
|||
|
||||
hide_all_history = rto_history["hide_all"][view_layer]
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
global copy_buffer
|
||||
if modifiers == {"alt"}:
|
||||
# clear RTO history
|
||||
del rto_history["hide_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
if copy_buffer["RTO"] == "hide_viewport":
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
|
||||
# clear swap buffer
|
||||
if swap_buffer["A"]["RTO"] == "hide_viewport":
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if not copy_buffer["values"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = "hide_viewport"
|
||||
|
@ -1068,8 +1135,6 @@ class CMUnHideAllOperator(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl", "alt"}:
|
||||
global swap_buffer
|
||||
|
||||
if not swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = "hide_viewport"
|
||||
|
@ -1142,7 +1207,7 @@ class CMUnHideAllOperator(Operator):
|
|||
|
||||
|
||||
class CMDisableViewportOperator(Operator):
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation'''
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation\n * Alt-Click to discard history'''
|
||||
bl_label = "Disable Collection in Viewport"
|
||||
bl_idname = "view3d.disable_viewport_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -1166,7 +1231,11 @@ class CMDisableViewportOperator(Operator):
|
|||
target = rto_history["disable"][view_layer]["target"]
|
||||
disable_history = rto_history["disable"][view_layer]["history"]
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["disable"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
# isolate/de-isolate disablement of collections in viewport
|
||||
|
||||
laycol = layer_collections[self.name]
|
||||
|
@ -1334,13 +1403,15 @@ class CMDisableViewportOperator(Operator):
|
|||
|
||||
|
||||
class CMUnDisableViewportAllOperator(Operator):
|
||||
''' * Click to toggle between current viewport display and all enabled.\n * Shift-Click to invert viewport display of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs'''
|
||||
''' * Click to toggle between current viewport display and all enabled.\n * Shift-Click to invert viewport display of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs\n * Alt-Click to discard history and copy/swap actions'''
|
||||
bl_label = "Toggle Viewport Display of All Collections"
|
||||
bl_idname = "view3d.un_disable_viewport_all_collections"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
global copy_buffer
|
||||
global swap_buffer
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -1350,9 +1421,25 @@ class CMUnDisableViewportAllOperator(Operator):
|
|||
|
||||
disable_all_history = rto_history["disable_all"][view_layer]
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
global copy_buffer
|
||||
if modifiers == {"alt"}:
|
||||
# clear RTO history
|
||||
del rto_history["disable_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
if copy_buffer["RTO"] == "collection.hide_viewport":
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
|
||||
# clear swap buffer
|
||||
if swap_buffer["A"]["RTO"] == "collection.hide_viewport":
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if not copy_buffer["values"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = "collection.hide_viewport"
|
||||
|
@ -1374,8 +1461,6 @@ class CMUnDisableViewportAllOperator(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl", "alt"}:
|
||||
global swap_buffer
|
||||
|
||||
if not swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = "collection.hide_viewport"
|
||||
|
@ -1450,7 +1535,7 @@ class CMUnDisableViewportAllOperator(Operator):
|
|||
|
||||
|
||||
class CMDisableRenderOperator(Operator):
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation'''
|
||||
''' * Shift-Click to isolate/restore previous state\n * Ctrl-Click to toggle children\n * Shift-Ctrl-Click to toggle nested isolation\n * Alt-Click to discard history'''
|
||||
bl_label = "Disable Collection in Render"
|
||||
bl_idname = "view3d.disable_render_collection"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
@ -1474,7 +1559,12 @@ class CMDisableRenderOperator(Operator):
|
|||
target = rto_history["render"][view_layer]["target"]
|
||||
render_history = rto_history["render"][view_layer]["history"]
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["render"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
# isolate/de-isolate render of collections
|
||||
|
||||
laycol = layer_collections[self.name]
|
||||
|
@ -1642,13 +1732,15 @@ class CMDisableRenderOperator(Operator):
|
|||
|
||||
|
||||
class CMUnDisableRenderAllOperator(Operator):
|
||||
''' * Click to toggle between current render status and all rendered.\n * Shift-Click to invert render status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs'''
|
||||
''' * Click to toggle between current render status and all rendered.\n * Shift-Click to invert render status of all collections\n * Ctrl-Click to Copy/Paste RTOs\n * Ctrl-Alt-Click to swap RTOs\n * Alt-Click to discard history and copy/swap actions'''
|
||||
bl_label = "Toggle Render Status of All Collections"
|
||||
bl_idname = "view3d.un_disable_render_all_collections"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
global copy_buffer
|
||||
global swap_buffer
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -1658,9 +1750,25 @@ class CMUnDisableRenderAllOperator(Operator):
|
|||
|
||||
render_all_history = rto_history["render_all"][view_layer]
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
global copy_buffer
|
||||
if modifiers == {"alt"}:
|
||||
# clear RTO history
|
||||
del rto_history["render_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
if copy_buffer["RTO"] == "collection.hide_render":
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
|
||||
# clear swap buffer
|
||||
if swap_buffer["A"]["RTO"] == "collection.hide_render":
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl"}:
|
||||
if not copy_buffer["values"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = "collection.hide_render"
|
||||
|
@ -1682,8 +1790,6 @@ class CMUnDisableRenderAllOperator(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
if modifiers == {"ctrl", "alt"}:
|
||||
global swap_buffer
|
||||
|
||||
if not swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = "collection.hide_render"
|
||||
|
|
Loading…
Reference in New Issue