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_graph/graph_select.c | |
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_graph/graph_select.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 23bc8e94ef8..08f561726d9 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -233,8 +233,7 @@ static void borderselect_graphkeys( rctf rectf, scaled_rectf; /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ - UI_view2d_region_to_view(v2d, rectf_view->xmin, rectf_view->ymin, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rectf_view->xmax, rectf_view->ymax, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf); /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); @@ -952,7 +951,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const float x; /* determine which side of the current frame mouse is on */ - UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); + x = UI_view2d_region_to_view_x(v2d, event->mval[0]); if (x < CFRA) RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); else @@ -1036,7 +1035,9 @@ static bool fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt) /* check if the given vertex is within bounds or not */ // TODO: should we return if we hit something? -static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale) +static void nearest_fcurve_vert_store( + ListBase *matches, View2D *v2d, FCurve *fcu, + BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale) { /* Keyframes or Samples? */ if (bezt) { @@ -1047,13 +1048,12 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc * needed to access the relevant vertex coordinates in the 3x3 * 'vec' matrix */ - UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, &screen_co[0], &screen_co[1]); + UI_view2d_view_to_region_clip(v2d, + bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, + &screen_co[0], &screen_co[1]); /* check if distance from mouse cursor to vert in screen space is within tolerance */ - // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... - //dist = len_v2v2(mval, screen_co); - dist = sqrt((mval[0] - screen_co[0]) * (mval[0] - screen_co[0]) + - (mval[1] - screen_co[1]) * (mval[1] - screen_co[1])); + dist = len_v2v2_int(mval, screen_co); if (dist <= GVERTSEL_TOL) { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; |