X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.h;h=6b52a094730c06e6f089efe1e5244554095a2d37;hp=a034d2a12a0309c502865a5bf395d49f1527a30a;hb=6dd539966821debd18e0b86ed126742cd81d7fc9;hpb=8942bd699d8e1ddede1127421ad18bed53232ff3 diff --git a/src/screen.h b/src/screen.h index a034d2a..6b52a09 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,7 @@ #ifndef _SCREEN_H #define _SCREEN_H -#include +#include "SDL.h" #include @@ -11,6 +11,7 @@ namespace IPDF { + class View; /* * The "Screen" class handles managing the OS window (using SDL2). */ @@ -41,7 +42,7 @@ namespace IPDF void DebugFontPrintF(const char *fmt, ...); // Handle mouse input. - typedef std::function MouseHandler; + typedef void(*MouseHandler)(int x, int y, int button, int wheel, Screen * scr, View * view); void SetMouseHandler(MouseHandler handler) { m_mouse_handler = handler; @@ -62,10 +63,15 @@ namespace IPDF void RenderPixels(int x, int y, int w, int h, uint8_t * pixels) const; + void SetView(View * new_view) {m_view = new_view;} + // Returns the CPU time (in seconds) it took to render the last completed frame. double GetLastFrameTimeCPU() const { return m_last_frame_time / SDL_GetPerformanceFrequency(); } // Returns the GPU time (in seconds) it took to render the last completed frame. double GetLastFrameTimeGPU() const; + + void RequestQuit() {m_no_quit_requested = false;} + bool QuitRequested() const {return !m_no_quit_requested;} private: void ResizeViewport(int width, int height); void DebugFontFlush(); @@ -96,6 +102,8 @@ namespace IPDF GraphicsBuffer m_debug_font_indices; int m_debug_font_vertex_head; int m_debug_font_index_head; + View * m_view; + bool m_no_quit_requested; }; }