blender-addons/pose_library/keymaps.py
Julian Eisel 2faef81041 Pose Library: Update to use the asset shelf (when enabled)
A dedicated region to display poses was already on the wish-list during initial
discussions for the new asset based pose library design. To minimize
development time, it was decided to use the sidebar for the start instead.
Problem is that this space is used for bone pickers, selection set access and
all kinds of other features, typically from add-ons. So this is precious space
for all kinds of important functionality, and animators end up scrolling and
switching tabs a lot, slowing down the workflow.

The recently introduced asset shelf addresses this, see 98142f5e35.  As of
writing, the asset shelf is still an experimental feature. It will probably be
made non-experimental soon. The updates to the pose library add-on use the old
UI in the sidebar if the asset shelf is disabled.

Pull Request: #104546
2023-08-04 15:00:19 +02:00

39 lines
1.2 KiB
Python

# SPDX-FileCopyrightText: 2010-2023 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
from typing import List, Tuple
import bpy
addon_keymaps: List[Tuple[bpy.types.KeyMap, bpy.types.KeyMapItem]] = []
def register() -> None:
wm = bpy.context.window_manager
if wm.keyconfigs.addon is None:
# This happens when Blender is running in the background.
return
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")
addon_keymaps.append((km, kmi))
# Asset Shelf
km = wm.keyconfigs.addon.keymaps.new(name="Asset Shelf")
# Click to apply pose.
kmi = km.keymap_items.new("poselib.apply_pose_asset", "LEFTMOUSE", "CLICK")
addon_keymaps.append((km, kmi))
# Drag to blend pose.
kmi = km.keymap_items.new("poselib.blend_pose_asset", "LEFTMOUSE", "CLICK_DRAG")
addon_keymaps.append((km, kmi))
def unregister() -> None:
# Clear shortcuts from the keymap.
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()