forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.h
More file actions
138 lines (117 loc) · 4.17 KB
/
event.h
File metadata and controls
138 lines (117 loc) · 4.17 KB
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
132
133
134
135
136
137
138
// SHE library
// Copyright (C) 2012-2017 David Capello
//
// This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information.
#ifndef SHE_EVENT_H_INCLUDED
#define SHE_EVENT_H_INCLUDED
#pragma once
#include "gfx/point.h"
#include "gfx/size.h"
#include "she/keys.h"
#include "she/pointer_type.h"
#include <string>
#include <vector>
#pragma push_macro("None")
#undef None // Undefine the X11 None macro
namespace she {
class Display;
class Event {
public:
enum Type {
None,
CloseDisplay,
ResizeDisplay,
DropFiles,
MouseEnter,
MouseLeave,
MouseMove,
MouseDown,
MouseUp,
MouseWheel,
MouseDoubleClick,
KeyDown,
KeyUp,
TouchMagnify,
};
enum MouseButton {
NoneButton,
LeftButton,
RightButton,
MiddleButton
};
typedef std::vector<std::string> Files;
Event() : m_type(None),
m_display(nullptr),
m_scancode(kKeyNil),
m_modifiers(kKeyUninitializedModifier),
m_unicodeChar(0),
m_isDead(false),
m_repeat(0),
m_preciseWheel(false),
m_pointerType(PointerType::Unknown),
m_button(NoneButton),
m_magnification(0.0),
m_pressure(0.0) {
}
Type type() const { return m_type; }
Display* display() const { return m_display; }
const Files& files() const { return m_files; }
// TODO Rename this to virtualKey(), which is the real
// meaning. Then we need another kind of "scan code" with the
// position in the keyboard, which might be useful to identify
// keys by its position (e.g. WASD keys in other keyboard
// layouts).
KeyScancode scancode() const { return m_scancode; }
KeyModifiers modifiers() const { return m_modifiers; }
int unicodeChar() const { return m_unicodeChar; }
bool isDeadKey() const { return m_isDead; }
int repeat() const { return m_repeat; }
gfx::Point position() const { return m_position; }
gfx::Point wheelDelta() const { return m_wheelDelta; }
// We suppose that if we are receiving precise scrolling deltas,
// it means that the user is using a touch-like surface (trackpad,
// magic mouse scrolling, touch wacom tablet, etc.)
// TODO change this with the new PointerType::Multitouch
bool preciseWheel() const { return m_preciseWheel; }
PointerType pointerType() const { return m_pointerType; }
MouseButton button() const { return m_button; }
double magnification() const { return m_magnification; }
double pressure() const { return m_pressure; }
void setType(Type type) { m_type = type; }
void setDisplay(Display* display) { m_display = display; }
void setFiles(const Files& files) { m_files = files; }
void setScancode(KeyScancode scancode) { m_scancode = scancode; }
void setModifiers(KeyModifiers modifiers) { m_modifiers = modifiers; }
void setUnicodeChar(int unicodeChar) { m_unicodeChar = unicodeChar; }
void setDeadKey(bool state) { m_isDead = state; }
void setRepeat(int repeat) { m_repeat = repeat; }
void setPosition(const gfx::Point& pos) { m_position = pos; }
void setWheelDelta(const gfx::Point& delta) { m_wheelDelta = delta; }
void setPreciseWheel(bool precise) { m_preciseWheel = precise; }
void setPointerType(PointerType pointerType) { m_pointerType = pointerType; }
void setButton(MouseButton button) { m_button = button; }
void setMagnification(double magnification) { m_magnification = magnification; }
void setPressure(double pressure) { m_pressure = pressure; }
private:
Type m_type;
Display* m_display;
Files m_files;
KeyScancode m_scancode;
KeyModifiers m_modifiers;
int m_unicodeChar;
bool m_isDead;
int m_repeat; // repeat=0 means the first time the key is pressed
gfx::Point m_position;
gfx::Point m_wheelDelta;
bool m_preciseWheel;
PointerType m_pointerType;
MouseButton m_button;
// For TouchMagnify event
double m_magnification;
// Pressure of stylus used in mouse-like events
double m_pressure;
};
} // namespace she
#pragma pop_macro("None")
#endif