diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:47:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 10:59:40 +0400 |
commit | 9ae0e585b0aab466c978ec1a55c824d902faa3b4 (patch) | |
tree | 6a99d63651f1b66ffacac2582b5f03d58898ad99 /source/blender/editors/space_clip | |
parent | 6ee8670fca946d146332e80ceff29e459cd91ed5 (diff) |
View2d: API Cleanup for view<->region conversion
View2D had some inconsistencies making it error prone in some cases.
- Inconstant checking for NULL x/y args.
Disallow NULL args for x/y destination pointers, instead add:
- UI_view2d_region_to_view_x/y
- UI_view2d_view_to_region_x/y
- '_no_clip' suffix wasn't always used for non-clipping conversion,
switch it around and use a '_clip' suffix for all funcs that clip.
- UI_view2d_text_cache_add now clips before adding cache.
- '_clip' funcs return a bool to quickly check if its in the view.
- add conversion for rectangles, since this is a common task:
- UI_view2d_view_to_region_rcti
- UI_view2d_region_to_view_rctf
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_editor.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_ops.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 2 |
4 files changed, 15 insertions, 17 deletions
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index eaf12a8d51c..7425d0cf5ff 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -279,7 +279,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx int x, y; /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); glColor3f(0.0f, 0.0f, 0.0f); glRectf(x, y, x + zoomx * width, y + zoomy * height); @@ -293,7 +293,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, int x, y; /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); /* checkerboard for case alpha */ if (ibuf->planes == 32) { @@ -328,7 +328,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int MovieClip *clip = ED_space_clip_get_clip(sc); /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); /* draw boundary border for frame if stabilization is enabled */ if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { @@ -1256,12 +1256,12 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie /* ** find window pixel coordinates of origin ** */ - /* UI_view2d_to_region_no_clip return integer values, this could + /* UI_view2d_view_to_region_no_clip return integer values, this could * lead to 1px flickering when view is locked to selection during playbeck. * to avoid this flickering, calculate base point in the same way as it happens - * in UI_view2d_to_region_no_clip, but do it in floats here */ + * in UI_view2d_view_to_region_no_clip, but do it in floats here */ - UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); glPushMatrix(); glTranslatef(x, y, 0); @@ -1503,7 +1503,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) return; - UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); glPushMatrix(); glTranslatef(x, y, 0); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 4fe12fdd7e9..c5dcc745da1 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -453,7 +453,7 @@ void ED_clip_point_stable_pos(SpaceClip *sc, ARegion *ar, float x, float y, floa 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); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); pos[0] = (x - sx) / zoomx; pos[1] = (y - sy) / zoomy; @@ -489,7 +489,7 @@ void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float c int width, height; int sx, sy; - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &sx, &sy); ED_space_clip_get_size(sc, &width, &height); ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 2aaf064ef53..074d76c1a41 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -193,8 +193,8 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) if (userdata.marker) { int x1, y1, x2, y2; - UI_view2d_view_to_region(v2d, co[0], co[1], &x1, &y1); - UI_view2d_view_to_region(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2); + UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1); + UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2); if (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta) { if (!extend) { @@ -366,17 +366,15 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); BorderSelectuserData userdata; - rcti rect; + rctf rect; if (act_track == NULL) { return OPERATOR_CANCELLED; } /* get rectangle from operator */ - WM_operator_properties_border_to_rcti(op, &rect); - - UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &userdata.rect.xmin, &userdata.rect.ymin); - UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &userdata.rect.xmax, &userdata.rect.ymax); + WM_operator_properties_border_to_rctf(op, &rect); + UI_view2d_region_to_view_rctf(&ar->v2d, &rect, &userdata.rect); userdata.changed = false; userdata.mode = RNA_int_get(op->ptr, "gesture_mode"); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index ad425d21612..b2af3c41a18 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1184,7 +1184,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) clip_draw_main(C, sc, ar); /* TODO(sergey): would be nice to find a way to de-duplicate all this space conversions */ - UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y); 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); |