git.ucc.asn.au
/
ipdf
/
code.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Modify symlinks
[ipdf/code.git]
/
src
/
main.h
diff --git
a/src/main.h
b/src/main.h
index
ee8076a
..
2346119
100644
(file)
--- 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();
UCC
git Repository :: git.ucc.asn.au