Bugfix [#33043] Changing the name of a keying set does not change group name
This now works for absolute Keying Sets (Builtin Keying Sets are highly context dependent, and usually cannot be renamed, so this shouldn't be a problem there)
This commit is contained in:
@@ -296,6 +296,43 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
|
||||
|
||||
/* ****************************** */
|
||||
|
||||
static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
KeyingSet *ks = (KeyingSet *)ptr->data;
|
||||
|
||||
/* update names of corresponding groups if name changes */
|
||||
if (strcmp(ks->name, value)) {
|
||||
KS_Path *ksp;
|
||||
|
||||
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
|
||||
if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
|
||||
AnimData *adt = BKE_animdata_from_id(ksp->id);
|
||||
|
||||
/* TODO: NLA strips? */
|
||||
if (adt && adt->action) {
|
||||
bActionGroup *agrp;
|
||||
|
||||
/* lazy check - should really find the F-Curve for the affected path and check its group
|
||||
* but this way should be faster and work well for most cases, as long as there are no
|
||||
* conflicts
|
||||
*/
|
||||
for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) {
|
||||
if (strcmp(ks->name, agrp->name) == 0) {
|
||||
/* there should only be one of these in the action, so can stop... */
|
||||
BLI_strncpy(agrp->name, value, sizeof(agrp->name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* finally, update name to new value */
|
||||
BLI_strncpy(ks->name, value, sizeof(ks->name));
|
||||
}
|
||||
|
||||
|
||||
static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
|
||||
{
|
||||
KeyingSet *ks = (KeyingSet *)ptr->data;
|
||||
@@ -721,19 +758,20 @@ static void rna_def_keyingset(BlenderRNA *brna)
|
||||
srna = RNA_def_struct(brna, "KeyingSet", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
|
||||
|
||||
/* Id/Label. */
|
||||
/* Id/Label */
|
||||
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "idname");
|
||||
RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
|
||||
RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
|
||||
/* RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
|
||||
|
||||
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "name");
|
||||
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set");
|
||||
RNA_def_property_ui_text(prop, "UI Name", "");
|
||||
RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "description");
|
||||
|
Reference in New Issue
Block a user