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_file/file_ops.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_file/file_ops.c')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 8becb287cf1..9c8bcc09a3e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -69,18 +69,24 @@ #include <ctype.h> /* ---------- FILE SELECTION ------------ */ -static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect) +static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region) { FileSelection sel; - float fxmin, fymin, fxmax, fymax; View2D *v2d = &ar->v2d; rcti rect_view; + rctf rect_view_fl; + rctf rect_region_fl; - UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); - UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax, &fxmax, &fymax); + BLI_rctf_rcti_copy(&rect_region_fl, rect_region); - BLI_rcti_init(&rect_view, (int)(v2d->tot.xmin + fxmin), (int)(v2d->tot.xmin + fxmax), (int)(v2d->tot.ymax - fymin), (int)(v2d->tot.ymax - fymax)); + UI_view2d_region_to_view_rctf(v2d, &rect_region_fl, &rect_view_fl); + + BLI_rcti_init(&rect_view, + (int)(v2d->tot.xmin + rect_view_fl.xmin), + (int)(v2d->tot.xmin + rect_view_fl.xmax), + (int)(v2d->tot.ymax - rect_view_fl.ymin), + (int)(v2d->tot.ymax - rect_view_fl.ymax)); sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); |