Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2012-11-06 09:04:54 +0400
committerJoshua Leung <aligorith@gmail.com>2012-11-06 09:04:54 +0400
commit5a2136104838c833e6e1c88643b9bdb79379e26d (patch)
tree6ba15aedd885e87c54c769789646363cb32b46ec /source/blender/makesrna/intern/rna_animation.c
parent96cb05f02803c342ac89add0d393d1d0dc23d2af (diff)
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)
Diffstat (limited to 'source/blender/makesrna/intern/rna_animation.c')
-rw-r--r--source/blender/makesrna/intern/rna_animation.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index ce884fa4ecc..0553f4fa78e 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -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");