...
 
Commits (10)
......@@ -87,8 +87,8 @@ from amaranth.misc import (
bl_info = {
"name": "Amaranth Toolset",
"author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez, CansecoGPC",
"version": (1, 0, 7),
"blender": (2, 80, 0),
"version": (1, 0, 8),
"blender": (2, 81, 0),
"location": "Everywhere!",
"description": "A collection of tools and settings to improve productivity",
"warning": "",
......
......@@ -21,6 +21,12 @@ shows up if the file is saved.
import bpy
# From space_filebrowser.py
def panel_poll_is_upper_region(region):
# The upper region is left-aligned, the lower is split into it then.
# Note that after "Flip Regions" it's right-aligned.
return region.alignment in {'LEFT', 'RIGHT'}
class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
......@@ -33,19 +39,42 @@ class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
return {"FINISHED"}
def button_directory_current_blend(self, context):
if bpy.data.filepath:
self.layout.operator(
AMTH_FILE_OT_directory_current_blend.bl_idname,
text="Current Blend's Folder",
icon="APPEND_BLEND")
class FILEBROWSER_PT_amaranth(bpy.types.Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Bookmarks"
bl_label = "Amaranth"
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
return panel_poll_is_upper_region(context.region)
def register():
bpy.utils.register_class(AMTH_FILE_OT_directory_current_blend)
bpy.types.FILEBROWSER_HT_header.append(button_directory_current_blend)
def draw(self, context):
layout = self.layout
layout.scale_x = 1.3
layout.scale_y = 1.3
if bpy.data.filepath:
row = layout.row()
flow = row.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
subrow = flow.row()
subsubrow = subrow.row(align=True)
subsubrow.operator(
AMTH_FILE_OT_directory_current_blend.bl_idname,
icon="DESKTOP")
classes = (
AMTH_FILE_OT_directory_current_blend,
FILEBROWSER_PT_amaranth
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
bpy.utils.unregister_class(AMTH_FILE_OT_directory_current_blend)
bpy.types.FILEBROWSER_HT_header.remove(button_directory_current_blend)
for cls in classes:
bpy.utils.unregister_class(cls)
......@@ -23,9 +23,9 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (1,0),
"version": (1,3,0),
"blender": (2, 80, 0),
"location": "View3D - Object Mode",
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel
"wiki_url": "",
"category": "User Interface"}
......@@ -69,6 +69,7 @@ classes = (
operators.CMNewCollectionOperator,
operators.CMRemoveCollectionOperator,
operators.CMSetCollectionOperator,
operators.CMPhantomModeOperator,
ui.CM_UL_items,
ui.CollectionManager,
ui.CMRestrictionTogglesPanel,
......@@ -79,13 +80,15 @@ def register():
bpy.utils.register_class(cls)
bpy.types.Scene.CMListCollection = CollectionProperty(type=internals.CMListCollection)
bpy.types.Scene.CMListIndex = IntProperty()
bpy.types.Scene.CMListIndex = IntProperty(update=ui.update_selection)
bpy.types.Scene.show_exclude = BoolProperty(default=True, name="Exclude from View Layer")
bpy.types.Scene.show_selectable = BoolProperty(default=True, name="Selectable")
bpy.types.Scene.show_hideviewport = BoolProperty(default=True, name="Hide in Viewport")
bpy.types.Scene.show_disableviewport = BoolProperty(default=False, name="Disable in Viewports")
bpy.types.Scene.show_render = BoolProperty(default=False, name="Disable in Renders")
bpy.types.Scene.CM_Phantom_Mode = BoolProperty(default=False)
# create the global menu hotkey
......@@ -107,6 +110,8 @@ def unregister():
del bpy.types.Scene.show_disableviewport
del bpy.types.Scene.show_render
del bpy.types.Scene.CM_Phantom_Mode
# remove keymaps when add-on is deactivated
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
......
......@@ -8,25 +8,34 @@ collection_tree = []
expanded = []
max_lvl = 0
row_index = 0
def get_max_lvl():
return max_lvl
def clone_list(l1, l2):
l1.clear()
for x in l2:
l1.append(x)
class CMListCollection(PropertyGroup):
name: StringProperty()
def update_collection_tree(context):
global max_lvl
global row_index
collection_tree.clear()
layer_collections.clear()
max_lvl = 0
row_index = 0
init_laycol_list = context.view_layer.layer_collection.children
master_laycol = {"id": 0,
"name": context.view_layer.layer_collection.name,
"lvl": -1,
"row_index": -1,
"visible": True,
"has_children": True,
"expanded": True,
......@@ -39,10 +48,13 @@ def update_collection_tree(context):
def get_all_collections(context, collections, parent, tree, level=0, visible=False):
global row_index
for item in collections:
laycol = {"id": len(layer_collections) +1,
"name": item.name,
"lvl": level,
"row_index": row_index,
"visible": visible,
"has_children": False,
"expanded": False,
......@@ -51,6 +63,8 @@ def get_all_collections(context, collections, parent, tree, level=0, visible=Fal
"ptr": item
}
row_index += 1
layer_collections[item.name] = laycol
tree.append(laycol)
......@@ -61,7 +75,7 @@ def get_all_collections(context, collections, parent, tree, level=0, visible=Fal
if item.name in expanded and laycol["visible"]:
laycol["expanded"] = True
get_all_collections(context, item.children, laycol, laycol["children"], level+1, visible=True)
get_all_collections(context, item.children, laycol, laycol["children"], level+1, visible=True)
else:
get_all_collections(context, item.children, laycol, laycol["children"], level+1)
......
This diff is collapsed.
......@@ -12,6 +12,8 @@ from .operators import (
hideall_history,
disableviewall_history,
disablerenderall_history,
rename,
phantom_history,
)
......@@ -104,6 +106,14 @@ class CollectionManager(Operator):
addcollec_row.operator("view3d.add_collection", text="Add SubCollection", icon='COLLECTION_NEW').child = True
phantom_row = layout.row()
toggle_text = "Disable " if scn.CM_Phantom_Mode else "Enable "
phantom_row.operator("view3d.toggle_phantom_mode", text=toggle_text+"Phantom Mode")
if scn.CM_Phantom_Mode:
view.enabled = False
addcollec_row.enabled = False
def execute(self, context):
wm = context.window_manager
......@@ -116,22 +126,41 @@ class CollectionManager(Operator):
#hideall_history.clear()
#disableviewall_history.clear()
#disablerenderall_history.clear()
context.scene.CMListIndex = 0
update_property_group(context)
if get_max_lvl() > 5:
lvl = get_max_lvl() - 5
lvl = get_max_lvl()
if lvl > 25:
lvl = 25
self.view_layer = context.view_layer.name
# sync selection in ui list with active layer collection
try:
active_laycol_name = context.view_layer.active_layer_collection.name
active_laycol_row_index = layer_collections[active_laycol_name]["row_index"]
context.scene.CMListIndex = active_laycol_row_index
except:
context.scene.CMListIndex = 0
if context.scene.CM_Phantom_Mode:
if set(layer_collections.keys()) != set(phantom_history["initial_state"].keys()):
context.scene.CM_Phantom_Mode = False
if context.view_layer.name != phantom_history["view_layer"]:
context.scene.CM_Phantom_Mode = False
return wm.invoke_popup(self, width=(400+(lvl*20)))
def update_selection(self, context):
selected_item = context.scene.CMListCollection[context.scene.CMListIndex]
layer_collection = layer_collections[selected_item.name]["ptr"]
context.view_layer.active_layer_collection = layer_collection
class CM_UL_items(UIList):
last_filter_value = ""
......@@ -142,7 +171,8 @@ class CM_UL_items(UIList):
laycol = layer_collections[item.name]
collection = laycol["ptr"].collection
row = layout.row(align=True)
split = layout.split(factor=0.96)
row = split.row(align=True)
row.alignment = 'LEFT'
# indent child items
......@@ -170,7 +200,13 @@ class CM_UL_items(UIList):
row.label(icon='GROUP')
row.prop(collection, "name", text="", expand=True)
name_row = row.row()
#if rename[0] and index == scn.CMListIndex:
#name_row.activate_init = True
#rename[0] = False
name_row.prop(collection, "name", text="", expand=True)
# used as a separator (actual separator not wide enough)
row.label()
......@@ -214,7 +250,14 @@ class CM_UL_items(UIList):
row.operator("view3d.disable_render_collection", text="", icon=icon, emboss=False).name = item.name
row.operator("view3d.remove_collection", text="", icon='X', emboss=False).collection_name = item.name
rm_op = split.row()
rm_op.alignment = 'RIGHT'
rm_op.operator("view3d.remove_collection", text="", icon='X', emboss=False).collection_name = item.name
if scn.CM_Phantom_Mode:
name_row.enabled = False
row_setcol.enabled = False
rm_op.enabled = False
def filter_items(self, context, data, propname):
......