/
Mouse.h
131 lines (110 loc) · 3.8 KB
/
Mouse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright 2012-2018 Falltergeist Developers.
*
* This file is part of Falltergeist.
*
* Falltergeist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Falltergeist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Falltergeist. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FALLTERGEIST_EVENT_MOUSE_H
#define FALLTERGEIST_EVENT_MOUSE_H
// C++ standard includes
// Falltergeist includes
#include "../Event/Event.h"
#include "../Graphics/Point.h"
// Third party includes
namespace Falltergeist
{
namespace Event
{
using Graphics::Point;
class Mouse : public Event
{
public:
enum class Button
{
NONE = 0,
LEFT,
RIGHT,
MIDDLE,
X1,
X2
};
enum class Type
{
BUTTON_DOWN,
BUTTON_UP,
MOVE
};
static const char* typeToString(Type);
Mouse(Type type);
Mouse(const Mouse& event, const std::string& newName);
Mouse(const Mouse& event);
~Mouse() override;
/**
* @brief Type of an original event from OS.
*/
Type originalType() const;
/**
* Cursor position on screen.
*/
const Point& position() const;
void setPosition(const Point& position);
/**
* The offset for which cursor moved relative to last event. Used for move events.
*/
const Point& offset() const;
void setOffset(const Point& offset);
/**
* @brief Which button was pressed during mouse button events.
*/
Button button() const;
void setButton(Button);
bool leftButton() const;
bool rightButton() const;
/**
* @brief Whether control key is pressed.
*/
bool controlPressed() const;
void setControlPressed(bool value);
/**
* @brief Whether shift key is pressed.
*/
bool shiftPressed() const;
void setShiftPressed(bool value);
/**
* @brief Whether alt key is pressed.
*/
bool altPressed() const;
void setAltPressed(bool altPressed);
/**
* Indicates that an obstacle was detected under mouse cursor during event capturing.
*/
bool obstacle() const;
/**
* Sets obstacle flag. Used for event capturing.
*/
void setObstacle(bool obstacle);
protected:
bool _controlPressed = false;
bool _shiftPressed = false;
bool _altPressed = false;
bool _obstacle = false;
Button _button = Button::NONE;
Type _type;
Point _position;
Point _offset;
};
}
}
#endif // FALLTERGEIST_EVENT_MOUSE_H