From 9d63f35279a26ee94270351c7d2dd9af4318949e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Aug 2012 12:58:05 +0200 Subject: [PATCH] Sdl2Context: split mouseEvent to mousePressEvent and mouseReleaseEvent. Preserving consistency with GlutContext and *XContext. --- src/Contexts/Sdl2Context.cpp | 6 +++--- src/Contexts/Sdl2Context.h | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Contexts/Sdl2Context.cpp b/src/Contexts/Sdl2Context.cpp index 91f21c36c..f55fa6125 100644 --- a/src/Contexts/Sdl2Context.cpp +++ b/src/Contexts/Sdl2Context.cpp @@ -83,10 +83,10 @@ int Sdl2Context::exec() { keyReleaseEvent(static_cast(event.key.keysym.sym)); break; case SDL_MOUSEBUTTONDOWN: + mousePressEvent(static_cast(event.button.button), {event.button.x, event.button.y}); + break; case SDL_MOUSEBUTTONUP: - mouseEvent(static_cast(event.button.button), - static_cast(event.button.state), - {event.button.x, event.button.y}); + mouseReleaseEvent(static_cast(event.button.button), {event.button.x, event.button.y}); break; case SDL_MOUSEWHEEL: mouseWheelEvent({event.wheel.x, event.wheel.y}); diff --git a/src/Contexts/Sdl2Context.h b/src/Contexts/Sdl2Context.h index da4024055..112b434b8 100644 --- a/src/Contexts/Sdl2Context.h +++ b/src/Contexts/Sdl2Context.h @@ -133,15 +133,24 @@ class Sdl2Context: public AbstractContext { protected: /** - * @brief Mouse event - * @param button Mouse button - * @param state Mouse state - * @param position Mouse position relative to the window + * @brief Mouse press event + * @param button Button pressed + * @param position Cursor position * - * Called when mouse button is pressed or released. Default - * implementation does nothing. + * Called when mouse button is pressed. Default implementation does + * nothing. + */ + virtual void mousePressEvent(MouseButton button, const Math::Vector2& position); + + /** + * @brief Mouse release event + * @param button Button released + * @param position Cursor position + * + * Called when mouse button is released. Default implementation does + * nothing. */ - virtual void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position); + virtual void mouseReleaseEvent(MouseButton button, const Math::Vector2& position); /** * @brief Mouse wheel event @@ -174,7 +183,8 @@ class Sdl2Context: public AbstractContext { /* Implementations for inline functions with unused parameters */ inline void Sdl2Context::keyPressEvent(Key, Uint8) {} inline void Sdl2Context::keyReleaseEvent(Key) {} -inline void Sdl2Context::mouseEvent(MouseButton, MouseState, const Math::Vector2&) {} +inline void Sdl2Context::mousePressEvent(MouseButton, const Math::Vector2&) {} +inline void Sdl2Context::mouseReleaseEvent(MouseButton, const Math::Vector2&) {} inline void Sdl2Context::mouseWheelEvent(const Math::Vector2&) {} inline void Sdl2Context::mouseMotionEvent(const Math::Vector2&, const Math::Vector2&) {}