Blender  V2.93
rna_action.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "DNA_action_types.h"
24 #include "DNA_anim_types.h"
25 #include "DNA_scene_types.h"
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "BLI_utildefines.h"
30 
31 #include "BLT_translation.h"
32 
33 #include "BKE_action.h"
34 
35 #include "RNA_access.h"
36 #include "RNA_define.h"
37 #include "RNA_enum_types.h"
38 
39 #include "rna_internal.h"
40 
41 #include "WM_types.h"
42 
43 #ifdef RNA_RUNTIME
44 
45 # include "BLI_math_base.h"
46 
47 # include "BKE_fcurve.h"
48 
49 # include "DEG_depsgraph.h"
50 
51 # include "ED_keyframing.h"
52 
53 # include "WM_api.h"
54 
55 static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
56 {
57  ListBaseIterator *internal = &iter->internal.listbase;
58  FCurve *fcu = (FCurve *)internal->link;
59  bActionGroup *grp = fcu->grp;
60 
61  /* only continue if the next F-Curve (if existent) belongs in the same group */
62  if ((fcu->next) && (fcu->next->grp == grp)) {
63  internal->link = (Link *)fcu->next;
64  }
65  else {
66  internal->link = NULL;
67  }
68 
69  iter->valid = (internal->link != NULL);
70 }
71 
72 static bActionGroup *rna_Action_groups_new(bAction *act, const char name[])
73 {
74  return action_groups_add_new(act, name);
75 }
76 
77 static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerRNA *agrp_ptr)
78 {
79  bActionGroup *agrp = agrp_ptr->data;
80  FCurve *fcu, *fcn;
81 
82  /* try to remove the F-Curve from the action */
83  if (BLI_remlink_safe(&act->groups, agrp) == false) {
84  BKE_reportf(reports,
85  RPT_ERROR,
86  "Action group '%s' not found in action '%s'",
87  agrp->name,
88  act->id.name + 2);
89  return;
90  }
91 
92  /* move every one one of the group's F-Curves out into the Action again */
93  for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcn) {
94  fcn = fcu->next;
95 
96  /* remove from group */
98 
99  /* tack onto the end */
100  BLI_addtail(&act->curves, fcu);
101  }
102 
103  MEM_freeN(agrp);
104  RNA_POINTER_INVALIDATE(agrp_ptr);
105 
108 }
109 
110 static FCurve *rna_Action_fcurve_new(bAction *act,
111  Main *bmain,
112  ReportList *reports,
113  const char *data_path,
114  int index,
115  const char *group)
116 {
117  if (group && group[0] == '\0') {
118  group = NULL;
119  }
120 
121  if (data_path[0] == '\0') {
122  BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
123  return NULL;
124  }
125 
126  /* Annoying, check if this exists. */
127  if (ED_action_fcurve_find(act, data_path, index)) {
128  BKE_reportf(reports,
129  RPT_ERROR,
130  "F-Curve '%s[%d]' already exists in action '%s'",
131  data_path,
132  index,
133  act->id.name + 2);
134  return NULL;
135  }
136  return ED_action_fcurve_ensure(bmain, act, group, NULL, data_path, index);
137 }
138 
139 static FCurve *rna_Action_fcurve_find(bAction *act,
140  ReportList *reports,
141  const char *data_path,
142  int index)
143 {
144  if (data_path[0] == '\0') {
145  BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
146  return NULL;
147  }
148 
149  /* Returns NULL if not found. */
150  return BKE_fcurve_find(&act->curves, data_path, index);
151 }
152 
153 static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerRNA *fcu_ptr)
154 {
155  FCurve *fcu = fcu_ptr->data;
156  if (fcu->grp) {
157  if (BLI_findindex(&act->groups, fcu->grp) == -1) {
158  BKE_reportf(reports,
159  RPT_ERROR,
160  "F-Curve's action group '%s' not found in action '%s'",
161  fcu->grp->name,
162  act->id.name + 2);
163  return;
164  }
165 
167  BKE_fcurve_free(fcu);
168  RNA_POINTER_INVALIDATE(fcu_ptr);
169  }
170  else {
171  if (BLI_findindex(&act->curves, fcu) == -1) {
172  BKE_reportf(reports, RPT_ERROR, "F-Curve not found in action '%s'", act->id.name + 2);
173  return;
174  }
175 
176  BLI_remlink(&act->curves, fcu);
177  BKE_fcurve_free(fcu);
178  RNA_POINTER_INVALIDATE(fcu_ptr);
179  }
180 
183 }
184 
185 static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
186 {
187  TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
188  marker->flag = 1;
189  marker->frame = 1;
190  BLI_strncpy_utf8(marker->name, name, sizeof(marker->name));
191  BLI_addtail(&act->markers, marker);
192  return marker;
193 }
194 
195 static void rna_Action_pose_markers_remove(bAction *act,
196  ReportList *reports,
197  PointerRNA *marker_ptr)
198 {
199  TimeMarker *marker = marker_ptr->data;
200  if (!BLI_remlink_safe(&act->markers, marker)) {
201  BKE_reportf(reports,
202  RPT_ERROR,
203  "Timeline marker '%s' not found in action '%s'",
204  marker->name,
205  act->id.name + 2);
206  return;
207  }
208 
209  MEM_freeN(marker);
210  RNA_POINTER_INVALIDATE(marker_ptr);
211 }
212 
213 static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr)
214 {
215  bAction *act = (bAction *)ptr->data;
218 }
219 
220 static void rna_Action_active_pose_marker_set(PointerRNA *ptr,
221  PointerRNA value,
222  struct ReportList *UNUSED(reports))
223 {
224  bAction *act = (bAction *)ptr->data;
225  act->active_marker = BLI_findindex(&act->markers, value.data) + 1;
226 }
227 
228 static int rna_Action_active_pose_marker_index_get(PointerRNA *ptr)
229 {
230  bAction *act = (bAction *)ptr->data;
231  return MAX2(act->active_marker - 1, 0);
232 }
233 
234 static void rna_Action_active_pose_marker_index_set(PointerRNA *ptr, int value)
235 {
236  bAction *act = (bAction *)ptr->data;
237  act->active_marker = value + 1;
238 }
239 
240 static void rna_Action_active_pose_marker_index_range(
241  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
242 {
243  bAction *act = (bAction *)ptr->data;
244 
245  *min = 0;
246  *max = max_ii(0, BLI_listbase_count(&act->markers) - 1);
247 }
248 
249 static void rna_Action_frame_range_get(PointerRNA *ptr, float *values)
250 { /* don't include modifiers because they too easily can have very large
251  * ranges: MINAFRAMEF to MAXFRAMEF. */
252  calc_action_range((bAction *)ptr->owner_id, values, values + 1, false);
253 }
254 
255 /* Used to check if an action (value pointer)
256  * is suitable to be assigned to the ID-block that is ptr. */
258 {
259  ID *srcId = ptr->owner_id;
260  bAction *act = (bAction *)value.owner_id;
261 
262  if (act) {
263  /* there can still be actions that will have undefined id-root
264  * (i.e. floating "action-library" members) which we will not
265  * be able to resolve an idroot for automatically, so let these through
266  */
267  if (act->idroot == 0) {
268  return 1;
269  }
270  else if (srcId) {
271  return GS(srcId->name) == act->idroot;
272  }
273  }
274 
275  return 0;
276 }
277 
278 /* Used to check if an action (value pointer)
279  * can be assigned to Action Editor given current mode. */
281 {
282  SpaceAction *saction = (SpaceAction *)ptr->data;
283  bAction *act = (bAction *)value.owner_id;
284 
285  if (act) {
286  /* there can still be actions that will have undefined id-root
287  * (i.e. floating "action-library" members) which we will not
288  * be able to resolve an idroot for automatically, so let these through
289  */
290  if (act->idroot == 0) {
291  return 1;
292  }
293 
294  if (saction) {
295  if (saction->mode == SACTCONT_ACTION) {
296  /* this is only Object-level for now... */
297  return act->idroot == ID_OB;
298  }
299  else if (saction->mode == SACTCONT_SHAPEKEY) {
300  /* obviously shapekeys only */
301  return act->idroot == ID_KE;
302  }
303  }
304  }
305 
306  return 0;
307 }
308 
309 static char *rna_DopeSheet_path(PointerRNA *UNUSED(ptr))
310 {
311  return BLI_strdup("dopesheet");
312 }
313 
314 #else
315 
316 static void rna_def_dopesheet(BlenderRNA *brna)
317 {
318  StructRNA *srna;
319  PropertyRNA *prop;
320 
321  srna = RNA_def_struct(brna, "DopeSheet", NULL);
322  RNA_def_struct_sdna(srna, "bDopeSheet");
323  RNA_def_struct_path_func(srna, "rna_DopeSheet_path");
325  srna, "Dope Sheet", "Settings for filtering the channels shown in animation editors");
326 
327  /* Source of DopeSheet data */
328  /* XXX: make this obsolete? */
329  prop = RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE);
330  RNA_def_property_struct_type(prop, "ID");
332  prop, "Source", "ID-Block representing source data, usually ID_SCE (i.e. Scene)");
333 
334  /* Show data-block filters */
335  prop = RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE);
338  prop,
339  "Show Data-Block Filters",
340  "Show options for whether channels related to certain types of data are included");
341  RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
343 
344  /* General Filtering Settings */
345  prop = RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE);
348  prop, "Only Show Selected", "Only include channels relating to selected objects and data");
349  RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
351 
352  prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
355  prop, "Show Hidden", "Include channels from objects/bone that are not visible");
356  RNA_def_property_ui_icon(prop, ICON_OBJECT_HIDDEN, 0);
358 
359  prop = RNA_def_property(srna, "use_datablock_sort", PROP_BOOLEAN, PROP_NONE);
362  "Sort Data-Blocks",
363  "Alphabetically sorts data-blocks - mainly objects in the scene "
364  "(disable to increase viewport speed)");
365  RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
367 
368  prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE);
370  RNA_def_property_ui_text(prop, "Invert", "Invert filter search");
371  RNA_def_property_ui_icon(prop, ICON_ZOOM_IN, 0);
373 
374  /* Debug Filtering Settings */
375  prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
378  "Only Show Errors",
379  "Only include F-Curves and drivers that are disabled or have errors");
380  RNA_def_property_ui_icon(prop, ICON_ERROR, 0);
382 
383  /* Object Collection Filtering Settings */
384  prop = RNA_def_property(srna, "filter_collection", PROP_POINTER, PROP_NONE);
385  RNA_def_property_pointer_sdna(prop, NULL, "filter_grp");
388  prop, "Filtering Collection", "Collection that included object should be a member of");
390 
391  /* FCurve Display Name Search Settings */
392  prop = RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE);
393  RNA_def_property_string_sdna(prop, NULL, "searchstr");
394  RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string");
395  RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
398 
399  /* NLA Name Search Settings (Shared with FCurve setting, but with different labels) */
400  prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE);
401  RNA_def_property_string_sdna(prop, NULL, "searchstr");
402  RNA_def_property_ui_text(prop, "Name Filter", "Live filtering string");
404  RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
406 
407  /* Multi-word fuzzy search option for name/text filters */
408  prop = RNA_def_property(srna, "use_multi_word_filter", PROP_BOOLEAN, PROP_NONE);
411  "Multi-Word Fuzzy Filter",
412  "Perform fuzzy/multi-word matching.\n"
413  "Warning: May be slow");
414  RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
416 
417  /* NLA Specific Settings */
418  prop = RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE);
421  "Include Missing NLA",
422  "Include animation data-blocks with no NLA data (NLA editor only)");
423  RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
425 
426  /* Summary Settings (DopeSheet editors only) */
427  prop = RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE);
430  prop, "Display Summary", "Display an additional 'summary' line (Dope Sheet editors only)");
431  RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0);
433 
434  prop = RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE);
437  prop,
438  "Collapse Summary",
439  "Collapse summary when shown, so all other channels get hidden (Dope Sheet editors only)");
441 
442  /* General DataType Filtering Settings */
443  prop = RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE);
446  prop,
447  "Display Transforms",
448  "Include visualization of object-level animation data (mostly transforms)");
449  RNA_def_property_ui_icon(prop, ICON_ORIENTATION_GLOBAL, 0); /* XXX? */
451 
452  prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE);
455  prop, "Display Shape Keys", "Include visualization of shape key related animation data");
456  RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
458 
459  prop = RNA_def_property(srna, "show_modifiers", PROP_BOOLEAN, PROP_NONE);
462  prop,
463  "Display Modifier Data",
464  "Include visualization of animation data related to data-blocks linked to modifiers");
465  RNA_def_property_ui_icon(prop, ICON_MODIFIER_DATA, 0);
467 
468  prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE);
471  prop, "Display Meshes", "Include visualization of mesh related animation data");
472  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_MESH, 0);
474 
475  prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE);
478  prop, "Display Lattices", "Include visualization of lattice related animation data");
479  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LATTICE, 0);
481 
482  prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE);
485  prop, "Display Camera", "Include visualization of camera related animation data");
486  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0);
488 
489  prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE);
492  prop, "Display Material", "Include visualization of material related animation data");
493  RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
495 
496  prop = RNA_def_property(srna, "show_lights", PROP_BOOLEAN, PROP_NONE);
499  prop, "Display Light", "Include visualization of light related animation data");
500  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHT, 0);
502 
503  prop = RNA_def_property(srna, "show_linestyles", PROP_BOOLEAN, PROP_NONE);
506  prop, "Display Line Style", "Include visualization of Line Style related Animation data");
507  RNA_def_property_ui_icon(prop, ICON_LINE_DATA, 0);
509 
510  prop = RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE);
513  prop, "Display Texture", "Include visualization of texture related animation data");
514  RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0);
516 
517  prop = RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE);
520  prop, "Display Curve", "Include visualization of curve related animation data");
521  RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0);
523 
524  prop = RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE);
527  prop, "Display World", "Include visualization of world related animation data");
528  RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0);
530 
531  prop = RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE);
534  prop, "Display Scene", "Include visualization of scene related animation data");
535  RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
537 
538  prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
541  prop, "Display Particle", "Include visualization of particle related animation data");
542  RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0);
544 
545  prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE);
548  prop, "Display Metaball", "Include visualization of metaball related animation data");
549  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_META, 0);
551 
552  prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE);
555  prop, "Display Armature", "Include visualization of armature related animation data");
556  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0);
558 
559  prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE);
562  prop, "Display Node", "Include visualization of node related animation data");
563  RNA_def_property_ui_icon(prop, ICON_NODETREE, 0);
565 
566  prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE);
569  prop, "Display Speaker", "Include visualization of speaker related animation data");
570  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0);
572 
573  prop = RNA_def_property(srna, "show_cache_files", PROP_BOOLEAN, PROP_NONE);
576  prop, "Display Cache Files", "Include visualization of cache file related animation data");
577  RNA_def_property_ui_icon(prop, ICON_FILE, 0);
579 
580  prop = RNA_def_property(srna, "show_hairs", PROP_BOOLEAN, PROP_NONE);
583  prop, "Display Hair", "Include visualization of hair related animation data");
584  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_HAIR, 0);
586 
587  prop = RNA_def_property(srna, "show_pointclouds", PROP_BOOLEAN, PROP_NONE);
590  prop, "Display Point Cloud", "Include visualization of point cloud related animation data");
591  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_POINTCLOUD, 0);
593 
594  prop = RNA_def_property(srna, "show_volumes", PROP_BOOLEAN, PROP_NONE);
597  prop, "Display Volume", "Include visualization of volume related animation data");
598  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_VOLUME, 0);
600 
601  prop = RNA_def_property(srna, "show_gpencil", PROP_BOOLEAN, PROP_NONE);
604  prop,
605  "Display Grease Pencil",
606  "Include visualization of Grease Pencil related animation data and frames");
607  RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_GREASEPENCIL, 0);
609 
610  prop = RNA_def_property(srna, "show_movieclips", PROP_BOOLEAN, PROP_NONE);
613  prop, "Display Movie Clips", "Include visualization of movie clip related animation data");
614  RNA_def_property_ui_icon(prop, ICON_TRACKER, 0);
616 }
617 
619 {
620  StructRNA *srna;
621  PropertyRNA *prop;
622 
623  srna = RNA_def_struct(brna, "ActionGroup", NULL);
624  RNA_def_struct_sdna(srna, "bActionGroup");
625  RNA_def_struct_ui_text(srna, "Action Group", "Groups of F-Curves");
626 
627  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
628  RNA_def_property_ui_text(prop, "Name", "");
629  RNA_def_struct_name_property(srna, prop);
631 
632  /* WARNING: be very careful when working with this list, since the endpoint is not
633  * defined like a standard ListBase. Adding/removing channels from this list needs
634  * extreme care, otherwise the F-Curve list running through adjacent groups does
635  * not match up with the one stored in the Action, resulting in curves which do not
636  * show up in animation editors. In extreme cases, animation may also selectively
637  * fail to play back correctly.
638  *
639  * If such changes are required, these MUST go through the API functions for manipulating
640  * these F-Curve groupings. Also, note that groups only apply in actions ONLY.
641  */
642  prop = RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
643  RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
644  RNA_def_property_struct_type(prop, "FCurve");
646  prop, NULL, "rna_ActionGroup_channels_next", NULL, NULL, NULL, NULL, NULL, NULL);
647  RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group");
648 
649  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
651  RNA_def_property_ui_text(prop, "Select", "Action group is selected");
653 
654  prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
656  RNA_def_property_ui_text(prop, "Lock", "Action group is locked");
658 
659  prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
662  RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded except in graph editor");
664 
665  prop = RNA_def_property(srna, "show_expanded_graph", PROP_BOOLEAN, PROP_NONE);
669  prop, "Expanded in Graph Editor", "Action group is expanded in graph editor");
671 
672  prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
675  RNA_def_property_ui_text(prop, "Pin in Graph Editor", "");
677 
678  /* color set */
680 }
681 
682 /* fcurve.keyframe_points */
683 static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop)
684 {
685  StructRNA *srna;
686 
687  FunctionRNA *func;
688  PropertyRNA *parm;
689 
690  RNA_def_property_srna(cprop, "ActionGroups");
691  srna = RNA_def_struct(brna, "ActionGroups", NULL);
692  RNA_def_struct_sdna(srna, "bAction");
693  RNA_def_struct_ui_text(srna, "Action Groups", "Collection of action groups");
694 
695  func = RNA_def_function(srna, "new", "rna_Action_groups_new");
696  RNA_def_function_ui_description(func, "Create a new action group and add it to the action");
697  parm = RNA_def_string(func, "name", "Group", 0, "", "New name for the action group");
699 
700  parm = RNA_def_pointer(func, "action_group", "ActionGroup", "", "Newly created action group");
701  RNA_def_function_return(func, parm);
702 
703  func = RNA_def_function(srna, "remove", "rna_Action_groups_remove");
704  RNA_def_function_ui_description(func, "Remove action group");
706  parm = RNA_def_pointer(func, "action_group", "ActionGroup", "", "Action group to remove");
709 }
710 
712 {
713  StructRNA *srna;
714 
715  FunctionRNA *func;
716  PropertyRNA *parm;
717 
718  RNA_def_property_srna(cprop, "ActionFCurves");
719  srna = RNA_def_struct(brna, "ActionFCurves", NULL);
720  RNA_def_struct_sdna(srna, "bAction");
721  RNA_def_struct_ui_text(srna, "Action F-Curves", "Collection of action F-Curves");
722 
723  /* Action.fcurves.new(...) */
724  func = RNA_def_function(srna, "new", "rna_Action_fcurve_new");
725  RNA_def_function_ui_description(func, "Add an F-Curve to the action");
727  parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path to use");
729  RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
731  func, "action_group", NULL, 0, "Action Group", "Acton group to add this F-Curve into");
732 
733  parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "Newly created F-Curve");
734  RNA_def_function_return(func, parm);
735 
736  /* Action.fcurves.find(...) */
737  func = RNA_def_function(srna, "find", "rna_Action_fcurve_find");
739  func,
740  "Find an F-Curve. Note that this function performs a linear scan "
741  "of all F-Curves in the action.");
743  parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path");
745  RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
746  parm = RNA_def_pointer(
747  func, "fcurve", "FCurve", "", "The found F-Curve, or None if it doesn't exist");
748  RNA_def_function_return(func, parm);
749 
750  /* Action.fcurves.remove(...) */
751  func = RNA_def_function(srna, "remove", "rna_Action_fcurve_remove");
752  RNA_def_function_ui_description(func, "Remove action group");
754  parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
757 }
758 
760 {
761  StructRNA *srna;
762  PropertyRNA *prop;
763 
764  FunctionRNA *func;
765  PropertyRNA *parm;
766 
767  RNA_def_property_srna(cprop, "ActionPoseMarkers");
768  srna = RNA_def_struct(brna, "ActionPoseMarkers", NULL);
769  RNA_def_struct_sdna(srna, "bAction");
770  RNA_def_struct_ui_text(srna, "Action Pose Markers", "Collection of timeline markers");
771 
772  func = RNA_def_function(srna, "new", "rna_Action_pose_markers_new");
773  RNA_def_function_ui_description(func, "Add a pose marker to the action");
774  parm = RNA_def_string(func, "name", "Marker", 0, NULL, "New name for the marker (not unique)");
776  parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Newly created marker");
777  RNA_def_function_return(func, parm);
778 
779  func = RNA_def_function(srna, "remove", "rna_Action_pose_markers_remove");
780  RNA_def_function_ui_description(func, "Remove a timeline marker");
782  parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove");
785 
786  prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
787  RNA_def_property_struct_type(prop, "TimelineMarker");
790  prop, "rna_Action_active_pose_marker_get", "rna_Action_active_pose_marker_set", NULL, NULL);
791  RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action");
792 
793  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
794  RNA_def_property_int_sdna(prop, NULL, "active_marker");
797  "rna_Action_active_pose_marker_index_get",
798  "rna_Action_active_pose_marker_index_set",
799  "rna_Action_active_pose_marker_index_range");
800  RNA_def_property_ui_text(prop, "Active Pose Marker Index", "Index of active pose marker");
801 }
802 
803 static void rna_def_action(BlenderRNA *brna)
804 {
805  StructRNA *srna;
806  PropertyRNA *prop;
807 
808  srna = RNA_def_struct(brna, "Action", "ID");
809  RNA_def_struct_sdna(srna, "bAction");
810  RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation");
811  RNA_def_struct_ui_icon(srna, ICON_ACTION);
812 
813  /* collections */
814  prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
815  RNA_def_property_collection_sdna(prop, NULL, "curves", NULL);
816  RNA_def_property_struct_type(prop, "FCurve");
817  RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the action");
818  rna_def_action_fcurves(brna, prop);
819 
820  prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
821  RNA_def_property_collection_sdna(prop, NULL, "groups", NULL);
822  RNA_def_property_struct_type(prop, "ActionGroup");
823  RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves");
824  rna_def_action_groups(brna, prop);
825 
826  prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE);
827  RNA_def_property_collection_sdna(prop, NULL, "markers", NULL);
828  RNA_def_property_struct_type(prop, "TimelineMarker");
829  /* Use lib exception so the list isn't grayed out;
830  * adding/removing is still banned though, see T45689. */
833  prop, "Pose Markers", "Markers specific to this action, for labeling poses");
834  rna_def_action_pose_markers(brna, prop);
835 
836  /* properties */
837  prop = RNA_def_float_vector(srna,
838  "frame_range",
839  2,
840  NULL,
841  0,
842  0,
843  "Frame Range",
844  "The final frame range of all F-Curves within this action",
845  0,
846  0);
847  RNA_def_property_float_funcs(prop, "rna_Action_frame_range_get", NULL, NULL);
849 
850  /* special "type" limiter - should not really be edited in general,
851  * but is still available/editable in 'emergencies' */
852  prop = RNA_def_property(srna, "id_root", PROP_ENUM, PROP_NONE);
853  RNA_def_property_enum_sdna(prop, NULL, "idroot");
856  "ID Root Type",
857  "Type of ID block that action can be used on - "
858  "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING");
860 
861  /* API calls */
862  RNA_api_action(srna);
863 }
864 
865 /* --------- */
866 
868 {
869  rna_def_action(brna);
870  rna_def_action_group(brna);
871  rna_def_dopesheet(brna);
872 }
873 
874 #endif
Blender kernel action and pose functionality.
struct bActionGroup * action_groups_add_new(struct bAction *act, const char name[])
Definition: action.c:402
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu)
Definition: action.c:538
void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers)
void BKE_fcurve_free(struct FCurve *fcu)
Definition: fcurve.c:81
struct FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_index)
Definition: fcurve.c:274
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLI_remlink_safe(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:159
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
#define UNUSED(x)
#define MAX2(a, b)
#define BLT_I18NCONTEXT_ID_ID
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition: DNA_ID.h:690
@ ID_KE
Definition: DNA_ID_enums.h:70
@ ID_OB
Definition: DNA_ID_enums.h:59
@ ADS_FILTER_NOMOVIECLIPS
@ ADS_FILTER_NOVOLUME
@ ADS_FILTER_NOHAIR
@ ADS_FILTER_NOCACHEFILES
@ ADS_FILTER_NOPOINTCLOUD
@ ADS_FILTER_ONLYSEL
@ ADS_FILTER_NOARM
@ ADS_FILTER_NLA_NOACT
@ ADS_FILTER_NOMAT
@ ADS_FILTER_NONTREE
@ ADS_FILTER_NOCAM
@ ADS_FILTER_NOSHAPEKEYS
@ ADS_FILTER_NOTEX
@ ADS_FILTER_ONLY_ERRORS
@ ADS_FILTER_NOSCE
@ ADS_FILTER_NOLAM
@ ADS_FILTER_NOMODIFIERS
@ ADS_FILTER_NOLINESTYLE
@ ADS_FILTER_SUMMARY
@ ADS_FILTER_NOGPENCIL
@ ADS_FILTER_NOOBJ
@ ADS_FILTER_NOCUR
@ ADS_FILTER_NOPART
@ ADS_FILTER_NOSPK
@ ADS_FILTER_NOMESH
@ ADS_FILTER_NOWOR
@ ADS_FILTER_INCL_HIDDEN
@ ADS_FILTER_NOMBA
@ ADS_FILTER_NOLAT
@ AGRP_SELECTED
@ AGRP_EXPANDED_G
@ AGRP_EXPANDED
@ AGRP_PROTECTED
@ ADS_FLAG_SHOW_DBFILTERS
@ ADS_FLAG_SUMMARY_COLLAPSED
@ ADS_FLAG_INVERT_FILTER
@ ADS_FLAG_NO_DB_SORT
@ ADS_FLAG_FUZZY_NAMES
@ SACTCONT_ACTION
@ SACTCONT_SHAPEKEY
@ ADT_CURVES_ALWAYS_VISIBLE
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
Definition: RNA_access.h:1425
StructRNA RNA_TimelineMarker
@ PARM_RNAPTR
Definition: RNA_types.h:339
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_MAIN
Definition: RNA_types.h:576
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_LIB_EXCEPTION
Definition: RNA_types.h:181
@ PROP_NEVER_NULL
Definition: RNA_types.h:225
@ PROP_NO_DEG_UPDATE
Definition: RNA_types.h:286
@ PROP_TEXTEDIT_UPDATE
Definition: RNA_types.h:195
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_UNSIGNED
Definition: RNA_types.h:129
#define NC_ANIMATION
Definition: WM_types.h:289
#define NA_EDITED
Definition: WM_types.h:462
#define ND_KEYFRAME
Definition: WM_types.h:394
#define ND_ANIMCHAN
Definition: WM_types.h:396
#define NA_SELECTED
Definition: WM_types.h:467
#define GS(x)
Definition: iris.c:241
FCurve * ED_action_fcurve_ensure(struct Main *bmain, struct bAction *act, const char group[], struct PointerRNA *ptr, const char rna_path[], const int array_index)
Definition: keyframing.c:194
FCurve * ED_action_fcurve_find(struct bAction *act, const char rna_path[], const int array_index)
Definition: keyframing.c:181
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
const EnumPropertyItem rna_enum_id_type_items[]
Definition: rna_ID.c:46
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:196
static void rna_def_action(BlenderRNA *brna)
Definition: rna_action.c:803
static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_action.c:711
static void rna_def_action_groups(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_action.c:683
static void rna_def_dopesheet(BlenderRNA *brna)
Definition: rna_action.c:316
void RNA_def_action(BlenderRNA *brna)
Definition: rna_action.c:867
static void rna_def_action_group(BlenderRNA *brna)
Definition: rna_action.c:618
static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_action.c:759
void RNA_api_action(StructRNA *srna)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1212
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1555
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2717
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1684
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3462
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3851
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2791
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1122
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3373
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
Definition: rna_define.c:2870
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
Definition: rna_define.c:2348
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, const char *update_cb)
Definition: rna_pose.c:889
bool rna_Action_id_poll(struct PointerRNA *ptr, struct PointerRNA value)
bool rna_Action_actedit_assign_poll(struct PointerRNA *ptr, struct PointerRNA value)
#define min(a, b)
Definition: sort.c:51
union CollectionPropertyIterator::@1099 internal
ListBaseIterator listbase
Definition: RNA_types.h:394
struct FCurve * next
bActionGroup * grp
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
char name[64]
unsigned int flag
ListBase curves
ListBase groups
ListBase markers
float max
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157