X-Git-Url: https://git.blender.org/gitweb/gitweb.cgi/blender.git/blobdiff_plain/f7de8cee28ed1f26971728d18eb399fe85b86197..43b26b72ab0df5ff8bbdb7e30c761099b95385a6:/source/blender/editors/include/UI_view2d.h diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 7b5712b66de..1929e29bb4a 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -21,53 +21,90 @@ * All rights reserved. * * - * Contributor(s): Blender Foundation + * Contributor(s): Blender Foundation, Joshua Leung * + * + * Generic 2d view with should allow drawing grids, + * panning, zooming, scrolling, .. * ***** END GPL LICENSE BLOCK ***** */ #ifndef UI_VIEW2D_H #define UI_VIEW2D_H -/* 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 +/* --- Grids --- */ +/* grid-units (for drawing time) */ #define V2D_UNIT_SECONDS 0 #define V2D_UNIT_FRAMES 1 +/* clamping of grid values to whole numbers */ #define V2D_GRID_CLAMP 0 #define V2D_GRID_NOCLAMP 1 -#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: */ struct View2D; struct View2DGrid; +struct View2DScrollers; + +struct wmWindowManager; struct bContext; typedef struct View2DGrid View2DGrid; +typedef struct View2DScrollers View2DScrollers; + +/* ----------------------------------------- */ +/* Prototypes: */ /* setup */ void UI_view2d_ortho(const struct bContext *C, struct View2D *v2d); void UI_view2d_update_size(struct View2D *v2d, int winx, int winy); +void UI_view2d_enforce_status(struct View2D *v2d, int winx, int winy); /* grid drawing */ -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); +/* scrollbar drawing */ + +void UI_view2d_draw_scrollers(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers, int flag); +void UI_view2d_free_scrollbars(View2DScrollers *scrollers); + /* 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 */ -void UI_view2d_getscale(View2D *v2d, float *x, float *y); +void UI_view2d_getscale(struct View2D *v2d, float *x, float *y); + +/* operators */ +void ui_view2d_operatortypes(void); +void UI_view2d_keymap(struct wmWindowManager *wm); #endif /* UI_VIEW2D_H */