Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r--source/blender/editors/space_action/action_edit.c508
1 files changed, 254 insertions, 254 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 1c15a7c5950..285e9afb8b4 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -95,56 +95,56 @@
static int act_markers_make_local_poll(bContext *C)
{
SpaceAction *sact = CTX_wm_space_action(C);
-
+
/* 1) */
if (sact == NULL)
return 0;
-
+
/* 2) */
if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0)
return 0;
if (sact->action == NULL)
return 0;
-
+
/* 3) */
if (sact->flag & SACTION_POSEMARKERS_SHOW)
return 0;
-
+
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
}
static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
-{
+{
ListBase *markers = ED_context_get_markers(C);
-
+
SpaceAction *sact = CTX_wm_space_action(C);
bAction *act = (sact) ? sact->action : NULL;
-
+
TimeMarker *marker, *markern = NULL;
-
+
/* sanity checks */
if (ELEM(NULL, markers, act))
return OPERATOR_CANCELLED;
-
+
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
markern = marker->next;
-
+
/* move if marker is selected */
if (marker->flag & SELECT) {
BLI_remlink(markers, marker);
BLI_addtail(&act->markers, marker);
}
}
-
+
/* now enable the "show posemarkers only" setting, so that we can see that something did happen */
sact->flag |= SACTION_POSEMARKERS_SHOW;
-
+
/* notifiers - both sets, as this change affects both */
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -154,11 +154,11 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot)
ot->name = "Make Markers Local";
ot->idname = "ACTION_OT_markers_make_local";
ot->description = "Move selected scene markers to the active Action as local 'pose' markers";
-
+
/* callbacks */
ot->exec = act_markers_make_local_exec;
ot->poll = act_markers_make_local_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -175,17 +175,17 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const
bAnimListElem *ale;
int filter;
bool found = false;
-
+
/* get data to filter, from Action or Dopesheet */
/* XXX: what is sel doing here?!
* Commented it, was breaking things (eg. the "auto preview range" tool). */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* set large values to try to override */
*min = 999999999.0f;
*max = -999999999.0f;
-
+
/* check if any channels to set range with */
if (anim_data.first) {
/* go through channels, finding max extents */
@@ -268,7 +268,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
Scene *scene;
float min, max;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -276,7 +276,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
else
scene = ac.scene;
-
+
/* set the range directly */
get_keyframe_extents(&ac, &min, &max, false);
scene->r.flag |= SCER_PRV_RANGE;
@@ -286,25 +286,25 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
if (scene->r.psfra == scene->r.pefra) {
scene->r.pefra = scene->r.psfra + 1;
}
-
+
/* set notifier that things have changed */
// XXX err... there's nothing for frame ranges yet, but this should do fine too
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_previewrange_set(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Auto-Set Preview Range";
ot->idname = "ACTION_OT_previewrange_set";
ot->description = "Set Preview Range based on extents of selected Keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_previewrange_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -323,31 +323,31 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */
float y;
-
+
/* get all items - we need to do it this way */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through all channels, finding the first one that's selected */
y = (float)ACHANNEL_FIRST(ac);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
-
+
/* must be selected... */
- if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
+ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT))
{
/* update best estimate */
*min = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
*max = (float)(y + ACHANNEL_HEIGHT_HALF(ac));
-
+
/* is this high enough priority yet? */
found = acf->channel_role;
-
+
/* only stop our search when we've found an actual channel
* - datablock expanders get less priority so that we don't abort prematurely
*/
@@ -355,14 +355,14 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min,
break;
}
}
-
+
/* adjust y-position for next one */
y -= ACHANNEL_STEP(ac);
}
-
+
/* free all temp data */
ANIM_animdata_freelist(&anim_data);
-
+
return (found != 0);
}
@@ -372,12 +372,12 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
View2D *v2d;
float extra, min, max;
bool found;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
v2d = &ac.ar->v2d;
-
+
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
found = get_keyframe_extents(&ac, &min, &max, only_sel);
@@ -390,7 +390,7 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
-
+
/* set vertical range */
if (only_sel == false) {
/* view all -> the summary channel is usually the shows everything, and resides right at the top... */
@@ -401,30 +401,30 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
/* locate first selected channel (or the active one), and frame those */
float ymin = v2d->cur.ymin;
float ymax = v2d->cur.ymax;
-
+
if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) {
/* recenter the view so that this range is in the middle */
float ymid = (ymax - ymin) / 2.0f + ymin;
float x_center;
-
+
UI_view2d_center_get(v2d, &x_center, NULL);
UI_view2d_center_set(v2d, x_center, ymid);
}
}
-
+
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
-
+
/* just redraw this view */
ED_area_tag_redraw(CTX_wm_area(C));
-
+
return OPERATOR_FINISHED;
}
/* ......... */
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
-{
+{
/* whole range */
return actkeys_viewall(C, false);
}
@@ -443,11 +443,11 @@ void ACTION_OT_view_all(wmOperatorType *ot)
ot->name = "View All";
ot->idname = "ACTION_OT_view_all";
ot->description = "Reset viewable area to show full keyframe range";
-
+
/* api callbacks */
ot->exec = actkeys_viewall_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -458,11 +458,11 @@ void ACTION_OT_view_selected(wmOperatorType *ot)
ot->name = "View Selected";
ot->idname = "ACTION_OT_view_selected";
ot->description = "Reset viewable area to show selected keyframes range";
-
+
/* api callbacks */
ot->exec = actkeys_viewsel_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -473,7 +473,7 @@ static int actkeys_view_frame_exec(bContext *C, wmOperator *op)
{
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
ANIM_center_frame(C, smooth_viewtx);
-
+
return OPERATOR_FINISHED;
}
@@ -483,11 +483,11 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
ot->name = "View Frame";
ot->idname = "ACTION_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
-
+
/* api callbacks */
ot->exec = actkeys_view_frame_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -499,20 +499,20 @@ void ACTION_OT_view_frame(wmOperatorType *ot)
/* NOTE: the backend code for this is shared with the graph editor */
static short copy_action_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
+
/* clear buffer first */
ANIM_fcurves_copybuf_free();
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* copy keyframes */
ok = copy_animedit_keys(ac, &anim_data);
-
+
/* clean up */
ANIM_animdata_freelist(&anim_data);
@@ -522,21 +522,21 @@ static short copy_action_keys(bAnimContext *ac)
static short paste_action_keys(bAnimContext *ac,
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
-{
+{
ListBase anim_data = {NULL, NULL};
int filter, ok = 0;
-
- /* filter data
- * - First time we try to filter more strictly, allowing only selected channels
+
+ /* filter data
+ * - First time we try to filter more strictly, allowing only selected channels
* to allow copying animation between channels
* - Second time, we loosen things up if nothing was found the first time, allowing
* users to just paste keyframes back into the original curve again [#31670]
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
-
+
if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* paste keyframes */
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip);
@@ -551,7 +551,7 @@ static short paste_action_keys(bAnimContext *ac,
static int actkeys_copy_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
@@ -574,17 +574,17 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
}
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_copy(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Copy Keyframes";
ot->idname = "ACTION_OT_copy";
ot->description = "Copy selected keyframes to the copy/paste buffer";
-
+
/* api callbacks */
ot->exec = actkeys_copy_exec;
ot->poll = ED_operator_action_active;
@@ -600,14 +600,14 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
-
+
/* paste keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false) {
@@ -629,10 +629,10 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_paste(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -640,15 +640,15 @@ void ACTION_OT_paste(wmOperatorType *ot)
ot->name = "Paste Keyframes";
ot->idname = "ACTION_OT_paste";
ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame";
-
+
/* api callbacks */
// ot->invoke = WM_operator_props_popup; // better wait for action redo panel
ot->exec = actkeys_paste_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
@@ -667,39 +667,39 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = {
};
/* this function is responsible for inserting new keyframes */
-static void insert_action_keys(bAnimContext *ac, short mode)
+static void insert_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
ReportList *reports = ac->reports;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
short flag = 0;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
if (mode == 2) filter |= ANIMFILTER_SEL;
else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED;
-
+
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* init keyframing flag */
flag = ANIM_get_keyframing_flags(scene, 1);
-
+
/* insert keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
FCurve *fcu = (FCurve *)ale->key_data;
float cfra;
-
+
/* adjust current frame for NLA-scaling */
if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ else
cfra = (float)CFRA;
-
+
/* read value from property the F-Curve represents, or from the curve only?
* - ale->id != NULL: Typically, this means that we have enough info to try resolving the path
* - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone,
@@ -713,10 +713,10 @@ static void insert_action_keys(bAnimContext *ac, short mode)
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
}
@@ -727,31 +727,31 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
eGP_GetFrame_Mode add_frame_mode;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
if (mode == 2) filter |= ANIMFILTER_SEL;
-
+
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
-
+
+
/* add a copy or a blank frame? */
if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */
else
add_frame_mode = GP_GETFRAME_ADD_NEW;
-
-
+
+
/* insert gp frames */
for (ale = anim_data.first; ale; ale = ale->next) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
BKE_gpencil_layer_getframe(gpl, CFRA, add_frame_mode);
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
}
@@ -762,19 +762,19 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode");
return OPERATOR_CANCELLED;
}
-
+
/* what channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* insert keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
insert_gpencil_keys(&ac, mode);
@@ -785,7 +785,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -795,15 +795,15 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot)
ot->name = "Insert Keyframes";
ot->idname = "ACTION_OT_keyframe_insert";
ot->description = "Insert keyframes for the specified channels";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_insertkey_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", "");
}
@@ -815,14 +815,14 @@ static void duplicate_action_keys(bAnimContext *ac)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
@@ -846,31 +846,31 @@ static void duplicate_action_keys(bAnimContext *ac)
static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* duplicate keyframes */
duplicate_action_keys(&ac);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_duplicate(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Duplicate Keyframes";
ot->idname = "ACTION_OT_duplicate";
ot->description = "Make a copy of all selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_duplicate_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -904,26 +904,26 @@ static bool delete_action_keys(bAnimContext *ac)
else {
FCurve *fcu = (FCurve *)ale->key_data;
AnimData *adt = ale->adt;
-
+
/* delete selected keyframes only */
changed = delete_fcurve_keys(fcu);
-
+
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
ale->key_data = NULL;
}
}
-
+
if (changed) {
ale->update |= ANIM_UPDATE_DEFAULT;
changed_final = true;
}
}
-
+
ANIM_animdata_update(ac, &anim_data);
ANIM_animdata_freelist(&anim_data);
-
+
return changed_final;
}
@@ -932,33 +932,33 @@ static bool delete_action_keys(bAnimContext *ac)
static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* delete keyframes */
if (!delete_action_keys(&ac))
return OPERATOR_CANCELLED;
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Keyframes";
ot->idname = "ACTION_OT_delete";
ot->description = "Remove all selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = actkeys_delete_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -966,15 +966,15 @@ void ACTION_OT_delete(wmOperatorType *ot)
/* ******************** Clean Keyframes Operator ************************* */
static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and clean curves */
for (ale = anim_data.first; ale; ale = ale->next) {
clean_fcurve(ac, ale, thresh, clean_chan);
@@ -993,44 +993,44 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
bAnimContext ac;
float thresh;
bool clean_chan;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
clean_chan = RNA_boolean_get(op->ptr, "channels");
-
+
/* clean keyframes */
clean_action_keys(&ac, thresh, clean_chan);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_clean(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clean Keyframes";
ot->idname = "ACTION_OT_clean";
ot->description = "Simplify F-Curves by removing closely spaced keyframes";
-
+
/* api callbacks */
- //ot->invoke = // XXX we need that number popup for this!
+ //ot->invoke = // XXX we need that number popup for this!
ot->exec = actkeys_clean_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
RNA_def_boolean(ot->srna, "channels", false, "Channels", "");
@@ -1040,15 +1040,15 @@ void ACTION_OT_clean(wmOperatorType *ot)
/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
static void sample_action_keys(bAnimContext *ac)
-{
+{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through filtered data and add keys between selected keyframes on every frame */
for (ale = anim_data.first; ale; ale = ale->next) {
sample_fcurve((FCurve *)ale->key_data);
@@ -1065,36 +1065,36 @@ static void sample_action_keys(bAnimContext *ac)
static int actkeys_sample_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* sample keyframes */
sample_action_keys(&ac);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_sample(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Sample Keyframes";
ot->idname = "ACTION_OT_sample";
ot->description = "Add keyframes on every frame between the selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_sample_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1112,33 +1112,33 @@ void ACTION_OT_sample(wmOperatorType *ot)
static const EnumPropertyItem prop_actkeys_expo_types[] = {
{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"},
{FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"},
-
+
{MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
{CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL}
};
/* this function is responsible for setting extrapolation mode for keyframes */
-static void setexpo_action_keys(bAnimContext *ac, short mode)
+static void setexpo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting mode per F-Curve */
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
-
+
if (mode >= 0) {
/* just set mode setting */
fcu->extend = mode;
}
else {
- /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
+ /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
* without having to go through FModifier UI in Graph Editor to do so
*/
if (mode == MAKE_CYCLIC_EXPO) {
@@ -1151,10 +1151,10 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
else if (mode == CLEAR_CYCLIC_EXPO) {
/* remove all the modifiers fitting this description */
FModifier *fcm, *fcn = NULL;
-
+
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
-
+
if (fcm->type == FMODIFIER_TYPE_CYCLES)
remove_fmodifier(&fcu->modifiers, fcm);
}
@@ -1174,43 +1174,43 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setexpo_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_extrapolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Extrapolation";
ot->idname = "ACTION_OT_extrapolation_type";
ot->description = "Set extrapolation mode for selected F-Curves";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_expo_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", "");
}
@@ -1218,17 +1218,17 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot)
/* ******************** Set Interpolation-Type Operator *********************** */
/* this function is responsible for setting interpolation mode for keyframes */
-static void setipo_action_keys(bAnimContext *ac, short mode)
+static void setipo_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple interpolation
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1248,43 +1248,43 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
setipo_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_interpolation_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Interpolation";
ot->idname = "ACTION_OT_interpolation_type";
ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_ipo_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", "");
}
@@ -1292,25 +1292,25 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
/* this function is responsible for setting handle-type of selected keyframes */
-static void sethandles_action_keys(bAnimContext *ac, short mode)
+static void sethandles_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* loop through setting flags for handles
+
+ /* loop through setting flags for handles
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
-
+
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
/* change type of selected handles */
@@ -1330,43 +1330,43 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
sethandles_action_keys(&ac, mode);
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_handle_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Handle Type";
ot->idname = "ACTION_OT_handle_type";
ot->description = "Set type of handle for selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_handletype_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", "");
}
@@ -1374,17 +1374,17 @@ void ACTION_OT_handle_type(wmOperatorType *ot)
/* ******************** Set Keyframe-Type Operator *********************** */
/* this function is responsible for setting keyframe type for keyframes */
-static void setkeytype_action_keys(bAnimContext *ac, short mode)
+static void setkeytype_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode);
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through setting BezTriple interpolation
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
*/
@@ -1404,11 +1404,11 @@ static void setkeytype_gpencil_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* loop through each layer */
for (ale = anim_data.first; ale; ale = ale->next) {
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -1427,19 +1427,19 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks");
return OPERATOR_PASS_THROUGH;
}
-
+
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* set handle type */
if (ac.datatype == ANIMCONT_GPENCIL) {
setkeytype_gpencil_keys(&ac, mode);
@@ -1447,28 +1447,28 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
else {
setkeytype_action_keys(&ac, mode);
}
-
+
/* set notifier that keyframe properties have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_keyframe_type(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Keyframe Type";
ot->idname = "ACTION_OT_keyframe_type";
ot->description = "Set type of keyframe for the selected keyframes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_keytype_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_keyframe_type_items, 0, "Type", "");
}
@@ -1495,39 +1495,39 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
bAnimListElem *ale;
int filter;
KeyframeEditData ked = {{NULL}};
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* init edit data */
/* loop over action data, averaging values */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
}
-
+
ANIM_animdata_freelist(&anim_data);
-
+
/* set the new current frame value, based on the average time */
if (ked.i1) {
Scene *scene = ac.scene;
CFRA = round_fl_to_int(ked.f1 / ked.i1);
SUBFRA = 0.f;
}
-
+
/* set notifier that things have changed */
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
-
+
return OPERATOR_FINISHED;
}
@@ -1537,11 +1537,11 @@ void ACTION_OT_frame_jump(wmOperatorType *ot)
ot->name = "Jump to Keyframes";
ot->idname = "ACTION_OT_frame_jump";
ot->description = "Set the current frame to the average frame value of selected keyframes";
-
+
/* api callbacks */
ot->exec = actkeys_framejump_exec;
ot->poll = actkeys_framejump_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1562,22 +1562,22 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = {
};
/* this function is responsible for snapping keyframes to frame-times */
-static void snap_action_keys(bAnimContext *ac, short mode)
+static void snap_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc edit_cb;
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_snap(mode);
@@ -1586,11 +1586,11 @@ static void snap_action_keys(bAnimContext *ac, short mode)
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
}
-
+
/* snap keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_snap_frames(ale->data, ac->scene, mode);
}
@@ -1598,7 +1598,7 @@ static void snap_action_keys(bAnimContext *ac, short mode)
ED_masklayer_snap_frames(ale->data, ac->scene, mode);
}
else if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
@@ -1619,38 +1619,38 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* snap keyframes */
snap_action_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_snap(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Snap Keys";
ot->idname = "ACTION_OT_snap";
ot->description = "Snap selected keyframes to the times specified";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_snap_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", "");
}
@@ -1669,42 +1669,42 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = {
};
/* this function is responsible for mirroring keyframes */
-static void mirror_action_keys(bAnimContext *ac, short mode)
+static void mirror_action_keys(bAnimContext *ac, short mode)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc edit_cb;
-
+
/* get beztriple editing callbacks */
edit_cb = ANIM_editkeyframes_mirror(mode);
ked.scene = ac->scene;
-
+
/* for 'first selected marker' mode, need to find first selected marker first! */
/* XXX should this be made into a helper func in the API? */
if (mode == ACTKEYS_MIRROR_MARKER) {
TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
-
+
if (marker)
ked.f1 = (float)marker->frame;
else
return;
}
-
+
/* filter data */
if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
else
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* mirror keyframes */
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
-
+
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_mirror_frames(ale->data, ac->scene, mode);
}
@@ -1712,14 +1712,14 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* TODO */
}
else if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
}
-
+
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -1733,38 +1733,38 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
short mode;
-
+
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
+
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
-
+
/* mirror keyframes */
mirror_action_keys(&ac, mode);
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
-
+
void ACTION_OT_mirror(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Mirror Keys";
ot->idname = "ACTION_OT_mirror";
ot->description = "Flip selected keyframes over the selected mirror line";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = actkeys_mirror_exec;
ot->poll = ED_operator_action_active;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* id-props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", "");
}