Implement Pointless Broken Things
[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() const { return m_viewport_width; }
28                 int ViewportHeight() const { 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
47                 void ScreenShot(const char * filename) const;
48                 void RenderBMP(const char * filename) const;
49         private:
50                 void ResizeViewport(int width, int height);
51                 
52                 MouseHandler m_mouse_handler;
53                 int m_last_mouse_x;
54                 int m_last_mouse_y;
55
56                 int m_viewport_width;
57                 int m_viewport_height;
58                 SDL_Window *m_window;
59                 SDL_GLContext m_gl_context;
60         };
61
62 }
63
64 #endif // _SCREEN_H

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