1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
25
26
27
34
35
36
37
38
39
46
47
48
49
50
51
52
53
54
55
58
59
60
61
62
63
64
65
66
67
68
69
70
71
78
79
80
89
90
91
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
139
140
144
145
149
150
151
/* ... */
#ifndef GESTURES_HPP
#define GESTURES_HPP
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/events/ClickEvent.hpp>
#include <touchgfx/events/DragEvent.hpp>
#include <touchgfx/events/GestureEvent.hpp>
#include <touchgfx/UIEventListener.hpp>
5 includes
namespace touchgfx
{
/* ... */
class Gestures
{
static const uint8_t MAX_TICKS_BETWEEN_MOVES_FOR_SWIPE = 7;
static const uint8_t MIN_VELOCITY_AT_RELEASE_BEFORE_SWIPE = 3;
/* ... */
struct DragState
{
DragState() : startX(0),
startY(0),
downX(0),
downY(0),
tickCount(0),
velocityX(0),
velocityY(0),
inProgress(false)
{
}{ ... }
uint16_t startX;
uint16_t startY;
uint16_t downX;
uint16_t downY;
uint16_t tickCount;
int16_t velocityX;
int16_t velocityY;
bool inProgress;
...};
public:
/* ... */
Gestures() : listener(0), dragThresholdValue(0) { }
/* ... */
void registerEventListener(UIEventListener& l);
/* ... */
void tick();
/* ... */
bool registerDragEvent(uint16_t oldX, uint16_t oldY, uint16_t newX, uint16_t newY);
/* ... */
void registerClickEvent(ClickEvent::ClickEventType evt, uint16_t x, uint16_t y);
/* ... */
void setDragThreshold(uint16_t val)
{
dragThresholdValue = val;
}{ ... }
public:private:
DragState drag;
UIEventListener* listener;
uint16_t dragThresholdValue;private:
...};
...} /* ... */
#endif