X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=inline;f=src%2Fscreen.cpp;h=d924c064dab55236814daa60ada129374d45a9bb;hb=e6c66a8e58f1dda071e6fc4abed39afe49d348f8;hp=6909be2acaa73c7be81148029a594d5135a93e1c;hpb=a6935331331de7f1d48b49bd688963039078e390;p=ipdf%2Fcode.git diff --git a/src/screen.cpp b/src/screen.cpp index 6909be2..d924c06 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -18,6 +18,8 @@ Screen::Screen() } m_gl_context = SDL_GL_CreateContext(m_window); + + ResizeViewport(800, 600); } @@ -55,6 +57,19 @@ bool Screen::PumpEvents() break; } break; + case SDL_MOUSEMOTION: + if (m_mouse_handler) + { + m_mouse_handler(evt.motion.x, evt.motion.y,evt.motion.state, 0); + } + break; + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + if (m_mouse_handler) + { + m_mouse_handler(evt.button.x, evt.button.y, evt.button.state, 0); + } + break; default: break; } @@ -62,6 +77,23 @@ bool Screen::PumpEvents() return no_quit_requested; } +void Screen::SetMouseCursor(Screen::MouseCursors cursor) +{ + SDL_SystemCursor system_cursor_id = SDL_SYSTEM_CURSOR_ARROW; + switch (cursor) + { + case CursorArrow: system_cursor_id = SDL_SYSTEM_CURSOR_ARROW; break; + case CursorWait: system_cursor_id = SDL_SYSTEM_CURSOR_WAIT; break; + case CursorWaitArrow: system_cursor_id = SDL_SYSTEM_CURSOR_WAITARROW; break; + case CursorMove: system_cursor_id = SDL_SYSTEM_CURSOR_SIZEALL; break; + case CursorHand: system_cursor_id = SDL_SYSTEM_CURSOR_HAND; break; + default: break; + } + SDL_Cursor *system_cursor = SDL_CreateSystemCursor(system_cursor_id); + SDL_SetCursor(system_cursor); + //TODO: Check if we need to free the system cursors. +} + void Screen::Present() { SDL_GL_SwapWindow(m_window);