Browse Source

Platform: implemented GlfwApplication::MouseMoveEvent::buttons().

Improves feature parity with Sdl2Application.
pull/191/head
Vladimír Vondruš 8 years ago
parent
commit
80e682d046
  1. 5
      doc/changelog.dox
  2. 14
      src/Magnum/Platform/GlfwApplication.cpp
  3. 26
      src/Magnum/Platform/GlfwApplication.h

5
doc/changelog.dox

@ -55,6 +55,11 @@ See also:
- Ability to convert @ref Math::BoolVector from and to external - Ability to convert @ref Math::BoolVector from and to external
representation representation
@subsubsection changelog-latest-new-platform Platform libraries
- Implemented @ref Platform::GlfwApplication::MouseMoveEvent::buttons() for
feature parity with @ref Platform::Sdl2Application
@subsection changelog-latest-changes Changes and improvements @subsection changelog-latest-changes Changes and improvements
@subsubsection changelog-latest-changes-audio Audio library @subsubsection changelog-latest-changes-audio Audio library

14
src/Magnum/Platform/GlfwApplication.cpp

@ -395,6 +395,20 @@ void GlfwApplication::staticKeyEvent(GLFWwindow* const window, const int key, in
} }
} }
auto GlfwApplication::MouseMoveEvent::buttons() -> Buttons {
if(!_buttons) {
_buttons = Buttons{};
for(const Int button: {GLFW_MOUSE_BUTTON_LEFT,
GLFW_MOUSE_BUTTON_MIDDLE,
GLFW_MOUSE_BUTTON_RIGHT}) {
if(glfwGetMouseButton(_window, button) == GLFW_PRESS)
*_buttons |= Button(1 << button);
}
}
return *_buttons;
}
auto GlfwApplication::MouseMoveEvent::modifiers() -> Modifiers { auto GlfwApplication::MouseMoveEvent::modifiers() -> Modifiers {
if(!_modifiers) _modifiers = currentGlfwModifiers(_window); if(!_modifiers) _modifiers = currentGlfwModifiers(_window);
return *_modifiers; return *_modifiers;

26
src/Magnum/Platform/GlfwApplication.h

@ -1193,6 +1193,31 @@ class GlfwApplication::MouseMoveEvent: public GlfwApplication::InputEvent {
friend GlfwApplication; friend GlfwApplication;
public: public:
/**
* @brief Mouse button
*
* @see @ref Buttons, @ref buttons()
*/
enum class Button: UnsignedInt {
Left = 1 << GLFW_MOUSE_BUTTON_LEFT, /**< Left button */
Middle = 1 << GLFW_MOUSE_BUTTON_MIDDLE, /**< Middle button */
Right = 1 << GLFW_MOUSE_BUTTON_RIGHT /**< Right button */
};
/**
* @brief Set of mouse buttons
*
* @see @ref buttons()
*/
typedef Containers::EnumSet<Button> Buttons;
/**
* @brief Mouse buttons
*
* Lazily populated on first request.
*/
Buttons buttons();
/** @brief Position */ /** @brief Position */
Vector2i position() const { return _position; } Vector2i position() const { return _position; }
@ -1207,6 +1232,7 @@ class GlfwApplication::MouseMoveEvent: public GlfwApplication::InputEvent {
explicit MouseMoveEvent(GLFWwindow* window, const Vector2i& position): _window{window}, _position{position} {} explicit MouseMoveEvent(GLFWwindow* window, const Vector2i& position): _window{window}, _position{position} {}
GLFWwindow* _window; GLFWwindow* _window;
Containers::Optional<Buttons> _buttons;
const Vector2i _position; const Vector2i _position;
Containers::Optional<Modifiers> _modifiers; Containers::Optional<Modifiers> _modifiers;
}; };

Loading…
Cancel
Save