Browse Source

Platform: added Sdl2Application::MouseEvent::clickCount().

pull/157/head
Vladimír Vondruš 10 years ago
parent
commit
e36b5e3517
  1. 4
      src/Magnum/Platform/Sdl2Application.cpp
  2. 10
      src/Magnum/Platform/Sdl2Application.h

4
src/Magnum/Platform/Sdl2Application.cpp

@ -374,13 +374,13 @@ void Sdl2Application::mainLoop() {
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: { case SDL_MOUSEBUTTONUP: {
MouseEvent e(static_cast<MouseEvent::Button>(event.button.button), {event.button.x, event.button.y}); MouseEvent e(static_cast<MouseEvent::Button>(event.button.button), {event.button.x, event.button.y}, event.button.clicks);
event.type == SDL_MOUSEBUTTONDOWN ? mousePressEvent(e) : mouseReleaseEvent(e); event.type == SDL_MOUSEBUTTONDOWN ? mousePressEvent(e) : mouseReleaseEvent(e);
} break; } break;
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
if(event.wheel.y != 0) { if(event.wheel.y != 0) {
MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}); MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}, 0);
mousePressEvent(e); mousePressEvent(e);
} break; } break;

10
src/Magnum/Platform/Sdl2Application.h

@ -1135,6 +1135,13 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
/** @brief Position */ /** @brief Position */
constexpr Vector2i position() const { return _position; } constexpr Vector2i position() const { return _position; }
/**
* @brief Click count
*
* Ignored for wheel events.
*/
constexpr Int clickCount() const { return _clickCount; }
/** /**
* @brief Modifiers * @brief Modifiers
* *
@ -1143,10 +1150,11 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
Modifiers modifiers(); Modifiers modifiers();
private: private:
constexpr MouseEvent(Button button, const Vector2i& position): _button{button}, _position{position}, _modifiersLoaded{false} {} constexpr MouseEvent(Button button, const Vector2i& position, Int clickCount): _button{button}, _position{position}, _clickCount{clickCount}, _modifiersLoaded{false} {}
const Button _button; const Button _button;
const Vector2i _position; const Vector2i _position;
const Int _clickCount;
bool _modifiersLoaded; bool _modifiersLoaded;
Modifiers _modifiers; Modifiers _modifiers;
}; };

Loading…
Cancel
Save