From: Carl Worth Date: Thu, 7 Nov 2013 04:34:43 +0000 (-0800) Subject: Zoom and pan a bit less with each keypress X-Git-Url: https://git.cworth.org/git?p=acre;a=commitdiff_plain;h=12b6b0f6a439c7838daac5e2a1e5764bd0218936 Zoom and pan a bit less with each keypress This makes it a bit smoother and less jumpy for better control. --- diff --git a/acre-x.c b/acre-x.c index c1f7c41..e89c7fc 100644 --- a/acre-x.c +++ b/acre-x.c @@ -120,6 +120,8 @@ handle_events(Display *dpy, Window window, Visual *visual, draw (dpy, window, visual, acre, width, height, x_min, x_max); +#define PAN 0.05 +#define ZOOM PAN XNextEvent (dpy, &xev); switch (xev.type) { case KeyPress: @@ -130,26 +132,26 @@ handle_events(Display *dpy, Window window, Visual *visual, } else if (keycode == left_code) { - shift = 0.25 * (x_max - x_min); + shift = PAN * (x_max - x_min); x_min += shift; x_max += shift; } else if (keycode == right_code) { - shift = 0.25 * (x_max - x_min); + shift = PAN * (x_max - x_min); x_min -= shift; x_max -= shift; } else if (keycode == plus_code || keycode == equal_code) { - shift = 0.25 * (x_max - x_min); + shift = ZOOM * (x_max - x_min); x_min += shift; x_max -= shift; } else if (keycode == minus_code) { - shift = 0.5 * (x_max - x_min); + shift = (1- 2*ZOOM) * (x_max - x_min); x_min -= shift; x_max += shift; }