-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/controller/exp004mouse.c | 55 | ||||
-rw-r--r-- | src/controller/mousewheel.c | 45 | ||||
-rw-r--r-- | src/controller/mousewheel.h | 11 | ||||
-rw-r--r-- | src/controller/performzoom.c | 65 | ||||
-rw-r--r-- | src/controller/performzoom.h | 9 | ||||
-rw-r--r-- | src/view/exp004view.c | 4 |
7 files changed, 149 insertions, 44 deletions
diff --git a/src/controller/mousewheel.c b/src/controller/mousewheel.c new file mode 100644 index 0000000..c9ac742 --- a/dev/null +++ b/src/controller/mousewheel.c | |||
@@ -0,0 +1,45 @@ | |||
1 | #include "mousewheel.h" | ||
2 | #include "performzoom.h" | ||
3 | #include <GL/glut.h> | ||
4 | |||
5 | void | ||
6 | mousewheel (int button, int dir, int x, int y) | ||
7 | { | ||
8 | /* | ||
9 | * Get the current coordinates, substract some fixed amount and | ||
10 | * then perform the zoom. | ||
11 | */ | ||
12 | GLint viewport[4]; | ||
13 | glGetIntegerv (GL_VIEWPORT, viewport); | ||
14 | |||
15 | /* | ||
16 | * The step size could be either a fixed number of pixels or a percentage. | ||
17 | */ | ||
18 | // int step = 5; | ||
19 | int step = (viewport[3] - viewport[1]) * 0.10; | ||
20 | |||
21 | /* | ||
22 | * Not that the focus of the zoom is currently the center of the | ||
23 | * window but could alternatively be the mouse pointer's position. | ||
24 | */ | ||
25 | |||
26 | // Zoom in | ||
27 | if (dir > 0) | ||
28 | { | ||
29 | performzoom (step, | ||
30 | step, | ||
31 | viewport[3] - step, | ||
32 | viewport[3] - step); | ||
33 | } | ||
34 | |||
35 | // Zoom out | ||
36 | else | ||
37 | { | ||
38 | performzoom (-step, | ||
39 | -step, | ||
40 | viewport[3] + step, | ||
41 | viewport[3] + step); | ||
42 | } | ||
43 | |||
44 | return; | ||
45 | } | ||