-/* start of a generic 2d view with should allow drawing grids,
- * panning, zooming, scrolling, .. */
+/* ------------------------------------------ */
+/* Settings: */
+
+/* generic value to use when coordinate lies out of view when converting */
+#define V2D_IS_CLIPPED 12000
-#define V2D_IS_CLIPPED 12000
+/* flags for grid-lines to draw */
+#define V2D_HORIZONTAL_LINES (1<<0)
+#define V2D_VERTICAL_LINES (1<<1)
+#define V2D_HORIZONTAL_AXIS (1<<2)
+#define V2D_VERTICAL_AXIS (1<<3)
+
+/* --- Scrollers --- */
+
+/* ------------------------------------------ */
+/* Macros: */
-#define V2D_HORIZONTAL_LINES 1
-#define V2D_VERTICAL_LINES 2
-#define V2D_HORIZONTAL_AXIS 4
-#define V2D_VERTICAL_AXIS 8
+/* test if mouse in a scrollbar */
+#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1]))
+#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1]))
+
+/* ------------------------------------------ */
+/* Type definitions: */
/* setup */
void UI_view2d_ortho(const struct bContext *C, struct View2D *v2d);
void UI_view2d_update_size(struct View2D *v2d, int winx, int winy);
/* setup */
void UI_view2d_ortho(const struct bContext *C, struct View2D *v2d);
void UI_view2d_update_size(struct View2D *v2d, int winx, int winy);
-View2DGrid *UI_view2d_calc_grid(const struct bContext *C, struct View2D *v2d, int unit, int type, int winx, int winy);
+View2DGrid *UI_view2d_calc_grid(const struct bContext *C, struct View2D *v2d, short unit, short type, int winx, int winy);
void UI_view2d_draw_grid(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_free_grid(View2DGrid *grid);
void UI_view2d_draw_grid(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
void UI_view2d_free_grid(View2DGrid *grid);
/* coordinate conversion */
void UI_view2d_region_to_view(struct View2D *v2d, short x, short y, float *viewx, float *viewy);
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
/* utilities */
/* coordinate conversion */
void UI_view2d_region_to_view(struct View2D *v2d, short x, short y, float *viewx, float *viewy);
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
/* utilities */