From 9ae0e585b0aab466c978ec1a55c824d902faa3b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Apr 2014 16:47:16 +1000 Subject: 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 --- source/blender/editors/space_clip/clip_graph_ops.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_clip/clip_graph_ops.c') 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"); -- cgit v1.2.3