From 344c17f439394f263a20b117326c5d2c068a3896 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 11 Apr 2016 02:39:10 +1200 Subject: Fix T42148: Copying/Pasting FModifiers copies to all selected FCurves, not just active one --- source/blender/editors/space_graph/graph_edit.c | 34 +++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 5854cb53c99..dd2ec2401a5 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2534,33 +2534,43 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok = 0; + int filter; + + const bool replace = RNA_boolean_get(op->ptr, "replace"); + bool ok = false; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* filter data */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + if (RNA_boolean_get(op->ptr, "only_active")) { + /* This should be the default (for buttons) - Just paste to the active FCurve */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + } + else { + /* This is only if the operator gets called from a hotkey or search - Paste to all visible curves */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + } + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; int tot; - - /* TODO: do we want to replace existing modifiers? add user pref for that! */ - tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0); - + + tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace); + if (tot) { ale->update |= ANIM_UPDATE_DEPS; + ok = true; } - - ok += tot; } - + if (ok) { ANIM_animdata_update(&ac, &anim_data); } @@ -2568,7 +2578,6 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) /* successful or not? */ if (ok) { - /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); @@ -2593,6 +2602,11 @@ void GRAPH_OT_fmodifier_paste(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active F-Curve"); + RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", + "Replace existing F-Modifiers, instead of just appending to the end of the existing list"); } /* ************************************************************************** */ -- cgit v1.2.3