Refactor: Anim, move function for setting active bone collection by name

Move the 'set active bone collection by name' functionality from RNA
to the ANIM module, so that it can be used in other places.

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2023-09-21 16:18:24 +02:00
parent f0840cee2a
commit 661065aed4
3 changed files with 15 additions and 2 deletions

View File

@@ -105,6 +105,14 @@ void ANIM_armature_bonecoll_active_set(struct bArmature *armature, struct BoneCo
void ANIM_armature_bonecoll_active_index_set(struct bArmature *armature,
int bone_collection_index);
/**
* Set the bone collection with the given name as the active one.
*
* Pass an empty name to clear the active bone collection. A non-existent name will also cause the
* active bone collection to be cleared.
*/
void ANIM_armature_bonecoll_active_name_set(struct bArmature *armature, const char *name);
/**
* Determine whether the given bone collection is editable.
*

View File

@@ -204,6 +204,12 @@ void ANIM_armature_bonecoll_active_index_set(bArmature *armature, const int bone
armature->runtime.active_collection = bcoll;
}
void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name)
{
BoneCollection *bcoll = ANIM_armature_bonecoll_get_by_name(armature, name);
ANIM_armature_bonecoll_active_set(armature, bcoll);
}
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
{
const bool is_override = ID_IS_OVERRIDE_LIBRARY(armature);

View File

@@ -222,8 +222,7 @@ static void rna_BoneCollections_active_index_range(
static void rna_BoneCollections_active_name_set(PointerRNA *ptr, const char *name)
{
bArmature *arm = (bArmature *)ptr->data;
BoneCollection *bcoll = ANIM_armature_bonecoll_get_by_name(arm, name);
ANIM_armature_bonecoll_active_set(arm, bcoll);
ANIM_armature_bonecoll_active_name_set(arm, name);
WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, ptr->data);
}