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