Browse Source

Platform: added Sdl2Application::multiGestureEvent().

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

7
src/Magnum/Platform/Sdl2Application.cpp

@ -390,6 +390,12 @@ void Sdl2Application::mainLoop() {
break;
}
case SDL_MULTIGESTURE: {
MultiGestureEvent e({event.mgesture.x, event.mgesture.y}, event.mgesture.dTheta, event.mgesture.dDist, event.mgesture.numFingers);
multiGestureEvent(e);
break;
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
case SDL_TEXTINPUT: {
TextInputEvent e{{event.text.text, std::strlen(event.text.text)}};
@ -476,6 +482,7 @@ void Sdl2Application::keyReleaseEvent(KeyEvent&) {}
void Sdl2Application::mousePressEvent(MouseEvent&) {}
void Sdl2Application::mouseReleaseEvent(MouseEvent&) {}
void Sdl2Application::mouseMoveEvent(MouseMoveEvent&) {}
void Sdl2Application::multiGestureEvent(MultiGestureEvent&) {}
void Sdl2Application::textInputEvent(TextInputEvent&) {}
void Sdl2Application::textEditingEvent(TextEditingEvent&) {}

83
src/Magnum/Platform/Sdl2Application.h

@ -331,6 +331,7 @@ class Sdl2Application {
class KeyEvent;
class MouseEvent;
class MouseMoveEvent;
class MultiGestureEvent;
class TextInputEvent;
class TextEditingEvent;
@ -583,6 +584,19 @@ class Sdl2Application {
/*@}*/
/** @{ @name Touch gesture handling */
/**
* @brief Multi gesture event
*
* Called when the user performs a gesture using multiple fingers.
* Default implementation does nothing.
* @experimental
*/
virtual void multiGestureEvent(MultiGestureEvent& event);
/*@}*/
/** @{ @name Text input handling */
public:
/**
@ -1210,6 +1224,75 @@ class Sdl2Application::MouseMoveEvent: public Sdl2Application::InputEvent {
Modifiers _modifiers;
};
/**
@brief Multi gesture event
@experimental
@see @ref multiGestureEvent()
*/
class Sdl2Application::MultiGestureEvent {
friend Sdl2Application;
public:
/** @brief Copying is not allowed */
MultiGestureEvent(const MultiGestureEvent&) = delete;
/** @brief Moving is not allowed */
MultiGestureEvent(MultiGestureEvent&&) = delete;
/** @brief Copying is not allowed */
MultiGestureEvent& operator=(const MultiGestureEvent&) = delete;
/** @brief Moving is not allowed */
MultiGestureEvent& operator=(MultiGestureEvent&&) = delete;
/** @brief Whether the event is accepted */
constexpr bool isAccepted() const { return _accepted; }
/**
* @brief Set event as accepted
*
* If the event is ignored (i.e., not set as accepted), it might be
* propagated elsewhere, for example to another screen when using
* @ref BasicScreenedApplication "ScreenedApplication". By default is
* each event ignored and thus propagated.
*/
void setAccepted(bool accepted = true) { _accepted = accepted; }
/** @brief Gesture center */
Vector2 center() const { return _center; }
/**
* @brief Relative rotation
*
* Rotation relative to previous event.
*/
Float relativeRotation() const { return _relativeRotation; }
/**
* @brief Relative distance
*
* Distance of the fingers relative to previous event.
*/
Float relativeDistance() const { return _relativeDistance; }
/**
* @brief Finger count
*
* Count of fingers performing the gesture.
*/
Int fingerCount() const { return _fingerCount; }
private:
constexpr MultiGestureEvent(const Vector2& center, Float relativeRotation, Float relativeDistance, Int fingerCount): _center{center}, _relativeRotation{relativeRotation}, _relativeDistance{relativeDistance}, _fingerCount{fingerCount}, _accepted{false} {}
Vector2 _center;
Float _relativeRotation,
_relativeDistance;
Int _fingerCount;
bool _accepted;
};
/**
@brief Text input event

Loading…
Cancel
Save