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/include/UI_view2d.h | |
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/include/UI_view2d.h')
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index b087469887b..95514149e90 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -34,6 +34,8 @@ #ifndef __UI_VIEW2D_H__ #define __UI_VIEW2D_H__ +#include "BLI_compiler_attrs.h" + /* ------------------------------------------ */ /* Settings and Defines: */ @@ -190,10 +192,19 @@ void UI_view2d_listview_visible_cells(struct View2D *v2d, float columnwidth, flo int *row_min, int *row_max); /* coordinate conversion */ -void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy); -void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony); -void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y); -void UI_view2d_to_region_float(struct View2D *v2d, float x, float y, float *regionx, float *regiony); +float UI_view2d_region_to_view_x(struct View2D *v2d, float x); +float UI_view2d_region_to_view_y(struct View2D *v2d, float y); +void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL(); +void UI_view2d_region_to_view_rctf(struct View2D *v2d, const struct rctf *rect_src, struct rctf *rect_dst) ATTR_NONNULL(); + +float UI_view2d_view_to_region_x(struct View2D *v2d, float x); +float UI_view2d_view_to_region_y(struct View2D *v2d, float y); +bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL(); + +void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL(); +void UI_view2d_view_to_region_fl(struct View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL(); +void UI_view2d_view_to_region_rcti(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL(); +bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf *rect_src, struct rcti *rect_dst) ATTR_NONNULL(); /* utilities */ struct View2D *UI_view2d_fromcontext(const struct bContext *C); @@ -211,7 +222,7 @@ short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, /* cached text drawing in v2d, to allow pixel-aligned draw as post process */ void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y, const char *str, size_t str_len, const char col[4]); -void UI_view2d_text_cache_rectf(struct View2D *v2d, const struct rctf *rect, const char *str, size_t str_len, const char col[4]); +void UI_view2d_text_cache_rectf(struct View2D *v2d, const struct rctf *rect_view, const char *str, size_t str_len, const char col[4]); void UI_view2d_text_cache_draw(struct ARegion *ar); /* operators */ |