2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2008 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Joshua Leung
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file ED_anim_api.h
31 #ifndef __ED_ANIM_API_H__
32 #define __ED_ANIM_API_H__
61 /* ************************************************ */
62 /* ANIMATION CHANNEL FILTERING */
65 /* --------------- Context --------------------- */
67 /* This struct defines a structure used for animation-specific
68 * 'context' information
70 typedef struct bAnimContext {
71 void *data; /* data to be filtered for use in animation editor */
72 short datatype; /* type of data eAnimCont_Types */
74 short mode; /* editor->mode */
75 short spacetype; /* sa->spacetype */
76 short regiontype; /* active region -> type (channels or main) */
77 struct ScrArea *sa; /* editor host */
78 struct SpaceLink *sl; /* editor data */
79 struct ARegion *ar; /* region within editor */
81 struct bDopeSheet *ads; /* dopesheet data for editor (or which is being used) */
83 struct Scene *scene; /* active scene */
84 struct Object *obact; /* active object */
85 ListBase *markers; /* active set of markers */
87 struct ReportList *reports; /* pointer to current reports list */
90 /* Main Data container types */
91 typedef enum eAnimCont_Types {
92 ANIMCONT_NONE = 0, /* invalid or no data */
93 ANIMCONT_ACTION = 1, /* action (bAction) */
94 ANIMCONT_SHAPEKEY = 2, /* shapekey (Key) */
95 ANIMCONT_GPENCIL = 3, /* grease pencil (screen) */
96 ANIMCONT_DOPESHEET = 4, /* dopesheet (bDopesheet) */
97 ANIMCONT_FCURVES = 5, /* animation F-Curves (bDopesheet) */
98 ANIMCONT_DRIVERS = 6, /* drivers (bDopesheet) */
99 ANIMCONT_NLA = 7, /* nla (bDopesheet) */
100 ANIMCONT_CHANNEL = 8, /* animation channel (bAnimListElem) */
101 ANIMCONT_MASK = 9 /* mask dopesheet */
104 /* --------------- Channels -------------------- */
106 /* This struct defines a structure used for quick and uniform access for
107 * channels of animation data
109 typedef struct bAnimListElem {
110 struct bAnimListElem *next, *prev;
112 void *data; /* source data this elem represents */
113 int type; /* (eAnim_ChannelType) one of the ANIMTYPE_* values */
114 int flag; /* copy of elem's flags for quick access */
115 int index; /* for un-named data, the index of the data in its collection */
117 char update; /* (eAnim_Update_Flags) tag the element for updating */
118 char tag; /* tag the included data. Temporary always */
120 short datatype; /* (eAnim_KeyType) type of motion data to expect */
121 void *key_data; /* motion data - mostly F-Curves, but can be other types too */
124 struct ID *id; /* ID block that channel is attached to */
125 struct AnimData *adt; /* source of the animation data attached to ID block (for convenience) */
127 void *owner; /* for per-element F-Curves (e.g. NLA Control Curves), the element that this represents (e.g. NlaStrip) */
131 /* Some types for easier type-testing
132 * NOTE: need to keep the order of these synchronized with the channels define code
133 * which is used for drawing and handling channel lists for
135 typedef enum eAnim_ChannelType {
138 ANIMTYPE_SPECIALDATA,
147 ANIMTYPE_NLACONTROLS,
151 ANIMTYPE_FILLDRIVERS,
166 ANIMTYPE_DSLINESTYLE,
172 ANIMTYPE_GPDATABLOCK,
175 ANIMTYPE_MASKDATABLOCK,
181 /* always as last item, the total number of channel types... */
185 /* types of keyframe data in bAnimListElem */
186 typedef enum eAnim_KeyType {
187 ALE_NONE = 0, /* no keyframe data */
188 ALE_FCURVE, /* F-Curve */
189 ALE_GPFRAME, /* Grease Pencil Frames */
190 ALE_MASKLAY, /* Mask */
191 ALE_NLASTRIP, /* NLA Strips */
193 ALE_ALL, /* All channels summary */
194 ALE_SCE, /* Scene summary */
195 ALE_OB, /* Object summary */
196 ALE_ACT, /* Action summary */
197 ALE_GROUP /* Action Group summary */
200 /* Flags for specifying the types of updates (i.e. recalculation/refreshing) that
201 * needs to be performed to the data contained in a channel following editing.
202 * For use with ANIM_animdata_update()
204 typedef enum eAnim_Update_Flags {
205 ANIM_UPDATE_DEPS = (1 << 0), /* referenced data and dependencies get refreshed */
206 ANIM_UPDATE_ORDER = (1 << 1), /* keyframes need to be sorted */
207 ANIM_UPDATE_HANDLES = (1 << 2), /* recalculate handles */
208 } eAnim_Update_Flags;
210 /* used for most tools which change keyframes (flushed by ANIM_animdata_update) */
211 #define ANIM_UPDATE_DEFAULT (ANIM_UPDATE_DEPS | ANIM_UPDATE_ORDER | ANIM_UPDATE_HANDLES)
212 #define ANIM_UPDATE_DEFAULT_NOHANDLES (ANIM_UPDATE_DEFAULT & ~ANIM_UPDATE_HANDLES)
214 /* ----------------- Filtering -------------------- */
216 /* filtering flags - under what circumstances should a channel be returned */
217 typedef enum eAnimFilter_Flags {
218 /* data which channel represents is fits the dopesheet filters (i.e. scene visibility criteria) */
219 // XXX: it's hard to think of any examples where this *ISN'T* the case... perhaps becomes implicit?
220 ANIMFILTER_DATA_VISIBLE = (1 << 0),
221 /* channel is visible within the channel-list hierarchy (i.e. F-Curves within Groups in ActEdit) */
222 ANIMFILTER_LIST_VISIBLE = (1 << 1),
223 /* channel has specifically been tagged as visible in Graph Editor (* Graph Editor Only) */
224 ANIMFILTER_CURVE_VISIBLE = (1 << 2),
226 /* include summary channels and "expanders" (for drawing/mouse-selection in channel list) */
227 ANIMFILTER_LIST_CHANNELS = (1 << 3),
229 /* for its type, channel should be "active" one */
230 ANIMFILTER_ACTIVE = (1 << 4),
231 /* channel is a child of the active group (* Actions speciality) */
232 ANIMFILTER_ACTGROUPED = (1 << 5),
234 /* channel must be selected/not-selected, but both must not be set together */
235 ANIMFILTER_SEL = (1 << 6),
236 ANIMFILTER_UNSEL = (1 << 7),
238 /* editability status - must be editable to be included */
239 ANIMFILTER_FOREDIT = (1 << 8),
240 /* only selected animchannels should be considerable as editable - mainly for Graph Editor's option for keys on select curves only */
241 ANIMFILTER_SELEDIT = (1 << 9),
243 /* flags used to enforce certain data types */
244 // NOTE: the ones for curves and NLA tracks were redundant and have been removed for now...
245 ANIMFILTER_ANIMDATA = (1 << 10),
247 /* duplicate entries for animation data attached to multi-user blocks must not occur */
248 ANIMFILTER_NODUPLIS = (1 << 11),
250 /* for checking if we should keep some collapsed channel around (internal use only!) */
251 ANIMFILTER_TMP_PEEK = (1 << 30),
253 /* ignore ONLYSEL flag from filterflag, (internal use only!) */
254 ANIMFILTER_TMP_IGNORE_ONLYSEL = (1 << 31)
257 /* ---------- Flag Checking Macros ------------ */
258 // xxx check on all of these flags again...
261 /* 'Scene' channels */
262 #define SEL_SCEC(sce) (CHECK_TYPE_INLINE(sce, Scene *), ((sce->flag & SCE_DS_SELECTED)))
263 #define EXPANDED_SCEC(sce) (CHECK_TYPE_INLINE(sce, Scene *), ((sce->flag & SCE_DS_COLLAPSED) == 0))
264 /* 'Sub-Scene' channels (flags stored in Data block) */
265 #define FILTER_WOR_SCED(wo) (CHECK_TYPE_INLINE(wo, World *), (wo->flag & WO_DS_EXPAND))
266 #define FILTER_LS_SCED(linestyle) ((linestyle->flag & LS_DS_EXPAND))
267 /* 'Object' channels */
268 #define SEL_OBJC(base) (CHECK_TYPE_INLINE(base, Base *), ((base->flag & SELECT)))
269 #define EXPANDED_OBJC(ob) (CHECK_TYPE_INLINE(ob, Object *), ((ob->nlaflag & OB_ADS_COLLAPSED) == 0))
270 /* 'Sub-object' channels (flags stored in Data block) */
271 #define FILTER_SKE_OBJD(key) (CHECK_TYPE_INLINE(key, Key *), ((key->flag & KEY_DS_EXPAND)))
272 #define FILTER_MAT_OBJD(ma) (CHECK_TYPE_INLINE(ma, Material *), ((ma->flag & MA_DS_EXPAND)))
273 #define FILTER_LAM_OBJD(la) (CHECK_TYPE_INLINE(la, Lamp *), ((la->flag & LA_DS_EXPAND)))
274 #define FILTER_CAM_OBJD(ca) (CHECK_TYPE_INLINE(ca, Camera *), ((ca->flag & CAM_DS_EXPAND)))
275 #define FILTER_CUR_OBJD(cu) (CHECK_TYPE_INLINE(cu, Curve *), ((cu->flag & CU_DS_EXPAND)))
276 #define FILTER_PART_OBJD(part) (CHECK_TYPE_INLINE(part, ParticleSettings *), ((part->flag & PART_DS_EXPAND)))
277 #define FILTER_MBALL_OBJD(mb) (CHECK_TYPE_INLINE(mb, MetaBall *), ((mb->flag2 & MB_DS_EXPAND)))
278 #define FILTER_ARM_OBJD(arm) (CHECK_TYPE_INLINE(arm, bArmature *), ((arm->flag & ARM_DS_EXPAND)))
279 #define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh *), ((me->flag & ME_DS_EXPAND)))
280 #define FILTER_LATTICE_OBJD(lt) (CHECK_TYPE_INLINE(lt, Lattice *), ((lt->flag & LT_DS_EXPAND)))
281 #define FILTER_SPK_OBJD(spk) (CHECK_TYPE_INLINE(spk, Speaker *), ((spk->flag & SPK_DS_EXPAND)))
282 /* Variable use expanders */
283 #define FILTER_NTREE_DATA(ntree) (CHECK_TYPE_INLINE(ntree, bNodeTree *), ((ntree->flag & NTREE_DS_EXPAND)))
284 #define FILTER_TEX_DATA(tex) (CHECK_TYPE_INLINE(tex, Tex *), ((tex->flag & TEX_DS_EXPAND)))
286 /* 'Sub-object/Action' channels (flags stored in Action) */
287 #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED))
288 #define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED) == 0)
289 /* 'Sub-AnimData' channels */
290 #define EXPANDED_DRVD(adt) ((adt->flag & ADT_DRIVERS_COLLAPSED) == 0)
293 /* Actions (also used for Dopesheet) */
294 /* Action Channel Group */
295 #define EDITABLE_AGRP(agrp) ((agrp->flag & AGRP_PROTECTED) == 0)
296 #define EXPANDED_AGRP(ac, agrp) \
297 ( ((!(ac) || ((ac)->spacetype != SPACE_IPO)) && (agrp->flag & AGRP_EXPANDED)) || \
298 (( (ac) && ((ac)->spacetype == SPACE_IPO)) && (agrp->flag & AGRP_EXPANDED_G)) )
299 #define SEL_AGRP(agrp) ((agrp->flag & AGRP_SELECTED) || (agrp->flag & AGRP_ACTIVE))
300 /* F-Curve Channels */
301 #define EDITABLE_FCU(fcu) ((fcu->flag & FCURVE_PROTECTED) == 0)
302 #define SEL_FCU(fcu) (fcu->flag & FCURVE_SELECTED)
304 /* ShapeKey mode only */
305 #define EDITABLE_SHAPEKEY(kb) ((kb->flag & KEYBLOCK_LOCKED) == 0)
306 #define SEL_SHAPEKEY(kb) (kb->flag & KEYBLOCK_SEL)
308 /* Grease Pencil only */
309 /* Grease Pencil datablock settings */
310 #define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND)
311 /* Grease Pencil Layer settings */
312 #define EDITABLE_GPL(gpl) ((gpl->flag & GP_LAYER_LOCKED) == 0)
313 #define SEL_GPL(gpl) (gpl->flag & GP_LAYER_SELECT)
316 /* Grease Pencil datablock settings */
317 #define EXPANDED_MASK(mask) (mask->flag & MASK_ANIMF_EXPAND)
318 /* Grease Pencil Layer settings */
319 #define EDITABLE_MASK(masklay) ((masklay->flag & MASK_LAYERFLAG_LOCKED) == 0)
320 #define SEL_MASKLAY(masklay) (masklay->flag & SELECT)
324 #define SEL_NLT(nlt) (nlt->flag & NLATRACK_SELECTED)
325 #define EDITABLE_NLT(nlt) ((nlt->flag & NLATRACK_PROTECTED) == 0)
328 /* AnimData - NLA mostly... */
329 #define SEL_ANIMDATA(adt) (adt->flag & ADT_UI_SELECTED)
331 /* -------------- Channel Defines -------------- */
333 /* channel heights */
334 #define ACHANNEL_FIRST (-0.8f * U.widget_unit)
335 #define ACHANNEL_HEIGHT (0.8f * U.widget_unit)
336 #define ACHANNEL_HEIGHT_HALF (0.4f * U.widget_unit)
337 #define ACHANNEL_SKIP (0.1f * U.widget_unit)
338 #define ACHANNEL_STEP (ACHANNEL_HEIGHT + ACHANNEL_SKIP)
341 #define ACHANNEL_NAMEWIDTH (10 * U.widget_unit)
343 /* channel toggle-buttons */
344 #define ACHANNEL_BUTTON_WIDTH (0.8f * U.widget_unit)
347 /* -------------- NLA Channel Defines -------------- */
349 /* NLA channel heights */
350 // XXX: NLACHANNEL_FIRST isn't used?
351 #define NLACHANNEL_FIRST (-0.8f * U.widget_unit)
352 #define NLACHANNEL_HEIGHT(snla) ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.8f * U.widget_unit) : (1.2f * U.widget_unit))
353 #define NLACHANNEL_HEIGHT_HALF(snla) ((snla && (snla->flag & SNLA_NOSTRIPCURVES)) ? (0.4f * U.widget_unit) : (0.6f * U.widget_unit))
354 #define NLACHANNEL_SKIP (0.1f * U.widget_unit)
355 #define NLACHANNEL_STEP(snla) (NLACHANNEL_HEIGHT(snla) + NLACHANNEL_SKIP)
358 #define NLACHANNEL_NAMEWIDTH (10 * U.widget_unit)
360 /* channel toggle-buttons */
361 #define NLACHANNEL_BUTTON_WIDTH (0.8f * U.widget_unit)
363 /* ---------------- API -------------------- */
365 /* Obtain list of filtered Animation channels to operate on.
366 * Returns the number of channels in the list
368 size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_Flags filter_mode, void *data, eAnimCont_Types datatype);
370 /* Obtain current anim-data context from Blender Context info.
371 * Returns whether the operation was successful.
373 bool ANIM_animdata_get_context(const struct bContext *C, bAnimContext *ac);
375 /* Obtain current anim-data context (from Animation Editor) given
376 * that Blender Context info has already been set.
377 * Returns whether the operation was successful.
379 bool ANIM_animdata_context_getdata(bAnimContext *ac);
381 /* Acts on bAnimListElem eAnim_Update_Flags */
382 void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data);
384 void ANIM_animdata_freelist(ListBase *anim_data);
386 /* ************************************************ */
387 /* ANIMATION CHANNELS LIST */
388 /* anim_channels_*.c */
390 /* ------------------------ Drawing TypeInfo -------------------------- */
392 /* role or level of animchannel in the hierarchy */
393 typedef enum eAnimChannel_Role {
394 ACHANNEL_ROLE_EXPANDER = -1, /* datablock expander - a "composite" channel type */
395 ACHANNEL_ROLE_SPECIAL = 0, /* special purposes - not generally for hierarchy processing */
396 ACHANNEL_ROLE_CHANNEL = 1 /* data channel - a channel representing one of the actual building blocks of channels */
399 /* flag-setting behavior */
400 typedef enum eAnimChannels_SetFlag {
401 ACHANNEL_SETFLAG_CLEAR = 0, /* turn off */
402 ACHANNEL_SETFLAG_ADD = 1, /* turn on */
403 ACHANNEL_SETFLAG_INVERT = 2, /* on->off, off->on */
404 ACHANNEL_SETFLAG_TOGGLE = 3 /* some on -> all off // all on */
405 } eAnimChannels_SetFlag;
407 /* types of settings for AnimChannels */
408 typedef enum eAnimChannel_Settings {
409 ACHANNEL_SETTING_SELECT = 0,
410 ACHANNEL_SETTING_PROTECT = 1, /* warning: for drawing UI's, need to check if this is off (maybe inverse this later) */
411 ACHANNEL_SETTING_MUTE = 2,
412 ACHANNEL_SETTING_EXPAND = 3,
413 ACHANNEL_SETTING_VISIBLE = 4, /* only for Graph Editor */
414 ACHANNEL_SETTING_SOLO = 5, /* only for NLA Tracks */
415 ACHANNEL_SETTING_PINNED = 6, /* only for NLA Actions */
416 ACHANNEL_SETTING_MOD_OFF = 7
417 } eAnimChannel_Settings;
420 /* Drawing, mouse handling, and flag setting behavior... */
421 typedef struct bAnimChannelType {
422 /* -- Type data -- */
423 /* name of the channel type, for debugging */
424 const char *channel_type_name;
425 /* "level" or role in hierarchy - for finding the active channel */
426 eAnimChannel_Role channel_role;
429 /* get RGB color that is used to draw the majority of the backdrop */
430 void (*get_backdrop_color)(bAnimContext *ac, bAnimListElem *ale, float r_color[3]);
431 /* draw backdrop strip for channel */
432 void (*draw_backdrop)(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc);
433 /* get depth of indention (relative to the depth channel is nested at) */
434 short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale);
435 /* get offset in pixels for the start of the channel (in addition to the indent depth) */
436 short (*get_offset)(bAnimContext *ac, bAnimListElem *ale);
438 /* get name (for channel lists) */
439 void (*name)(bAnimListElem *ale, char *name);
440 /* get RNA property+pointer for editing the name */
441 bool (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop);
442 /* get icon (for channel lists) */
443 int (*icon)(bAnimListElem *ale);
446 /* check if the given setting is valid in the current context */
447 bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting);
448 /* get the flag used for this setting */
449 int (*setting_flag)(bAnimContext *ac, eAnimChannel_Settings setting, bool *neg);
450 /* get the pointer to int/short where data is stored,
451 * with type being sizeof(ptr_data) which should be fine for runtime use...
452 * - assume that setting has been checked to be valid for current context
454 void *(*setting_ptr)(bAnimListElem *ale, eAnimChannel_Settings setting, short *type);
457 /* ------------------------ Drawing API -------------------------- */
459 /* Get typeinfo for the given channel */
460 const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale);
462 /* Print debugging info about a given channel */
463 void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level);
465 /* Draw the given channel */
466 void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index);
467 /* Draw the widgets for the given channel */
468 void ANIM_channel_draw_widgets(const struct bContext *C, bAnimContext *ac, bAnimListElem *ale, struct uiBlock *block, float yminc, float ymaxc, size_t channel_index);
471 /* ------------------------ Editing API -------------------------- */
473 /* Check if some setting for a channel is enabled
474 * Returns: 1 = On, 0 = Off, -1 = Invalid
476 * - setting: eAnimChannel_Settings
478 short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting);
480 /* Change value of some setting for a channel
481 * - setting: eAnimChannel_Settings
482 * - mode: eAnimChannels_SetFlag
484 void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode);
487 /* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
488 * - anim_data: list of the all the anim channels that can be chosen
489 * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
490 * then the channels under closed expanders get ignored...
491 * - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
492 * with the new state of the setting that we want flushed up/down the hierarchy
493 * - setting: type of setting to set
494 * - on: whether the visibility setting has been enabled or disabled
496 void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode);
499 /* Deselect all animation channels */
500 void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types datatype, bool test, eAnimChannels_SetFlag sel);
502 /* Set the 'active' channel of type channel_type, in the given action */
503 void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datatype, eAnimFilter_Flags filter, void *channel_data, eAnim_ChannelType channel_type);
506 /* Delete the F-Curve from the given AnimData block (if possible), as appropriate according to animation context */
507 void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, struct AnimData *adt, struct FCurve *fcu);
509 /* ************************************************ */
513 /* ---------- Current Frame Drawing ---------------- */
515 /* flags for Current Frame Drawing */
516 enum eAnimEditDraw_CurrentFrame {
517 /* plain time indicator with no special indicators */
519 /* draw box indicating current frame number */
520 DRAWCFRA_SHOW_NUMBOX = (1 << 0),
521 /* time indication in seconds or frames */
522 DRAWCFRA_UNIT_SECONDS = (1 << 1),
523 /* draw indicator extra wide (for timeline) */
524 DRAWCFRA_WIDE = (1 << 2)
527 /* main call to draw current-frame indicator in an Animation Editor */
528 void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag);
530 /* ------------- Preview Range Drawing -------------- */
532 /* main call to draw preview range curtains */
533 void ANIM_draw_previewrange(const struct bContext *C, struct View2D *v2d, int end_frame_width);
535 /* ************************************************* */
536 /* F-MODIFIER TOOLS */
538 /* ------------- UI Panel Drawing -------------- */
540 /* draw a given F-Modifier for some layout/UI-Block */
541 void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, ListBase *modifiers, struct FModifier *fcm);
543 /* ------------- Copy/Paste Buffer -------------- */
546 /* free the copy/paste buffer */
547 void ANIM_fmodifiers_copybuf_free(void);
549 /* copy the given F-Modifiers to the buffer, returning whether anything was copied or not
550 * assuming that the buffer has been cleared already with ANIM_fmodifiers_copybuf_free()
551 * - active: only copy the active modifier
553 bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active);
555 /* 'Paste' the F-Modifier(s) from the buffer to the specified list
556 * - replace: free all the existing modifiers to leave only the pasted ones
558 bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace);
560 /* ************************************************* */
563 /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */
564 /* anim_ipo_utils.c */
566 /* Get icon + name for channel-list displays for F-Curve */
567 int getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu);
569 /* Automatically determine a color for the nth F-Curve */
570 void getcolor_fcurve_rainbow(int cur, int tot, float out[3]);
572 /* ----------------- NLA Drawing ----------------------- */
573 /* NOTE: Technically, this is not in the animation module (it's in space_nla)
574 * but these are sometimes needed by various animation apis.
577 /* Get color to use for NLA Action channel's background */
578 void nla_action_get_color(struct AnimData *adt, struct bAction *act, float color[4]);
580 /* ----------------- NLA-Mapping ----------------------- */
583 /* Obtain the AnimData block providing NLA-scaling for the given channel if applicable */
584 struct AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale);
586 /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve */
587 void ANIM_nla_mapping_apply_fcurve(struct AnimData *adt, struct FCurve *fcu, bool restore, bool only_keys);
591 /* Perform auto-blending/extend refreshes after some operations */
592 // NOTE: defined in space_nla/nla_edit.c, not in animation/
593 void ED_nla_postop_refresh(bAnimContext *ac);
595 /* ------------- Unit Conversion Mappings ------------- */
598 /* flags for conversion mapping */
599 typedef enum eAnimUnitConv_Flags {
600 /* restore to original internal values */
601 ANIM_UNITCONV_RESTORE = (1 << 0),
602 /* ignore handles (i.e. only touch main keyframes) */
603 ANIM_UNITCONV_ONLYKEYS = (1 << 1),
604 /* only touch selected BezTriples */
605 ANIM_UNITCONV_ONLYSEL = (1 << 2),
606 /* only touch selected vertices */
607 ANIM_UNITCONV_SELVERTS = (1 << 3),
608 ANIM_UNITCONV_SKIPKNOTS = (1 << 4),
609 /* Scale FCurve i a way it fits to -1..1 space */
610 ANIM_UNITCONV_NORMALIZE = (1 << 5),
611 /* Only whennormalization is used: use scale factor from previous run,
612 * prevents curves from jumping all over the place when tweaking them.
614 ANIM_UNITCONV_NORMALIZE_FREEZE = (1 << 6),
615 } eAnimUnitConv_Flags;
617 /* Normalization flags from Space Graph passing to ANIM_unit_mapping_get_factor */
618 short ANIM_get_normalization_flags(bAnimContext *ac);
620 /* Get unit conversion factor for given ID + F-Curve */
621 float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag, float *r_offset);
623 /* ------------- Utility macros ----------------------- */
625 /* provide access to Keyframe Type info in BezTriple
626 * NOTE: this is so that we can change it from being stored in 'hide'
628 #define BEZKEYTYPE(bezt) ((bezt)->hide)
630 /* set/clear/toggle macro
631 * - channel - channel with a 'flag' member that we're setting
632 * - smode - 0=clear, 1=set, 2=invert
633 * - sflag - bitflag to set
635 #define ACHANNEL_SET_FLAG(channel, smode, sflag) \
637 if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
638 else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \
639 else (channel)->flag &= ~(sflag); \
642 /* set/clear/toggle macro, where the flag is negative
643 * - channel - channel with a 'flag' member that we're setting
644 * - smode - 0=clear, 1=set, 2=invert
645 * - sflag - bitflag to set
647 #define ACHANNEL_SET_FLAG_NEG(channel, smode, sflag) \
649 if (smode == ACHANNEL_SETFLAG_INVERT) (channel)->flag ^= (sflag); \
650 else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag &= ~(sflag); \
651 else (channel)->flag |= (sflag); \
655 /* --------- anim_deps.c, animation updates -------- */
657 void ANIM_id_update(struct Scene *scene, struct ID *id);
658 void ANIM_list_elem_update(struct Scene *scene, bAnimListElem *ale);
660 /* data -> channels syncing */
661 void ANIM_sync_animchannels_to_data(const struct bContext *C);
663 void ANIM_center_frame(struct bContext *C, int smooth_viewtx);
664 /* ************************************************* */
667 /* generic animation channels */
668 void ED_operatortypes_animchannels(void);
669 void ED_keymap_animchannels(struct wmKeyConfig *keyconf);
671 /* generic time editing */
672 void ED_operatortypes_anim(void);
673 void ED_keymap_anim(struct wmKeyConfig *keyconf);
676 void ED_operatormacros_graph(void);
678 void ED_operatormacros_action(void);
680 /* ************************************************ */
681 /* Animation Editor Exports */
682 /* XXX: Should we be doing these here, or at all? */
684 /* Action Editor - Action Management */
685 struct AnimData *ED_actedit_animdata_from_context(struct bContext *C);
686 void ED_animedit_unlink_action(struct bContext *C, struct ID *id,
687 struct AnimData *adt, struct bAction *act,
688 struct ReportList *reports, bool force_delete);
690 /* ************************************************ */
692 #endif /* __ED_ANIM_API_H__ */