4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation, Joshua Leung
27 * Generic 2d view with should allow drawing grids,
28 * panning, zooming, scrolling, ..
29 * ***** END GPL LICENSE BLOCK *****
35 /* ------------------------------------------ */
36 /* Settings and Defines: */
38 /* generic value to use when coordinate lies out of view when converting */
39 #define V2D_IS_CLIPPED 12000
41 /* 'dummy' argument to pass when argument is irrelevant */
42 #define V2D_ARG_DUMMY -1
45 /* grid-units (for drawing time) */
46 #define V2D_UNIT_SECONDS 0
47 #define V2D_UNIT_FRAMES 1
49 /* grid-units (for drawing values) */
50 #define V2D_UNIT_VALUES 2
51 #define V2D_UNIT_DEGREES 3
52 #define V2D_UNIT_TIME 4
53 #define V2D_UNIT_SECONDSSEQ 5
55 /* clamping of grid values to whole numbers */
56 #define V2D_GRID_NOCLAMP 0
57 #define V2D_GRID_CLAMP 1
60 /* flags for grid-lines to draw */
61 #define V2D_HORIZONTAL_LINES (1<<0)
62 #define V2D_VERTICAL_LINES (1<<1)
63 #define V2D_HORIZONTAL_AXIS (1<<2)
64 #define V2D_VERTICAL_AXIS (1<<3)
67 /* ------------------------------------------ */
70 /* test if mouse in a scrollbar */
71 #define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1]))
72 #define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1]))
74 /* ------------------------------------------ */
75 /* Type definitions: */
79 struct View2DScrollers;
81 struct wmWindowManager;
84 typedef struct View2DGrid View2DGrid;
85 typedef struct View2DScrollers View2DScrollers;
87 /* ----------------------------------------- */
90 /* refresh and validation (of view rects) */
91 void UI_view2d_size_update(struct View2D *v2d, int winx, int winy);
92 void UI_view2d_curRect_validate(struct View2D *v2d);
93 void UI_view2d_curRect_reset(struct View2D *v2d);
94 void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
96 /* view matrix operations */
97 void UI_view2d_view_ortho(const struct bContext *C, struct View2D *v2d);
98 void UI_view2d_view_orthoSpecial(const struct bContext *C, struct View2D *v2d, short xaxis);
99 void UI_view2d_view_restore(const struct bContext *C);
102 View2DGrid *UI_view2d_grid_calc(const struct bContext *C, struct View2D *v2d, short unit, short clamp, int winx, int winy);
103 void UI_view2d_grid_draw(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
104 void UI_view2d_grid_free(View2DGrid *grid);
106 /* scrollbar drawing */
107 View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
108 void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
109 void UI_view2d_scrollers_free(View2DScrollers *scrollers);
111 /* coordinate conversion */
112 void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
113 void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
114 void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
117 struct View2D *UI_view2d_fromcontext(const struct bContext *C);
118 struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
119 void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
120 void UI_view2d_header_default(struct View2D *v2d);
123 void ui_view2d_operatortypes(void);
124 void UI_view2d_keymap(struct wmWindowManager *wm);
126 #endif /* UI_VIEW2D_H */