Anim: rename .action_slots to .action_suitable_slots

`AnimData`, NLA strips, and action constraints all have an
`action_slots` field in RNA. The purpose of this field is to list
the slots of the currently assigned action (if any) that are suitable
for the relevant ID.

However, this is not clear from the naming. In particular, given that
there is another field `action_slot` that represents the currently
assigned slot, the name `action_slots` could be easily misinterpreted
as a way to assign multiple slots at once, which is not possible.

To help clarify its actual purpose and meaning, this PR renames the
field to `action_suitable_slots`.

As a bonus, this also ends up decluttering the Python autocomplete when
looking for things related to `action_slot`.

Ref: #130892
Pull Request: https://projects.blender.org/blender/blender/pulls/130754
This commit is contained in:
Nathan Vegdahl
2024-11-26 11:40:05 +01:00
committed by Nathan Vegdahl
parent e692c916f8
commit 370a11342c
8 changed files with 34 additions and 27 deletions

View File

@@ -1132,7 +1132,7 @@ class ConstraintButtonsSubPanel:
col.context_pointer_set("animated_id", con.id_data)
col.template_search(
con, "action_slot",
con, "action_slots",
con, "action_suitable_slots",
new="", # No use in making a new slot here.
unlink="anim.slot_unassign_from_constraint",
text="Slot",

View File

@@ -320,7 +320,7 @@ class DOPESHEET_HT_editor_buttons:
row.context_pointer_set("animated_id", animated_id)
row.template_search(
adt, "action_slot",
adt, "action_slots",
adt, "action_suitable_slots",
new="anim.slot_new_for_id",
unlink="anim.slot_unassign_from_id",
)

View File

@@ -133,7 +133,7 @@ class PropertiesAnimationMixin:
layout.context_pointer_set("animated_id", animated_id)
layout.template_search(
adt, "action_slot",
adt, "action_slots",
adt, "action_suitable_slots",
new="anim.slot_new_for_id",
unlink="anim.slot_unassign_from_id",
)

View File

@@ -339,8 +339,15 @@ static void nla_panel_animdata(const bContext *C, Panel *panel)
/* action */
uiLayout *col = uiLayoutColumn(layout, true);
uiTemplateID(col, C, &adt_ptr, "action", "ACTION_OT_new", nullptr, "NLA_OT_action_unlink");
uiTemplateSearch(
col, C, &adt_ptr, "action_slot", &adt_ptr, "action_slots", nullptr, nullptr, IFACE_("Slot"));
uiTemplateSearch(col,
C,
&adt_ptr,
"action_slot",
&adt_ptr,
"action_suitable_slots",
nullptr,
nullptr,
IFACE_("Slot"));
/* extrapolation */
row = uiLayoutRow(layout, true);
@@ -500,7 +507,7 @@ static void nla_panel_actclip(const bContext *C, Panel *panel)
&strip_ptr,
"action_slot",
&strip_ptr,
"action_slots",
"action_suitable_slots",
nullptr,
"anim.slot_unassign_from_nla_strip",
"Slot");

View File

@@ -50,7 +50,7 @@ void rna_generic_action_slot_handle_set(blender::animrig::slot_handle_t slot_han
* Use these functions to complete the array property: "rna_iterator_array_next",
* "rna_iterator_array_end", "rna_iterator_array_dereference_get".
*/
void rna_iterator_generic_action_slots_begin(CollectionPropertyIterator *iter,
bAction *assigned_action);
void rna_iterator_generic_action_suitable_slots_begin(CollectionPropertyIterator *iter,
bAction *assigned_action);
#endif /* RNA_RUNTIME */

View File

@@ -358,7 +358,7 @@ static void rna_AnimData_action_slot_update(Main *bmain, Scene *scene, PointerRN
* to refer to this from any other file, though, which is why it's not declared in
* rna_action_tools.hh.
*/
bool rna_iterator_generic_action_slots_skip(CollectionPropertyIterator *iter, void *data)
bool rna_iterator_generic_action_suitable_slots_skip(CollectionPropertyIterator *iter, void *data)
{
using animrig::Slot;
@@ -376,8 +376,8 @@ bool rna_iterator_generic_action_slots_skip(CollectionPropertyIterator *iter, vo
return !slot.is_suitable_for(*animated_id);
}
void rna_iterator_generic_action_slots_begin(CollectionPropertyIterator *iter,
bAction *assigned_action)
void rna_iterator_generic_action_suitable_slots_begin(CollectionPropertyIterator *iter,
bAction *assigned_action)
{
if (!assigned_action) {
/* No action means no slots. */
@@ -392,13 +392,13 @@ void rna_iterator_generic_action_slots_begin(CollectionPropertyIterator *iter,
sizeof(animrig::Slot *),
slots.size(),
0,
rna_iterator_generic_action_slots_skip);
rna_iterator_generic_action_suitable_slots_skip);
}
static void rna_iterator_animdata_action_slots_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
static void rna_iterator_animdata_action_suitable_slots_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
{
rna_iterator_generic_action_slots_begin(iter, rna_animdata(ptr).action);
rna_iterator_generic_action_suitable_slots_begin(iter, rna_animdata(ptr).action);
}
/* ****************************** */
@@ -1724,10 +1724,10 @@ static void rna_def_animdata(BlenderRNA *brna)
* and that's enough. */
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
prop = RNA_def_property(srna, "action_slots", PROP_COLLECTION, PROP_NONE);
prop = RNA_def_property(srna, "action_suitable_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "ActionSlot");
RNA_def_property_collection_funcs(prop,
"rna_iterator_animdata_action_slots_begin",
"rna_iterator_animdata_action_suitable_slots_begin",
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_dereference_get",

View File

@@ -803,13 +803,13 @@ static void rna_ActionConstraint_action_slot_set(PointerRNA *ptr,
value, *ptr->owner_id, acon->act, acon->action_slot_handle, acon->action_slot_name, reports);
}
static void rna_iterator_ActionConstraint_action_slots_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
static void rna_iterator_ActionConstraint_action_suitable_slots_begin(
CollectionPropertyIterator *iter, PointerRNA *ptr)
{
bConstraint *con = (bConstraint *)ptr->data;
bActionConstraint *acon = (bActionConstraint *)con->data;
rna_iterator_generic_action_slots_begin(iter, acon->act);
rna_iterator_generic_action_suitable_slots_begin(iter, acon->act);
}
static int rna_SplineIKConstraint_joint_bindings_get_length(const PointerRNA *ptr,
@@ -2014,10 +2014,10 @@ static void rna_def_constraint_action(BlenderRNA *brna)
* and that's enough. */
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
prop = RNA_def_property(srna, "action_slots", PROP_COLLECTION, PROP_NONE);
prop = RNA_def_property(srna, "action_suitable_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "ActionSlot");
RNA_def_property_collection_funcs(prop,
"rna_iterator_ActionConstraint_action_slots_begin",
"rna_iterator_ActionConstraint_action_suitable_slots_begin",
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_dereference_get",

View File

@@ -510,11 +510,11 @@ static void rna_NlaStrip_action_slot_set(PointerRNA *ptr, PointerRNA value, Repo
reports);
}
static void rna_iterator_nlastrip_action_slots_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
static void rna_iterator_nlastrip_action_suitable_slots_begin(CollectionPropertyIterator *iter,
PointerRNA *ptr)
{
NlaStrip *strip = (NlaStrip *)ptr->data;
rna_iterator_generic_action_slots_begin(iter, strip->act);
rna_iterator_generic_action_suitable_slots_begin(iter, strip->act);
}
static void rna_NlaStrip_action_start_frame_set(PointerRNA *ptr, float value)
@@ -948,10 +948,10 @@ static void rna_def_nlastrip(BlenderRNA *brna)
* and that's enough. */
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
prop = RNA_def_property(srna, "action_slots", PROP_COLLECTION, PROP_NONE);
prop = RNA_def_property(srna, "action_suitable_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "ActionSlot");
RNA_def_property_collection_funcs(prop,
"rna_iterator_nlastrip_action_slots_begin",
"rna_iterator_nlastrip_action_suitable_slots_begin",
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_dereference_get",