diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 02:41:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 02:41:40 +0400 |
commit | ff078d309e65d2383fa0829954c724fc49189492 (patch) | |
tree | e383ad5f7fa69eba20adfa691f7a90f49925c64d | |
parent | ee572a9642d5360f0ba852c17cc345f21ad1f985 (diff) |
change clip utility function arguments to take space data and region rather then the context.
this allows a fix to be applied that corrects the helper line in the image view when transforming a mask.
20 files changed, 201 insertions, 143 deletions
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index f1b405c2c3e..8c4eb5c3879 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -52,9 +52,9 @@ int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_maskedit_poll(struct bContext *C); int ED_space_clip_maskedit_mask_poll(bContext *C); -void ED_space_clip_get_size(const struct bContext *C, int *width, int *height); -void ED_space_clip_get_size_fl(const struct bContext *C, float size[2]); -void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy); +void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height); +void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]); +void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy); void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy); void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); @@ -67,9 +67,9 @@ void ED_clip_update_frame(const struct Main *mainp, int cfra); int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]); -void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]); -void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); +void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr); +void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]); +void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, struct wmEvent *event, float co[2]); int ED_space_clip_check_show_trackedit(struct SpaceClip *sc); int ED_space_clip_check_show_maskedit(struct SpaceClip *sc); diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 372d4665a73..72be9cc2726 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -37,15 +37,16 @@ struct MaskLayerShape; struct wmEvent; /* mask_edit.c */ -void ED_mask_size(const struct bContext *C, int *width, int *height); -void ED_mask_zoom(const struct bContext *C, float *zoomx, float *zoomy); -void ED_mask_aspect(const struct bContext *C, float *aspx, float *aspy); +void ED_mask_get_size(struct ScrArea *sa, int *width, int *height); +void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy); +void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *ar, float *aspx, float *aspy); -void ED_mask_pixelspace_factor(const struct bContext *C, float *scalex, float *scaley); -void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); +void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley); +void ED_mask_mouse_pos(struct ScrArea *sa, struct ARegion *ar, struct wmEvent *event, float co[2]); -void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr); +void ED_mask_point_pos__reverse(struct ScrArea *sa, struct ARegion *ar, + float x, float y, float *xr, float *yr); void ED_operatortypes_mask(void); void ED_keymap_mask(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index c9f6dc0c5fb..48c81894b55 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -38,6 +38,7 @@ #include "BKE_mask.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_mask_types.h" #include "DNA_object_types.h" /* SELECT */ @@ -57,6 +58,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no float *u_r, float tangent[2], const short use_deform) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay, *point_masklay; MaskSpline *point_spline; MaskSplinePoint *point = NULL; @@ -65,9 +69,9 @@ static int find_nearest_diff_point(const bContext *C, Mask *mask, const float no float u; float scalex, scaley, aspx, aspy; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -180,6 +184,8 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline const float point_co[2], const float tangent[2], const float u, MaskSplinePoint *reference_point, const short reference_adjacent) { + ScrArea *sa = CTX_wm_area(C); + MaskSplinePoint *prev_point = NULL; MaskSplinePoint *next_point = NULL; BezTriple *bezt; @@ -190,7 +196,7 @@ static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline copy_v2_v2(co, point_co); co[2] = 0.0f; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); /* point coordinate */ bezt = &new_point->bezt; @@ -610,9 +616,12 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -681,9 +690,12 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) static int add_feather_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index c79920eeb01..f416e31c1de 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -456,19 +456,21 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) { + ScrArea *sa = CTX_wm_area(C); + Mask *mask = CTX_data_edit_mask(C); int width, height; if (!mask) return; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); draw_masklays(mask, draw_flag, draw_type, width, height); } /* sets up the opengl context. - * width, height are to match the values from ED_mask_size() */ + * width, height are to match the values from ED_mask_get_size() */ void ED_mask_draw_region(Mask *mask, ARegion *ar, const char draw_flag, const char draw_type, int width, int height, diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 5c724d9e5a3..7b94cb83fe9 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -90,21 +90,19 @@ int ED_maskedit_mask_poll(bContext *C) /********************** registration *********************/ -void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) +void ED_mask_mouse_pos(ScrArea *sa, ARegion *ar, wmEvent *event, float co[2]) { - ScrArea *sa = CTX_wm_area(C); if (sa) { switch (sa->spacetype) { case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; } case SPACE_SEQ: { - ARegion *ar = CTX_wm_region(C); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); break; } @@ -112,7 +110,6 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); ED_image_mouse_pos(sima, ar, event, co); BKE_mask_coord_from_frame(co, co, frame_size); @@ -133,9 +130,8 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) /* input: x/y - mval space * output: xr/yr - mask point space */ -void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos(struct ScrArea *sa, struct ARegion *ar, float x, float y, float *xr, float *yr) { - ScrArea *sa = CTX_wm_area(C); float co[2]; if (sa) { @@ -143,7 +139,7 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; - ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]); + ED_clip_point_stable_pos(sc, ar, x, y, &co[0], &co[1]); BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co); break; } @@ -154,7 +150,6 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]); BKE_mask_coord_from_frame(co, co, frame_size); @@ -176,9 +171,8 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr *yr = co[1]; } -void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr) +void ED_mask_point_pos__reverse(ScrArea *sa, ARegion *ar, float x, float y, float *xr, float *yr) { - ScrArea *sa = CTX_wm_area(C); float co[2]; if (sa) { @@ -189,7 +183,7 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); - ED_clip_point_stable_pos__reverse(C, co, co); + ED_clip_point_stable_pos__reverse(sc, ar, co, co); break; } case SPACE_SEQ: @@ -199,7 +193,6 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, { float frame_size[2]; SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_size_fl(sima, frame_size); co[0] = x; @@ -224,21 +217,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, *yr = co[1]; } -void ED_mask_size(const bContext *C, int *width, int *height) +void ED_mask_get_size(struct ScrArea *sa, int *width, int *height) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: { - ED_space_clip_get_size(C, width, height); + SpaceClip *sc = sa->spacedata.first; + ED_space_clip_get_size(sc, width, height); break; } case SPACE_SEQ: { - Scene *scene = CTX_data_scene(C); - *width = (scene->r.size * scene->r.xsch) / 100; - *height = (scene->r.size * scene->r.ysch) / 100; +// Scene *scene = CTX_data_scene(C); +// *width = (scene->r.size * scene->r.xsch) / 100; +// *height = (scene->r.size * scene->r.ysch) / 100; break; } case SPACE_IMAGE: @@ -262,14 +255,14 @@ void ED_mask_size(const bContext *C, int *width, int *height) } } -void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) +void ED_mask_zoom(struct ScrArea *sa, struct ARegion *ar, float *zoomx, float *zoomy) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: { - ED_space_clip_get_zoom(C, zoomx, zoomy); + SpaceClip *sc = sa->spacedata.first; + ED_space_clip_get_zoom(sc, ar, zoomx, zoomy); break; } case SPACE_SEQ: @@ -280,7 +273,6 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); ED_space_image_get_zoom(sima, ar, zoomx, zoomy); break; } @@ -297,9 +289,8 @@ void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) } } -void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) +void ED_mask_get_aspect(struct ScrArea *sa, struct ARegion *UNUSED(ar), float *aspx, float *aspy) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: @@ -332,9 +323,8 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) } } -void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) +void ED_mask_pixelspace_factor(struct ScrArea *sa, struct ARegion *ar, float *scalex, float *scaley) { - ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { switch (sa->spacetype) { case SPACE_CLIP: @@ -343,8 +333,8 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) int width, height; float zoomx, zoomy, aspx, aspy; - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ED_space_clip_get_aspect(sc, &aspx, &aspy); *scalex = ((float)width * aspx) * zoomx; @@ -359,7 +349,6 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; - ARegion *ar = CTX_wm_region(C); int width, height; float zoomx, zoomy, aspx, aspy; diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 99c46c38bfc..116c3dcede1 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -62,6 +62,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r, float *score) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay; MaskLayer *point_masklay = NULL; MaskSpline *point_spline = NULL; @@ -70,9 +73,9 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, float float len = FLT_MAX, scalex, scaley; int is_handle = FALSE, width, height; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -158,6 +161,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[ MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r, MaskSplinePointUW **uw_r, float *score) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + MaskLayer *masklay, *point_masklay = NULL; MaskSpline *point_spline = NULL; MaskSplinePoint *point = NULL; @@ -166,9 +172,9 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[ float scalex, scaley, aspx, aspy; int width, height; - ED_mask_size(C, &width, &height); - ED_mask_aspect(C, &aspx, &aspy); - ED_mask_pixelspace_factor(C, &scalex, &scaley); + ED_mask_get_size(sa, &width, &height); + ED_mask_get_aspect(sa, ar, &aspx, &aspy); + ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley); co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; @@ -426,6 +432,9 @@ static int slide_point_check_initial_feather(MaskSpline *spline) static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); SlidePointData *customdata = NULL; MaskLayer *masklay, *cv_masklay, *feather_masklay; @@ -437,8 +446,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) float co[2], cv_score, feather_score; const float threshold = 19; - ED_mask_mouse_pos(C, event, co); - ED_mask_size(C, &width, &height); + ED_mask_mouse_pos(sa, ar, event, co); + ED_mask_get_size(sa, &width, &height); cv_point = ED_mask_point_find_nearest(C, mask, co, threshold, &cv_masklay, &cv_spline, &is_handle, &cv_score); @@ -502,7 +511,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, wmEvent *event) copy_m3_m3(customdata->vec, point->bezt.vec); if (BKE_mask_point_has_handle(point)) BKE_mask_point_handle(point, customdata->handle); - ED_mask_mouse_pos(C, event, customdata->co); + ED_mask_mouse_pos(sa, ar, event, customdata->co); } return customdata; @@ -639,7 +648,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) /* no break! update CV position */ case MOUSEMOVE: - ED_mask_mouse_pos(C, event, co); + { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + + ED_mask_mouse_pos(sa, ar, event, co); sub_v2_v2v2(dco, co, data->co); if (data->action == SLIDE_ACTION_HANDLE) { @@ -768,6 +781,7 @@ static int slide_point_modal(bContext *C, wmOperator *op, wmEvent *event) DAG_id_tag_update(&data->mask->id, 0); break; + } case LEFTMOUSE: if (event->val == KM_RELEASE) { diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 565beaf34ef..2f5fef1d59a 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -343,9 +343,12 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -380,6 +383,9 @@ void MASK_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -394,8 +400,8 @@ static int border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - ED_mask_point_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - ED_mask_point_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + ED_mask_point_pos(sa, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); + ED_mask_point_pos(sa, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); mode = RNA_int_get(op->ptr, "gesture_mode"); extend = RNA_boolean_get(op->ptr, "extend"); @@ -465,6 +471,9 @@ void MASK_OT_select_border(wmOperatorType *ot) static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short select) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -496,7 +505,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short float screen_co[2]; /* marker in screen coords */ - ED_mask_point_pos__reverse(C, + ED_mask_point_pos__reverse(sa, ar, point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1], &screen_co[0], &screen_co[1]); @@ -578,6 +587,9 @@ static int mask_spline_point_inside_ellipse(BezTriple *bezt, float offset[2], fl static int circle_select_exec(bContext *C, wmOperator *op) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; int i; @@ -593,14 +605,14 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_mask_size(C, &width, &height); - ED_mask_zoom(C, &zoomx, &zoomy); + ED_mask_get_size(sa, &width, &height); + ED_mask_zoom(sa, ar, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; - ED_mask_point_pos(C, x, y, &offset[0], &offset[1]); + ED_mask_point_pos(sa, ar, x, y, &offset[0], &offset[1]); /* do actual selection */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { @@ -663,6 +675,9 @@ void MASK_OT_select_circle(wmOperatorType *ot) static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; MaskSpline *spline; @@ -674,7 +689,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent * const float threshold = 19; int change = FALSE; - ED_mask_mouse_pos(C, event, co); + ED_mask_mouse_pos(sa, ar, event, co); point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 7734661aa96..d650ea7b61d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1408,17 +1408,16 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); } -void clip_draw_main(const bContext *C, ARegion *ar) +void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) { - SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); ImBuf *ibuf; int width, height; float zoomx, zoomy; - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); /* if no clip, nothing to do */ if (!clip) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 92fcbc2964d..c04cd864d2e 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -124,10 +124,8 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) /* ******** common editing functions ******** */ -void ED_space_clip_get_size(const bContext *C, int *width, int *height) +void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height) { - SpaceClip *sc = CTX_wm_space_clip(C); - if (sc->clip) { BKE_movieclip_get_size(sc->clip, &sc->user, width, height); } @@ -136,20 +134,19 @@ void ED_space_clip_get_size(const bContext *C, int *width, int *height) } } -void ED_space_clip_get_size_fl(const bContext *C, float size[2]) +void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]) { int size_i[2]; - ED_space_clip_get_size(C, &size_i[0], &size_i[1]); + ED_space_clip_get_size(sc, &size_i[0], &size_i[1]); size[0] = size_i[0]; size[1] = size_i[1]; } -void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy) +void ED_space_clip_get_zoom(struct SpaceClip *sc, struct ARegion *ar, float *zoomx, float *zoomy) { - ARegion *ar = CTX_wm_region(C); int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); @@ -273,9 +270,8 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -static int selected_boundbox(const bContext *C, float min[2], float max[2]) +static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) { - SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; @@ -284,7 +280,7 @@ static int selected_boundbox(const bContext *C, float min[2], float max[2]) INIT_MINMAX2(min, max); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); track = tracksbase->first; while (track) { @@ -327,17 +323,17 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) int w, h, frame_width, frame_height; float min[2], max[2]; - ED_space_clip_get_size(C, &frame_width, &frame_height); + ED_space_clip_get_size(sc, &frame_width, &frame_height); if (frame_width == 0 || frame_height == 0) return FALSE; - if (!selected_boundbox(C, min, max)) + if (!selected_boundbox(sc, min, max)) return FALSE; /* center view */ - clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -385,15 +381,13 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ } } -void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, float *yr) +void ED_clip_point_stable_pos(struct SpaceClip *sc, struct ARegion *ar, float x, float y, float *xr, float *yr) { - ARegion *ar = CTX_wm_region(C); - SpaceClip *sc = CTX_wm_space_clip(C); int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; - ED_space_clip_get_zoom(C, &zoomx, &zoomy); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); @@ -424,18 +418,16 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(struct SpaceClip *sc, struct ARegion *ar, const float co[2], float r_co[2]) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float zoomx, zoomy; float pos[3]; int width, height; int sx, sy; UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ED_clip_point_undistorted_pos(sc, co, pos); pos[2] = 0.0f; @@ -447,9 +439,9 @@ void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], flo r_co[1] = (pos[1] * height * zoomy) + (float)sy; } -void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2]) +void ED_clip_mouse_pos(struct SpaceClip *sc, struct ARegion *ar, wmEvent *event, float co[2]) { - ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); + ED_clip_point_stable_pos(sc, ar, event->mval[0], event->mval[1], &co[0], &co[1]); } int ED_space_clip_check_show_trackedit(SpaceClip *sc) diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index abf7f416b9c..c0b11dda5c7 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -345,6 +345,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index c4652c2f04d..3422aacf264 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar); void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ -void clip_draw_main(const struct bContext *C, struct ARegion *ar); +void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); @@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(const struct bContext *C, float x, float y); +void clip_view_center_to_point(SpaceClip *sc, 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 ee799566970..1dabef75c21 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -74,6 +74,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); + float oldzoom = sc->zoom; int width, height; @@ -81,7 +82,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); width *= sc->zoom; height *= sc->zoom; @@ -95,7 +96,7 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; @@ -111,16 +112,20 @@ static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float locati static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { + ARegion *ar = CTX_wm_region(C); + float location[2], *mpos = NULL; if (event) { - ED_clip_mouse_pos(C, event, location); + SpaceClip *sc = CTX_wm_space_clip(C); + + ED_clip_mouse_pos(sc, ar, event, location); mpos = location; } sclip_zoom_set_factor(C, factor, mpos); - ED_region_tag_redraw(CTX_wm_region(C)); + ED_region_tag_redraw(ar); } /******************** open clip operator ********************/ @@ -466,6 +471,8 @@ typedef struct ViewZoomData { static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + ViewZoomData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); @@ -476,7 +483,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) vpd->zoom = sc->zoom; vpd->event_type = event->type; - ED_clip_mouse_pos(C, event, vpd->location); + ED_clip_mouse_pos(sc, ar, event, vpd->location); WM_event_add_modal_handler(C, op); } @@ -593,9 +600,12 @@ static int view_zoom_in_exec(bContext *C, wmOperator *op) static int view_zoom_in_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float location[2]; - ED_clip_mouse_pos(C, event, location); + ED_clip_mouse_pos(sc, ar, event, location); RNA_float_set_array(op->ptr, "location", location); return view_zoom_in_exec(C, op); @@ -633,9 +643,12 @@ static int view_zoom_out_exec(bContext *C, wmOperator *op) static int view_zoom_out_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float location[2]; - ED_clip_mouse_pos(C, event, location); + ED_clip_mouse_pos(sc, ar, event, location); RNA_float_set_array(op->ptr, "location", location); return view_zoom_out_exec(C, op); @@ -706,7 +719,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sc = CTX_wm_space_clip(C); ar = CTX_wm_region(C); - ED_space_clip_get_size(C, &w, &h); + ED_space_clip_get_size(sc, &w, &h); ED_space_clip_get_aspect(sc, &aspx, &aspy); w = w * aspx; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index d9c9f63e4a3..9e93aed6df7 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -223,13 +223,12 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, } } -void clip_view_center_to_point(const bContext *C, float x, float y) +void clip_view_center_to_point(SpaceClip *sc, float x, float y) { - SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float aspx, aspy; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); ED_space_clip_get_aspect(sc, &aspx, &aspy); sc->xof = (x - 0.5f) * width * aspx; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index bd7359e8bb0..3428c47ff43 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1024,7 +1024,7 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) float x1, y1, w, h; int width, height, winx, winy; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); w = width; h = height; @@ -1119,14 +1119,15 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) /* data... */ movieclip_main_area_set_view2d(C, ar); - clip_draw_main(C, ar); + clip_draw_main(C, sc, ar); if (sc->mode == SC_MODE_MASKEDIT) { Mask *mask = CTX_data_edit_mask(C); if (mask) { + ScrArea *sa = CTX_wm_area(C); int width, height; - ED_mask_size(C, &width, &height); + ED_mask_get_size(sa, &width, &height); ED_mask_draw_region(mask, ar, sc->mask_info.draw_flag, sc->mask_info.draw_type, width, height, diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 360a3f74130..28bb0f70611 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -91,7 +91,7 @@ static void add_marker(const bContext *C, float x, float y) int width, height; int framenr = ED_space_clip_get_clip_frame_number(sc); - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height); @@ -107,7 +107,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) float pos[2]; int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (!width || !height) return OPERATOR_CANCELLED; @@ -127,9 +127,12 @@ static int add_marker_exec(bContext *C, wmOperator *op) static int add_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); RNA_float_set_array(op->ptr, "location", co); @@ -525,6 +528,8 @@ static void show_cursor(bContext *C) MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int *area_r, int *action_r, int *corner_r) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height; @@ -533,12 +538,12 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int int framenr = ED_space_clip_get_clip_frame_number(sc); int action = -1, area = 0, corner = -1; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (width == 0 || height == 0) return NULL; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); track = tracksbase->first; while (track) { @@ -622,6 +627,8 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int static void *slide_marker_customdata(bContext *C, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieTrackingTrack *track; int width, height; float co[2]; @@ -629,12 +636,12 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) int framenr = ED_space_clip_get_clip_frame_number(sc); int area, action, corner; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); if (width == 0 || height == 0) return NULL; - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); track = tracking_marker_check_slide(C, event, &area, &action, &corner); if (track) { @@ -700,6 +707,8 @@ static void free_slide_data(SlideMarkerData *data) static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + SlideMarkerData *data = (SlideMarkerData *)op->customdata; float dx, dy, mdelta[2]; @@ -751,7 +760,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) float start[2], end[2]; float scale; - ED_clip_point_stable_pos(C, data->mval[0], data->mval[1], &start[0], &start[1]); + ED_clip_point_stable_pos(sc, ar, data->mval[0], data->mval[1], &start[0], &start[1]); sub_v2_v2(start, data->old_pos); @@ -767,7 +776,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) mval[1] = event->mval[1]; } - ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]); + ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]); sub_v2_v2(end, data->old_pos); @@ -825,7 +834,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) sub_v2_v2v2(start, data->spos, data->old_pos); - ED_clip_point_stable_pos(C, mval[0], mval[1], &end[0], &end[1]); + ED_clip_point_stable_pos(sc, ar, mval[0], mval[1], &end[0], &end[1]); sub_v2_v2(end, data->old_pos); if (len_v2(start) > 0.0f) { diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 0d933c1dff3..26a596ead07 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -119,7 +119,7 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack * float epsx, epsy; int width, height; - ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_size(sc, &width, &height); BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); @@ -281,6 +281,9 @@ static int select_exec(bContext *C, wmOperator *op) static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + float co[2]; int extend = RNA_boolean_get(op->ptr, "extend"); @@ -299,7 +302,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - ED_clip_mouse_pos(C, event, co); + ED_clip_mouse_pos(sc, ar, event, co); RNA_float_set_array(op->ptr, "location", co); return select_exec(C, op); @@ -333,6 +336,8 @@ void CLIP_OT_select(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -348,8 +353,8 @@ static int border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - ED_clip_point_stable_pos(C, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); - ED_clip_point_stable_pos(C, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); + ED_clip_point_stable_pos(sc, ar, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); + ED_clip_point_stable_pos(sc, ar, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); mode = RNA_int_get(op->ptr, "gesture_mode"); extend = RNA_boolean_get(op->ptr, "extend"); @@ -414,6 +419,8 @@ void CLIP_OT_select_border(wmOperatorType *ot) static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -435,7 +442,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho float screen_co[2]; /* marker in screen coords */ - ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co); + ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) @@ -519,6 +526,8 @@ static int marker_inside_ellipse(MovieTrackingMarker *marker, float offset[2], f static int circle_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -535,13 +544,13 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(sc, &width, &height); + ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; - ED_clip_point_stable_pos(C, x, y, &offset[0], &offset[1]); + ED_clip_point_stable_pos(sc, ar, x, y, &offset[0], &offset[1]); /* do selection */ track = tracksbase->first; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 55e22a999bc..1ef319c45e2 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -636,7 +636,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) if (mask) { int width, height; - ED_mask_size(C, &width, &height); + ED_space_image_get_size(sima, &width, &height); ED_mask_draw_region(mask, ar, sima->mask_info.draw_flag, sima->mask_info.draw_type, width, height, diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ac2f8a7a34c..f90b2cf4deb 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -996,7 +996,12 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (mask) { int width, height; - ED_mask_size(C, &width, &height); + // ED_mask_get_size(C, &width, &height); + + //Scene *scene = CTX_data_scene(C); + width = (scene->r.size * scene->r.xsch) / 100; + height = (scene->r.size * scene->r.ysch) / 100; + ED_mask_draw_region(mask, ar, 0, 0, /* TODO */ width, height, diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4f26f563ac6..a49fa895e99 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -226,16 +226,13 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) project_int_noclip(t->ar, vec, adr); } else if (t->spacetype == SPACE_IMAGE) { -#if 0 if (t->options & CTX_MASK) { float v[2]; - ED_mask_point_pos__reverse(t->context, vec[0], vec[1], &v[0], &v[1]); + ED_mask_point_pos__reverse(t->sa, t->ar, vec[0], vec[1], &v[0], &v[1]); adr[0] = v[0]; adr[1] = v[1]; } - else -#endif - { + else { float aspx, aspy, v[2]; ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 597be0fd33b..02101b9d02d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6230,7 +6230,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) return; } - ED_mask_aspect(C, &asp[0], &asp[1]); + ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]); t->total = (propmode) ? count : countsel; td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Mask Editing)"); @@ -6281,7 +6281,7 @@ void flushTransMasking(TransInfo *t) int a; float asp[2], inv[2]; - ED_mask_aspect(t->context, &asp[0], &asp[1]); + ED_mask_get_aspect(t->sa, t->ar, &asp[0], &asp[1]); inv[0] = 1.0f / asp[0]; inv[1] = 1.0f / asp[1]; |