-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzglPluginEx.cpp
executable file
·176 lines (139 loc) · 2.85 KB
/
zglPluginEx.cpp
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* Copyright (C) 2010 ZiiLABS Pte Ltd
* All Rights Reserved.
*
* This software and its associated documentation may contain some
* proprietary, confidential and trade secret information of
* ZiiLABS Pte Ltd and except as provided by written agreement with
* ZiiLABS Pte Ltd
*
* a) no part may be disclosed, distributed, reproduced, transmitted,
* transcribed, stored in a retrieval system, adapted or translated
* in any form or by any means electronic, mechanical, magnetic,
* optical, chemical, manual or otherwise,
*
* and
*
* b) the recipient is not entitled to discover through reverse
* engineering or reverse compiling or other such techniques or
* processes the trade secrets contained therein or in the
* documentation.
*/
#include "zglPluginEx.h"
bool zglPluginEx::handleTouchEvent(int type, int x, int y, long time)
{
switch (type)
{
case TOUCH_DOWN:
{
m_gesture = GESTURE_DOWN;
m_motion_x = x;
m_motion_y = y;
m_last_x = x;
m_last_y = y;
m_tracker.clear();
bool ret = onGestureTouchDown(x, y, time);
return ret;
}
case TOUCH_UP:
{
bool ret = false;
switch (m_gesture)
{
default:
case GESTURE_NONE:
break;
case GESTURE_DOWN:
ret = onGestureClick(x, y, time);
break;
case GESTURE_MOVE_X:
ret = onGestureFlingX(time);
break;
case GESTURE_MOVE_Y:
ret = onGestureFlingY(time);
break;
}
m_gesture = GESTURE_NONE;
return ret;
}
case TOUCH_MOVE:
{
bool ret = false;
m_tracker.addMoveMent((int)x, (int)y, time);
switch (m_gesture)
{
case GESTURE_DOWN:
{
int dx = x - m_motion_x;
dx = dx > 0 ? dx : -dx;
int dy = y - m_motion_y;
dy = dy > 0 ? dy : -dy;
if ((dx >= m_motion_max) || (dy >= m_motion_max))
{
if (dx > dy)
{
m_gesture = GESTURE_MOVE_X;
}
else
{
m_gesture = GESTURE_MOVE_Y;
}
}
}
break;
case GESTURE_MOVE_X:
{
ret = onGestureScrollX(x, time);
}
break;
case GESTURE_MOVE_Y:
{
ret = onGestureScrollY(y, time);
}
break;
default:
break;
}
if (!ret)
{
ret = onGestureMove(x, y, time);
}
m_last_x = x;
m_last_y = y;
return ret;
}
}
return false;
}
bool zglPluginEx::onGestureTouchDown(float x, float y, long time)
{
return false;
}
bool zglPluginEx::onGestureClick(float x, float y, long time)
{
return false;
}
bool zglPluginEx::onGestureFlingX(long time)
{
return false;
}
bool zglPluginEx::onGestureFlingY(long time)
{
return false;
}
bool zglPluginEx::onGestureScrollX(float x, long time)
{
return false;
}
bool zglPluginEx::onGestureScrollY(float y, long time)
{
return false;
}
bool zglPluginEx::onGestureMove(float x, float y, long time)
{
return false;
}
bool zglPluginEx::onGestureLongPress()
{
return false;
}