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