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 ed87062a24 - Show all commits

View File

@ -8,7 +8,6 @@ import bpy
from bpy.types import (
AssetHandle,
Context,
Header,
Menu,
Panel,
UIList,
@ -43,19 +42,35 @@ class VIEW3D_AST_pose_library(bpy.types.AssetShelf):
def asset_poll__(cls, asset: AssetHandle) -> bool:
return asset.file_data.id_type == 'ACTION'
class VIEW3D_PT_pose_library(PoseLibraryPanel, Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "ASSET_SHELF"
bl_region_type = "UI"
bl_category = "Animation"
bl_label = "Pose Library"
def draw(self, context: Context) -> None:
layout = self.layout
row = layout.row(align=True)
row.operator("poselib.create_pose_asset").activate_new_action = False
if bpy.types.POSELIB_OT_restore_previous_action.poll(context):
row.operator("poselib.restore_previous_action", text="", icon='LOOP_BACK')
row.operator("poselib.copy_as_asset", icon="COPYDOWN", text="")
if hasattr(layout, "template_asset_view"):
workspace = context.workspace
wm = context.window_manager
activate_op_props, drag_op_props = layout.template_asset_view(
"pose_assets",
workspace,
"asset_library_ref",
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
filter_id_types={"filter_action"},
activate_operator="poselib.apply_pose_asset",
drag_operator="poselib.blend_pose_asset",
)
# Make sure operators properties match those used in
# `pose_library_list_item_context_menu` so shortcuts show in menus (see T103267).
activate_op_props.flipped = False
def pose_library_list_item_context_menu(self: UIList, context: Context) -> None: