diff options
Diffstat (limited to 'source/blender/editors/space_action/action_select.c')
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 877b40c5cb1..8f1d2d4be0e 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -558,6 +558,61 @@ void ACTION_OT_select_column (wmOperatorType *ot) ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } +/* ******************** Select Linked Operator *********************** */ + +static int actkeys_select_linked_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data= {NULL, NULL}; + bAnimListElem *ale; + int filter; + + KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD); + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* loop through all of the keys and select additional keyframes based on these */ + filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + for (ale= anim_data.first; ale; ale= ale->next) { + FCurve *fcu= (FCurve *)ale->key_data; + + /* check if anything selected? */ + if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { + /* select every keyframe in this curve then */ + ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); + } + } + + /* Cleanup */ + BLI_freelistN(&anim_data); + + /* set notifier that keyframe selection has changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL); + + return OPERATOR_FINISHED; +} + +void ACTION_OT_select_linked (wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Linked"; + ot->idname= "ACTION_OT_select_linked"; + ot->description = "Select keyframes occurring the same F-Curves as selected ones"; + + /* api callbacks */ + ot->exec= actkeys_select_linked_exec; + ot->poll= ED_operator_action_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; +} + /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ |