Files
test2/scripts/startup/bl_ui/anim.py
Nathan Vegdahl b2a06888c7 Anim: add Action+Slot selector for Masks
This adds an Animation panel to the Mask tab of the n-panel of the
Movie Clip and Image editors. Masks can be animated (for example, the
opacity of a Mask Layer), but there was no way to manage the Action
and Slot that held those F-Curves.

To keep things DRY, this PR also moves the code for drawing Action+Slot
selectors from the `PropertiesAnimationMixin` class to a utility
function, which is now called from both that class and the Mask UI code.

Pull Request: https://projects.blender.org/blender/blender/pulls/133153
2025-01-21 15:12:59 +01:00

63 lines
1.7 KiB
Python

# SPDX-FileCopyrightText: 2024 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
from bpy.types import Menu
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",
)
class ANIM_MT_keyframe_insert_pie(Menu):
bl_label = "Keyframe Insert Pie"
def draw(self, _context):
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)