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/transform/transform.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/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 88261d5e8ca..a1c17f9a851 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -374,7 +374,7 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr v[0] = vec[0] / aspx; v[1] = vec[1] / aspy; - UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1); + UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]); } } else if (t->spacetype == SPACE_ACTION) { @@ -385,12 +385,12 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr if (sact->flag & SACTION_DRAWTIME) { //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); /* same as below */ - UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1); + UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]); } else #endif { - UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1); + UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]); } adr[0] = out[0]; @@ -399,14 +399,14 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { int out[2] = {0, 0}; - UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1); + UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]); adr[0] = out[0]; adr[1] = out[1]; } else if (t->spacetype == SPACE_SEQ) { /* XXX not tested yet, but should work */ int out[2] = {0, 0}; - UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1); + UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &out[0], &out[1]); adr[0] = out[0]; adr[1] = out[1]; } @@ -452,14 +452,14 @@ void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DPr v[0] /= aspx; v[1] /= aspy; - UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr + 1); + UI_view2d_view_to_region(t->view, v[0], v[1], &adr[0], &adr[1]); } else { BLI_assert(0); } } else if (t->spacetype == SPACE_NODE) { - UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], adr, adr + 1); + UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], &adr[0], &adr[1]); } } void projectIntView(TransInfo *t, const float vec[3], int adr[2]) |