36 files changed, 332 insertions, 176 deletions
diff --git a/src/controller/callbacks/mouse_wheel.c b/src/controller/callbacks/mouse_wheel.c new file mode 100644 index 0000000..52d3c8b --- a/dev/null +++ b/src/controller/callbacks/mouse_wheel.c @@ -0,0 +1,45 @@ +#include "mouse_wheel.h" +#include "../actions/zoom.h" +#include <GL/glut.h> + +void +mouse_wheel (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) + { + zoom (step, + step, + viewport[3] - step, + viewport[3] - step); + } + + // Zoom out + else + { + zoom (-step, + -step, + viewport[3] + step, + viewport[3] + step); + } + + return; +} |