sculpto
mouse_event.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file mouse_event.h
3 * \brief Mouse actions events (buttons click, move, wheel) events implementation module.
4 *
5 * \author Sabitov Kirill
6 * \date 25 June 2022
7 *********************************************************************/
8
9#pragma once
10
12
13namespace scl
14{
15 enum class mouse_button
16 {
17#ifdef SCL_PLATFORM_WINDOWS
18 NONE = 0,
19 LEFT = 1,
20 RIGHT = 2,
21 MIDDLE = 16,
22#else
23 LEFT = 0,
24 RIGHT = 1,
25 MIDDLE = 2,
26#endif
27 };
28
31 {
32 SCL_MAKE_EVENT(MouseButton);
33
34 private:
35 bool Pressed;
36 int X, Y;
37 mouse_button KeyCode;
38
39 public:
40 /*!*
41 * Mouse button click default constructor..
42 *
43 * \param Pressed - is mouse key pressed or released flag.
44 * \param DbClick - is button pressecd second time in a row flag.
45 * \param X - mouse x position.
46 * \param Y - mouse y possition.
47 * \param KeyCode - mouse button code.
48 */
49 mouse_button_event(bool Pressed, int X, int Y, mouse_button KeyCode) :
50 Pressed(Pressed), X(X), Y(Y), KeyCode(KeyCode) {}
51
53 bool GetPressed() { return Pressed; }
55 int GetX() { return X; }
57 int GetY() { return Y; }
59 mouse_button GetKeyCode() { return KeyCode; }
60
61 /*!*
62 * Convert event to string (for debug).
63 *
64 * \param None.
65 * \return string representation of event.
66 */
67 inline std::string ToString() const override
68 {
69 std::stringstream ss;
70 ss << GetName() << ": Pressed? - " << Pressed
71 << ", (X, Y) - (" << X << ", " << Y << "), KeyCode - " << (int)KeyCode;
72 return ss.str();
73 }
74 };
75
78 {
79 SCL_MAKE_EVENT(MouseWheel);
80
81 private :
82 int WheelPosDelta;
83
84 public:
85 /*!*
86 * Mouse wheel scroll event default constructor.
87 *
88 * \param WheelPos - mouse wheel position delta.
89 */
90 mouse_wheel_event(int WheelPosDelta) :
91 WheelPosDelta(WheelPosDelta) {}
92
94 int GetWheelPos() { return WheelPosDelta; }
95
96 /*!*
97 * Convert event to string (for debug).
98 *
99 * \param None.
100 * \return string representation of event.
101 */
102 inline std::string ToString() const override
103 {
104 std::stringstream ss;
105 ss << GetName() << ": Wheel position delta - " << WheelPosDelta;
106 return ss.str();
107 }
108 };
109
112 {
113 SCL_MAKE_EVENT(MouseMove);
114
115 private:
116 int X, Y;
117 bool RButton, LButton, MButton;
118 bool Shift, Control;
119
120 public:
121 /*!*
122 * Mouse move event deault constructor..
123 *
124 * \param X - mouse x possition.
125 * \param Y - mouse y possition.
126 * \param RButton - mouse right button state.
127 * \param LButton - mouse left button state.
128 * \param MButton - mouse middle button state.
129 * \param Shift - shift key state.
130 * \param Control - contrl key state.
131 */
132 mouse_move_event(int X, int Y, bool RButton, bool LButton, bool MButton,
133 bool Shift, bool Control) :
134 X(X), Y(Y), RButton(RButton), LButton(LButton), MButton(MButton),
135 Shift(Shift), Control(Control) {}
136
138 int GetX() { return X; }
140 int GetY() { return Y; }
142 bool GetRButton() { return RButton; }
144 bool GetLButton() { return LButton; }
146 bool GetMButton() { return MButton; }
148 bool GetShift() { return Shift; }
150 bool GetControl() { return Control; }
151
152 /*!*
153 * Convert event to string (for debug).
154 *
155 * \param None.
156 * \return string representation of event.
157 */
158 inline std::string ToString() const override
159 {
160 std::stringstream ss;
161 ss << GetName() << ": (X, Y) - (" << X << ", " << Y
162 << "), RButton - " << RButton << ", LButton - " << LButton << ", MButton - " << MButton;
163 return ss.str();
164 }
165 };
166}
virtual const char * GetName() const =0
std::string ToString() const override
Definition: mouse_event.h:67
mouse_button_event(bool Pressed, int X, int Y, mouse_button KeyCode)
Definition: mouse_event.h:49
mouse_button GetKeyCode()
Definition: mouse_event.h:59
std::string ToString() const override
Definition: mouse_event.h:158
mouse_move_event(int X, int Y, bool RButton, bool LButton, bool MButton, bool Shift, bool Control)
Definition: mouse_event.h:132
std::string ToString() const override
Definition: mouse_event.h:102
mouse_wheel_event(int WheelPosDelta)
Definition: mouse_event.h:90
Definition: base.h:33
mouse_button
Definition: mouse_event.h:16