Browse Source

Platform: implement fake GlutApplication::MouseMoveEvent::buttons().

The event is called only if any button is pressed, added Button::Left
which is always present. This is just for source compatibility with
other Application implementations.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
f15609bc3d
  1. 2
      src/Platform/GlutApplication.cpp
  2. 28
      src/Platform/GlutApplication.h

2
src/Platform/GlutApplication.cpp

@ -104,7 +104,7 @@ void GlutApplication::staticMouseEvent(int button, int state, int x, int y) {
}
void GlutApplication::staticMouseMoveEvent(int x, int y) {
MouseMoveEvent e({x, y});
MouseMoveEvent e({x, y}, MouseMoveEvent::Button::Left);
instance->mouseMoveEvent(e);
}

28
src/Platform/GlutApplication.h

@ -462,13 +462,37 @@ class GlutApplication::MouseMoveEvent: public GlutApplication::InputEvent {
friend class GlutApplication;
public:
/**
* @brief Mouse button
*
* @see Buttons, buttons()
*/
enum class Button: UnsignedByte {
/**
* Any button. Note that GLUT doesn't differentiate between mouse
* buttons when firing the event.
*/
Left = 1
};
/**
* @brief Set of mouse buttons
*
* @see buttons()
*/
typedef Containers::EnumSet<Button, UnsignedByte> Buttons;
/** @brief Position */
constexpr Vector2i position() const { return _position; }
/** @brief Mouse buttons */
constexpr Buttons buttons() { return _buttons; }
private:
constexpr MouseMoveEvent(const Vector2i& position): _position(position) {}
constexpr MouseMoveEvent(const Vector2i& position, Buttons buttons): _position(position), _buttons(buttons) {}
const Vector2i _position;
const Buttons _buttons;
};
/** @hideinitializer
@ -502,6 +526,8 @@ typedef GlutApplication Application;
#endif
#endif
CORRADE_ENUMSET_OPERATORS(GlutApplication::MouseMoveEvent::Buttons)
/* Implementations for inline functions with unused parameters */
inline void GlutApplication::keyPressEvent(KeyEvent&) {}
inline void GlutApplication::mousePressEvent(MouseEvent&) {}

Loading…
Cancel
Save