Refactor: Use coordinate in API for track selection

Currently no functional changes. Prepares for a change which will
allow to more consistently redo the track selection operator.
This commit is contained in:
Sergey Sharybin
2022-05-13 17:14:28 +02:00
parent 4680331749
commit a80ad0a545
3 changed files with 9 additions and 12 deletions

View File

@@ -190,7 +190,7 @@ void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);
/* Find track which can be slid in a proximity of the given event.
* Uses the same rules w.r.t distance tolerances for track sliding and selection operators. */
struct MovieTrackingTrack *tracking_find_slidable_track_in_proximity(struct bContext *C,
const struct wmEvent *event);
const float co[2]);
void CLIP_OT_add_marker(struct wmOperatorType *ot);
void CLIP_OT_add_marker_at_click(struct wmOperatorType *ot);

View File

@@ -528,11 +528,10 @@ static bool slide_check_corners(float (*corners)[2])
}
static MovieTrackingTrack *tracking_marker_check_slide(
bContext *C, const wmEvent *event, int *r_area, eSlideAction *r_action, int *r_corner)
bContext *C, const float co[2], int *r_area, eSlideAction *r_action, int *r_corner)
{
const float distance_clip_squared = 12.0f * 12.0f;
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *region = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
const int framenr = ED_space_clip_get_clip_frame_number(sc);
@@ -549,9 +548,6 @@ static MovieTrackingTrack *tracking_marker_check_slide(
return NULL;
}
float co[2];
ED_clip_mouse_pos(sc, region, event->mval, co);
LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
if (!TRACK_VIEW_SELECTED(sc, track) || (track->flag & TRACK_LOCKED)) {
continue;
@@ -640,9 +636,9 @@ static MovieTrackingTrack *tracking_marker_check_slide(
}
struct MovieTrackingTrack *tracking_find_slidable_track_in_proximity(struct bContext *C,
const struct wmEvent *event)
const float co[2])
{
return tracking_marker_check_slide(C, event, NULL, NULL, NULL);
return tracking_marker_check_slide(C, co, NULL, NULL, NULL);
}
static void *slide_marker_customdata(bContext *C, const wmEvent *event)
@@ -666,7 +662,7 @@ static void *slide_marker_customdata(bContext *C, const wmEvent *event)
ED_clip_mouse_pos(sc, region, event->mval, co);
track = tracking_marker_check_slide(C, event, &area, &action, &corner);
track = tracking_marker_check_slide(C, co, &area, &action, &corner);
if (track != NULL) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
customdata = create_slide_marker_data(

View File

@@ -402,15 +402,17 @@ static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *region = CTX_wm_region(C);
float co[2];
const bool extend = RNA_boolean_get(op->ptr, "extend");
float co[2];
ED_clip_mouse_pos(sc, region, event->mval, co);
/* Special code which allows to slide a marker which belongs to currently selected but not yet
* active track. If such track is found activate it and return pass-though so that marker slide
* operator can be used immediately after.
* This logic makes it convenient to slide markers when left mouse selection is used. */
if (!extend) {
MovieTrackingTrack *track = tracking_find_slidable_track_in_proximity(C, event);
MovieTrackingTrack *track = tracking_find_slidable_track_in_proximity(C, co);
if (track != NULL) {
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -423,7 +425,6 @@ static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
}
ED_clip_mouse_pos(sc, region, event->mval, co);
RNA_float_set_array(op->ptr, "location", co);
return select_exec(C, op);