Skip to content
Snippets Groups Projects
Commit 561f37e9 authored by anfeo's avatar anfeo
Browse files

Add a new layer groups visualization using the UIList class to edit the Template list

parent e8b8f0cf
No related branches found
No related tags found
No related merge requests found
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
bl_info = { bl_info = {
"name": "Layer Management", "name": "Layer Management",
"author": "Alfonso Annarumma", "author": "Alfonso Annarumma",
"version": (1, 5), "version": (1, 5,1),
"blender": (2, 65, 4), "blender": (2, 70, 0),
"location": "View3D > Properties panel > Layer Management", "location": "View3D > Properties panel > Layer Management",
"warning": "", "warning": "",
"description": "Display and Edit Layer Name", "description": "Display and Edit Layer Name",
...@@ -33,6 +33,7 @@ bl_info = { ...@@ -33,6 +33,7 @@ bl_info = {
"category": "3D View"} "category": "3D View"}
import bpy import bpy
from bpy.types import Menu, Panel, UIList
from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty, BoolVectorProperty from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty, BoolVectorProperty
EDIT = ["EDIT_MESH", "EDIT_CURVE", "EDIT_SURFACE", "EDIT_METABALL", "EDIT_TEXT", "EDIT_ARMATURE"] EDIT = ["EDIT_MESH", "EDIT_CURVE", "EDIT_SURFACE", "EDIT_METABALL", "EDIT_TEXT", "EDIT_ARMATURE"]
...@@ -683,6 +684,58 @@ class LayerName(bpy.types.Panel): ...@@ -683,6 +684,58 @@ class LayerName(bpy.types.Panel):
if len(scene.objects)==0: if len(scene.objects)==0:
layout.label(text='No objects in scene') layout.label(text='No objects in scene')
class UI_UL_layergroups(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.VertexGroup)
lgroup = item
scene = context.scene
view_3d = context.area.spaces.active
#check for lock camera and layer is active
if view_3d.lock_camera_and_layers is True:
space= scene
spacecheck = False
else:
space= view_3d
spacecheck = True
#######################
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.prop(lgroup, "name", text="", emboss=False)
if lgroup.toggle:
iconLayer = 'RESTRICT_VIEW_OFF'
else:
iconLayer = 'RESTRICT_VIEW_ON'
if lgroup.lock:
iconLock= 'LOCKED'
else:
iconLock='UNLOCKED'
lk = layout.operator("object.lockselected", text="", emboss=False, icon= iconLock)
lk.index_group = index
lk.lock=lgroup.lock
lk.layerN=-1
view = layout.operator("object.layertoggle", text="", emboss=False, icon= iconLayer)
view.index_group = index
view.layerN=-1
view.spacecheck=spacecheck
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
class LayerGroupsUI(bpy.types.Panel): class LayerGroupsUI(bpy.types.Panel):
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
bl_region_type = "TOOLS" bl_region_type = "TOOLS"
...@@ -701,23 +754,14 @@ class LayerGroupsUI(bpy.types.Panel): ...@@ -701,23 +754,14 @@ class LayerGroupsUI(bpy.types.Panel):
def draw(self, context): def draw(self, context):
scene = context.scene scene = context.scene
view_3d = context.area.spaces.active
#check for lock camera and layer is active
if view_3d.lock_camera_and_layers is True:
space= scene
spacecheck = False
else:
space= view_3d
spacecheck = True
#######################
index_group = scene.layergroups_index index_group = scene.layergroups_index
items =len(scene.layergroups) items =len(scene.layergroups)
viewIcon = 'RESTRICT_VIEW_OFF' viewIcon = 'RESTRICT_VIEW_OFF'
layout = self.layout layout = self.layout
row = layout.row() row = layout.row()
row.template_list("UI_UL_list", "ui_layer_groups", context.scene, "layergroups", row.template_list("UI_UL_layergroups", "", context.scene, "layergroups",
context.scene, "layergroups_index", rows=items) context.scene, "layergroups_index", rows=items)
col =row.column(align =True) col =row.column(align =True)
add = col.operator("object.layergroup_add", icon='ZOOMIN', text="") add = col.operator("object.layergroup_add", icon='ZOOMIN', text="")
...@@ -727,55 +771,17 @@ class LayerGroupsUI(bpy.types.Panel): ...@@ -727,55 +771,17 @@ class LayerGroupsUI(bpy.types.Panel):
remove.index_group= index_group remove.index_group= index_group
if items > 0: if items > 0:
lock=scene.layergroups[index_group].lock
toggle = scene.layergroups[index_group].toggle
if lock:
iconLock= 'LOCKED'
else:
iconLock='UNLOCKED'
lk = col.operator("object.lockselected", text="", emboss=True, icon= iconLock)
lk.index_group = index_group
lk.lock=lock
lk.layerN=-1
#set icon for layer view
if toggle:
iconLayer = 'RESTRICT_VIEW_OFF'
#noitem = True
else:
iconLayer = 'RESTRICT_VIEW_ON'
#noitem = False
view = col.operator("object.layertoggle", text="", icon= iconLayer, emboss=True)
view.index_group = index_group
view.layerN=-1
view.spacecheck=spacecheck
layout.prop(scene.layergroups[index_group], "layer_groups", text="", toggle=True) layout.prop(scene.layergroups[index_group], "layer_groups", text="", toggle=True)
layout.prop(scene.layergroups[index_group], "name", text="Name:") layout.prop(scene.layergroups[index_group], "name", text="Name:")
def register(): def register():
bpy.utils.register_class(AddLayerGroup)
bpy.utils.register_class(RemoveLayerGroup)
bpy.utils.register_class(LayerGroupsUI)
bpy.utils.register_class(AllLayersSelect)
bpy.utils.register_class(LayerToggle)
bpy.utils.register_class(MergeSelected)
bpy.utils.register_class(LayerName)
bpy.utils.register_class(LockSelected)
bpy.utils.register_class(SelectObjectsLayer)
bpy.utils.register_module(__name__)
def unregister(): def unregister():
bpy.utils.unregister_class(AddLayerGroup)
bpy.utils.unregister_class(RemoveLayerGroup) bpy.utils.register_module(__name__)
bpy.utils.unregister_class(LayerGroupsUI)
bpy.utils.unregister_class(LayerName)
bpy.utils.uregister_class(AllLayersSelect)
bpy.utils.unregister_class(LayerToggle)
bpy.utils.uregister_class(MergeSelected)
bpy.utils.unregister_class(LockSelected)
bpy.utils.unregister_class(SelectObjectsLayer)
if __name__ == "__main__": if __name__ == "__main__":
register() register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment