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-03-18 00:45:54 +0300
committerRyan Inch <mythologylover75@gmail.com>2020-03-18 07:48:47 +0300
commitf149e0a4442e2503e9910ff91c43105856a83387 (patch)
treed8766fd7436fdf6f96eebc78ad6f67b7337eadab /object_collection_manager
parentfae4f145e54d2238f5e9e25fc336f9a78abc693e (diff)
Collection Manager: Add swap RTOs feature. Task: T69577
Diffstat (limited to 'object_collection_manager')
-rw-r--r--object_collection_manager/__init__.py2
-rw-r--r--object_collection_manager/operators.py237
-rw-r--r--object_collection_manager/ui.py31
3 files changed, 259 insertions, 11 deletions
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index c473e6c7..bf3959af 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,0,2),
+ "version": (2,1,0),
"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 067a5277..27b5a032 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -54,6 +54,8 @@ rto_history = {
"render_all": {}
}
+swap_buffer = {"A": {"RTO": "", "values": []}, "B": {"RTO": "", "values": []}}
+
class ExpandAllOperator(Operator):
'''Expand/Collapse all collections'''
bl_label = "Expand All Items"
@@ -405,7 +407,7 @@ 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'''
+ ''' * Click to toggle between current excluded state and all included.\n * Shift-Click to invert excluded status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Excluded Status Of All Collections"
bl_idname = "view3d.un_exclude_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -420,6 +422,51 @@ class CMUnExcludeAllOperator(Operator):
exclude_all_history = rto_history["exclude_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "exclude"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].exclude)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "exclude"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].exclude)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(exclude_all_history) == 0:
exclude_all_history.clear()
keep_history = False
@@ -648,7 +695,7 @@ 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'''
+ ''' * Click to toggle between current selectable state and all selectable.\n * Shift-Click to invert selectable status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Selectable Status Of All Collections"
bl_idname = "view3d.un_restrict_select_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -663,6 +710,51 @@ class CMUnRestrictSelectAllOperator(Operator):
select_all_history = rto_history["select_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "collection.hide_select"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].collection.hide_select)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "collection.hide_select"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].collection.hide_select)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(select_all_history) == 0:
select_all_history.clear()
keep_history = False
@@ -887,7 +979,7 @@ 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'''
+ ''' * Click to toggle between current visibility state and all visible.\n * Shift-Click to invert visibility status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Hidden Status Of All Collections"
bl_idname = "view3d.un_hide_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -902,6 +994,51 @@ class CMUnHideAllOperator(Operator):
hide_all_history = rto_history["hide_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].hide_viewport)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].hide_viewport)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(hide_all_history) == 0:
hide_all_history.clear()
keep_history = False
@@ -1124,7 +1261,7 @@ 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'''
+ ''' * Click to toggle between current viewport display and all enabled.\n * Shift-Click to invert viewport display of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Viewport Display of All Collections"
bl_idname = "view3d.un_disable_viewport_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -1139,6 +1276,51 @@ class CMUnDisableViewportAllOperator(Operator):
disable_all_history = rto_history["disable_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "collection.hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].collection.hide_viewport)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "collection.hide_viewport"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].collection.hide_viewport)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(disable_all_history) == 0:
disable_all_history.clear()
keep_history = False
@@ -1363,7 +1545,7 @@ 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'''
+ ''' * Click to toggle between current render status and all rendered.\n * Shift-Click to invert render status of all collections\n * Ctrl-Alt-Click to swap RTOs'''
bl_label = "Toggle Render Status of All Collections"
bl_idname = "view3d.un_disable_render_all_collections"
bl_options = {'REGISTER', 'UNDO'}
@@ -1378,6 +1560,51 @@ class CMUnDisableRenderAllOperator(Operator):
render_all_history = rto_history["render_all"][view_layer]
+ if event.ctrl and event.alt:
+ global swap_buffer
+
+ if not swap_buffer["A"]["values"]:
+ # get A
+ swap_buffer["A"]["RTO"] = "collection.hide_render"
+ for laycol in layer_collections.values():
+ swap_buffer["A"]["values"].append(laycol["ptr"].collection.hide_render)
+
+ else:
+ if len(swap_buffer["A"]["values"]) != len(layer_collections):
+ return {'CANCELLED'}
+
+ # get B
+ swap_buffer["B"]["RTO"] = "collection.hide_render"
+ for laycol in layer_collections.values():
+ swap_buffer["B"]["values"].append(laycol["ptr"].collection.hide_render)
+
+ # swap A with B
+ for x, laycol in enumerate(layer_collections.values()):
+ attr_A = attr_B = laycol["ptr"]
+
+ # get attributes
+ RTO_A = swap_buffer["A"]["RTO"].split(".")
+ RTO_B = swap_buffer["B"]["RTO"].split(".")
+
+ if RTO_A[0] == "collection":
+ attr_A = getattr(attr_A, RTO_A[0])
+
+ if RTO_B[0] == "collection":
+ attr_B = getattr(attr_B, RTO_B[0])
+
+
+ # swap values
+ setattr(attr_A, RTO_A[-1], swap_buffer["B"]["values"][x])
+ setattr(attr_B, RTO_B[-1], swap_buffer["A"]["values"][x])
+
+ # clear swap buffer
+ swap_buffer["A"]["RTO"] = ""
+ swap_buffer["A"]["values"].clear()
+ swap_buffer["B"]["RTO"] = ""
+ swap_buffer["B"]["values"].clear()
+
+ return {'FINISHED'}
+
if len(render_all_history) == 0:
render_all_history.clear()
keep_history = False
diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py
index b29f5c59..dcc52455 100644
--- a/object_collection_manager/ui.py
+++ b/object_collection_manager/ui.py
@@ -38,6 +38,7 @@ from .internals import (
from .operators import (
rto_history,
+ swap_buffer,
expand_history,
phantom_history,
)
@@ -120,32 +121,52 @@ class CollectionManager(Operator):
if cm.show_exclude:
exclude_all_history = rto_history["exclude_all"].get(view_layer.name, [])
depress = True if len(exclude_all_history) else False
+ icon = 'CHECKBOX_HLT'
- sec2.operator("view3d.un_exclude_all_collections", text="", icon='CHECKBOX_HLT', depress=depress)
+ if swap_buffer["A"]["RTO"] == "exclude":
+ icon = 'ARROW_LEFTRIGHT'
+
+ sec2.operator("view3d.un_exclude_all_collections", text="", icon=icon, depress=depress)
if cm.show_selectable:
select_all_history = rto_history["select_all"].get(view_layer.name, [])
depress = True if len(select_all_history) else False
+ icon = 'RESTRICT_SELECT_OFF'
+
+ if swap_buffer["A"]["RTO"] == "collection.hide_select":
+ icon = 'ARROW_LEFTRIGHT'
- sec2.operator("view3d.un_restrict_select_all_collections", text="", icon='RESTRICT_SELECT_OFF', depress=depress)
+ sec2.operator("view3d.un_restrict_select_all_collections", text="", icon=icon, depress=depress)
if cm.show_hide_viewport:
hide_all_history = rto_history["hide_all"].get(view_layer.name, [])
depress = True if len(hide_all_history) else False
+ icon = 'HIDE_OFF'
+
+ if swap_buffer["A"]["RTO"] == "hide_viewport":
+ icon = 'ARROW_LEFTRIGHT'
- sec2.operator("view3d.un_hide_all_collections", text="", icon='HIDE_OFF', depress=depress)
+ sec2.operator("view3d.un_hide_all_collections", text="", icon=icon, depress=depress)
if cm.show_disable_viewport:
disable_all_history = rto_history["disable_all"].get(view_layer.name, [])
depress = True if len(disable_all_history) else False
+ icon = 'RESTRICT_VIEW_OFF'
- sec2.operator("view3d.un_disable_viewport_all_collections", text="", icon='RESTRICT_VIEW_OFF', depress=depress)
+ if swap_buffer["A"]["RTO"] == "collection.hide_viewport":
+ icon = 'ARROW_LEFTRIGHT'
+
+ sec2.operator("view3d.un_disable_viewport_all_collections", text="", icon=icon, depress=depress)
if cm.show_render:
render_all_history = rto_history["render_all"].get(view_layer.name, [])
depress = True if len(render_all_history) else False
+ icon = 'RESTRICT_RENDER_OFF'
+
+ if swap_buffer["A"]["RTO"] == "collection.hide_render":
+ icon = 'ARROW_LEFTRIGHT'
- sec2.operator("view3d.un_disable_render_all_collections", text="", icon='RESTRICT_RENDER_OFF', depress=depress)
+ sec2.operator("view3d.un_disable_render_all_collections", text="", icon=icon, depress=depress)
layout.row().template_list("CM_UL_items", "",
cm, "cm_list_collection",