]> git.cworth.org Git - acre/commitdiff
Zoom and pan a bit less with each keypress
authorCarl Worth <cworth@cworth.org>
Thu, 7 Nov 2013 04:34:43 +0000 (20:34 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 7 Nov 2013 04:34:43 +0000 (20:34 -0800)
This makes it a bit smoother and less jumpy for better control.

acre-x.c

index c1f7c414f42ef26b74cdb563d8ace4aba7e9dd67..e89c7fcf285f556d1b402a245cd3f43f42f57f1a 100644 (file)
--- 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;
                        }