Blender V5.0
blender::animrig::Slot Class Reference

#include <ANIM_action.hh>

Inherits ActionSlot.

Public Types

enum class  Flags : uint8_t { Expanded = (1 << 0) , Selected = (1 << 1) , Active = (1 << 2) }

Public Member Functions

 Slot ()
 Slot (const Slot &other)
 ~Slot ()
void blend_read_post ()
std::string idtype_string () const
StringRef identifier_prefix () const
StringRefNull identifier_without_prefix () const
bool is_suitable_for (const ID &animated_id) const
bool has_idtype () const
Flags flags () const
bool is_expanded () const
void set_expanded (bool expanded)
bool is_selected () const
void set_selected (bool selected)
bool is_active () const
Span< ID * > users (Main &bmain) const
Vector< ID * > runtime_users ()
void users_add (ID &animated_id)
void users_remove (ID &animated_id)
void identifier_ensure_prefix ()

Static Public Member Functions

static void users_invalidate (Main &bmain)

Static Public Attributes

static constexpr slot_handle_t unassigned = 0
static constexpr int identifier_length_min = 3
static constexpr int identifier_length_max = MAX_ID_NAME

Protected Member Functions

void set_active (bool active)

Protected Attributes

friend Action

Additional Inherited Members

Public Attributes inherited from ActionSlot
char identifier [258]
int16_t idtype
int32_t handle
int8_t slot_flags
uint8_t _pad1 [7]
ActionSlotRuntimeHandleruntime

Detailed Description

Identifier for a sub-set of the animation data inside an Action.

An animatable ID specifies both an Action* and an ActionSlot::handle to identify which F-Curves (and in the future other animation data) it will be animated by.

See also
AnimData::slot_handle

Definition at line 765 of file ANIM_action.hh.

Member Enumeration Documentation

◆ Flags

enum class blender::animrig::Slot::Flags : uint8_t
strong
Enumerator
Expanded 

Expanded/collapsed in animation editors.

Selected 

Selected in animation editors.

Active 

The active Slot for this Action. Set via a method on the Action.

Definition at line 870 of file ANIM_action.hh.

Constructor & Destructor Documentation

◆ Slot() [1/2]

blender::animrig::Slot::Slot ( )

Definition at line 1015 of file animrig/intern/action.cc.

References ActionSlot::runtime.

Referenced by Slot().

◆ Slot() [2/2]

blender::animrig::Slot::Slot ( const Slot & other)
explicit

Definition at line 1022 of file animrig/intern/action.cc.

References ActionSlot::runtime, and Slot().

◆ ~Slot()

blender::animrig::Slot::~Slot ( )

Definition at line 1027 of file animrig/intern/action.cc.

References ActionSlot::runtime.

Member Function Documentation

◆ blend_read_post()

void blender::animrig::Slot::blend_read_post ( )

Update the Slot after reading it from a blend file.

This is a low-level function and should not typically be used. It's only here to let blenkernel allocate the runtime struct when reading a Slot from disk, without having to share the struct definition itself.

Definition at line 1032 of file animrig/intern/action.cc.

References BLI_assert, and ActionSlot::runtime.

◆ flags()

Slot::Flags blender::animrig::Slot::flags ( ) const

Definition at line 1055 of file animrig/intern/action.cc.

References ActionSlot::slot_flags.

◆ has_idtype()

◆ identifier_ensure_prefix()

void blender::animrig::Slot::identifier_ensure_prefix ( )

Ensure the first two characters of this Slot's identifier match its intended ID type.

This typically does not need to be called outside of some low-level functions. Aside from versioning code that upgrades legacy actions, Slots should always be created with a specific intended ID type and corresponding identifier prefix that never changes after creation, making this method unnecessary.

In the rare cases that a Slot does not have a specified intended ID type, this method still should typically not be called directly. In those cases prefer assigning to an ID (e.g. via Action::assign_action_slot()), which will set the Slot's intended ID type and identifier prefix to match the given ID's type, as well as ensure identifier uniqueness within the Action.

Note
This does NOT ensure identifier uniqueness within the Action. That is the responsibility of the caller.
See also
assign_action_slot

Definition at line 1169 of file animrig/intern/action.cc.

References BLI_assert, has_idtype(), ActionSlot::identifier, identifier_length_min, ActionSlot::idtype, and size().

Referenced by blender::animrig::tests::TEST_F(), and blender::animrig::tests::TEST_F().

◆ identifier_prefix()

StringRef blender::animrig::Slot::identifier_prefix ( ) const

Return the two-character type prefix of this Slot's identifier.

This corresponds to the intended ID type of the slot, e.g "OB" for object, "CA" for camera, etc.

This is subtly different from idtype_string(). See its documentation for details.

See also
idtype_string()
identifier_ensure_prefix()

Definition at line 1150 of file animrig/intern/action.cc.

References BLI_assert, and ActionSlot::identifier.

Referenced by blender::animrig::tests::TEST_F().

◆ identifier_without_prefix()

StringRefNull blender::animrig::Slot::identifier_without_prefix ( ) const

Return this Slot's identifier without the prefix, also known as the "display name".

E.g. if the identifier is "OBCube", then "Cube" is returned.

See also
identifier_prefix()

Definition at line 1158 of file animrig/intern/action.cc.

References BLI_assert, ActionSlot::identifier, identifier_length_min, and size().

Referenced by acf_action_slot_name().

◆ idtype_string()

std::string blender::animrig::Slot::idtype_string ( ) const

Return a string that represents the Slot's 'idtype'.

E.g "OB" for object, "CA" for camera, etc.

