diff --git a/src/Platform/AbstractXApplication.h b/src/Platform/AbstractXApplication.h index 0921d2d6c..d1e61cf5d 100644 --- a/src/Platform/AbstractXApplication.h +++ b/src/Platform/AbstractXApplication.h @@ -257,9 +257,29 @@ class AbstractXApplication::InputEvent { Alt = Mod1Mask, /**< Alt */ AltGr = Mod5Mask, /**< AltGr */ - LeftButton = Button1Mask, /**< Left mouse button */ - MiddleButton = Button2Mask, /**< Middle mouse button */ - RightButton = Button3Mask, /**< Right mouse button */ + /** + * @copybrief Button::Left + * @deprecated Use @ref Magnum::Platform::AbstractXApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::AbstractXApplication::InputEvent::Button::Left "Button::Left" + * instead. + */ + LeftButton = Button1Mask, + + /** + * @copybrief Button::Middle + * @deprecated Use @ref Magnum::Platform::AbstractXApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::AbstractXApplication::InputEvent::Button::Middle "Button::Middle" + * instead. + */ + MiddleButton = Button2Mask, + + /** + * @copybrief Button::Right + * @deprecated Use @ref Magnum::Platform::AbstractXApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::AbstractXApplication::InputEvent::Button::Right "Button::Right" + * instead. + */ + RightButton = Button3Mask, CapsLock = LockMask, /**< Caps lock */ NumLock = Mod2Mask /**< Num lock */ @@ -272,6 +292,24 @@ class AbstractXApplication::InputEvent { */ typedef Containers::EnumSet Modifiers; + /** + * @brief Mouse button + * + * @see @ref Buttons, @ref buttons() + */ + enum class Button: unsigned int { + Left = Button1Mask, /**< Left button */ + Middle = Button2Mask, /**< Middle button */ + Right = Button3Mask /**< Right button */ + }; + + /** + * @brief Set of mouse buttons + * + * @see @ref buttons() + */ + typedef Containers::EnumSet Buttons; + /** @copydoc GlutApplication::InputEvent::setAccepted() */ void setAccepted(bool accepted = true) { _accepted = accepted; } @@ -281,6 +319,9 @@ class AbstractXApplication::InputEvent { /** @brief Modifiers */ constexpr Modifiers modifiers() const { return _modifiers; } + /** @brief Mouse buttons */ + constexpr Buttons buttons() const { return Button(static_cast(_modifiers)); } + #ifndef DOXYGEN_GENERATING_OUTPUT protected: constexpr InputEvent(Modifiers modifiers): _modifiers(modifiers), _accepted(false) {} @@ -294,6 +335,7 @@ class AbstractXApplication::InputEvent { }; CORRADE_ENUMSET_OPERATORS(AbstractXApplication::InputEvent::Modifiers) +CORRADE_ENUMSET_OPERATORS(AbstractXApplication::InputEvent::Buttons) /** @brief Key event diff --git a/src/Platform/NaClApplication.h b/src/Platform/NaClApplication.h index 632232c02..53d76ab07 100644 --- a/src/Platform/NaClApplication.h +++ b/src/Platform/NaClApplication.h @@ -372,9 +372,29 @@ class NaClApplication::InputEvent { Alt = PP_INPUTEVENT_MODIFIER_ALTKEY, /**< Alt */ Meta = PP_INPUTEVENT_MODIFIER_METAKEY, /**< Meta */ - LeftButton = PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, /**< Left mouse button */ - MiddleButton = PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, /**< Middle mouse button */ - RightButton = PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN, /**< Right mouse button */ + /** + * @copybrief Button::Left + * @deprecated Use @ref Magnum::Platform::NaClApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::NaClApplication::InputEvent::Button::Left "Button::Left" + * instead. + */ + LeftButton = PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, + + /** + * @copybrief Button::Middle + * @deprecated Use @ref Magnum::Platform::NaClApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::NaClApplication::InputEvent::Button::Middle "Button::Middle" + * instead. + */ + MiddleButton = PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, + + /** + * @copybrief Button::Right + * @deprecated Use @ref Magnum::Platform::NaClApplication::InputEvent::buttons() "buttons()" + * and @ref Magnum::Platform::NaClApplication::InputEvent::Button::Right "Button::Right" + * instead. + */ + RightButton = PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN, CapsLock = PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY, /**< Caps lock */ NumLock = PP_INPUTEVENT_MODIFIER_NUMLOCKKEY /**< Num lock */ @@ -387,9 +407,30 @@ class NaClApplication::InputEvent { */ typedef Containers::EnumSet Modifiers; + /** + * @brief Mouse button + * + * @see @ref Buttons, @ref buttons() + */ + enum class Button: std::uint32_t { + Left = PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, /**< Left button */ + Middle = PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, /**< Middle button */ + Right = PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN /**< Right button */ + }; + + /** + * @brief Set of mouse buttons + * + * @see @ref buttons() + */ + typedef Containers::EnumSet Buttons; + /** @brief Modifiers */ constexpr Modifiers modifiers() const { return _modifiers; } + /** @brief Mouse buttons */ + constexpr Buttons buttons() const { return Buttons(_modifiers); } + /** * @brief Set event as accepted * @@ -613,6 +654,7 @@ typedef NaClApplication Application; #endif CORRADE_ENUMSET_OPERATORS(NaClApplication::InputEvent::Modifiers) +CORRADE_ENUMSET_OPERATORS(NaClApplication::InputEvent::Buttons) /* Implementations for inline functions with unused parameters */ inline void NaClApplication::keyPressEvent(KeyEvent&) {}