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/rna_animation_api.c | |
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/rna_animation_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation_api.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 |