2024-03-06 14:43:14 +11:00
|
|
|
# SPDX-FileCopyrightText: 2024 Blender Authors
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
2024-01-25 14:46:04 +01:00
|
|
|
from bpy.types import Menu
|
|
|
|
|
|
|
|
|
|
|
2025-01-21 15:12:59 +01:00
|
|
|
def draw_action_and_slot_selector_for_id(layout, animated_id):
|
|
|
|
|
"""
|
|
|
|
|
Draw the action and slot selector for an ID, using the given layout.
|
|
|
|
|
|
|
|
|
|
The ID must be an animatable ID.
|
|
|
|
|
|
|
|
|
|
Note that the slot selector is only drawn when the ID has an assigned
|
|
|
|
|
Action.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
layout.template_action(animated_id, new="action.new", unlink="action.unlink")
|
|
|
|
|
|
|
|
|
|
adt = animated_id.animation_data
|
|
|
|
|
if not adt or not adt.action:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Only show the slot selector when a layered Action is assigned.
|
|
|
|
|
if adt.action.is_action_layered:
|
|
|
|
|
layout.context_pointer_set("animated_id", animated_id)
|
|
|
|
|
layout.template_search(
|
|
|
|
|
adt, "action_slot",
|
|
|
|
|
adt, "action_suitable_slots",
|
|
|
|
|
new="anim.slot_new_for_id",
|
|
|
|
|
unlink="anim.slot_unassign_from_id",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2024-01-25 14:46:04 +01:00
|
|
|
class ANIM_MT_keyframe_insert_pie(Menu):
|
|
|
|
|
bl_label = "Keyframe Insert Pie"
|
|
|
|
|
|
2024-12-11 11:26:24 +11:00
|
|
|
def draw(self, _context):
|
2024-01-25 14:46:04 +01:00
|
|
|
layout = self.layout
|
|
|
|
|
pie = layout.menu_pie()
|
|
|
|
|
|
|
|
|
|
prop = pie.operator("anim.keyframe_insert_by_name", text="Location")
|
|
|
|
|
prop.type = "Location"
|
|
|
|
|
|
|
|
|
|
prop = pie.operator("anim.keyframe_insert_by_name", text="Scale")
|
|
|
|
|
prop.type = "Scaling"
|
|
|
|
|
|
|
|
|
|
prop = pie.operator("anim.keyframe_insert_by_name", text="Available")
|
|
|
|
|
prop.type = "Available"
|
|
|
|
|
|
|
|
|
|
prop = pie.operator("anim.keyframe_insert_by_name", text="Rotation")
|
|
|
|
|
prop.type = "Rotation"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes = (
|
|
|
|
|
ANIM_MT_keyframe_insert_pie,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|