[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27991] trunk/blender/source/blender/ makesrna/intern: make keying set path functions members of the paths collection
Campbell Barton
ideasman42 at gmail.com
Sun Apr 4 19:42:40 CEST 2010
Revision: 27991
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27991
Author: campbellbarton
Date: 2010-04-04 19:42:40 +0200 (Sun, 04 Apr 2010)
Log Message:
-----------
make keying set path functions members of the paths collection
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_animation.c
trunk/blender/source/blender/makesrna/intern/rna_animation_api.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_animation.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_animation.c 2010-04-04 15:03:45 UTC (rev 27990)
+++ trunk/blender/source/blender/makesrna/intern/rna_animation.c 2010-04-04 17:42:40 UTC (rev 27991)
@@ -47,6 +47,8 @@
#ifdef RNA_RUNTIME
+#include "BKE_animsys.h"
+
static int rna_AnimData_action_editable(PointerRNA *ptr)
{
AnimData *adt= (AnimData *)ptr->data;
@@ -322,6 +324,70 @@
return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetInfo, ksi);
}
+
+
+static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *reports,
+ ID *id, char rna_path[], int index, int grouping_method, char group_name[])
+{
+ KS_Path *ksp = NULL;
+ short flag = 0;
+
+ /* special case when index = -1, we key the whole array (as with other places where index is used) */
+ if (index == -1) {
+ flag |= KSP_FLAG_WHOLE_ARRAY;
+ index = 0;
+ }
+
+ /* if data is valid, call the API function for this */
+ if (keyingset) {
+ ksp= BKE_keyingset_add_path(keyingset, id, group_name, rna_path, index, flag, grouping_method);
+ keyingset->active_path= BLI_countlist(&keyingset->paths);
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added.");
+ }
+
+ /* return added path */
+ return ksp;
+}
+
+static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, KS_Path *ksp)
+{
+ /* if data is valid, call the API function for this */
+ if (keyingset && ksp) {
+ /* remove the active path from the KeyingSet */
+ BKE_keyingset_free_path(keyingset, ksp);
+
+ /* the active path number will most likely have changed */
+ // TODO: we should get more fancy and actually check if it was removed, but this will do for now
+ keyingset->active_path = 0;
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed.");
+ }
+}
+
+static void rna_KeyingSet_paths_clear(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
/* helper function for Keying Set -> keying settings */
@@ -461,6 +527,57 @@
rna_def_common_keying_flags(srna, 0);
}
+
+
+/* keyingset.paths */
+static void rna_def_keyingset_paths(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "KeyingSetPaths");
+ srna= RNA_def_struct(brna, "KeyingSetPaths", NULL);
+ RNA_def_struct_sdna(srna, "KeyingSet");
+ RNA_def_struct_ui_text(srna, "Keying set paths", "Collection of keying set paths");
+
+
+ /* Add Path */
+ func= RNA_def_function(srna, "add", "rna_KeyingSet_paths_add");
+ RNA_def_function_ui_description(func, "Add a new path for the Keying Set.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* return arg */
+ parm= RNA_def_pointer(func, "ksp", "KeyingSetPath", "New Path", "Path created and added to the Keying Set");
+ RNA_def_function_return(func, parm);
+ /* ID-block for target */
+ parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* rna-path */
+ parm= RNA_def_string(func, "data_path", "", 256, "Data-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* index (defaults to -1 for entire array) */
+ parm=RNA_def_int(func, "index", -1, 0, INT_MAX, "Index", "The index of the destination property (i.e. axis of Location/Rotation/etc.), or -1 for the entire array.", 0, INT_MAX);
+ /* grouping */
+ parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use.");
+ parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name).");
+
+
+ /* Remove Path */
+ func= RNA_def_function(srna, "remove", "rna_KeyingSet_paths_remove");
+ RNA_def_function_ui_description(func, "Remove the given path from the Keying Set.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* 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, "clear", "rna_KeyingSet_paths_clear");
+ RNA_def_function_ui_description(func, "Remove all the paths from the Keying Set.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+}
+
static void rna_def_keyingset(BlenderRNA *brna)
{
StructRNA *srna;
@@ -486,6 +603,7 @@
RNA_def_property_collection_sdna(prop, NULL, "paths", NULL);
RNA_def_property_struct_type(prop, "KeyingSetPath");
RNA_def_property_ui_text(prop, "Paths", "Keying Set Paths to define settings that get keyframed together");
+ rna_def_keyingset_paths(brna, prop);
prop= RNA_def_property(srna, "active_path", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSetPath");
Modified: trunk/blender/source/blender/makesrna/intern/rna_animation_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_animation_api.c 2010-04-04 15:03:45 UTC (rev 27990)
+++ trunk/blender/source/blender/makesrna/intern/rna_animation_api.c 2010-04-04 17:42:40 UTC (rev 27991)
@@ -40,105 +40,12 @@
#include "BKE_animsys.h"
-static KS_Path *rna_KeyingSet_add_path(KeyingSet *keyingset, ReportList *reports,
- ID *id, char rna_path[], int index, int grouping_method, char group_name[])
-{
- KS_Path *ksp = NULL;
- short flag = 0;
-
- /* special case when index = -1, we key the whole array (as with other places where index is used) */
- if (index == -1) {
- flag |= KSP_FLAG_WHOLE_ARRAY;
- index = 0;
- }
-
- /* if data is valid, call the API function for this */
- if (keyingset) {
- ksp= BKE_keyingset_add_path(keyingset, id, group_name, rna_path, index, flag, grouping_method);
- keyingset->active_path= BLI_countlist(&keyingset->paths);
- }
- else {
- BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added.");
- }
-
- /* return added path */
- return ksp;
-}
-
-static void rna_KeyingSet_remove_path(KeyingSet *keyingset, ReportList *reports, KS_Path *ksp)
-{
- /* if data is valid, call the API function for this */
- if (keyingset && ksp) {
- /* remove the active path from the KeyingSet */
- BKE_keyingset_free_path(keyingset, ksp);
-
- /* the active path number will most likely have changed */
- // TODO: we should get more fancy and actually check if it was removed, but this will do for now
- keyingset->active_path = 0;
- }
- else {
- BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed.");
- }
-}
-
-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)
{
FunctionRNA *func;
PropertyRNA *parm;
-
- /* Add Path */
- func= RNA_def_function(srna, "add_path", "rna_KeyingSet_add_path");
- RNA_def_function_ui_description(func, "Add a new path for the Keying Set.");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- /* return arg */
- parm= RNA_def_pointer(func, "ksp", "KeyingSetPath", "New Path", "Path created and added to the Keying Set");
- RNA_def_function_return(func, parm);
- /* ID-block for target */
- parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
- /* rna-path */
- parm= RNA_def_string(func, "data_path", "", 256, "Data-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough
- RNA_def_property_flag(parm, PROP_REQUIRED);
- /* index (defaults to -1 for entire array) */
- parm=RNA_def_int(func, "index", -1, 0, INT_MAX, "Index", "The index of the destination property (i.e. axis of Location/Rotation/etc.), or -1 for the entire array.", 0, INT_MAX);
- /* grouping */
- parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use.");
- parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name).");
-
- /* Remove Path */
- func= RNA_def_function(srna, "remove_path", "rna_KeyingSet_remove_path");
- RNA_def_function_ui_description(func, "Remove the given path from the Keying Set.");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- /* 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
More information about the Bf-blender-cvs
mailing list