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
You can move around a document with Click+Drag!
[ipdf/code.git]
/
src
/
main.h
diff --git
a/src/main.h
b/src/main.h
index
ee8076a
..
c7d5eca
100644
(file)
--- a/
src/main.h
+++ b/
src/main.h
@@
-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