Blender V2.61 - r43446

rna_action.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008), Roland Hess, Joshua Leung
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 
00030 #include "RNA_define.h"
00031 #include "RNA_enum_types.h"
00032 
00033 #include "rna_internal.h"
00034 
00035 #include "DNA_anim_types.h"
00036 #include "DNA_action_types.h"
00037 #include "DNA_scene_types.h"
00038 
00039 #include "MEM_guardedalloc.h"
00040 
00041 #include "BKE_action.h"
00042 
00043 #include "WM_types.h"
00044 
00045 
00046 #ifdef RNA_RUNTIME
00047 
00048 #include "ED_keyframing.h"
00049 #include "BKE_fcurve.h"
00050 
00051 static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
00052 {
00053     ListBaseIterator *internal= iter->internal;
00054     FCurve *fcu= (FCurve*)internal->link;
00055     bActionGroup *grp= fcu->grp;
00056     
00057     /* only continue if the next F-Curve (if existant) belongs in the same group */
00058     if ((fcu->next) && (fcu->next->grp == grp))
00059         internal->link= (Link*)fcu->next;
00060     else
00061         internal->link= NULL;
00062         
00063     iter->valid= (internal->link != NULL);
00064 }
00065 
00066 static bActionGroup *rna_Action_groups_new(bAction *act, const char name[])
00067 {
00068     return action_groups_add_new(act, name);
00069 }
00070 
00071 static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp)
00072 {
00073     FCurve *fcu, *fcn;
00074     
00075     /* try to remove the F-Curve from the action */
00076     if (!BLI_remlink_safe(&act->groups, agrp)) {
00077         BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name+2);
00078         return;
00079     }
00080 
00081     /* move every one one of the group's F-Curves out into the Action again */
00082     for (fcu= agrp->channels.first; (fcu) && (fcu->grp==agrp); fcu=fcn) {
00083         fcn= fcu->next;
00084         
00085         /* remove from group */
00086         action_groups_remove_channel(act, fcu);
00087         
00088         /* tack onto the end */
00089         BLI_addtail(&act->curves, fcu);
00090     }
00091     
00092     /* XXX, invalidates PyObject */
00093     MEM_freeN(agrp); 
00094 }
00095 
00096 static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path, int index, const char *group)
00097 {
00098     if (group && group[0]=='\0') group= NULL;
00099 
00100     if (data_path[0] == '\0') {
00101         BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
00102         return NULL;
00103     }
00104 
00105     /* annoying, check if this exists */
00106     if (verify_fcurve(act, group, data_path, index, 0)) {
00107         BKE_reportf(reports, RPT_ERROR, "F-Curve '%s[%d]' already exists in action '%s'", data_path, index, act->id.name+2);
00108         return NULL;
00109     }
00110     return verify_fcurve(act, group, data_path, index, 1);
00111 }
00112 
00113 static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu)
00114 {
00115     if (fcu->grp) {
00116         if (BLI_findindex(&act->groups, fcu->grp) == -1) {
00117             BKE_reportf(reports, RPT_ERROR, "F-Curve's ActionGroup '%s' not found in action '%s'", fcu->grp->name, act->id.name+2);
00118             return;
00119         }
00120         
00121         action_groups_remove_channel(act, fcu);
00122         free_fcurve(fcu);
00123     }
00124     else {
00125         if (BLI_findindex(&act->curves, fcu) == -1) {
00126             BKE_reportf(reports, RPT_ERROR, "F-Curve not found in action '%s'", act->id.name+2);
00127             return;
00128         }
00129         
00130         BLI_remlink(&act->curves, fcu);
00131         free_fcurve(fcu);
00132     }
00133 }
00134 
00135 static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
00136 {
00137     TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
00138     marker->flag= 1;
00139     marker->frame= 1;
00140     BLI_strncpy_utf8(marker->name, name, sizeof(marker->name));
00141     BLI_addtail(&act->markers, marker);
00142     return marker;
00143 }
00144 
00145 static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker)
00146 {
00147     if (!BLI_remlink_safe(&act->markers, marker)) {
00148         BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in Action '%s'", marker->name, act->id.name+2);
00149         return;
00150     }
00151 
00152     /* XXX, invalidates PyObject */
00153     MEM_freeN(marker);
00154 }
00155 
00156 static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr)
00157 {
00158     bAction *act= (bAction*)ptr->data;
00159     return rna_pointer_inherit_refine(ptr, &RNA_TimelineMarker, BLI_findlink(&act->markers, act->active_marker-1));
00160 }
00161 
00162 static void rna_Action_active_pose_marker_set(PointerRNA *ptr, PointerRNA value)
00163 {
00164     bAction *act= (bAction*)ptr->data;
00165     act->active_marker= BLI_findindex(&act->markers, value.data) + 1;
00166 }
00167 
00168 static int rna_Action_active_pose_marker_index_get(PointerRNA *ptr)
00169 {
00170     bAction *act= (bAction*)ptr->data;
00171     return MAX2(act->active_marker-1, 0);
00172 }
00173 
00174 static void rna_Action_active_pose_marker_index_set(PointerRNA *ptr, int value)
00175 {
00176     bAction *act= (bAction*)ptr->data;
00177     act->active_marker= value+1;
00178 }
00179 
00180 static void rna_Action_active_pose_marker_index_range(PointerRNA *ptr, int *min, int *max)
00181 {
00182     bAction *act= (bAction*)ptr->data;
00183 
00184     *min= 0;
00185     *max= BLI_countlist(&act->markers)-1;
00186     *max= MAX2(0, *max);
00187 }
00188 
00189 
00190 
00191 static void rna_Action_frame_range_get(PointerRNA *ptr,float *values)
00192 {   /* don't include modifiers because they too easily can have very large
00193      * ranges: MINAFRAMEF to MAXFRAMEF. */
00194     calc_action_range(ptr->id.data, values, values+1, FALSE);
00195 }
00196 
00197 
00198 /* used to check if an action (value pointer) is suitable to be assigned to the ID-block that is ptr */
00199 int rna_Action_id_poll(PointerRNA *ptr, PointerRNA value)
00200 {
00201     ID *srcId = (ID *)ptr->id.data;
00202     bAction *act = (bAction *)value.id.data;
00203     
00204     if (act) {
00205         /* there can still be actions that will have undefined id-root 
00206          * (i.e. floating "action-library" members) which we will not
00207          * be able to resolve an idroot for automatically, so let these through
00208          */
00209         if (act->idroot == 0)
00210             return 1;
00211         else if (srcId)
00212             return GS(srcId->name) == act->idroot;
00213     }
00214     
00215     return 0;
00216 }
00217 
00218 /* used to check if an action (value pointer) can be assigned to Action Editor given current mode */
00219 int rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value)
00220 {
00221     SpaceAction *saction = (SpaceAction *)ptr->data;
00222     bAction *act = (bAction *)value.id.data;
00223     
00224     if (act) {
00225         /* there can still be actions that will have undefined id-root 
00226          * (i.e. floating "action-library" members) which we will not
00227          * be able to resolve an idroot for automatically, so let these through
00228          */
00229         if (act->idroot == 0)
00230             return 1;
00231         
00232         if (saction) {
00233             if (saction->mode == SACTCONT_ACTION) {
00234                 /* this is only Object-level for now... */
00235                 return act->idroot == ID_OB;
00236             }
00237             else if (saction->mode == SACTCONT_SHAPEKEY) {
00238                 /* obviously shapekeys only */
00239                 return act->idroot == ID_KE;
00240             }
00241         }
00242     }
00243     
00244     return 0;
00245 }
00246 
00247 #else
00248 
00249 static void rna_def_dopesheet(BlenderRNA *brna)
00250 {
00251     StructRNA *srna;
00252     PropertyRNA *prop;
00253 
00254     srna= RNA_def_struct(brna, "DopeSheet", NULL);
00255     RNA_def_struct_sdna(srna, "bDopeSheet");
00256     RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in Animation Editors");
00257     
00258     /* Source of DopeSheet data */
00259     // XXX: make this obsolete?
00260     prop= RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE);
00261     RNA_def_property_struct_type(prop, "ID");
00262     RNA_def_property_ui_text(prop, "Source", "ID-Block representing source data, currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil)");
00263     
00264     /* Show datablock filters */
00265     prop= RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE);
00266     RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SHOW_DBFILTERS);
00267     RNA_def_property_ui_text(prop, "Show Datablock Filters", "Show options for whether channels related to certain types of data are included");
00268     RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, -1);
00269     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN, NULL);
00270     
00271     /* General Filtering Settings */
00272     prop= RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
00273     RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYSEL);
00274     RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
00275     RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
00276     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00277     
00278     prop= RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
00279     RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_INCL_HIDDEN);
00280     RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
00281     RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
00282     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00283     
00284     /* Object Group Filtering Settings */
00285     prop= RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE);
00286     RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP);
00287     RNA_def_property_ui_text(prop, "Only Objects in Group", "Only include channels from Objects in the specified Group");
00288     RNA_def_property_ui_icon(prop, ICON_GROUP, 0);
00289     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00290     
00291     prop= RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE);
00292     RNA_def_property_pointer_sdna(prop, NULL, "filter_grp");
00293     RNA_def_property_flag(prop, PROP_EDITABLE);
00294     RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of");
00295     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00296     
00297     /* FCurve Display Name Search Settings */
00298     prop= RNA_def_property(srna, "show_only_matching_fcurves", PROP_BOOLEAN, PROP_NONE);
00299     RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME);
00300     RNA_def_property_ui_text(prop, "Only Matching F-Curves", "Only include F-Curves with names containing search text");
00301     RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
00302     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00303     
00304     prop= RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE);
00305     RNA_def_property_string_sdna(prop, NULL, "searchstr");
00306     RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string");
00307     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00308     
00309     /* NLA Specific Settings */
00310     prop= RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE);
00311     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT);
00312     RNA_def_property_ui_text(prop, "Include Missing NLA", "Include Animation Data blocks with no NLA data (NLA Editor only)");
00313     RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
00314     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00315     
00316     /* Summary Settings (DopeSheet editors only) */
00317     prop= RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE);
00318     RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY);
00319     RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet Editors only)");
00320     RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0);
00321     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00322     
00323     prop= RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE);
00324     RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED);
00325     RNA_def_property_ui_text(prop, "Collapse Summary", "Collapse summary when shown, so all other channels get hidden (DopeSheet Editors Only)");
00326     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00327     
00328     
00329     /* General DataType Filtering Settings */
00330     prop= RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE);
00331     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ);
00332     RNA_def_property_ui_text(prop, "Display Transforms", "Include visualization of Object-level Animation data (mostly Transforms)");
00333     RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); // XXX?
00334     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00335     
00336     prop= RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE);
00337     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS);
00338     RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data");
00339     RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
00340     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00341     
00342     prop= RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE);
00343     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH);
00344     RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data");
00345     RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
00346     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00347     
00348     prop= RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE);
00349     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT);
00350     RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of Lattice related Animation data");
00351     RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0);
00352     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00353     
00354     prop= RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE);
00355     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM);
00356     RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data");
00357     RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0);
00358     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00359     
00360     prop= RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE);
00361     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT);
00362     RNA_def_property_ui_text(prop, "Display Material", "Include visualization of Material related Animation data");
00363     RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
00364     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00365     
00366     prop= RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE);
00367     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM);
00368     RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of Lamp related Animation data");
00369     RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
00370     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00371     
00372     prop= RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE);
00373     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX);
00374     RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of Texture related Animation data");
00375     RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0);
00376     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00377     
00378     prop= RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE);
00379     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR);
00380     RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of Curve related Animation data");
00381     RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0);
00382     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00383     
00384     prop= RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE);
00385     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR);
00386     RNA_def_property_ui_text(prop, "Display World", "Include visualization of World related Animation data");
00387     RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0);
00388     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00389     
00390     prop= RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE);
00391     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE);
00392     RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of Scene related Animation data");
00393     RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
00394     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00395     
00396     prop= RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
00397     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART);
00398     RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of Particle related Animation data");
00399     RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0);
00400     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00401     
00402     prop= RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE);
00403     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA);
00404     RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of Metaball related Animation data");
00405     RNA_def_property_ui_icon(prop, ICON_META_DATA, 0);
00406     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00407     
00408     prop= RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE);
00409     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM);
00410     RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of Armature related Animation data");
00411     RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0);
00412     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00413     
00414     prop= RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE);
00415     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE);
00416     RNA_def_property_ui_text(prop, "Display Node", "Include visualization of Node related Animation data");
00417     RNA_def_property_ui_icon(prop, ICON_NODETREE, 0);
00418     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00419 
00420     prop= RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE);
00421     RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSPK);
00422     RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of Speaker related Animation data");
00423     RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0);
00424     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00425 }
00426 
00427 static void rna_def_action_group(BlenderRNA *brna)
00428 {
00429     StructRNA *srna;
00430     PropertyRNA *prop;
00431     
00432     srna= RNA_def_struct(brna, "ActionGroup", NULL);
00433     RNA_def_struct_sdna(srna, "bActionGroup");
00434     RNA_def_struct_ui_text(srna, "Action Group", "Groups of F-Curves");
00435     
00436     prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
00437     RNA_def_property_ui_text(prop, "Name", "");
00438     RNA_def_struct_name_property(srna, prop);
00439     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00440     
00441     /* WARNING: be very careful when working with this list, since the endpoint is not
00442      * defined like a standard ListBase. Adding/removing channels from this list needs
00443      * extreme care, otherwise the F-Curve list running through adjacent groups does
00444      * not match up with the one stored in the Action, resulting in curves which do not
00445      * show up in animation editors. In extreme cases, animation may also selectively 
00446      * fail to play back correctly. 
00447      *
00448      * If such changes are required, these MUST go through the API functions for manipulating
00449      * these F-Curve groupings. Also, note that groups only apply in actions ONLY.
00450      */
00451     prop= RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
00452     RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
00453     RNA_def_property_struct_type(prop, "FCurve");
00454     RNA_def_property_collection_funcs(prop, 0, "rna_ActionGroup_channels_next", NULL, NULL, NULL, NULL, NULL, NULL);
00455     RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group");
00456     
00457     prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
00458     RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED);
00459     RNA_def_property_ui_text(prop, "Select", "Action Group is selected");
00460     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL);
00461     
00462     prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
00463     RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED);
00464     RNA_def_property_ui_text(prop, "Lock", "Action Group is locked");
00465     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00466     
00467     prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
00468     RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED);
00469     RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded");
00470     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00471     
00472     prop= RNA_def_property(srna, "custom_color", PROP_INT, PROP_NONE);
00473     RNA_def_property_int_sdna(prop, NULL, "customCol");
00474     RNA_def_property_ui_text(prop, "Custom Color", "Index of custom color set");
00475     RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
00476 }
00477 
00478 /* fcurve.keyframe_points */
00479 static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop)
00480 {
00481     StructRNA *srna;
00482 
00483     FunctionRNA *func;
00484     PropertyRNA *parm;
00485 
00486     RNA_def_property_srna(cprop, "ActionGroups");
00487     srna= RNA_def_struct(brna, "ActionGroups", NULL);
00488     RNA_def_struct_sdna(srna, "bAction");
00489     RNA_def_struct_ui_text(srna, "Action Groups", "Collection of action groups");
00490 
00491     func= RNA_def_function(srna, "new", "rna_Action_groups_new");
00492     RNA_def_function_ui_description(func, "Add a keyframe to the curve");
00493     parm= RNA_def_string(func, "name", "Group", 0, "", "New name for the action group");
00494     RNA_def_property_flag(parm, PROP_REQUIRED);
00495 
00496     parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", "Newly created action group");
00497     RNA_def_function_return(func, parm);
00498 
00499 
00500     func= RNA_def_function(srna, "remove", "rna_Action_groups_remove");
00501     RNA_def_function_ui_description(func, "Remove action group");
00502     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00503     parm= RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group to remove");
00504     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00505 }
00506 
00507 static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
00508 {
00509     StructRNA *srna;
00510 
00511     FunctionRNA *func;
00512     PropertyRNA *parm;
00513 
00514     RNA_def_property_srna(cprop, "ActionFCurves");
00515     srna= RNA_def_struct(brna, "ActionFCurves", NULL);
00516     RNA_def_struct_sdna(srna, "bAction");
00517     RNA_def_struct_ui_text(srna, "Action F-Curves", "Collection of action F-Curves");
00518 
00519     func= RNA_def_function(srna, "new", "rna_Action_fcurve_new");
00520     RNA_def_function_ui_description(func, "Add a keyframe to the F-Curve");
00521     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00522     parm= RNA_def_string(func, "data_path", "", 0, "Data Path", "F-Curve data path to use");
00523     RNA_def_property_flag(parm, PROP_REQUIRED);
00524     RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
00525     RNA_def_string(func, "action_group", "", 0, "Action Group", "Acton group to add this F-Curve into");
00526 
00527     parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created F-Curve");
00528     RNA_def_function_return(func, parm);
00529 
00530 
00531     func= RNA_def_function(srna, "remove", "rna_Action_fcurve_remove");
00532     RNA_def_function_ui_description(func, "Remove action group");
00533     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00534     parm= RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
00535     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00536 }
00537 
00538 static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
00539 {
00540     StructRNA *srna;
00541     PropertyRNA *prop;
00542 
00543     FunctionRNA *func;
00544     PropertyRNA *parm;
00545 
00546     RNA_def_property_srna(cprop, "ActionPoseMarkers");
00547     srna= RNA_def_struct(brna, "ActionPoseMarkers", NULL);
00548     RNA_def_struct_sdna(srna, "bAction");
00549     RNA_def_struct_ui_text(srna, "Action Pose Markers", "Collection of timeline markers");
00550 
00551     func= RNA_def_function(srna, "new", "rna_Action_pose_markers_new");
00552     RNA_def_function_ui_description(func, "Add a pose marker to the action");
00553     parm= RNA_def_string(func, "name", "Marker", 0, "", "New name for the marker (not unique)");
00554     RNA_def_property_flag(parm, PROP_REQUIRED);
00555 
00556     parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Newly created marker");
00557     RNA_def_function_return(func, parm);
00558 
00559     func= RNA_def_function(srna, "remove", "rna_Action_pose_markers_remove");
00560     RNA_def_function_ui_description(func, "Remove a timeline marker");
00561     RNA_def_function_flag(func, FUNC_USE_REPORTS);
00562     parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove");
00563     RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
00564     
00565     prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
00566     RNA_def_property_struct_type(prop, "TimelineMarker");
00567     RNA_def_property_flag(prop, PROP_EDITABLE);
00568     RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get", "rna_Action_active_pose_marker_set", NULL, NULL);
00569     RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this Action");
00570     
00571     prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
00572     RNA_def_property_int_sdna(prop, NULL, "active_marker");
00573     RNA_def_property_int_funcs(prop, "rna_Action_active_pose_marker_index_get", "rna_Action_active_pose_marker_index_set", "rna_Action_active_pose_marker_index_range");
00574     RNA_def_property_ui_text(prop, "Active Pose Marker Index", "Index of active pose marker");
00575 }
00576 
00577 static void rna_def_action(BlenderRNA *brna)
00578 {
00579     StructRNA *srna;
00580     PropertyRNA *prop;
00581     
00582     srna= RNA_def_struct(brna, "Action", "ID");
00583     RNA_def_struct_sdna(srna, "bAction");
00584     RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation");
00585     RNA_def_struct_ui_icon(srna, ICON_ACTION);
00586     
00587     /* collections */
00588     prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
00589     RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
00590     RNA_def_property_struct_type(prop, "FCurve");
00591     RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action");
00592     rna_def_action_fcurves(brna, prop);
00593     
00594     prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
00595     RNA_def_property_collection_sdna(prop, NULL, "groups", NULL);
00596     RNA_def_property_struct_type(prop, "ActionGroup");
00597     RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves");
00598     rna_def_action_groups(brna, prop);
00599     
00600     prop= RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
00601     RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
00602     RNA_def_property_struct_type(prop, "TimelineMarker");
00603     RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses");
00604     rna_def_action_pose_markers(brna, prop);
00605     
00606     /* properties */
00607     prop= RNA_def_float_vector(srna, "frame_range" , 2 , NULL , 0, 0, "Frame Range" , "The final frame range of all F-Curves within this action" , 0 , 0);
00608     RNA_def_property_float_funcs(prop, "rna_Action_frame_range_get" , NULL, NULL);
00609     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00610     
00611     /* special "type" limiter - should not really be edited in general, but is still available/editable in 'emergencies' */
00612     prop= RNA_def_property(srna, "id_root", PROP_ENUM, PROP_NONE);
00613     RNA_def_property_enum_sdna(prop, NULL, "idroot");
00614     RNA_def_property_enum_items(prop, id_type_items);
00615     RNA_def_property_ui_text(prop, "ID Root Type", "Type of ID-block that action can be used on - DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING");
00616     
00617     /* API calls */
00618     RNA_api_action(srna);
00619 }
00620 
00621 /* --------- */
00622 
00623 void RNA_def_action(BlenderRNA *brna)
00624 {
00625     rna_def_action(brna);
00626     rna_def_action_group(brna);
00627     rna_def_dopesheet(brna);
00628 }
00629 
00630 
00631 #endif