diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-05-06 16:01:03 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-05-07 12:38:17 +0200 |
commit | 16629e9d6d4ceece77948513daa2e1d3e20d439b (patch) | |
tree | ef7be35711c70e031e81bae1acc6903a40bc164a /platform/x11 | |
parent | 2142cd1581faeed51c42cedb93e18352327b70b2 (diff) | |
download | mupdf-16629e9d6d4ceece77948513daa2e1d3e20d439b.tar.xz |
Fix 693313: increase the zoom range and use fixed steps.
Use an explicit list of resolutions for +/- zoom stepping.
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/pdfapp.c | 33 | ||||
-rw-r--r-- | platform/x11/pdfapp.h | 5 |
2 files changed, 27 insertions, 11 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) diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h index 6fb1f57f..0286f82d 100644 --- a/platform/x11/pdfapp.h +++ b/platform/x11/pdfapp.h @@ -10,8 +10,9 @@ * uses a number of callbacks to the GUI app. */ -#define MINRES 54 -#define MAXRES 300 +/* 25% .. 400% */ +#define MINRES 18 +#define MAXRES 288 typedef struct pdfapp_s pdfapp_t; |