Fix RealToFloat test (hopefully)
[ipdf/code.git] / src / screen.h
1 #ifndef _SCREEN_H
2 #define _SCREEN_H
3
4 #include <SDL.h>
5
6 #include <functional>
7
8 namespace IPDF
9 {
10         /*
11          * The "Screen" class handles managing the OS window (using SDL2).
12          */
13         class Screen
14         {
15         public:
16                 Screen();
17                 ~Screen();
18
19                 // 'Pumps' the system event queue.
20                 // Returns 'false' if the program should quit.
21                 bool PumpEvents();
22
23                 // Finishes rendering a frame, and presents it on the screen.
24                 void Present();
25
26                 // Get the current width/height of the window's viewport.
27                 int ViewportWidth() { return m_viewport_width; }
28                 int ViewportHeight() { return m_viewport_height; }
29                 
30                 // Handle mouse input.
31                 typedef std::function<void(int x, int y, int button, int wheel)> MouseHandler;
32                 void SetMouseHandler(MouseHandler handler)
33                 {
34                         m_mouse_handler = handler;
35                 }
36                 
37                 enum MouseCursors
38                 {
39                         CursorArrow,
40                         CursorWait,
41                         CursorWaitArrow,
42                         CursorMove,
43                         CursorHand
44                 };
45                 void SetMouseCursor(MouseCursors cursor);
46         private:
47                 void ResizeViewport(int width, int height);
48                 
49                 MouseHandler m_mouse_handler;
50                 int m_last_mouse_x;
51                 int m_last_mouse_y;
52
53                 int m_viewport_width;
54                 int m_viewport_height;
55                 SDL_Window *m_window;
56                 SDL_GLContext m_gl_context;
57         };
58
59 }
60
61 #endif // _SCREEN_H

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