libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
mouseevent.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/core/event.h>
11#include <promeki/core/string.h>
12#include <promeki/core/point.h>
13
15
23class MouseEvent : public Event {
24 public:
26 static const Type Mouse;
27
29 enum Button : uint8_t {
30 NoButton = 0x00,
31 LeftButton = 0x01,
32 MiddleButton = 0x02,
33 RightButton = 0x04
34 };
35
37 enum Action : uint8_t {
38 Press,
39 Release,
40 Move,
41 DoubleClick,
42 ScrollUp,
43 ScrollDown
44 };
45
48 NoModifier = 0x00,
49 ShiftModifier = 0x01,
50 CtrlModifier = 0x02,
51 AltModifier = 0x04,
52 MetaModifier = 0x08
53 };
54
64 uint8_t modifiers = NoModifier, uint8_t buttons = 0)
65 : Event(Mouse), _pos(pos), _button(button),
66 _action(action), _modifiers(modifiers), _buttons(buttons) {}
67
69 const Point2Di32 &pos() const { return _pos; }
70
72 int x() const { return _pos.x(); }
73
75 int y() const { return _pos.y(); }
76
78 Button button() const { return _button; }
79
81 Action action() const { return _action; }
82
84 uint8_t modifiers() const { return _modifiers; }
85
87 uint8_t buttons() const { return _buttons; }
88
91
94
97
98 private:
99 Point2Di32 _pos;
100 Button _button;
101 Action _action;
102 uint8_t _modifiers;
103 uint8_t _buttons = 0;
104};
105
Base class for the event system.
Definition event.h:29
Dynamic array container wrapping std::vector.
Definition list.h:40
Event delivered for mouse input.
Definition mouseevent.h:23
uint8_t buttons() const
Returns the bitmask of all currently pressed buttons.
Definition mouseevent.h:87
uint8_t modifiers() const
Returns the modifier flags.
Definition mouseevent.h:84
const Point2Di32 & pos() const
Returns the mouse position (column, row).
Definition mouseevent.h:69
static const Type Mouse
Event type ID for MouseEvent.
Definition mouseevent.h:26
static String buttonName(Button button)
Returns a human-readable name for the given button.
MouseEvent(const Point2Di32 &pos, Button button, Action action, uint8_t modifiers=NoModifier, uint8_t buttons=0)
Constructs a MouseEvent.
Definition mouseevent.h:63
static String buttonsString(uint8_t buttons)
Returns a human-readable string for a button bitmask (e.g. "Left Right").
Button
Mouse button flags (bit values for combining).
Definition mouseevent.h:29
Modifier
Modifier flags (same as KeyEvent).
Definition mouseevent.h:47
int x() const
Returns the X coordinate (column).
Definition mouseevent.h:72
Action
Mouse action enumeration.
Definition mouseevent.h:37
int y() const
Returns the Y coordinate (row).
Definition mouseevent.h:75
Action action() const
Returns the mouse action.
Definition mouseevent.h:81
Button button() const
Returns the mouse button.
Definition mouseevent.h:78
static String actionName(Action action)
Returns a human-readable name for the given action.
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19