summaryrefslogtreecommitdiffstats
Side-by-side diff
-rw-r--r--src/Makefile.am4
-rw-r--r--src/controller/exp004mouse.c55
-rw-r--r--src/controller/mousewheel.c45
-rw-r--r--src/controller/mousewheel.h11
-rw-r--r--src/controller/performzoom.c65
-rw-r--r--src/controller/performzoom.h9
-rw-r--r--src/view/exp004view.c4
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 @@
+#include "mousewheel.h"
+#include "performzoom.h"
+#include <GL/glut.h>
+
+void
+mousewheel (int button, int dir, int x, int y)
+{
+ /*
+ * Get the current coordinates, substract some fixed amount and
+ * then perform the zoom.
+ */
+ GLint viewport[4];
+ glGetIntegerv (GL_VIEWPORT, viewport);
+
+ /*
+ * The step size could be either a fixed number of pixels or a percentage.
+ */
+ // int step = 5;
+ int step = (viewport[3] - viewport[1]) * 0.10;
+
+ /*
+ * Not that the focus of the zoom is currently the center of the
+ * window but could alternatively be the mouse pointer's position.
+ */
+
+ // Zoom in
+ if (dir > 0)
+ {
+ performzoom (step,
+ step,
+ viewport[3] - step,
+ viewport[3] - step);
+ }
+
+ // Zoom out
+ else
+ {
+ performzoom (-step,
+ -step,
+ viewport[3] + step,
+ viewport[3] + step);
+ }
+
+ return;
+}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.