From 29ed7a69e6e3269d31963f230dd321438a3621ca Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 4 Jan 2024 16:38:13 +0100 Subject: [PATCH] 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 --- .../blender/editors/animation/keyingsets.cc | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/keyingsets.cc b/source/blender/editors/animation/keyingsets.cc index f2b548aa319..d9a444d4862 100644 --- a/source/blender/editors/animation/keyingsets.cc +++ b/source/blender/editors/animation/keyingsets.cc @@ -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); }