Allow VFPU to save output vcd file
[ipdf/code.git] / src / main.h
1 #include "common.h"
2
3 #include "document.h"
4 #include "view.h"
5 #include "screen.h"
6
7
8 using namespace std;
9 using namespace IPDF;
10
11 inline void MainLoop(Document & doc)
12 {
13         View view(doc);
14         Screen scr;
15         scr.SetMouseHandler([&](int x, int y, int buttons, int wheel)
16         {
17                 static bool oldButtonDown = false;
18                 static int oldx, oldy;
19                 if (buttons && !oldButtonDown)
20                 {
21                         // We're beginning a drag.
22                         oldButtonDown = true;
23                         oldx = x;
24                         oldy = y;
25                         scr.SetMouseCursor(Screen::CursorMove);
26                 }
27                 if (buttons)
28                 {
29                         view.Translate(Real(oldx-x)/Real(scr.ViewportWidth()), Real(oldy-y)/Real(scr.ViewportHeight()));
30                 }
31                 else
32                 {
33                         oldButtonDown = false;
34                         scr.SetMouseCursor(Screen::CursorArrow);
35                 }
36                 oldx = x;
37                 oldy = y;
38                 
39                 if (wheel)
40                 {
41                         view.ScaleAroundPoint(Real(x)/Real(scr.ViewportWidth()),Real(y)/Real(scr.ViewportHeight()), expf(-wheel/20.f));
42                 }
43         }
44         );
45         while (scr.PumpEvents())
46         {
47                 view.Render();
48                 scr.Present();
49         }
50 }

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