X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fmain.h;h=234611920c903c43249126d898fcaaf0a4a17af5;hb=c0f947a6ce10a329eec81e4df820ac52f7ab371f;hp=ee8076aee26d7fb4d98f0b3f4c7083bfc948046e;hpb=42737c4c096f6469fb27e261806b48338a8f672f;p=ipdf%2Fcode.git diff --git a/src/main.h b/src/main.h index ee8076a..2346119 100644 --- a/src/main.h +++ b/src/main.h @@ -12,6 +12,36 @@ 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; + + if (wheel) + { + view.ScaleAroundPoint(Real(x)/Real(scr.ViewportWidth()),Real(y)/Real(scr.ViewportHeight()), expf(-wheel/20.f)); + } + } + ); while (scr.PumpEvents()) { view.Render();