This is different from identifier_prefix(): this constructs a string directly from the actual 'idtype' field of the Slot, whereas identifier_prefix() returns the first two characters of the identifier string.

This distinction matters in some lower-level code where the two can momentarily be out of sync, although this should always be corrected before exiting such code so that it's never observable in higher-level code.

See also
identifier_prefix()
identifier_ensure_prefix()

Definition at line 1139 of file animrig/intern/action.cc.

References has_idtype(), ActionSlot::idtype, and name.

Referenced by blender::animrig::versioning::convert_legacy_animato_action(), and blender::animrig::tests::TEST_F().

◆ is_active()

bool blender::animrig::Slot::is_active ( ) const

◆ is_expanded()

bool blender::animrig::Slot::is_expanded ( ) const

Definition at line 1059 of file animrig/intern/action.cc.

References Expanded, and ActionSlot::slot_flags.

Referenced by ANIM_animfilter_action_slot().

◆ is_selected()

◆ is_suitable_for()

bool blender::animrig::Slot::is_suitable_for ( const ID & animated_id) const

Return whether this Slot is suitable to be used by the given ID.

"Suitable" means that one of the following is true:

If either of those hold true, the Slot is considered suitable for the ID. Otherwise it is considered unsuitable.

Note that it is possible, but odd, for an ID to use a Slot that is not suitable for it. This is discouraged, and a best effort is made to prevent this in typical cases, but it is not possible to completely prevent due to library linking (e.g. an Action linked from another file may be replaced in that other file, causing its Slots to effectively change). Therefore this method returning false should NOT be taken as a guarantee that this Slot will never be used by the given ID or other IDs of the same type.

See also
idtype_string()
has_idtype()

Definition at line 1038 of file animrig/intern/action.cc.

References GS, has_idtype(), ActionSlot::idtype, and ID::name.

Referenced by blender::animrig::nla::assign_action(), blender::animrig::assign_action_ensure_slot_for_keying(), blender::animrig::generic_assign_action_slot(), and blender::animrig::generic_slot_for_autoassign().

◆ runtime_users()

Vector< ID * > blender::animrig::Slot::runtime_users ( )

Directly return the runtime users vector.

This function does not refresh the users cache, so it may be out of date.

This is a low-level function, and should only be used when calling users(bmain) is not appropriate.

See also
#Slot::users(Main &bmain)

Definition at line 1110 of file animrig/intern/action.cc.

References BLI_assert_msg, and ActionSlot::runtime.

Referenced by blender::animrig::nla::tests::TEST_F(), blender::animrig::nla::tests::TEST_F(), and blender::animrig::tests::TEST_F().

◆ set_active()

void blender::animrig::Slot::set_active ( bool active)
protected

Set the 'Active' flag. Only allowed to be called by Action.

Definition at line 1091 of file animrig/intern/action.cc.

References Active, active, and ActionSlot::slot_flags.

◆ set_expanded()

void blender::animrig::Slot::set_expanded ( bool expanded)

Definition at line 1063 of file animrig/intern/action.cc.

References Expanded, and ActionSlot::slot_flags.

Referenced by blender::animrig::tests::TEST_F().

◆ set_selected()

void blender::animrig::Slot::set_selected ( bool selected)

◆ users()

◆ users_add()

void blender::animrig::Slot::users_add ( ID & animated_id)

Register this ID as animated by this Slot.

This is a low-level function and should not typically be used. Use #Action::assign_id(slot, animated_id) instead.

Definition at line 1116 of file animrig/intern/action.cc.

References BLI_assert, and ActionSlot::runtime.

Referenced by BKE_nla_tweakmode_exit(), and blender::animrig::generic_assign_action_slot().

◆ users_invalidate()

void blender::animrig::Slot::users_invalidate ( Main & bmain)
static

Mark the users cache as 'dirty', triggering a full rebuild next time it is accessed.

This is typically not necessary, and only called from low-level code.

Note
This static method invalidates all user caches of all Action Slots.
See also
blender::animrig::internal::rebuild_slot_user_cache()
blender::bke::animdata::action_slots_user_cache_invalidate(), which is an alternative to calling this static method in case the caller only wants to depend on BKE headers.

Definition at line 1134 of file animrig/intern/action.cc.

References Main::is_action_slot_to_id_map_dirty.

Referenced by blender::bke::action_foreach_id(), blender::bke::animdata::action_slots_user_cache_invalidate(), and BKE_animdata_copy_in_lib().

◆ users_remove()

void blender::animrig::Slot::users_remove ( ID & animated_id)

Register this ID as no longer animated by this Slot.

This is a low-level function and should not typically be used. Use #Action::assign_id(nullptr, animated_id) instead.

Definition at line 1122 of file animrig/intern/action.cc.

References BLI_assert, ActionSlot::runtime, and users().

Referenced by blender::animrig::generic_assign_action_slot().

Member Data Documentation

◆ Action

friend blender::animrig::Slot::Action
protected

Definition at line 955 of file ANIM_action.hh.

◆ identifier_length_max

int blender::animrig::Slot::identifier_length_max = MAX_ID_NAME
staticconstexpr

◆ identifier_length_min

int blender::animrig::Slot::identifier_length_min = 3
staticconstexpr

Slot identifiers consist of a two-character ID code, then the display name. This means that the minimum length of a valid identifier is 3 characters.

Definition at line 788 of file ANIM_action.hh.

Referenced by identifier_ensure_prefix(), identifier_without_prefix(), and blender::animrig::Action::slot_identifier_define().

◆ unassigned


The documentation for this class was generated from the following files: