From 057cb7e5e77bcf932882292a774156b5d8c90ab4 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 16 Jul 2021 12:36:57 +0300 Subject: Context: add accessors returning selected actions for animation editors. Add a new 'selected_visible_actions' property to allow querying actions that are selected in animation related editors for use in UI and operators. The 'selected_editable_actions' variant excludes linked actions (the only reason an action can be read-only). In the Action and Shape Key editors there is only one action that is specified by the field at the top of the editor. In Dope Sheet it scans the channel rows and returns all actions related to the selected items. This includes summary items for actions and groups. In Graph Editor, it lists actions associated with selected curves. The new property is also used for Copy To Selected and Alt-Click. Ref D11803 --- .../blender/editors/animation/anim_channels_defines.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/blender/editors/animation/anim_channels_defines.c') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 9f2681fbf7a..8e0452de8ea 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4212,6 +4212,24 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) } } +/* Retrieves the Action associated with this animation channel. */ +bAction *ANIM_channel_action_get(const bAnimListElem *ale) +{ + if (ale->datatype == ALE_ACT) { + return (bAction *)ale->key_data; + } + + if (ELEM(ale->type, ANIMTYPE_GROUP, ANIMTYPE_FCURVE)) { + ID *owner = ale->fcurve_owner_id; + + if (owner && GS(owner->name) == ID_AC) { + return (bAction *)owner; + } + } + + return NULL; +} + /* --------------------------- */ /* Check if some setting for a channel is enabled -- cgit v1.2.3