diff options
Diffstat (limited to 'platform/x11/pdfapp.c')
-rw-r--r-- | platform/x11/pdfapp.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index c59d44d0..8f5b09ac 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -3,7 +3,6 @@ #include <ctype.h> /* for tolower() */ -#define ZOOMSTEP 1.142857 #define BEYOND_THRESHHOLD 40 #ifndef PATH_MAX #define PATH_MAX (1024) @@ -29,6 +28,26 @@ enum static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repaint, int transition, int searching); static void pdfapp_updatepage(pdfapp_t *app); +static const int zoomlist[] = { 18, 24, 36, 54, 72, 96, 120, 144, 180, 216, 288 }; + +static int zoom_in(int oldres) +{ + int i; + for (i = 0; i < nelem(zoomlist) - 1; ++i) + if (zoomlist[i] <= oldres && zoomlist[i+1] > oldres) + return zoomlist[i+1]; + return zoomlist[i]; +} + +static int zoom_out(int oldres) +{ + int i; + for (i = 0; i < nelem(zoomlist) - 1; ++i) + if (zoomlist[i] < oldres && zoomlist[i+1] >= oldres) + return zoomlist[i]; + return zoomlist[0]; +} + static void pdfapp_warn(pdfapp_t *app, const char *fmt, ...) { char buf[1024]; @@ -1038,15 +1057,11 @@ void pdfapp_onkey(pdfapp_t *app, int c) case '+': case '=': - app->resolution *= ZOOMSTEP; - if (app->resolution > MAXRES) - app->resolution = MAXRES; + app->resolution = zoom_in(app->resolution); pdfapp_showpage(app, 0, 1, 1, 0, 0); break; case '-': - app->resolution /= ZOOMSTEP; - if (app->resolution < MINRES) - app->resolution = MINRES; + app->resolution = zoom_out(app->resolution); pdfapp_showpage(app, 0, 1, 1, 0, 0); break; @@ -1508,9 +1523,9 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta { /* zoom in/out if ctrl is pressed */ if (dir > 0) - app->resolution *= ZOOMSTEP; + app->resolution = zoom_in(app->resolution); else - app->resolution /= ZOOMSTEP; + app->resolution = zoom_out(app->resolution); if (app->resolution > MAXRES) app->resolution = MAXRES; if (app->resolution < MINRES) |