Pose Library: use "Flip Pose" bool property in more places

Use the "Flip Pose" boolean property also for activate & drag in the
UIList, and when doubleclicking in the asset browser.
This commit is contained in:
Sybren A. Stüvel 2021-04-12 17:42:13 +02:00
parent 3f806a0457
commit 347c310444
3 changed files with 50 additions and 16 deletions

View File

@ -47,11 +47,12 @@ class VIEW3D_PT_pose_library(Panel):
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,
"active_asset_library",
context.window_manager,
wm,
"pose_assets",
workspace,
"active_pose_asset_index",
@ -60,6 +61,8 @@ class VIEW3D_PT_pose_library(Panel):
drag_operator="poselib.blend_pose_asset",
)
drag_op_props.release_confirm = True
drag_op_props.flipped = wm.poselib_flipped
activate_op_props.flipped = wm.poselib_flipped
def pose_library_list_item_context_menu(self: UIList, context: Context) -> None:

View File

@ -32,23 +32,11 @@ def register() -> None:
km = wm.keyconfigs.addon.keymaps.new(name="File Browser Main", space_type="FILE_BROWSER")
# DblClick to apply pose.
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK")
kmi.properties.flipped = False
kmi = km.keymap_items.new("poselib.apply_pose_asset_for_keymap", "LEFTMOUSE", "DOUBLE_CLICK")
addon_keymaps.append((km, kmi))
# Shift-dblClick to apply pose flipped.
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK", shift=True)
kmi.properties.flipped = True
addon_keymaps.append((km, kmi))
# Ctrl-dblClick to blend pose.
kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK", ctrl=True)
kmi.properties.flipped = False
addon_keymaps.append((km, kmi))
# Ctrl-Shift-dblClick to blend pose flipped.
kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "DOUBLE_CLICK", ctrl=True)
kmi.properties.flipped = True
# Shift-dblClick to blend pose.
kmi = km.keymap_items.new("poselib.blend_pose_asset_for_keymap", "LEFTMOUSE", "DOUBLE_CLICK", shift=True)
addon_keymaps.append((km, kmi))
# Alt-dblClick to select bones.

View File

@ -41,6 +41,7 @@ from bpy.props import BoolProperty, StringProperty
from bpy.types import (
Action,
Context,
Event,
FileSelectEntry,
Object,
Operator,
@ -334,8 +335,50 @@ class POSELIB_OT_pose_asset_select_bones(PoseAssetUser, Operator):
return cls.bl_description.replace("Select", "Deselect")
class POSELIB_OT_blend_pose_asset_for_keymap(Operator):
bl_idname = "poselib.blend_pose_asset_for_keymap"
bl_options = {"REGISTER", "UNDO"}
_rna = bpy.ops.poselib.blend_pose_asset.get_rna_type()
bl_label = _rna.name
bl_description = _rna.description
del _rna
@classmethod
def poll(cls, context: Context) -> bool:
return bpy.ops.poselib.blend_pose_asset.poll(context.copy())
def execute(self, context: Context) -> Set[str]:
flipped = context.window_manager.poselib_flipped
return bpy.ops.poselib.blend_pose_asset(context.copy(), 'EXEC_DEFAULT', flipped=flipped)
def invoke(self, context: Context, event: Event) -> Set[str]:
flipped = context.window_manager.poselib_flipped
return bpy.ops.poselib.blend_pose_asset(context.copy(), 'INVOKE_DEFAULT', flipped=flipped)
class POSELIB_OT_apply_pose_asset_for_keymap(Operator):
bl_idname = "poselib.apply_pose_asset_for_keymap"
bl_options = {"REGISTER", "UNDO"}
_rna = bpy.ops.poselib.apply_pose_asset.get_rna_type()
bl_label = _rna.name
bl_description = _rna.description
del _rna
@classmethod
def poll(cls, context: Context) -> bool:
return bpy.ops.poselib.apply_pose_asset.poll(context.copy())
def execute(self, context: Context) -> Set[str]:
flipped = context.window_manager.poselib_flipped
return bpy.ops.poselib.apply_pose_asset(context.copy(), 'EXEC_DEFAULT', flipped=flipped)
classes = (
ASSET_OT_assign_action,
POSELIB_OT_apply_pose_asset_for_keymap,
POSELIB_OT_blend_pose_asset_for_keymap,
POSELIB_OT_copy_as_asset,
POSELIB_OT_create_pose_asset,
POSELIB_OT_paste_asset,