From 67ef6e567b19c57720674242bb24c8d72c14e2ef Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Sat, 25 Apr 2020 04:15:30 -0400 Subject: Collection Manager: Fix active collections. Task: T69577 Fix display of and interaction with active collections. --- object_collection_manager/__init__.py | 4 ++-- object_collection_manager/operators.py | 12 ++++++++++-- object_collection_manager/ui.py | 26 ++++++++++++-------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 3ee2b18e..67300a8b 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, 13), + "version": (2, 7, 14), "blender": (2, 80, 0), "location": "View3D - Object Mode (Shortcut - M)", "warning": '', # used for warning icon and text in addons panel @@ -68,7 +68,7 @@ from bpy.props import ( class CollectionManagerProperties(PropertyGroup): cm_list_collection: CollectionProperty(type=internals.CMListCollection) - cm_list_index: IntProperty(update=ui.update_selection) + cm_list_index: IntProperty() show_exclude: BoolProperty(default=True, name="[EC] Exclude from View Layer") show_selectable: BoolProperty(default=True, name="[SS] Disable Selection") diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py index c1259acd..b03370d9 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -69,13 +69,13 @@ class SetActiveCollection(Operator): '''Set the active collection''' bl_label = "Set Active Collection" bl_idname = "view3d.set_active_collection" - bl_options = {'REGISTER', 'UNDO'} + bl_options = {'UNDO'} collection_index: IntProperty() collection_name: StringProperty() def execute(self, context): - if self.collection_index == 0: + if self.collection_index == -1: cm = context.scene.collection_manager cm.cm_list_index = -1 layer_collection = context.view_layer.layer_collection @@ -86,6 +86,9 @@ class SetActiveCollection(Operator): context.view_layer.active_layer_collection = layer_collection + if context.view_layer.active_layer_collection != layer_collection: + self.report({'WARNING'}, "Can't set excluded collection as active") + return {'FINISHED'} @@ -961,6 +964,11 @@ class CMNewCollectionOperator(Operator): cm.cm_list_index = 0 + + # set new collection to active + layer_collection = layer_collections[new_collection.name]["ptr"] + context.view_layer.active_layer_collection = layer_collection + global rename rename[0] = True diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py index 61c44a5b..f4f0e73e 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -150,7 +150,7 @@ class CollectionManager(Operator): prop = master_collection_row.operator("view3d.set_active_collection", text='', icon='GROUP', depress=highlight) - prop.collection_index = 0 + prop.collection_index = -1 prop.collection_name = 'Master Collection' master_collection_row.separator() @@ -471,7 +471,17 @@ class CM_UL_items(UIList): row.label(icon='BLANK1') - row.label(icon='GROUP') + # collection icon + c_icon = row.row() + highlight = False + if (context.view_layer.active_layer_collection == laycol["ptr"]): + highlight = True + + prop = c_icon.operator("view3d.set_active_collection", text='', icon='GROUP', + emboss=highlight, depress=highlight) + + prop.collection_index = laycol["row_index"] + prop.collection_name = item.name if context.preferences.addons[__package__].preferences.enable_qcd: QCD = row.row() @@ -792,18 +802,6 @@ def update_icon(base, icon, theme_color): icon.icon_pixels_float = colored_icon -def update_selection(self, context): - cm = context.scene.collection_manager - - if cm.cm_list_index == -1: - return - - selected_item = cm.cm_list_collection[cm.cm_list_index] - layer_collection = layer_collections[selected_item.name]["ptr"] - - context.view_layer.active_layer_collection = layer_collection - - def filter_items_by_name_insensitive(pattern, bitflag, items, propname="name", flags=None, reverse=False): """ Set FILTER_ITEM for items which name matches filter_name one (case-insensitive). -- cgit v1.2.3 From 0618a7636e543a507102bf4b425ab6f41d2c40bc Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Sat, 25 Apr 2020 04:19:33 -0400 Subject: Collection Manager: Fix selection issues. Task: T69577 Make treeview selection more stable and predictable. Fix not being able to select the row from the left side with a top level expander -- adjusts window sizing to account for this. --- object_collection_manager/__init__.py | 2 +- object_collection_manager/operators.py | 29 +++++++++++++++++++++-------- object_collection_manager/ui.py | 15 +++++---------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 67300a8b..f5ff542e 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, 14), + "version": (2, 7, 15), "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 b03370d9..3fe19660 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -76,14 +76,16 @@ class SetActiveCollection(Operator): def execute(self, context): if self.collection_index == -1: - cm = context.scene.collection_manager - cm.cm_list_index = -1 layer_collection = context.view_layer.layer_collection else: laycol = layer_collections[self.collection_name] layer_collection = laycol["ptr"] + # set selection to this row + cm = context.scene.collection_manager + cm.cm_list_index = laycol["row_index"] + context.view_layer.active_layer_collection = layer_collection if context.view_layer.active_layer_collection != layer_collection: @@ -119,7 +121,6 @@ class ExpandAllOperator(Operator): class ExpandSublevelOperator(Operator): - '''''' bl_label = "Expand Sublevel Items" bl_description = ( " * Ctrl+LMB - Expand/Collapse all sublevels\n" @@ -204,8 +205,7 @@ class ExpandSublevelOperator(Operator): expand_history["history"].clear() - # set selected row to the collection you're expanding/collapsing and update tree view - context.scene.collection_manager.cm_list_index = self.index + #update tree view update_property_group(context) return {'FINISHED'} @@ -862,6 +862,7 @@ class CMRemoveCollectionOperator(Operator): laycol = layer_collections[self.collection_name] collection = laycol["ptr"].collection parent_collection = laycol["parent"]["ptr"].collection + selected_row_name = cm.cm_list_collection[cm.cm_list_index].name # shift all objects in this collection to the parent collection @@ -889,9 +890,21 @@ class CMRemoveCollectionOperator(Operator): update_property_group(context) - if len(cm.cm_list_collection) == cm.cm_list_index: - cm.cm_list_index = len(cm.cm_list_collection) - 1 - update_property_group(context) + # update selected row + laycol = layer_collections.get(selected_row_name, None) + if laycol: + cm.cm_list_index = laycol["row_index"] + + elif len(cm.cm_list_collection) == cm.cm_list_index: + cm.cm_list_index -= 1 + + if cm.cm_list_index > -1: + name = cm.cm_list_collection[cm.cm_list_index].name + laycol = layer_collections[name] + while not laycol["visible"]: + laycol = laycol["parent"] + + cm.cm_list_index = laycol["row_index"] # update qcd diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py index f4f0e73e..46d27e77 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -322,15 +322,6 @@ class CollectionManager(Operator): self.view_layer = view_layer.name - # sync selection in ui list with active layer collection - try: - active_laycol_name = view_layer.active_layer_collection.name - active_laycol_row_index = layer_collections[active_laycol_name]["row_index"] - cm.cm_list_index = active_laycol_row_index - - except KeyError: # Master Collection is special and not part of regular collections - cm.cm_list_index = -1 - # check if expanded & history/buffer state still correct if collection_state: new_state = generate_state() @@ -387,11 +378,12 @@ class CollectionManager(Operator): # handle window sizing max_width = 960 min_width = 456 + row_indent_width = 15 width_step = 21 scrollbar_width = 21 lvl = get_max_lvl() - width = min_width + (width_step * lvl) + width = min_width + row_indent_width + (width_step * lvl) if len(layer_collections) > 14: width += scrollbar_width @@ -440,6 +432,9 @@ class CM_UL_items(UIList): row = split.row(align=True) row.alignment = 'LEFT' + # allow room to select the row from the beginning + row.separator() + # indent child items if laycol["lvl"] > 0: for _ in range(laycol["lvl"]): -- cgit v1.2.3 From 1e1f8b636dfa37acd266c768fd7ae456440d64c7 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Sat, 25 Apr 2020 04:27:54 -0400 Subject: Collection Manager: Fix popup sizing. Task: T69577 Adjust popup sizing to account for the width of the QCD field when present. --- object_collection_manager/__init__.py | 2 +- object_collection_manager/ui.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index f5ff542e..91063cc0 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, 15), + "version": (2, 7, 16), "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/ui.py b/object_collection_manager/ui.py index 46d27e77..9fe483a7 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -380,11 +380,15 @@ class CollectionManager(Operator): min_width = 456 row_indent_width = 15 width_step = 21 + qcd_width = 30 scrollbar_width = 21 lvl = get_max_lvl() width = min_width + row_indent_width + (width_step * lvl) + if bpy.context.preferences.addons[__package__].preferences.enable_qcd: + width += qcd_width + if len(layer_collections) > 14: width += scrollbar_width -- cgit v1.2.3 From 59db3adeb4994745146b099cce3a19de3815b959 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Wed, 29 Apr 2020 04:01:29 -0400 Subject: Collection Manager: Phantom Mode fixes. Task: T69577 Fix Phantom Mode not disabling the active collection operators and the set object operator for the Scene Collection. --- object_collection_manager/__init__.py | 2 +- object_collection_manager/ui.py | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 91063cc0..2c950c84 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, 16), + "version": (2, 7, 17), "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/ui.py b/object_collection_manager/ui.py index 9fe483a7..00f5c2f7 100644 --- a/object_collection_manager/ui.py +++ b/object_collection_manager/ui.py @@ -78,15 +78,17 @@ class CollectionManager(Operator): cls = CollectionManager layout = self.layout cm = context.scene.collection_manager + prefs = context.preferences.addons[__package__].preferences view_layer = context.view_layer if view_layer.name != cls.last_view_layer: - if context.preferences.addons[__package__].preferences.enable_qcd: + if prefs.enable_qcd: bpy.app.timers.register(update_qcd_header) update_collection_tree(context) cls.last_view_layer = view_layer.name + # title and view layer title_row = layout.split(factor=0.5) main = title_row.row() view = title_row.row(align=True) @@ -108,6 +110,7 @@ class CollectionManager(Operator): layout.row().separator() layout.row().separator() + # buttons button_row = layout.row() op_sec = button_row.row() @@ -129,11 +132,12 @@ class CollectionManager(Operator): collapse_sec.enabled = True break - if context.preferences.addons[__package__].preferences.enable_qcd: + if prefs.enable_qcd: renum_sec = op_sec.row() renum_sec.alignment = 'LEFT' renum_sec.operator("view3d.renumerate_qcd_slots") + # filter filter_sec = button_row.row() filter_sec.alignment = 'RIGHT' @@ -143,24 +147,28 @@ class CollectionManager(Operator): mc_box = layout.box() master_collection_row = mc_box.row(align=True) + # collection icon + c_icon = master_collection_row.row() highlight = False if (context.view_layer.active_layer_collection == context.view_layer.layer_collection): highlight = True - prop = master_collection_row.operator("view3d.set_active_collection", + prop = c_icon.operator("view3d.set_active_collection", text='', icon='GROUP', depress=highlight) prop.collection_index = -1 prop.collection_name = 'Master Collection' master_collection_row.separator() + # name name_row = master_collection_row.row() name_row.prop(self, "master_collection", text='') name_row.enabled = False master_collection_row.separator() + # global rtos global_rto_row = master_collection_row.row() global_rto_row.alignment = 'RIGHT' @@ -287,12 +295,14 @@ class CollectionManager(Operator): global_rto_row.operator("view3d.un_disable_render_all_collections", text="", icon=icon, depress=depress) + # treeview layout.row().template_list("CM_UL_items", "", cm, "cm_list_collection", cm, "cm_list_index", rows=15, sort_lock=True) + # add collections addcollec_row = layout.row() addcollec_row.operator("view3d.add_collection", text="Add Collection", icon='COLLECTION_NEW').child = False @@ -300,16 +310,19 @@ class CollectionManager(Operator): addcollec_row.operator("view3d.add_collection", text="Add SubCollection", icon='COLLECTION_NEW').child = True + # phantom mode phantom_row = layout.row() toggle_text = "Disable " if cm.in_phantom_mode else "Enable " phantom_row.operator("view3d.toggle_phantom_mode", text=toggle_text+"Phantom Mode") if cm.in_phantom_mode: view.enabled = False - addcollec_row.enabled = False + if prefs.enable_qcd: + renum_sec.enabled = False - if context.preferences.addons[__package__].preferences.enable_qcd: - renum.enabled = False + c_icon.enabled = False + row_setcol.enabled = False + addcollec_row.enabled = False def execute(self, context): @@ -426,6 +439,7 @@ class CM_UL_items(UIList): self.use_filter_show = True cm = context.scene.collection_manager + prefs = context.preferences.addons[__package__].preferences view_layer = context.view_layer laycol = layer_collections[item.name] collection = laycol["ptr"].collection @@ -482,7 +496,7 @@ class CM_UL_items(UIList): prop.collection_index = laycol["row_index"] prop.collection_name = item.name - if context.preferences.addons[__package__].preferences.enable_qcd: + if prefs.enable_qcd: QCD = row.row() QCD.scale_x = 0.4 QCD.prop(item, "qcd_slot_idx", text="") @@ -586,11 +600,12 @@ class CM_UL_items(UIList): emboss=False).collection_name = item.name if cm.in_phantom_mode: + c_icon.enabled = False name_row.enabled = False row_setcol.enabled = False rm_op.enabled = False - if context.preferences.addons[__package__].preferences.enable_qcd: + if prefs.enable_qcd: QCD.enabled = False -- cgit v1.2.3 From 06fc55648012d133451469f584c9cadd34852552 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Sat, 2 May 2020 02:37:52 -0400 Subject: Collection Manager: Fix exclude bug. Task: T69577 Fixes the exclude operator changing the active collection in some cases. --- object_collection_manager/__init__.py | 2 +- object_collection_manager/operators.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 2c950c84..2caf6bc7 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, 17), + "version": (2, 7, 18), "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 3fe19660..1d60d60c 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -340,6 +340,7 @@ class CMExcludeOperator(Operator): modifiers = get_modifiers(event) view_layer = context.view_layer.name + orig_active_collection = context.view_layer.active_layer_collection laycol_ptr = layer_collections[self.name]["ptr"] if not view_layer in rto_history["exclude"]: @@ -386,6 +387,9 @@ class CMExcludeOperator(Operator): cls.isolated = False + # reset active collection + context.view_layer.active_layer_collection = orig_active_collection + # reset exclude all history if view_layer in rto_history["exclude_all"]: del rto_history["exclude_all"][view_layer] -- cgit v1.2.3 From 5ec31459289eaa4031dc32ac39b93b80855fa9ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 May 2020 14:19:18 +1000 Subject: Fix T76383: Undo after cell fracture crashes --- object_fracture_cell/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py index 2e6d3b08..02e156b4 100644 --- a/object_fracture_cell/__init__.py +++ b/object_fracture_cell/__init__.py @@ -242,7 +242,7 @@ def main(context, **kw): class FractureCell(Operator): bl_idname = "object.add_fracture_cell_objects" bl_label = "Cell fracture selected mesh objects" - bl_options = {'PRESET'} + bl_options = {'PRESET', 'UNDO'} # ------------------------------------------------------------------------- # Source Options -- cgit v1.2.3