diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-03-25 14:34:18 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-03-25 14:34:18 +0300 |
commit | b88278b62b676765c03a94dd739ace73b582cea7 (patch) | |
tree | 1c5b0bc210aa0e38f91e49946bd35089f0192036 /source/blender/makesrna/intern | |
parent | 57b2ea62ab6f2f8e6dbd8cd51be0ef93b65ef34a (diff) |
More assorted Keying Sets changes for Cessen (mainly api stuff):
* Added operator (Ctrl Shift Alt I) to show menu for changing the active Keying Set in the 3D view (todo item from last commit)
* KeyingSetInfo (i.e. the Builtin Keying Set classes) can now be accessed from Keying Set instances with ks.type_info
* Added ks.remove_all_paths() function to remove all the paths for a Keying Set.
---
These two changes mean that builtin Keying Sets could be refreshed in response to context changes by doing:
<code>
ks = bpy.context.scene.active_keying_set
if ks.absolute==False and ks.type_info:
ksi = ks.type_info
# remove existing paths to fill with new
ks.remove_all_paths()
# check if Keying Set can be used in current context
if ksi.poll(bpy.context):
# call iterator() which calls generate() and re-populates paths list
ksi.iterator(bpy.context, ks)
</code>
And then, once this has been done, the paths that the Keying Set will operate on can be accessed as
<code>
paths = bpy.context.scene.active_keying_set.paths
</code>
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 32 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_animation_api.c | 25 |
2 files changed, 42 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index a1a769f5bf5..75cf06b5b2d 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -269,14 +269,6 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value) /* ****************************** */ -static int rna_KeyingSet_typeinfo_name_editable(PointerRNA *ptr) -{ - KeyingSet *ks= (KeyingSet *)ptr->data; - - /* only editable if we're using relative paths */ - return ((ks->flag & KEYINGSET_ABSOLUTE)==0); -} - static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr) { KeyingSet *ks= (KeyingSet *)ptr->data; @@ -319,6 +311,17 @@ static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, i *max= MAX2(0, *max); } +static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) +{ + KeyingSet *ks= (KeyingSet *)ptr->data; + KeyingSetInfo *ksi = NULL; + + /* keying set info is only for builtin Keying Sets */ + if ((ks->flag & KEYINGSET_ABSOLUTE)==0) + ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetInfo, ksi); +} + #else /* helper function for Keying Set -> keying settings */ @@ -353,7 +356,7 @@ static void rna_def_keyingset_info(BlenderRNA *brna) srna= RNA_def_struct(brna, "KeyingSetInfo", NULL); RNA_def_struct_sdna(srna, "KeyingSetInfo"); - RNA_def_struct_ui_text(srna, "Keying Set Info", "Callback function defines for relative Keying Sets"); + RNA_def_struct_ui_text(srna, "Keying Set Info", "Callback function defines for builtin Keying Sets"); RNA_def_struct_refine_func(srna, "rna_KeyingSetInfo_refine"); RNA_def_struct_register_funcs(srna, "rna_KeyingSetInfo_register", "rna_KeyingSetInfo_unregister"); @@ -472,12 +475,11 @@ static void rna_def_keyingset(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_KEY_HLT); // TODO: we need a dedicated icon RNA_def_struct_name_property(srna, prop); - /* TypeInfo associated with Relative KeyingSet (only) */ - prop= RNA_def_property(srna, "typeinfo_name", PROP_STRING, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_string_sdna(prop, NULL, "typeinfo"); - RNA_def_property_editable_func(prop, "rna_KeyingSet_typeinfo_name_editable"); - RNA_def_property_ui_text(prop, "TypeInfo Name", ""); + /* KeyingSetInfo (Type Info) for Builtin Sets only */ + prop= RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "KeyingSetInfo"); + RNA_def_property_pointer_funcs(prop, "rna_KeyingSet_typeinfo_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Type Info", "Callback function defines for builtin Keying Sets"); /* Paths */ prop= RNA_def_property(srna, "paths", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index d70370be68d..ba06697f9e9 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -81,6 +81,26 @@ static void rna_KeyingSet_remove_path(KeyingSet *keyingset, ReportList *reports, } } +static void rna_KeyingSet_remove_all_paths(KeyingSet *keyingset, ReportList *reports) +{ + /* if data is valid, call the API function for this */ + if (keyingset) { + KS_Path *ksp, *kspn; + + /* free each path as we go to avoid looping twice */ + for (ksp= keyingset->paths.first; ksp; ksp= kspn) { + kspn= ksp->next; + BKE_keyingset_free_path(keyingset, ksp); + } + + /* reset the active path, since there aren't any left */ + keyingset->active_path = 0; + } + else { + BKE_report(reports, RPT_ERROR, "Keying Set Paths could not be removed."); + } +} + #else void RNA_api_keyingset(StructRNA *srna) @@ -114,6 +134,11 @@ void RNA_api_keyingset(StructRNA *srna) /* path to remove */ parm= RNA_def_pointer(func, "path", "KeyingSetPath", "Path", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + + /* Remove All Paths */ + func= RNA_def_function(srna, "remove_all_paths", "rna_KeyingSet_remove_all_paths"); + RNA_def_function_ui_description(func, "Remove all the paths from the Keying Set."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); } #endif |