diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-04-29 18:29:05 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-04-30 12:34:22 +0300 |
commit | 7a0b3f927cc44c5880c61ed85443fec4de987933 (patch) | |
tree | a0d4e3eccace2fb5c23b0b115a6c5f19e9135296 /source/blender/editors/space_clip/tracking_select.c | |
parent | 7f4836a0a7cc224d6414b559be89e143bf0a1182 (diff) |
Select: Add 'deselect on nothing' behavior to tracking editor.
Part of T63995.
Diffstat (limited to 'source/blender/editors/space_clip/tracking_select.c')
-rw-r--r-- | source/blender/editors/space_clip/tracking_select.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index d144fc699c8..2b70aec02bb 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -280,7 +280,7 @@ void ed_tracking_deselect_all_plane_tracks(ListBase *plane_tracks_base) } } -static int mouse_select(bContext *C, float co[2], int extend) +static int mouse_select(bContext *C, float co[2], const bool extend, const bool deselect_all) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); @@ -295,6 +295,15 @@ static int mouse_select(bContext *C, float co[2], int extend) track = find_nearest_track(sc, tracksbase, co, &distance_to_track); plane_track = find_nearest_plane_track(sc, plane_tracks_base, co, &distance_to_plane_track); + /* Do not select beyond some reasonable distance, that is useless and + * prevents the 'deselect on nothing' behavior. */ + if (distance_to_track > 0.05f) { + track = NULL; + } + if (distance_to_plane_track > 0.05f) { + plane_track = NULL; + } + /* Between track and plane we choose closest to the mouse for selection here. */ if (track && plane_track) { if (distance_to_track < distance_to_plane_track) { @@ -305,11 +314,11 @@ static int mouse_select(bContext *C, float co[2], int extend) } } - if (!extend) { - ed_tracking_deselect_all_plane_tracks(plane_tracks_base); - } - if (track) { + if (!extend) { + ed_tracking_deselect_all_plane_tracks(plane_tracks_base); + } + int area = track_mouse_area(C, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) { @@ -352,6 +361,10 @@ static int mouse_select(bContext *C, float co[2], int extend) clip->tracking.act_track = NULL; clip->tracking.act_plane_track = plane_track; } + else if (deselect_all) { + ed_tracking_deselect_all_tracks(tracksbase); + ed_tracking_deselect_all_plane_tracks(plane_tracks_base); + } if (!extend) { sc->xlockof = 0.0f; @@ -380,12 +393,12 @@ static bool select_poll(bContext *C) static int select_exec(bContext *C, wmOperator *op) { float co[2]; - int extend; RNA_float_get_array(op->ptr, "location", co); - extend = RNA_boolean_get(op->ptr, "extend"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all"); - return mouse_select(C, co, extend); + return mouse_select(C, co, extend, deselect_all); } static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -433,11 +446,19 @@ void CLIP_OT_select(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ + PropertyRNA *prop; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection rather than clearing the existing selection"); + prop = RNA_def_boolean(ot->srna, + "deselect_all", + false, + "Deselect On Nothing", + "Deselect all when nothing under the cursor"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + RNA_def_float_vector( ot->srna, "location", |