diff options
Diffstat (limited to 'source/blender/editors')
4 files changed, 50 insertions, 53 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 08a7355694b..cd00b963482 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -542,7 +542,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) * only called from #ok_bezier_region_lasso */ static bool bezier_region_lasso_test( - const struct KeyframeEdit_LassoData *data_lasso, + const KeyframeEdit_LassoData *data_lasso, const float xy[2]) { if (BLI_rctf_isect_pt_v(data_lasso->rectf_scaled, xy)) { @@ -579,7 +579,7 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt) * only called from #ok_bezier_region_circle */ static bool bezier_region_circle_test( - const struct KeyframeEdit_CircleData *data_circle, + const KeyframeEdit_CircleData *data_circle, const float xy[2]) { if (BLI_rctf_isect_pt_v(data_circle->rectf_scaled, xy)) { diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index fae3e3677a0..ab51298eb6c 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -97,20 +97,20 @@ typedef enum eEditKeyframes_Mirror { } eEditKeyframes_Mirror; /* use with BEZT_OK_REGION_LASSO */ -struct KeyframeEdit_LassoData { +typedef struct KeyframeEdit_LassoData { const rctf *rectf_scaled; const rctf *rectf_view; const int (*mcords)[2]; int mcords_tot; -}; +} KeyframeEdit_LassoData; /* use with BEZT_OK_REGION_CIRCLE */ -struct KeyframeEdit_CircleData { +typedef struct KeyframeEdit_CircleData { const rctf *rectf_scaled; const rctf *rectf_view; float mval[2]; float radius_squared; -}; +} KeyframeEdit_CircleData; /* ************************************************ */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 6b860990c10..478dbd3d9c0 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -555,19 +555,20 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); RNA_boolean_set(kmi->ptr, "include_handles", false); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); RNA_boolean_set(kmi->ptr, "include_handles", true); 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", true); RNA_boolean_set(kmi->ptr, "include_handles", true); - + + /* region select */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "GRAPH_OT_select_circle", CKEY, KM_PRESS, 0, 0); /* column select */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index eb786d872ec..8c058d23cde 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -210,6 +210,8 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE) * -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE) + * + * The selection backend is also reused for the Lasso and Circle select operators. */ /* Borderselect only selects keyframes now, as overshooting handles often get caught too, @@ -245,12 +247,12 @@ static void borderselect_graphkeys( /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); if (mode == BEZT_OK_REGION_LASSO) { - struct KeyframeEdit_LassoData *data_lasso = data; + KeyframeEdit_LassoData *data_lasso = data; data_lasso->rectf_scaled = &scaled_rectf; ked.data = data_lasso; } else if (mode == BEZT_OK_REGION_CIRCLE) { - struct KeyframeEdit_CircleData *data_circle = data; + KeyframeEdit_CircleData *data_circle = data; data_circle->rectf_scaled = &scaled_rectf; ked.data = data; } @@ -265,27 +267,27 @@ static void borderselect_graphkeys( } else mapping_flag = ANIM_UNITCONV_ONLYKEYS; - + mapping_flag |= ANIM_get_normalization_flags(ac); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); - + /* apply NLA mapping to all the keyframes, since it's easier than trying to * guess when a callback might use something different */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); - + scaled_rectf.xmin = rectf.xmin; scaled_rectf.xmax = rectf.xmax; scaled_rectf.ymin = rectf.ymin / unit_scale - offset; scaled_rectf.ymax = rectf.ymax / unit_scale - offset; - + /* set horizontal range (if applicable) * NOTE: these values are only used for x-range and y-range but not region * (which uses ked.data, i.e. rectf) @@ -406,37 +408,42 @@ void GRAPH_OT_select_border(wmOperatorType *ot) RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria"); } + +/* ------------------- */ + static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; + + KeyframeEdit_LassoData data_lasso; rcti rect; rctf rect_fl; + short selectmode; bool incl_handles; bool extend; - - struct KeyframeEdit_LassoData data_lasso; - + + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data_lasso.rectf_view = &rect_fl; data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot); if (data_lasso.mcords == NULL) return OPERATOR_CANCELLED; - + /* clear all selection if not extending selection */ extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true); - + if (!RNA_boolean_get(op->ptr, "deselect")) selectmode = SELECT_ADD; else selectmode = SELECT_SUBTRACT; - - if (ac.spacetype == SPACE_IPO) { + + { SpaceIpo *sipo = (SpaceIpo *)ac.sl; if (selectmode == SELECT_ADD) { incl_handles = ((sipo->flag & SIPO_SELVHANDLESONLY) || @@ -446,60 +453,57 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op) incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0; } } - else { - incl_handles = false; - } - - + /* get settings from operator */ BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); - BLI_rctf_rcti_copy(&rect_fl, &rect); - + /* apply borderselect action */ borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_LASSO, selectmode, incl_handles, &data_lasso); - + MEM_freeN((void *)data_lasso.mcords); - - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - void GRAPH_OT_select_lasso(wmOperatorType *ot) { /* identifiers */ ot->name = "Lasso Select"; ot->description = "Select keyframe points using lasso selection"; ot->idname = "GRAPH_OT_select_lasso"; - + /* api callbacks */ ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = graphkeys_lassoselect_exec; ot->poll = graphop_visible_keyframes_poll; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Deselect rather than select items"); RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first"); } +/* ------------------- */ + static int graph_circle_select_exec(bContext *C, wmOperator *op) { bAnimContext ac; const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); - short selectmode; - bool incl_handles; + const short selectmode = (gesture_mode == GESTURE_MODAL_SELECT) ? SELECT_ADD : SELECT_SUBTRACT; + bool incl_handles = false; + + KeyframeEdit_CircleData data; rctf rect_fl; - struct KeyframeEdit_CircleData data; + float x = RNA_int_get(op->ptr, "x"); float y = RNA_int_get(op->ptr, "y"); float radius = RNA_int_get(op->ptr, "radius"); @@ -507,23 +511,18 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data.mval[0] = x; data.mval[1] = y; data.radius_squared = radius * radius; data.rectf_view = &rect_fl; - if (gesture_mode == GESTURE_MODAL_SELECT) - selectmode = SELECT_ADD; - else - selectmode = SELECT_SUBTRACT; - rect_fl.xmin = x - radius; rect_fl.xmax = x + radius; rect_fl.ymin = y - radius; rect_fl.ymax = y + radius; - if (ac.spacetype == SPACE_IPO) { + { SpaceIpo *sipo = (SpaceIpo *)ac.sl; if (selectmode == SELECT_ADD) { incl_handles = ((sipo->flag & SIPO_SELVHANDLESONLY) || @@ -533,10 +532,7 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0; } } - else { - incl_handles = false; - } - + /* apply borderselect action */ borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_CIRCLE, selectmode, incl_handles, &data); |