diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-04-18 06:03:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-04-18 06:03:19 +0400 |
commit | dfe2f8dc03267e041102837e92f547fb04881510 (patch) | |
tree | d9582c4667ce5b9e39e2adce40832aa4f44b4fe7 /source/blender/editors/space_graph/graph_select.c | |
parent | d7e08f2d33207fdf76b1b597ef0de9dec26e3987 (diff) | |
parent | 00e46ef739cf2bfddb8805af056aa59fd3b3c71c (diff) |
Merged changes in the trunk up to revision 28247.
Diffstat (limited to 'source/blender/editors/space_graph/graph_select.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 80 |
1 files changed, 74 insertions, 6 deletions
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 */ |