Order uilist by asset type
parent
538c0bf60a
commit
c518ccf2b4
|
@ -56,6 +56,7 @@ class Episode(PropertyGroup):
|
|||
|
||||
class Asset(PropertyGroup):
|
||||
id : StringProperty(default='')
|
||||
norm_name : StringProperty(default='')
|
||||
asset_type : StringProperty(default='')
|
||||
|
||||
|
||||
|
@ -80,7 +81,7 @@ class Project(PropertyGroup):
|
|||
name="Episode Name", default="e{index:03d}")
|
||||
|
||||
shot_template : StringProperty(
|
||||
name="Shot Name", default="{episode}sh{index:04d}")
|
||||
name="Shot Name", default="{episode}s{index:04d}")
|
||||
|
||||
episode_name : EnumProperty(items=get_episodes_items)
|
||||
episodes : CollectionProperty(type=Episode)
|
||||
|
@ -118,28 +119,50 @@ class VSETB_UL_casting(UIList):
|
|||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
split = layout.split(factor=0.6)
|
||||
split.label(text=f"{item.name}")
|
||||
split.label(text=f"{item.asset_type}", icon=icons[item.asset_type])
|
||||
split.label(text=f"{item.asset_type.title()}", icon=icons[item.asset_type])
|
||||
|
||||
elif self.layout_type in {'GRID'}:
|
||||
layout.alignment = 'CENTER'
|
||||
# layout.label(text="", icon = custom_icon)
|
||||
layout.label(text="")
|
||||
|
||||
#FIXME Custom Order marche pas
|
||||
# def filter_items(self, context, data, propname):
|
||||
# """Filter and order items in the list."""
|
||||
|
||||
# filtered = []
|
||||
# ordered = []
|
||||
# items = getattr(data, propname)
|
||||
def draw_filter(self, context, layout):
|
||||
row = layout.row()
|
||||
|
||||
# # Order by types
|
||||
# if self.order_by_type:
|
||||
# sort_items = bpy.types.UI_UL_list.sort_items_helper
|
||||
# ordered = sort_items(items.keys(), key=lambda i: i.asset_type)
|
||||
subrow = row.row(align=True)
|
||||
subrow.prop(self, "filter_name", text="")
|
||||
subrow.prop(self, "use_filter_invert", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
# subrow.separator()
|
||||
# subrow.prop(self, "use_filter_sort_alpha", text="", icon='SORTALPHA')
|
||||
# subrow.prop(self, "use_filter_sort_reverse", text="", icon='SORT_ASC')
|
||||
|
||||
subrow.separator()
|
||||
subrow.prop(self, "order_by_type", text="Order by Type", icon='MESH_DATA')
|
||||
|
||||
# return filtered, ordered
|
||||
|
||||
def filter_items(self, context, data, propname):
|
||||
"""Filter and order items in the list."""
|
||||
|
||||
helper_funcs = bpy.types.UI_UL_list
|
||||
|
||||
filtered = []
|
||||
ordered = []
|
||||
items = getattr(data, propname)
|
||||
|
||||
# Filtering by name
|
||||
if self.filter_name:
|
||||
filtered = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, items, "name",
|
||||
reverse=self.use_filter_sort_alpha)
|
||||
# Order by types
|
||||
if self.order_by_type:
|
||||
_sort = [(idx, asset) for idx, asset in enumerate(items)]
|
||||
sort_items = helper_funcs.sort_items_helper
|
||||
ordered = sort_items(_sort, lambda x: (x[1].name, x[1].asset_type))
|
||||
|
||||
return filtered, ordered
|
||||
|
||||
|
||||
class VSETB_PGT_settings(PropertyGroup):
|
||||
_projects = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue