Fix: Set active keying set menu showing wrong label

When opening the menu to set/change the
active keying set, the top entry would
show "Active Keying Set" (if there is one).
(Open the menu with Ctrl+Shift+Alt+I)

Clicking this option would unset the active keying set
though as pointed out by Nika Kutsniashvili in #115798

This PR fixes it by splitting the function that dynamically generates the enum.
The core of the function has been extracted, and only the section
that creates the entry for "Active Keying Set" has been changed.

It now reads "Clear Active Keying Set"

Pull Request: https://projects.blender.org/blender/blender/pulls/116189
This commit is contained in:
Christoph Lendenfeld 2024-01-04 16:38:13 +01:00 committed by Christoph Lendenfeld
parent 41ba876d78
commit 29ed7a69e6
1 changed files with 32 additions and 1 deletions

View File

@ -521,6 +521,37 @@ static void build_keyingset_enum(bContext *C, EnumPropertyItem **item, int *toti
*r_free = true;
}
static const EnumPropertyItem *keyingset_set_active_enum_itemf(bContext *C,
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
bool *r_free)
{
if (C == nullptr) {
return rna_enum_dummy_DEFAULT_items;
}
/* active Keying Set
* - only include entry if it exists
*/
Scene *scene = CTX_data_scene(C);
EnumPropertyItem *item = nullptr, item_tmp = {0};
int totitem = 0;
if (scene->active_keyingset) {
/* active Keying Set */
item_tmp.identifier = "__ACTIVE__";
item_tmp.name = "Clear Active Keying Set";
item_tmp.value = 0;
RNA_enum_item_add(&item, &totitem, &item_tmp);
/* separator */
RNA_enum_item_add_separator(&item, &totitem);
}
build_keyingset_enum(C, &item, &totitem, r_free);
return item;
}
void ANIM_OT_keying_set_active_set(wmOperatorType *ot)
{
PropertyRNA *prop;
@ -541,7 +572,7 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot)
/* keyingset to use (dynamic enum) */
prop = RNA_def_enum(
ot->srna, "type", rna_enum_dummy_DEFAULT_items, 0, "Keying Set", "The Keying Set to use");
RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf);
RNA_def_enum_funcs(prop, keyingset_set_active_enum_itemf);
// RNA_def_property_flag(prop, PROP_HIDDEN);
}