Pose Library: Update to use the asset shelf (when enabled) #104546

Merged
Julian Eisel merged 33 commits from asset-shelf into main 2023-08-04 15:00:21 +02:00
Showing only changes of commit 2b118a1cda - Show all commits

View File

@ -27,24 +27,21 @@ class PoseLibraryPanel:
return cls.pose_library_panel_poll(context) return cls.pose_library_panel_poll(context)
class VIEW3D_HT_pose_library_asset_shelf(PoseLibraryPanel, Header): class VIEW3D_AST_pose_library(bpy.types.AssetShelf):
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "ASSET_SHELF"
def draw(self, context: Context) -> None: # TODO flipped pose option?
layout = self.layout # TODO create/copy poses?
is_poses_only = PoseLibraryPanel.poll(context) @classmethod
def poll(cls, context: Context) -> bool:
wm = context.window_manager return PoseLibraryPanel.poll(context)
# TODO flipped pose option?
# TODO create/copy poses?
if hasattr(layout, "template_asset_shelf"):
filter_id_types = {"filter_action"} if is_poses_only else {"filter_object", "filter_material"}
layout.template_asset_shelf(filter_id_types=filter_id_types)
# XXX temporary design. Should be like this instead:
# bl_asset_traits = {'ACTION'}
@classmethod
def asset_poll__(cls, asset: AssetHandle) -> bool:
return asset.file_data.id_type == 'ACTION'
class VIEW3D_PT_pose_library(PoseLibraryPanel, Panel): class VIEW3D_PT_pose_library(PoseLibraryPanel, Panel):
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
@ -198,7 +195,7 @@ classes = (
DOPESHEET_PT_asset_panel, DOPESHEET_PT_asset_panel,
VIEW3D_PT_pose_library, VIEW3D_PT_pose_library,
ASSETBROWSER_MT_asset, ASSETBROWSER_MT_asset,
VIEW3D_HT_pose_library_asset_shelf, VIEW3D_AST_pose_library,
) )
_register, _unregister = bpy.utils.register_classes_factory(classes) _register, _unregister = bpy.utils.register_classes_factory(classes)