Debian Codegraph @

xbmc/input/touch/ITouchActionHandler.h

raw
1 /*
2 * Copyright (C) 2012-2024 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include <stdint.h>
12
13 /*!
14 * \ingroup touch
15 * \brief Directions in which a touch can moved
16 *
17 * These values can be combined (bitwise OR) to specify multiple directions.
18 */
19 typedef enum
20 {
21 TouchMoveDirectionNone = 0x0,
22 TouchMoveDirectionLeft = 0x1,
23 TouchMoveDirectionRight = 0x2,
24 TouchMoveDirectionUp = 0x4,
25 TouchMoveDirectionDown = 0x8
26 } TouchMoveDirection;
27
28 /*!
29 * \ingroup touch
30 * \brief Interface defining all supported touch action events
31 */
32 class ITouchActionHandler
33 {
34 public:
35 virtual ~ITouchActionHandler() = default;
36
37 /*!
38 * \brief A touch action has been aborted
39 */
40 virtual void OnTouchAbort() {}
41
42 /*!
43 * \brief A single touch has started
44 *
45 * \param x The x coordinate (with sub-pixel) of the touch
46 * \param y The y coordinate (with sub-pixel) of the touch
47 *
48 * \return True if the event was handled otherwise false
49 *
50 * \sa OnSingleTap
51 */
52 virtual bool OnSingleTouchStart(float x, float y) { return true; }
53 /*!
54 * \brief A single touch has been held down for a certain amount of time
55 *
56 * \param x The x coordinate (with sub-pixel) of the touch
57 * \param y The y coordinate (with sub-pixel) of the touch
58 *
59 * \return True if the event was handled otherwise false
60 *
61 * \sa OnSingleLongPress
62 */
63 virtual bool OnSingleTouchHold(float x, float y) { return true; }
64 /*!
65 * \brief A single touch has moved
66 *
67 * \param x The x coordinate (with sub-pixel) of the current touch
68 * \param y The y coordinate (with sub-pixel) of the current touch
69 * \param offsetX The covered distance on the x axis (with sub-pixel)
70 * \param offsetX The covered distance on the y axis (with sub-pixel)
71 * \param velocityX The velocity of the gesture in x direction (pixels/second)
72 * \param velocityX The velocity of the gesture in y direction (pixels/second)
73 *
74 * \return True if the event was handled otherwise false
75 *
76 * \sa OnTouchGesturePan
77 */
78 virtual bool OnSingleTouchMove(
79 float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
80 {
81 return true;
82 }
83 /*!
84 * \brief A single touch has been lifted
85 *
86 * \param x The x coordinate (with sub-pixel) of the touch
87 * \param y The y coordinate (with sub-pixel) of the touch
88 *
89 * \return True if the event was handled otherwise false
90 *
91 * \sa OnSingleTap
92 */
93 virtual bool OnSingleTouchEnd(float x, float y) { return true; }
94
95 /*!
96 * \brief An additional touch has been performed
97 *
98 * \param x The x coordinate (with sub-pixel) of the touch
99 * \param y The y coordinate (with sub-pixel) of the touch
100 * \param pointer The pointer that has performed the touch
101 *
102 * \return True if the event was handled otherwise false
103 */
104 virtual bool OnMultiTouchDown(float x, float y, int32_t pointer) { return true; }
105 /*!
106 * \brief Multiple simultaneous touches have been held down for a certain amount of time
107 *
108 * \param x The x coordinate (with sub-pixel) of the touch
109 * \param y The y coordinate (with sub-pixel) of the touch
110 * \param pointers The number of pointers involved (default 2)
111 *
112 * \return True if the event was handled otherwise false
113 */
114 virtual bool OnMultiTouchHold(float x, float y, int32_t pointers = 2) { return true; }
115 /*!
116 * \brief A touch has moved
117 *
118 * \param x The x coordinate (with sub-pixel) of the current touch
119 * \param y The y coordinate (with sub-pixel) of the current touch
120 * \param offsetX The covered distance on the x axis (with sub-pixel)
121 * \param offsetX The covered distance on the y axis (with sub-pixel)
122 * \param velocityX The velocity of the gesture in x direction (pixels/second)
123 * \param velocityX The velocity of the gesture in y direction (pixels/second)
124 * \param pointer The pointer that has performed the touch
125 *
126 * \return True if the event was handled otherwise false
127 */
128 virtual bool OnMultiTouchMove(float x,
129 float y,
130 float offsetX,
131 float offsetY,
132 float velocityX,
133 float velocityY,
134 int32_t pointer)
135 {
136 return true;
137 }
138 /*!
139 * \brief A touch has been lifted (but there are still active touches)
140 *
141 * \param x The x coordinate (with sub-pixel) of the touch
142 * \param y The y coordinate (with sub-pixel) of the touch
143 * \param pointer The pointer that has performed the touch
144 *
145 * \return True if the event was handled otherwise false
146 */
147 virtual bool OnMultiTouchUp(float x, float y, int32_t pointer) { return true; }
148
149 /*!
150 * \brief A pan gesture with a single touch has been started
151 *
152 * \param x The x coordinate (with sub-pixel) of the initial touch
153 * \param y The y coordinate (with sub-pixel) of the initial touch
154 *
155 * \return True if the event was handled otherwise false
156 */
157 virtual bool OnTouchGestureStart(float x, float y) { return true; }
158 /*!
159 * \brief A pan gesture with a single touch is in progress
160 *
161 * \param x The x coordinate (with sub-pixel) of the current touch
162 * \param y The y coordinate (with sub-pixel) of the current touch
163 * \param offsetX The covered distance on the x axis (with sub-pixel)
164 * \param offsetX The covered distance on the y axis (with sub-pixel)
165 * \param velocityX The velocity of the gesture in x direction (pixels/second)
166 * \param velocityX The velocity of the gesture in y direction (pixels/second)
167 *
168 * \return True if the event was handled otherwise false
169 */
170 virtual bool OnTouchGesturePan(
171 float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
172 {
173 return true;
174 }
175 /*!
176 * \brief A pan gesture with a single touch has ended
177 *
178 * \param x The x coordinate (with sub-pixel) of the current touch
179 * \param y The y coordinate (with sub-pixel) of the current touch
180 * \param offsetX The covered distance on the x axis (with sub-pixel)
181 * \param offsetX The covered distance on the y axis (with sub-pixel)
182 * \param velocityX The velocity of the gesture in x direction (pixels/second)
183 * \param velocityX The velocity of the gesture in y direction (pixels/second)
184 *
185 * \return True if the event was handled otherwise false
186 */
187 virtual bool OnTouchGestureEnd(
188 float x, float y, float offsetX, float offsetY, float velocityX, float velocityY)
189 {
190 return true;
191 }
192
193 // convenience events
194 /*!
195 * \brief A tap with a one or more touches has been performed
196 *
197 * \param x The x coordinate (with sub-pixel) of the touch
198 * \param y The y coordinate (with sub-pixel) of the touch
199 * \param pointers The number of pointers involved (default 1)
200 *
201 * \return True if the event was handled otherwise false
202 */
203 virtual void OnTap(float x, float y, int32_t pointers = 1) {}
204 /*!
205 * \brief One or more touches have been held down for a certain amount of time
206 *
207 * \param x The x coordinate (with sub-pixel) of the touch
208 * \param y The y coordinate (with sub-pixel) of the touch
209 * \param pointers The number of pointers involved (default 1)
210 *
211 * \return True if the event was handled otherwise false
212 *
213 * \sa OnSingleTouchHold
214 */
215 virtual void OnLongPress(float x, float y, int32_t pointers = 1) {}
216 /*!
217 * \brief One or more touches has been moved quickly in a single direction in a short time
218 *
219 * \param direction The direction (left, right, up, down) of the swipe gesture
220 * \param xDown The x coordinate (with sub-pixel) of the first touch
221 * \param yDown The y coordinate (with sub-pixel) of the first touch
222 * \param xUp The x coordinate (with sub-pixel) of the last touch
223 * \param yUp The y coordinate (with sub-pixel) of the last touch
224 * \param velocityX The velocity of the gesture in x direction (pixels/second)
225 * \param velocityX The velocity of the gesture in y direction (pixels/second)
226 * \param pointers The number of pointers involved (default 1)
227 *
228 * \return True if the event was handled otherwise false
229 */
230 virtual void OnSwipe(TouchMoveDirection direction,
231 float xDown,
232 float yDown,
233 float xUp,
234 float yUp,
235 float velocityX,
236 float velocityY,
237 int32_t pointers = 1)
238 {
239 }
240 /*!
241 * \brief Two simultaneous touches have been held down and moved to perform a zooming/pinching
242 * gesture
243 *
244 * \param centerX The x coordinate (with sub-pixel) of the center of the two touches
245 * \param centerY The y coordinate (with sub-pixel) of the center of the two touches
246 * \param zoomFactor The zoom (> 1.0) or pinch (< 1.0) factor of the two touches
247 *
248 * \return True if the event was handled otherwise false
249 */
250 virtual void OnZoomPinch(float centerX, float centerY, float zoomFactor) {}
251 /*!
252 * \brief Two simultaneous touches have been held down and moved to perform a rotating gesture
253 *
254 * \param centerX The x coordinate (with sub-pixel) of the center of the two touches
255 * \param centerY The y coordinate (with sub-pixel) of the center of the two touches
256 * \param angle The clockwise angle in degrees of the rotation
257 *
258 * \return True if the event was handled otherwise false
259 */
260 virtual void OnRotate(float centerX, float centerY, float angle) {}
261 };