You can move around a document with Click+Drag!
[ipdf/code.git] / src / main.h
index ee8076a..c7d5eca 100644 (file)
@@ -12,6 +12,31 @@ inline void MainLoop(Document & doc)
 {
        View view(doc);
        Screen scr;
+       scr.SetMouseHandler([&](int x, int y, int buttons, int wheel)
+       {
+               static bool oldButtonDown = false;
+               static int oldx, oldy;
+               if (buttons && !oldButtonDown)
+               {
+                       // We're beginning a drag.
+                       oldButtonDown = true;
+                       oldx = x;
+                       oldy = y;
+                       scr.SetMouseCursor(Screen::CursorMove);
+               }
+               if (buttons)
+               {
+                       view.Translate(Real(oldx-x)/Real(scr.ViewportWidth()), Real(oldy-y)/Real(scr.ViewportHeight()));
+               }
+               else
+               {
+                       oldButtonDown = false;
+                       scr.SetMouseCursor(Screen::CursorArrow);
+               }
+               oldx = x;
+               oldy = y;
+       }
+       );
        while (scr.PumpEvents())
        {
                view.Render();

UCC git Repository :: git.ucc.asn.au