[Bf-extensions-cvs] [a7fe2ba6] master: Collection Manager: Added proper view layer support. Task: T69577
Ryan Inch
noreply at git.blender.org
Mon Nov 25 08:58:39 CET 2019
Commit: a7fe2ba6378e81c7e8a9f73167567141882834c1
Author: Ryan Inch
Date: Sun Nov 24 22:22:49 2019 -0500
Branches: master
https://developer.blender.org/rBACa7fe2ba6378e81c7e8a9f73167567141882834c1
Collection Manager: Added proper view layer support. Task: T69577
Refactored toggle histories to facilitate this.
Fixed a bug with histories not being properly
saved/restored in some toggles
===================================================================
M collection_manager/__init__.py
M collection_manager/internals.py
M collection_manager/operators.py
M collection_manager/ui.py
===================================================================
diff --git a/collection_manager/__init__.py b/collection_manager/__init__.py
index faf849b8..3977de33 100644
--- a/collection_manager/__init__.py
+++ b/collection_manager/__init__.py
@@ -23,7 +23,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
- "version": (1,3,2),
+ "version": (1,4,0),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel
diff --git a/collection_manager/internals.py b/collection_manager/internals.py
index 3f35f143..e898de1c 100644
--- a/collection_manager/internals.py
+++ b/collection_manager/internals.py
@@ -13,11 +13,6 @@ row_index = 0
def get_max_lvl():
return max_lvl
-def clone_list(l1, l2):
- l1.clear()
- for x in l2:
- l1.append(x)
-
def update_col_name(self, context):
if self.name != self.last_name:
if self.name == '':
diff --git a/collection_manager/operators.py b/collection_manager/operators.py
index d3bfb345..413b228b 100644
--- a/collection_manager/operators.py
+++ b/collection_manager/operators.py
@@ -8,6 +8,18 @@ from bpy.props import (
from .internals import *
+rto_history = {"exclude": {},
+ "exclude_all": {},
+ "select": {},
+ "select_all": {},
+ "hide": {},
+ "hide_all": {},
+ "disable": {},
+ "disable_all": {},
+ "render": {},
+ "render_all": {}
+ }
+
class ExpandAllOperator(bpy.types.Operator):
'''Expand/Collapse all collections'''
bl_label = "Expand All Items"
@@ -125,7 +137,6 @@ class CMSetCollectionOperator(bpy.types.Operator):
return {'FINISHED'}
-exclude_history = []
class CMExcludeOperator(bpy.types.Operator):
'''Exclude collection. Shift-Click to isolate/restore collection'''
bl_label = "Exclude Collection"
@@ -135,10 +146,16 @@ class CMExcludeOperator(bpy.types.Operator):
name: StringProperty()
def invoke(self, context, event):
- global exclude_history
+ global rto_history
+ view_layer = context.view_layer.name
laycol_ptr = layer_collections[self.name]["ptr"]
+ if not view_layer in rto_history["exclude"]:
+ rto_history["exclude"][view_layer] = []
+
+ exclude_history = rto_history["exclude"][view_layer]
+
if event.shift:
# isolate/de-isolate exclusion of collections
@@ -168,11 +185,12 @@ class CMExcludeOperator(bpy.types.Operator):
keep_history = -1
for item in layer_collections.values():
exclude_history.append(item["ptr"].exclude)
+
if item["ptr"].exclude == False:
keep_history += 1
if not keep_history:
- exclude_history.clear()
+ del rto_history["exclude"][view_layer]
# isolate collection
@@ -199,7 +217,7 @@ class CMExcludeOperator(bpy.types.Operator):
# toggle exclusion
# reset exclude history
- exclude_history.clear()
+ del rto_history["exclude"][view_layer]
# get current child exclusion state
@@ -227,11 +245,12 @@ class CMExcludeOperator(bpy.types.Operator):
# reset exclude all history
- excludeall_history.clear()
+ if view_layer in rto_history["exclude_all"]:
+ del rto_history["exclude_all"][view_layer]
return {'FINISHED'}
-excludeall_history = []
+
class CMUnExcludeAllOperator(bpy.types.Operator):
'''Toggle excluded status of all collections'''
bl_label = "Toggle Exclude Collections"
@@ -239,34 +258,40 @@ class CMUnExcludeAllOperator(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
- global excludeall_history
+ global rto_history
- if len(excludeall_history) == 0 or len([l["ptr"].exclude for l in layer_collections.values() if l["ptr"].exclude == True]):
- excludeall_history.clear()
+ view_layer = context.view_layer.name
+
+ if not view_layer in rto_history["exclude_all"]:
+ rto_history["exclude_all"][view_layer] = []
+
+ exclude_all_history = rto_history["exclude_all"][view_layer]
+
+ if len(exclude_all_history) == 0 or len([l["ptr"].exclude for l in layer_collections.values() if l["ptr"].exclude == True]):
+ exclude_all_history.clear()
keep_history = 0
for item in reversed(list(layer_collections.values())):
if item["ptr"].exclude:
keep_history += 1
- excludeall_history.append(item["ptr"].exclude)
+ exclude_all_history.append(item["ptr"].exclude)
item["ptr"].exclude = False
- if not keep_history:
- excludeall_history.clear()
+ exclude_all_history.reverse()
- excludeall_history.reverse()
+ if not keep_history:
+ del rto_history["exclude_all"][view_layer]
else:
for x, item in enumerate(layer_collections.values()):
- item["ptr"].exclude = excludeall_history[x]
+ item["ptr"].exclude = exclude_all_history[x]
- excludeall_history.clear()
+ del rto_history["exclude_all"][view_layer]
return {'FINISHED'}
-restrictselect_history = []
class CMRestrictSelectOperator(bpy.types.Operator):
'''Change selectability. Shift-Click to isolate/restore selectability'''
bl_label = "Change Collection Selectability"
@@ -276,10 +301,16 @@ class CMRestrictSelectOperator(bpy.types.Operator):
name: StringProperty()
def invoke(self, context, event):
- global restrictselect_history
+ global rto_history
+ view_layer = context.view_layer.name
laycol_ptr = layer_collections[self.name]["ptr"]
+ if not view_layer in rto_history["select"]:
+ rto_history["select"][view_layer] = []
+
+ select_history = rto_history["select"][view_layer]
+
if event.shift:
# isolate/de-isolate selectability of collections
active_layer_collections = [x for x in layer_collections.values() \
@@ -287,10 +318,10 @@ class CMRestrictSelectOperator(bpy.types.Operator):
# check if selectable isolated
if len(active_layer_collections) == 1 and active_layer_collections[0]["name"] == self.name:
- if len(restrictselect_history) > 1:
+ if len(select_history) > 1:
# restore previous state
- for item in restrictselect_history:
- item["ptr"].collection.hide_select = False
+ for x, item in enumerate(layer_collections.values()):
+ item["ptr"].collection.hide_select = select_history[x]
else:
# make all collections selectable
@@ -298,8 +329,19 @@ class CMRestrictSelectOperator(bpy.types.Operator):
item["ptr"].collection.hide_select = False
else:
+ # reset select history
+ select_history.clear()
+
# save state
- restrictselect_history = active_layer_collections
+ keep_history = -1
+ for item in layer_collections.values():
+ select_history.append(item["ptr"].collection.hide_select)
+
+ if item["ptr"].collection.hide_select == False:
+ keep_history += 1
+
+ if not keep_history:
+ del rto_history["select"][view_layer]
# isolate selectable collection
for item in layer_collections.values():
@@ -311,19 +353,19 @@ class CMRestrictSelectOperator(bpy.types.Operator):
else:
# reset selectable history
- restrictselect_history.clear()
+ del rto_history["select"][view_layer]
# toggle selectability of collection
laycol_ptr.collection.hide_select = not laycol_ptr.collection.hide_select
# reset selectable all history
- restrictselectall_history.clear()
+ if view_layer in rto_history["select_all"]:
+ del rto_history["select_all"][view_layer]
return {'FINISHED'}
-restrictselectall_history = []
class CMUnRestrictSelectAllOperator(bpy.types.Operator):
'''Toggle selectable status of all collections'''
bl_label = "Toggle Selectable Collections"
@@ -331,32 +373,38 @@ class CMUnRestrictSelectAllOperator(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
- global restrictselectall_history
+ global rto_history
- if len(restrictselectall_history) == 0 or len([l["ptr"].collection.hide_select for l in layer_collections.values() if l["ptr"].collection.hide_select == True]):
- restrictselectall_history.clear()
+ view_layer = context.view_layer.name
+
+ if not view_layer in rto_history["select_all"]:
+ rto_history["select_all"][view_layer] = []
+
+ select_all_history = rto_history["select_all"][view_layer]
+
+ if len(select_all_history) == 0 or len([l["ptr"].collection.hide_select for l in layer_collections.values() if l["ptr"].collection.hide_select == True]):
+ select_all_history.clear()
keep_history = 0
for item in layer_collections.valu
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list