summaryrefslogtreecommitdiff
path: root/apps/pdfapp.c
diff options
context:
space:
mode:
authorCedric Sodhi <manday@gmx.net>2011-05-23 16:01:02 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-05-26 20:28:39 +0200
commit89bf9896bd9d05500ac6494452a1b9d9cf8a67cb (patch)
treed28db9681b91c816360e2e1667869b098bfc8d4b /apps/pdfapp.c
parente0c00ccad1e67b0706e4337ad33e711ea069f58e (diff)
downloadmupdf-89bf9896bd9d05500ac6494452a1b9d9cf8a67cb.tar.xz
Flip pages when panning beyond threshhold.
Added BEYOND_TRESHHOLD for pdfapp and code which flips to next/previous page if one pans beyond the page end plus that threshhold.
Diffstat (limited to 'apps/pdfapp.c')
-rw-r--r--apps/pdfapp.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index f199f12e..c42ba856 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -6,6 +6,7 @@
#include <ctype.h> /* for tolower() */
#define ZOOMSTEP 1.142857
+#define BEYOND_THRESHHOLD 40
enum panning
{
@@ -987,6 +988,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
app->ispanning = 1;
app->selx = x;
app->sely = y;
+ app->beyondy = 0;
}
if (btn == 3 && !app->ispanning)
{
@@ -1048,7 +1050,55 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
{
int newx = app->panx + x - app->selx;
int newy = app->pany + y - app->sely;
+ /* Scrolling beyond limits implies flipping pages */
+ /* Are we requested to scroll beyond limits? */
+ if (newy + app->image->h < app->winh || newy > 0)
+ {
+ /* Yes. We can assume that deltay != 0 */
+ int deltay = y - app->sely;
+ /* Check whether the panning has occured in the
+ * direction that we are already crossing the
+ * limit it. If not, we can conclude that we
+ * have switched ends of the page and will thus
+ * start over counting.
+ */
+ if( app->beyondy == 0 || (app->beyondy ^ deltay) >= 0 )
+ {
+ /* Updating how far we are beyond and
+ * flipping pages if beyond threshhold
+ */
+ app->beyondy += deltay;
+ if (app->beyondy > BEYOND_THRESHHOLD)
+ {
+ if( app->pageno > 1 )
+ {
+ app->pageno--;
+ pdfapp_showpage(app, 1, 1, 1);
+ newy = -app->image->h;
+ }
+ app->beyondy = 0;
+ }
+ else if (app->beyondy < -BEYOND_THRESHHOLD)
+ {
+ if( app->pageno < app->pagecount )
+ {
+ app->pageno++;
+ pdfapp_showpage(app, 1, 1, 1);
+ newy = 0;
+ }
+ app->beyondy = 0;
+ }
+ }
+ else
+ app->beyondy = 0;
+ }
+ /* Although at this point we've already determined that
+ * or that no scrolling will be performed in
+ * y-direction, the x-direction has not yet been taken
+ * care off. Therefore
+ */
pdfapp_panview(app, newx, newy);
+
app->selx = x;
app->sely = y;
}