diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 735b6c1c4a3..7d36159f47e 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -52,7 +52,7 @@ struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); void ED_clip_update_frame(const struct Main *mainp, int cfra); -void ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit); +int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit); void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]); void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index ddb1cc33a50..0de7fed1f1a 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -202,17 +202,17 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) return ok; } -void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) +int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) { int w, h, frame_width, frame_height; float min[2], max[2]; ED_space_clip_size(sc, &frame_width, &frame_height); - if(frame_width==0 || frame_height==0) return; + if(frame_width==0 || frame_height==0) return 0; if(!selected_boundbox(sc, min, max)) - return; + return 0; /* center view */ clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height)); @@ -238,6 +238,8 @@ void ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) if(fit || sc->zoom>newzoom) sc->zoom= newzoom; } + + return 1; } void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index c2b099a0f2b..78cf98886a6 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -684,10 +684,10 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) tmpibuf= ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - ED_clip_view_selection(sc, ar, 0); - - sc->xof+= sc->xlockof; - sc->yof+= sc->ylockof; + if(ED_clip_view_selection(sc, ar, 0)) { + sc->xof+= sc->xlockof; + sc->yof+= sc->ylockof; + } if(tmpibuf) IMB_freeImBuf(tmpibuf); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 6395e7e01fe..32177eee78a 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -143,6 +143,10 @@ static int add_marker_exec(bContext *C, wmOperator *op) add_marker(sc, pos[0], pos[1]); + /* reset offset from locked position, so frame jumping wouldn't be so confusing */ + sc->xlockof= 0; + sc->ylockof= 0; + WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); return OPERATOR_FINISHED;