diff options
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 3 | ||||
-rw-r--r-- | source/blender/editors/include/ED_clip.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 46 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_utils.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_select.c | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 8 |
11 files changed, 63 insertions, 49 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 1855f0aaf3b..49b7eaf0650 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -690,7 +690,7 @@ RegionSpaceClip *CTX_wm_region_clip(const bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *ar_curr = CTX_wm_region(C); - if (sa && sa->spacetype == SPACE_CLIP) + if (sa && sa->spacetype == SPACE_CLIP) { /* only RGN_TYPE_WINDOW has regiondata */ if (ar_curr && ar_curr->regiontype == RGN_TYPE_WINDOW) { return ar_curr->regiondata; @@ -712,6 +712,7 @@ RegionSpaceClip *CTX_wm_region_clip(const bContext *C) ar = ar->next; } } + } return NULL; } diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 83b6b66811e..b24c1b03a87 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -84,6 +84,8 @@ void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct S void ED_space_clip_set_secondary_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *secondary_clip); void ED_clip_update_correspondence_mode(struct bContext *C, struct SpaceClip *sc); +void ED_space_clip_region_set_lock_zero(struct bContext *C); + struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc); void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 5f9cfeaab15..e6011873685 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -431,8 +431,8 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit) return false; /* center view */ - clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(sc, rsc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -792,6 +792,16 @@ void ED_clip_update_correspondence_mode(bContext *C, SpaceClip *sc) } } +/* ******** space clip region functions ******** */ + +void ED_space_clip_region_set_lock_zero(bContext *C) +{ + RegionSpaceClip *rsc = CTX_wm_region_clip(C); + + rsc->xlockof = 0.f; + rsc->ylockof = 0.f; +} + /* ******** masking editing functions ******** */ Mask *ED_space_clip_get_mask(SpaceClip *sc) diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 91f394e1121..994dc300355 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -40,6 +40,7 @@ struct MovieTrackingTrack; struct Scene; struct ScrArea; struct SpaceClip; +struct RegionSpaceClip; struct wmOperatorType; /* channel heights */ @@ -139,7 +140,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(SpaceClip *sc, float x, float y); +void clip_view_center_to_point(SpaceClip *sc, RegionSpaceClip *rsc, float x, float y); void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 924cd71a08a..876ef3e8558 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -117,16 +117,16 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) ED_space_clip_get_size(sc, &width, &height); - dx = ((location[0] - 0.5f) * width - sc->xof) * (rsc->zoom - oldzoom) / rsc->zoom; - dy = ((location[1] - 0.5f) * height - sc->yof) * (rsc->zoom - oldzoom) / rsc->zoom; + dx = ((location[0] - 0.5f) * width - rsc->xof) * (rsc->zoom - oldzoom) / rsc->zoom; + dy = ((location[1] - 0.5f) * height - rsc->yof) * (rsc->zoom - oldzoom) / rsc->zoom; if (sc->flag & SC_LOCK_SELECTION) { - sc->xlockof += dx; - sc->ylockof += dy; + rsc->xlockof += dx; + rsc->ylockof += dy; } else { - sc->xof += dx; - sc->yof += dy; + rsc->xof += dx; + rsc->yof += dy; } } } @@ -472,6 +472,7 @@ typedef struct ViewPanData { static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); ViewPanData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ClipViewPanData"); @@ -481,9 +482,9 @@ static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event) vpd->y = event->y; if (sc->flag & SC_LOCK_SELECTION) - vpd->vec = &sc->xlockof; + vpd->vec = &rsc->xlockof; else - vpd->vec = &sc->xof; + vpd->vec = &rsc->xof; copy_v2_v2(&vpd->xof, vpd->vec); copy_v2_v2(&vpd->xorig, &vpd->xof); @@ -510,17 +511,18 @@ static void view_pan_exit(bContext *C, wmOperator *op, bool cancel) static int view_pan_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); float offset[2]; RNA_float_get_array(op->ptr, "offset", offset); if (sc->flag & SC_LOCK_SELECTION) { - sc->xlockof += offset[0]; - sc->ylockof += offset[1]; + rsc->xlockof += offset[0]; + rsc->ylockof += offset[1]; } else { - sc->xof += offset[0]; - sc->yof += offset[1]; + rsc->xof += offset[0]; + rsc->yof += offset[1]; } ED_region_tag_redraw(CTX_wm_region(C)); @@ -895,13 +897,13 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) static int view_zoom_ratio_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); sclip_zoom_set(C, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ - sc->xof = (int) sc->xof; - sc->yof = (int) sc->yof; + rsc->xof = (int) rsc->xof; + rsc->yof = (int) rsc->yof; ED_region_tag_redraw(CTX_wm_region(C)); @@ -937,6 +939,7 @@ static int view_all_exec(bContext *C, wmOperator *op) /* retrieve state */ sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); ar = CTX_wm_region(C); ED_space_clip_get_size(sc, &w, &h); @@ -969,7 +972,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sclip_zoom_set(C, 1.0f, NULL); } - sc->xof = sc->yof = 0.0f; + rsc->xof = rsc->yof = 0.0f; ED_region_tag_redraw(ar); @@ -998,11 +1001,11 @@ void CLIP_OT_view_all(wmOperatorType *ot) static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); ARegion *ar = CTX_wm_region(C); - sc->xlockof = 0.0f; - sc->ylockof = 0.0f; + rsc->xlockof = 0.0f; + rsc->ylockof = 0.0f; ED_clip_view_selection(C, ar, 1); ED_region_tag_redraw(ar); @@ -1552,7 +1555,6 @@ static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv if (event->type != NDOF_MOTION) return OPERATOR_CANCELLED; else { - SpaceClip *sc = CTX_wm_space_clip(C); RegionSpaceClip *rsc = CTX_wm_region_clip(C); ARegion *ar = CTX_wm_region(C); float pan_vec[3]; @@ -1566,8 +1568,8 @@ static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv pan_vec[2] *= -ndof->dt; sclip_zoom_set_factor(C, 1.0f + pan_vec[2], NULL); - sc->xof += pan_vec[0]; - sc->yof += pan_vec[1]; + rsc->xof += pan_vec[0]; + rsc->yof += pan_vec[1]; ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 5964e9a898b..0671594b67d 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -231,7 +231,7 @@ void clip_delete_marker(bContext *C, MovieClip *clip, MovieTrackingTrack *track, } } -void clip_view_center_to_point(SpaceClip *sc, float x, float y) +void clip_view_center_to_point(SpaceClip *sc, RegionSpaceClip *rsc, float x, float y) { int width, height; float aspx, aspy; @@ -239,8 +239,8 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y) ED_space_clip_get_size(sc, &width, &height); ED_space_clip_get_aspect(sc, &aspx, &aspy); - sc->xof = (x - 0.5f) * width * aspx; - sc->yof = (y - 0.5f) * height * aspy; + rsc->xof = (x - 0.5f) * width * aspx; + rsc->yof = (y - 0.5f) * height * aspy; } void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 2f99e7d36f1..fa2a36d0f6a 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1131,8 +1131,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) x1 = ar->winrct.xmin + (winx - rsc->zoom * w) / 2.0f; y1 = ar->winrct.ymin + (winy - rsc->zoom * h) / 2.0f; - x1 -= rsc->zoom * sc->xof; - y1 -= rsc->zoom * sc->yof; + x1 -= rsc->zoom * rsc->xof; + y1 -= rsc->zoom * rsc->yof; /* relative display right */ ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / rsc->zoom; @@ -1179,8 +1179,8 @@ static void movieclip_secondary_clip_set_view2d(const bContext *C, ARegion *ar) x1 = ar->winrct.xmin + (winx - rsc->zoom * w) / 2.0f; y1 = ar->winrct.ymin + (winy - rsc->zoom * h) / 2.0f; - x1 -= rsc->zoom * sc->xof; - y1 -= rsc->zoom * sc->yof; + x1 -= rsc->zoom * rsc->xof; + y1 -= rsc->zoom * rsc->yof; /* relative display right */ ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / rsc->zoom; @@ -1220,6 +1220,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); float aspx, aspy, zoomx, zoomy, x, y; int width, height; @@ -1238,8 +1239,8 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) } if (ED_clip_view_selection(C, ar, 0)) { - sc->xof += sc->xlockof; - sc->yof += sc->ylockof; + rsc->xof += rsc->xlockof; + rsc->yof += rsc->ylockof; } if (tmpibuf) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 79ae10ded06..998bac32a2f 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -93,6 +93,7 @@ static bool add_marker(const bContext *C, float x, float y) static int add_marker_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); float pos[2]; @@ -105,8 +106,8 @@ static int add_marker_exec(bContext *C, wmOperator *op) /* Reset offset from locked position, so frame jumping wouldn't be so * confusing. */ - sc->xlockof = 0; - sc->ylockof = 0; + rsc->xlockof = 0; + rsc->ylockof = 0; WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index e970b1b9743..6068cb7e38f 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -270,6 +270,7 @@ void ed_tracking_delect_all_plane_tracks(ListBase *plane_tracks_base) static int mouse_select(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); + RegionSpaceClip *rsc = CTX_wm_region_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -339,8 +340,8 @@ static int mouse_select(bContext *C, float co[2], int extend) } if (!extend) { - sc->xlockof = 0.0f; - sc->ylockof = 0.0f; + rsc->xlockof = 0.0f; + rsc->ylockof = 0.0f; } BKE_tracking_dopesheet_tag_update(tracking); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 1b13a7aa81c..51bcd440ed2 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1251,8 +1251,8 @@ typedef struct SpaceClip { ListBase regionbase; /* storage of regions for inactive spaces */ int spacetype; - float xof, yof; /* user defined offset, image is centered */ - float xlockof, ylockof; /* user defined offset from locked position */ + float xof DNA_DEPRECATED, yof DNA_DEPRECATED; /* user defined offset, image is centered */ + float xlockof DNA_DEPRECATED, ylockof DNA_DEPRECATED; /* user defined offset from locked position */ float zoom DNA_DEPRECATED; /* user defined zoom level */ struct MovieClipUser user; /* user of clip */ @@ -1290,9 +1290,6 @@ typedef struct RegionSpaceClip { float xof, yof; /* user defined offset, image is centered */ float xlockof, ylockof; /* user defined offset from locked position */ float zoom; /* user defined zoom level */ - float loc[2], scale, angle; /* pre-composed stabilization data */ - float stabmat[4][4], unistabmat[4][4]; /* current stabilization matrix and the same matrix in unified space, - * defined when drawing and used for mouse position calculation */ } RegionSpaceClip; /* SpaceClip->flag */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9038871cbf5..ba6cc1abb2f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1568,12 +1568,9 @@ static void rna_SpaceClipEditor_clip_mode_update(bContext *C, PointerRNA *ptr) ED_clip_update_correspondence_mode(C, sc); } -static void rna_SpaceClipEditor_lock_selection_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_SpaceClipEditor_lock_selection_update(bContext *C, PointerRNA *ptr) { - SpaceClip *sc = (SpaceClip *)(ptr->data); - - sc->xlockof = 0.f; - sc->ylockof = 0.f; + ED_space_clip_region_set_lock_zero(C); } static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -4574,6 +4571,7 @@ static void rna_def_space_clip(BlenderRNA *brna) prop = RNA_def_property(srna, "lock_selection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Lock to Selection", "Lock viewport to selected markers during playback"); RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_SELECTION); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_lock_selection_update"); /* lock to time cursor */ |