diff options
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 80 |
3 files changed, 90 insertions, 9 deletions
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index a875558d6ef..a637ed15fcd 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -63,6 +63,7 @@ void graph_header_buttons(const bContext *C, struct ARegion *ar); void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot); void GRAPH_OT_select_border(struct wmOperatorType *ot); void GRAPH_OT_select_column(struct wmOperatorType *ot); +void GRAPH_OT_select_linked(struct wmOperatorType *ot); void GRAPH_OT_select_more(struct wmOperatorType *ot); void GRAPH_OT_select_less(struct wmOperatorType *ot); void GRAPH_OT_clickselect(struct wmOperatorType *ot); @@ -149,6 +150,7 @@ void GRAPH_OT_ghost_curves_clear(struct wmOperatorType *ot); /* ***************************************** */ /* graph_buttons.c */ + void GRAPH_OT_properties(struct wmOperatorType *ot); void graph_buttons_register(struct ARegionType *art); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index b8b3dc97edf..d3d2743200b 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -231,6 +231,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_select_all_toggle); WM_operatortype_append(GRAPH_OT_select_border); WM_operatortype_append(GRAPH_OT_select_column); + WM_operatortype_append(GRAPH_OT_select_linked); WM_operatortype_append(GRAPH_OT_select_more); WM_operatortype_append(GRAPH_OT_select_less); @@ -298,9 +299,16 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1); /* borderselect */ - WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "axis_range", 1); + + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "include_handles", 1); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "axis_range", 1); + RNA_boolean_set(kmi->ptr, "include_handles", 1); + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA); @@ -311,6 +319,9 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); + /* select linked */ + WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0); + /* graph_edit.c */ /* snap - current frame to selected keys */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index e15dc797186..a81de25f265 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -196,10 +196,11 @@ void GRAPH_OT_select_all_toggle (wmOperatorType *ot) */ /* Borderselect only selects keyframes now, as overshooting handles often get caught too, - * which means that they may be inadvertantly moved as well. - * Also, for convenience, handles should get same status as keyframe (if it was within bounds) + * which means that they may be inadvertantly moved as well. However, incl_handles overrides + * this, and allow handles to be considered independently too. + * Also, for convenience, handles should get same status as keyframe (if it was within bounds). */ -static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode) +static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -227,6 +228,10 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho memset(&ked, 0, sizeof(KeyframeEditData)); ked.data= &rectf; + /* treat handles separately? */ + if (incl_handles) + ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES; + /* loop over data, doing border select */ for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(ac, ale); @@ -286,16 +291,23 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) bAnimContext ac; rcti rect; short mode=0, selectmode=0; + short incl_handles; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + + /* get select mode + * - 'gesture_mode' from the operator specifies how to select + * - 'include_handles' from the operator specifies whether to include handles in the selection + */ if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT) selectmode= SELECT_ADD; else selectmode= SELECT_SUBTRACT; - + + incl_handles = RNA_boolean_get(op->ptr, "include_handles"); + /* get settings from operator */ rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); @@ -318,7 +330,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) mode= BEZT_OK_REGION; /* apply borderselect action */ - borderselect_graphkeys(&ac, rect, mode, selectmode); + borderselect_graphkeys(&ac, rect, mode, selectmode, incl_handles); /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_SELECT, NULL); @@ -347,6 +359,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, FALSE); ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); + RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria"); } /* ******************** Column Select Operator **************************** */ @@ -534,6 +547,61 @@ void GRAPH_OT_select_column (wmOperatorType *ot) ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } +/* ******************** Select Linked Operator *********************** */ + +static int graphkeys_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 GRAPH_OT_select_linked (wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Linked"; + ot->idname= "GRAPH_OT_select_linked"; + ot->description = "Select keyframes occurring the same F-Curves as selected ones"; + + /* api callbacks */ + ot->exec= graphkeys_select_linked_exec; + ot->poll= graphop_visible_keyframes_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; +} + /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ |