summaryrefslogtreecommitdiff
path: root/apps
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
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')
-rw-r--r--apps/pdfapp.c50
-rw-r--r--apps/pdfapp.h7
2 files changed, 57 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;
}
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index feb0a8ce..f884f05a 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -69,6 +69,13 @@ struct pdfapp_s
int iscopying;
int selx, sely;
+ /* TODO - While sely keeps track of the relative change in
+ * cursor position between two ticks/events, beyondy shall keep
+ * track of the relative change in cursor position from the
+ * point where the user hits a scrolling limit. This is ugly.
+ * Used in pdfapp.c:pdfapp_onmouse.
+ */
+ int beyondy;
fz_bbox selr;
/* search state */