1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup ArkUI_NativeModule
18  * @{
19  *
20  * @brief Defines APIs for ArkUI to register gesture callbacks on the native side.
21  *
22  * @since 12
23  */
24 
25 /**
26  * @file native_gesture.h
27  *
28  * @brief Provides type definitions for <b>NativeGesture</b> APIs.
29  *
30  * @library libace_ndk.z.so
31  * @syscap SystemCapability.ArkUI.ArkUI.Full
32  * @since 12
33  */
34 
35 #ifndef ARKUI_NATIVE_GESTTURE_H
36 #define ARKUI_NATIVE_GESTTURE_H
37 
38 #include "ui_input_event.h"
39 #include "native_type.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Defines a gesture recognizer.
47  *
48  * @since 12
49  */
50 typedef struct ArkUI_GestureRecognizer ArkUI_GestureRecognizer;
51 
52 /**
53  * @brief Defines the gesture interruption information.
54  *
55  * @since 12
56  */
57 typedef struct ArkUI_GestureInterruptInfo ArkUI_GestureInterruptInfo;
58 
59 /**
60  * @brief Defines the gesture event.
61  *
62  * @since 12
63  */
64 typedef struct ArkUI_GestureEvent ArkUI_GestureEvent;
65 
66 /**
67  * @brief Enumerates gesture event types.
68  *
69  * @since 12
70  */
71 typedef enum {
72     /** Triggered. */
73     GESTURE_EVENT_ACTION_ACCEPT = 0x01,
74 
75     /** Updated. */
76     GESTURE_EVENT_ACTION_UPDATE = 0x02,
77 
78     /** Ended. */
79     GESTURE_EVENT_ACTION_END = 0x04,
80 
81     /** Canceled. */
82     GESTURE_EVENT_ACTION_CANCEL = 0x08,
83 } ArkUI_GestureEventActionType;
84 
85 /**
86  * @brief Defines a set of gesture event types.
87  *
88  * Example: ArkUI_GestureEventActionTypeMask actions = GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE;\n
89  *
90  * @since 12
91  */
92 typedef uint32_t ArkUI_GestureEventActionTypeMask;
93 
94 /**
95  * @brief Enumerates gesture event modes.
96  *
97  * @since 12
98  */
99 typedef enum {
100     /** Normal. */
101     NORMAL = 0,
102 
103     /** High-priority. */
104     PRIORITY = 1,
105 
106     /** Parallel. */
107     PARALLEL = 2,
108 } ArkUI_GesturePriority;
109 
110 /**
111  * @brief Enumerates gesture group modes.
112  *
113  * @since 12
114  */
115 typedef enum {
116     /* Sequential recognition. Gestures are recognized in the registration sequence until all gestures are recognized
117      * successfully. Once one gesture fails to be recognized, all subsequent gestures fail to be recognized.
118      * Only the last gesture in the gesture group can respond to the end event. */
119     SEQUENTIAL_GROUP = 0,
120 
121     /** Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized.
122       * The recognition result of each gesture does not affect each other. */
123     PARALLEL_GROUP = 1,
124 
125     /** Exclusive recognition. Registered gestures are identified concurrently.
126       * If one gesture is successfully recognized, gesture recognition ends. */
127     EXCLUSIVE_GROUP = 2,
128 } ArkUI_GroupGestureMode;
129 
130 /**
131  * @brief Enumerates gesture directions.
132  *
133  * @since 12
134  */
135 typedef enum {
136     /** All directions. */
137     GESTURE_DIRECTION_ALL = 0b1111,
138 
139     /** Horizontal direction. */
140     GESTURE_DIRECTION_HORIZONTAL = 0b0011,
141 
142     /** Vertical direction. */
143     GESTURE_DIRECTION_VERTICAL = 0b1100,
144 
145     /** Leftward. */
146     GESTURE_DIRECTION_LEFT = 0b0001,
147 
148     /** Rightward. */
149     GESTURE_DIRECTION_RIGHT = 0b0010,
150 
151     /** Upward. */
152     GESTURE_DIRECTION_UP = 0b0100,
153 
154     /** Downward. */
155     GESTURE_DIRECTION_DOWN = 0b1000,
156 
157     /** None. */
158     GESTURE_DIRECTION_NONE = 0,
159 } ArkUI_GestureDirection;
160 
161 /**
162  * @brief Defines a set of gesture directions.
163  *
164  * Example: ArkUI_GestureDirectionMask directions = GESTURE_DIRECTION_LEFT | GESTURE_DIRECTION_RIGHT \n
165  * This example indicates that the leftward and rightward directions are supported. \n
166  *
167  * @since 12
168  */
169 typedef uint32_t ArkUI_GestureDirectionMask;
170 
171 /**
172  * @brief Enumerates gesture masking modes.
173  *
174  * @since 12
175  */
176 typedef enum {
177     /** The gestures of child components are enabled and recognized based on the default gesture recognition sequence.*/
178     NORMAL_GESTURE_MASK = 0,
179 
180     /** The gestures of child components are disabled, including the built-in gestures. */
181     IGNORE_INTERNAL_GESTURE_MASK,
182 } ArkUI_GestureMask;
183 
184 /**
185  * @brief Enumerates gesture types.
186  *
187  * @since 12
188  */
189 typedef enum {
190     /** Tap. */
191     TAP_GESTURE = 0,
192 
193     /** Long press. */
194     LONG_PRESS_GESTURE,
195 
196     /** Pan. */
197     PAN_GESTURE,
198 
199     /** Pinch. */
200     PINCH_GESTURE,
201 
202     /** Rotate. */
203     ROTATION_GESTURE,
204 
205     /** Swipe. */
206     SWIPE_GESTURE,
207 
208     /** A group of gestures. */
209     GROUP_GESTURE,
210 } ArkUI_GestureRecognizerType;
211 
212 /**
213  * @brief Enumerates gesture interruption results.
214  *
215  * @since 12
216  */
217 typedef enum {
218     /** The gesture recognition process continues. */
219     GESTURE_INTERRUPT_RESULT_CONTINUE = 0,
220 
221     /** The gesture recognition process is paused. */
222     GESTURE_INTERRUPT_RESULT_REJECT,
223 } ArkUI_GestureInterruptResult;
224 
225 /**
226  * @brief Enumerates the gesture recognizer states.
227  *
228  * @since 12
229  */
230 typedef enum {
231     /** Ready. */
232     ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0,
233 
234     /** Detecting. */
235     ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1,
236 
237     /** Pending. */
238     ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2,
239 
240     /** Blocked. */
241     ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3,
242 
243     /** Successful. */
244     ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4,
245 
246     /** Failed. */
247     ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5,
248 } ArkUI_GestureRecognizerState;
249 
250 /**
251  * @brief Defines the gesture recognizer handle.
252  *
253  * @since 12
254  */
255 typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle;
256 
257 /**
258  * @brief Defines the gesture recognizer handle array.
259  *
260  * @since 12
261  */
262 typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray;
263 
264 /**
265  * @brief Defines a <b>GestureEventTargetInfo</b> object that provides information about a gesture event target.
266  *
267  * @since 12
268  */
269 typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo;
270 
271 /**
272  * @brief Defines a parallel internal gesture event.
273  *
274  * @since 12
275  */
276 typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent;
277 
278 /**
279  * @brief Defines a callback function for notifying gesture recognizer destruction.
280  * @since 12
281  */
282 typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData);
283 
284 /**
285 * @brief Checks whether a gesture is a built-in gesture of the component.
286 *
287 * @param event Indicates the pointer to the gesture interruption information.
288 * @return Returns <b>true</b> if the gesture is a built-in gesture; returns <b>false</b> otherwise.
289 
290 * @since 12
291 */
292 bool OH_ArkUI_GestureInterruptInfo_GetSystemFlag(const ArkUI_GestureInterruptInfo* event);
293 
294 /**
295 * @brief Obtains the pointer to interrupted gesture recognizer.
296 *
297 * @param event Indicates the pointer to the gesture interruption information.
298 * @return Returns the pointer to interrupted gesture recognizer.
299 * @since 12
300 */
301 ArkUI_GestureRecognizer* OH_ArkUI_GestureInterruptInfo_GetRecognizer(const ArkUI_GestureInterruptInfo* event);
302 
303 /**
304 * @brief Obtains the pointer to the interrupted gesture event.
305 *
306 * @param event Indicates the pointer to the gesture interruption information.
307 * @return Returns the pointer to the interrupted gesture event.
308 * @since 12
309 */
310 ArkUI_GestureEvent* OH_ArkUI_GestureInterruptInfo_GetGestureEvent(const ArkUI_GestureInterruptInfo* event);
311 
312 /**
313 * @brief Obtains the type of the system gesture to trigger.
314 *
315 * @param event Indicates the pointer to the gesture interruption information.
316 * @return Returns the type of the system gesture to trigger. If the gesture to trigger is not a system gesture,
317 *         <b>-1</b> is returned.
318 * @since 12
319 */
320 int32_t OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(const ArkUI_GestureInterruptInfo* event);
321 
322 /**
323 * @brief Obtains the gesture event type.
324 *
325 * @param event Indicates the pointer to the gesture event.
326 * @return Returns the gesture event type.
327 * @since 12
328 */
329 ArkUI_GestureEventActionType OH_ArkUI_GestureEvent_GetActionType(const ArkUI_GestureEvent* event);
330 
331 /**
332 * @brief Obtains gesture input.
333 *
334 * @param event Indicates the pointer to the gesture event.
335 * @return Returns the pointer to the input event of the gesture event.
336 * @since 12
337 */
338 const ArkUI_UIInputEvent* OH_ArkUI_GestureEvent_GetRawInputEvent(const ArkUI_GestureEvent* event);
339 
340 /**
341 * @brief Obtains the number of times that a long press gesture is triggered periodically.
342 *
343 * @param event Indicates the pointer to the gesture event.
344 * @return Returns the number of times that the long press gesture is triggered periodically.
345 * @since 12
346 */
347 int32_t OH_ArkUI_LongPress_GetRepeatCount(const ArkUI_GestureEvent* event);
348 
349 /**
350 * @brief Obtains the velocity of a pan gesture along the main axis.
351 *
352 * @param event Indicates the pointer to the gesture event.
353 * @return Returns the velocity of the pan gesture along the main axis, in px/s.
354 *         The value is the square root of the sum of the squares of the velocity on the x-axis and y-axis.
355 * @since 12
356 */
357 float OH_ArkUI_PanGesture_GetVelocity(const ArkUI_GestureEvent* event);
358 
359 /**
360 * @brief Obtains the velocity of a pan gesture along the x-axis.
361 *
362 * @param event Indicates the pointer to the gesture event.
363 * @return Returns the velocity of the pan gesture along the x-axis, in px/s.
364 * @since 12
365 */
366 float OH_ArkUI_PanGesture_GetVelocityX(const ArkUI_GestureEvent* event);
367 
368 /**
369 * @brief Obtains the velocity of a pan gesture along the y-axis.
370 *
371 * @param event Indicates the pointer to the gesture event.
372 * @return Returns the velocity of the pan gesture along the y-axis, in px/s.
373 * @since 12
374 */
375 float OH_ArkUI_PanGesture_GetVelocityY(const ArkUI_GestureEvent* event);
376 
377 /**
378 * @brief Obtains the relative offset of a pan gesture along the x-axis.
379 *
380 * @param event Indicates the pointer to the gesture event.
381 * @return Returns the relative offset of the gesture along the x-axis, in px.
382 * @since 12
383 */
384 float OH_ArkUI_PanGesture_GetOffsetX(const ArkUI_GestureEvent* event);
385 
386 /**
387 * @brief Obtains the relative offset of a pan gesture along the y-axis.
388 *
389 * @param event Indicates the pointer to the gesture event.
390 * @return Returns the relative offset of the gesture along the y-axis, in px.
391 * @since 12
392 */
393 float OH_ArkUI_PanGesture_GetOffsetY(const ArkUI_GestureEvent* event);
394 
395 /**
396 * @brief Obtains the angle information of the swipe gesture.
397 *
398 * After a swipe gesture is recognized, a line connecting the two fingers is identified as the initial line.
399 * As the fingers swipe, the line between the fingers rotates. \n
400 * Based on the coordinates of the initial line's and current line's end points, the arc tangent function is used to
401 * calculate the respective included angle of the points relative to the horizontal direction \n
402 * by using the following formula: Rotation angle = arctan2(cy2-cy1,cx2-cx1) - arctan2(y2-y1,x2-x1). \n
403 * The initial line is used as the coordinate system. Values from 0 to 180 degrees represent clockwise rotation,
404 * while values from –180 to 0 degrees represent counterclockwise rotation. \n
405 *
406 * @param event Indicates the pointer to the gesture event.
407 * @return Returns the angle of the swipe gesture, which is the result obtained based on the aforementioned formula.
408 * @since 12
409 */
410 float OH_ArkUI_SwipeGesture_GetAngle(const ArkUI_GestureEvent* event);
411 
412 /**
413 * @brief Obtains the average velocity of all fingers used in the swipe gesture.
414 *
415 * @param event Indicates the pointer to the gesture event.
416 * @return Returns the average velocity of all fingers used in the swipe gesture, in px/s.
417 * @since 12
418 */
419 float OH_ArkUI_SwipeGesture_GetVelocity(const ArkUI_GestureEvent* event);
420 
421 /**
422 * @brief Obtains the angle information of a rotation gesture.
423 *
424 * @param event Indicates the pointer to the gesture event.
425 * @return Returns the rotation angle.
426 * @since 12
427 */
428 float OH_ArkUI_RotationGesture_GetAngle(const ArkUI_GestureEvent* event);
429 
430 /**
431 * @brief Obtains the scale ratio of a pinch gesture.
432 *
433 * @param event Indicates the pointer to the gesture event.
434 * @return Returns the scale ratio.
435 * @since 12
436 */
437 float OH_ArkUI_PinchGesture_GetScale(const ArkUI_GestureEvent* event);
438 
439 /**
440 * @brief Obtains the X coordinate of the center of the pinch gesture, in vp,
441 * relative to the upper left corner of the current component.
442 *
443 * @param event Indicates the pointer to the gesture event.
444 * @return Returns the X coordinate of the center of the pinch gesture, in vp,
445 * relative to the upper left corner of the current component.
446 * @since 12
447 */
448 float OH_ArkUI_PinchGesture_GetCenterX(const ArkUI_GestureEvent* event);
449 
450 /**
451 * @brief Obtains the Y coordinate of the center of the pinch gesture, in vp,
452 * relative to the upper left corner of the current component.
453 *
454 * @param event Indicates the pointer to the gesture event.
455 * @return Returns the Y coordinate of the center of the pinch gesture, in vp,
456 * relative to the upper left corner of the current component.
457 * @since 12
458 */
459 float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event);
460 
461 /**
462 * @brief Obtains information about a gesture response chain.
463 *
464 * @param event Indicates the pointer to the gesture interruption information.
465 * @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain.
466 * @param count Indicates the pointer to the number of gesture recognizers on the response chain.
467 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
468 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
469 * @since 12
470 */
471 int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event,
472     ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count);
473 
474 /**
475 * @brief Sets the enabled state of a gesture recognizer.
476 *
477 * @param recognizer Indicates the pointer to a gesture recognizer.
478 * @param enabled Indicates the enabled state.
479 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
480 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
481 * @since 12
482 */
483 int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled);
484 
485 /**
486 * @brief Obtains the enabled state of a gesture recognizer.
487 *
488 * @param recognizer Indicates the pointer to a gesture recognizer.
489 * @return Returns <b>true</b> if the gesture recognizer is enabled.
490 *         Returns <b>false</b> if the gesture recognizer is disabled.
491 * @since 12
492 */
493 bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer);
494 
495 /**
496 * @brief Obtains the state of a gesture recognizer.
497 *
498 * @param recognizer Indicates the pointer to a gesture recognizer.
499 * @param state Indicates the pointer to the state of the gesture recognizer.
500 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
501 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
502 * @since 12
503 */
504 int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state);
505 
506 /**
507 * @brief Obtains the information about a gesture event target.
508 *
509 * @param recognizer Indicates the pointer to a gesture recognizer.
510 * @param info Indicates the information about a gesture event target.
511 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
512 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
513 * @since 12
514 */
515 int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info);
516 
517 /**
518 * @brief Obtains whether this scroll container is scrolled to the top.
519 *
520 * @param info Indicates the information about a gesture event target.
521 * @param ret Indicates whether the scroll container is scrolled to the top.
522 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
523 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
524 *         Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container.
525 * @since 12
526 */
527 int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret);
528 
529 /**
530 * @brief Obtains whether this scroll container is scrolled to the bottom.
531 *
532 * @param info Indicates the information about a gesture event target.
533 * @param ret Indicates whether the scroll container is scrolled to the bottom.
534 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
535 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
536 *         Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container.
537 * @since 12
538 */
539 int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret);
540 
541 /**
542 * @brief Obtains the direction of a pan gesture.
543 *
544 * @param recognizer Indicates the pointer to a gesture recognizer.
545 * @param directionMask Indicates the pan direction.
546 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
547 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
548 * @since 12
549 */
550 int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer,
551     ArkUI_GestureDirectionMask* directionMask);
552 
553 /**
554 * @brief Obtains whether a gesture is a built-in gesture.
555 *
556 * @param recognizer Indicates the pointer to a gesture recognizer.
557 * @return Returns <b>true</b> if the gesture is a built-in gesture; returns <b>false</b> otherwise.
558 * @since 12
559 */
560 bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer);
561 
562 /**
563 * @brief Obtains the tag of a gesture recognizer.
564 *
565 * @param recognizer Indicates the pointer to a gesture recognizer.
566 * @param buffer Indicates the buffer.
567 * @param bufferSize Indicates the buffer size.
568 * @param result Indicates the length of the string to be written to the buffer.
569 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
570 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
571 *         Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough.
572 * @since 12
573 */
574 int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result);
575 
576 /**
577 * @brief Obtains the ID of the component linked to a gesture recognizer.
578 *
579 * @param recognizer Indicates the pointer to a gesture recognizer.
580 * @param nodeId Indicates the component ID.
581 * @param size Indicates the buffer size.
582 * @param result Indicates the length of the string to be written to the buffer.
583 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
584 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
585 *         Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough.
586 * @since 12
587 */
588 int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size,
589     int32_t* result);
590 
591 /**
592 * @brief Obtains whether a gesture recognizer is valid.
593 *
594 * @param recognizer Indicates the pointer to a gesture recognizer.
595 * @return Returns <b>true</b> if the gesture recognizer is valid.
596 *         Returns <b>false</b> if the gesture recognizer is invalid.
597 * @since 12
598 */
599 bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer);
600 
601 /**
602 * @brief Obtains custom data in the parallel internal gesture event.
603 *
604 * @param event Indicates the pointer to a parallel internal gesture event.
605 * @return Returns the pointer to custom data.
606 * @since 12
607 */
608 void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event);
609 
610 /**
611 * @brief Obtains the current gesture recognizer in a parallel internal gesture event.
612 *
613 * @param event Indicates the pointer to a parallel internal gesture event.
614 * @return Returns the pointer to the current gesture recognizer.
615 * @since 12
616 */
617 ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer(
618     ArkUI_ParallelInnerGestureEvent* event);
619 
620 /**
621 * @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event.
622 *
623 * @param event Indicates the pointer to a parallel internal gesture event.
624 * @param array Indicates the pointer to the array of conflicting gesture recognizers.
625 * @param size Indicates the size of the array of conflicting gesture recognizers.
626 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
627 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
628 * @since 12
629 */
630 int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event,
631     ArkUI_GestureRecognizerHandleArray* array, int32_t* size);
632 
633 /**
634 * @brief Sets a callback function for notifying gesture recognizer destruction.
635 *
636 * @param recognizer Indicates the pointer to a gesture recognizer.
637 * @param callback Indicates the callback function for notifying gesture recognizer destruction.
638 * @param userData Indicates the custom data.
639 * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
640 *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
641 */
642 int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer,
643     ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData);
644 
645 ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event);
646 /**
647  * @brief Defines the gesture APIs.
648  *
649  * @since 12
650  */
651 typedef struct {
652     /** The struct version is 1. */
653     int32_t version;
654 
655     /**
656     * @brief Creates a tap gesture.
657     *
658     *        1. This API is used to trigger a tap gesture with one, two, or more taps. \n
659     *        2. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. \n
660     *        3. If the distance between the last tapped position and the current tapped position exceeds 60 vp,
661     *           gesture recognition fails. \n
662     *        4. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers
663     *           touching the screen within 300 ms of the first finger touch is less than the required number, \n
664     *           or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted
665     *           is less than the required number. \n
666     *        5. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. \n
667     *
668     * @param countNum Indicates the number of consecutive taps. If the value is less than 1 or is not set,
669     *        the default value <b>1</b> is used.
670     * @param fingersNum Indicates the number of fingers required to trigger a tap. The value ranges
671     *        from 1 to 10. If the value is less than 1 or is not set, the default value <b>1</b> is used.
672     * @return Returns the pointer to the created gesture.
673     */
674     ArkUI_GestureRecognizer* (*createTapGesture)(int32_t countNum, int32_t fingersNum);
675 
676     /**
677     * @brief Creates a long press gesture.
678     *
679     *        1. This API is used to trigger a long press gesture, which requires one or more fingers with a minimum
680     *           The value ranges 500 ms hold-down time. \n
681     *        2. In components that support drag actions by default, such as <b><Text></b>, <b><TextInput></b>,
682     *           <b><TextArea></b>, <b><Hyperlink></b>, <b><Image></b>, and <b>RichEditor></b>, the long press gesture \n
683     *           may conflict with the drag action. If this occurs, they are handled as follows: \n
684     *           If the minimum duration of the long press gesture is less than 500 ms, the long press gesture receives
685     *           a higher response priority than the drag action. \n
686     *           If the minimum duration of the long press gesture is greater than or equal to 500 ms,
687     *           the drag action receives a higher response priority than the long press gesture. \n
688     *        3. If a finger moves more than 15 px after being pressed, the gesture recognition fails. \n
689     *
690     * @param fingersNum Indicates the minimum number of fingers to trigger a long press gesture.
691     *        The value ranges from 1 to 10.
692     * @param repeatResult Indicates whether to continuously trigger the event callback.
693     * @param durationNum Indicates the minimum hold-down time, in ms.
694     *        If the value is less than or equal to 0, the default value <b>500</b> is used.
695     * @return Returns the pointer to the created gesture.
696     */
697     ArkUI_GestureRecognizer* (*createLongPressGesture)(int32_t fingersNum, bool repeatResult, int32_t durationNum);
698 
699     /**
700     * @brief Creates a pan gesture.
701     *
702     *        1. This API is used to trigger a pan gesture when the movement distance of a finger on the screen exceeds
703     *           the minimum value. \n
704     *        2. If a pan gesture and a tab swipe occur at the same time, set <b>distanceNum</b> to <b>1</b>
705     *           so that the gesture can be more easily recognized. \n
706     *
707     * @param fingersNum Indicates the minimum number of fingers to trigger a pan gesture. The value ranges from 1 to 10.
708     *        If the value is less than 1 or is not set, the default value <b>1</b> is used.
709     * @param directions Indicates the pan direction. The value supports the AND (&amp;) and OR (\|) operations.
710     * @param distanceNum Indicates the minimum pan distance to trigger the gesture, in vp. If this parameter is
711     *        set to a value less than or equal to 0, the default value <b>5</b> is used.
712     * @return Returns the pointer to the created gesture.
713     */
714     ArkUI_GestureRecognizer* (*createPanGesture)(
715         int32_t fingersNum, ArkUI_GestureDirectionMask directions, double distanceNum);
716 
717     /**
718     * @brief Creates a pinch gesture.
719     *
720     *        1. This API is used to trigger a pinch gesture, which requires two to five fingers with a minimum 5 vp
721     *           distance between the fingers. \n
722     *        2. While more fingers than the minimum number can be pressed to trigger the gesture, only the first
723     *           fingers of the minimum number participate in gesture calculation. \n
724     *
725     * @param fingersNum Indicates the minimum number of fingers to trigger a pinch. The value ranges from 2 to 5.
726     *        Default value: <b>2</b>
727     * @param distanceNum Indicates the minimum recognition distance, in px. If this parameter is set to a value less
728     *        than or equal to 0, the default value <b>5</b> is used.
729     * @return Returns the pointer to the created gesture.
730     */
731     ArkUI_GestureRecognizer* (*createPinchGesture)(int32_t fingersNum, double distanceNum);
732 
733     /**
734     * @brief Creates a rotation gesture.
735     *
736     *        1. This API is used to trigger a rotation gesture, which requires two to five fingers with a
737     *           minimum 1-degree rotation angle. \n
738     *        2. While more fingers than the minimum number can be pressed to trigger the gesture, only the first
739     *           two fingers participate in gesture calculation. \n
740     *
741     * @param fingersNum Indicates the minimum number of fingers to trigger a rotation. The value ranges from 2 to 5.
742     *        Default value: <b>2</b>
743     * @param angleNum Indicates the minimum degree that can trigger the rotation gesture. Default value: <b>1</b>
744     *        If this parameter is set to a value less than or equal to 0 or greater than 360,
745     *        the default value <b>1</b> is used.
746     * @return Returns the pointer to the created gesture.
747     */
748     ArkUI_GestureRecognizer* (*createRotationGesture)(int32_t fingersNum, double angleNum);
749 
750     /**
751     * @brief Creates a swipe gesture.
752     *
753     *        This API is used to implement a swipe gesture, which can be recognized when the swipe speed is 100
754     *        vp/s or higher. \n
755     *
756     * @param fingersNum Indicates the minimum number of fingers to trigger a swipe gesture.
757     *        The value ranges from 1 to 10.
758     * @param directions Indicates the swipe direction.
759     * @param speedNum Indicates the minimum speed of the swipe gesture, in px/s.
760     *        If this parameter is set to a value less than or equal to 0, the default value <b>100</b> is used.
761     * @return Returns the pointer to the created gesture.
762     */
763     ArkUI_GestureRecognizer* (*createSwipeGesture)(
764         int32_t fingersNum, ArkUI_GestureDirectionMask directions, double speedNum);
765 
766     /**
767     * @brief Creates a gesture group.
768     *
769     * @param gestureMode Indicates the gesture group mode.
770     * @return Returns the pointer to the created gesture group.
771     */
772     ArkUI_GestureRecognizer* (*createGroupGesture)(ArkUI_GroupGestureMode gestureMode);
773 
774     /**
775     * @brief Disposes a gesture to release resources.
776     *
777     * @param recognizer Indicates the pointer to the gesture to dispose.
778     */
779     void (*dispose)(ArkUI_GestureRecognizer* recognizer);
780 
781     /**
782     * @brief Adds a gesture to a gesture group.
783     *
784     * @param group Indicates the pointer to the gesture group.
785     * @param child Indicates the gesture to be added to the gesture group.
786     * @return Returns <b>0</b> if success.
787     *         Returns <b>401</b> if a parameter exception occurs. Returns 401 if a parameter exception occurs.
788     */
789     int32_t (*addChildGesture)(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child);
790 
791     /**
792     * @brief Removes a gesture to a gesture group.
793     *
794     * @param group Indicates the pointer to the gesture group.
795     * @param child Indicates the gesture to be removed to the gesture group.
796     * @return Returns <b>0</b> if success.
797     *         Returns <b>401</b> if a parameter exception occurs.
798     */
799     int32_t (*removeChildGesture)(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child);
800 
801     /**
802     * @brief Registers a callback for gestures.
803     *
804     * @param recognizer Indicates the pointer to the gesture recognizer.
805     * @param actionTypeMask Indicates the set of gesture event types. Multiple callbacks can be registered at once,
806     *        with the callback event types distinguished in the callbacks.
807     *        Example: actionTypeMask = GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE;
808     * @param extraParams Indicates the context passed in the <b>targetReceiver</b> callback.
809     * @param targetReceiver Indicates the callback to register for processing the gesture event types.
810     *        <b>event</b> indicates the gesture callback data.
811     * @return Returns <b>0</b> if success.
812     *         Returns <b>401</b> if a parameter exception occurs.
813     */
814     int32_t (*setGestureEventTarget)(
815         ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventActionTypeMask actionTypeMask, void* extraParams,
816         void (*targetReceiver)(ArkUI_GestureEvent* event, void* extraParams));
817 
818     /**
819     * @brief Adds a gesture to a UI component.
820     *
821     * @param node Indicates the UI component to which you want to add the gesture.
822     * @param recognizer Indicates the gesture to be added to the UI component.
823     * @param mode Indicates the gesture event mode. Available options are <b>NORMAL_GESTURE</b>,
824     *        <b>PARALLEL_GESTURE</b>, and <b>PRIORITY_GESTURE</b>.
825     * @param mask Indicates the gesture masking mode.
826     * @return Returns <b>0</b> if success.
827     *         Returns <b>401</b> if a parameter exception occurs.
828     */
829     int32_t (*addGestureToNode)(
830         ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer, ArkUI_GesturePriority mode, ArkUI_GestureMask mask);
831 
832     /**
833     * @brief Removes a gesture from a node.
834     *
835     * @param node Indicates the node from which you want to remove the gesture.
836     * @param recognizer Indicates the gesture to be removed.
837     * @return Returns <b>0</b> if success.
838     * Returns <b>401</b> if a parameter exception occurs.
839     */
840     int32_t (*removeGestureFromNode)(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer);
841 
842     /**
843     * @brief Sets a gesture interruption callback for a node.
844     *
845     * @param node Indicates the node for which you want to set a gesture interruption callback.
846     * @param interrupter Indicates the gesture interruption callback to set.
847     *        <b>info</b> indicates the gesture interruption data. If <b>interrupter</b> returns
848     *        <b>GESTURE_INTERRUPT_RESULT_CONTINUE</b>, the gesture recognition process continues. If it returns
849     *        <b>GESTURE_INTERRUPT_RESULT_REJECT</b>, the gesture recognition process is paused.
850     * @return Returns <b>0</b> if success.
851     * Returns <b>401</b> if a parameter exception occurs.
852     */
853     int32_t (*setGestureInterrupterToNode)(
854         ArkUI_NodeHandle node, ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info));
855 
856     /**
857     * @brief Obtains the type of a gesture.
858     *
859     * @param recognizer Indicates the pointer to the gesture.
860     * @return Returns the gesture type.
861     */
862     ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer);
863 
864     /**
865     * @brief Sets the callback function for a parallel internal gesture event.
866     *
867     * @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set.
868     * @param userData Indicates the custom data.
869     * @param parallelInnerGesture Indicates the parallel internal gesture event. <b>event</b> returns the data of the
870     *        parallel internal gesture event; <b>parallelInnerGesture</b> returns the pointer to the gesture recognizer
871     *        that requires parallel recognition.
872     * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success.
873     *         Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs.
874     */
875     int32_t (*setInnerGestureParallelTo)(
876         ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)(
877             ArkUI_ParallelInnerGestureEvent* event));
878 
879     /**
880     * @brief Creates a tap gesture that is subject to distance restrictions.
881     *
882     *        1. This API is used to trigger a tap gesture with one, two, or more taps. \n
883     *        2. If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. \n
884     *        3. If the distance between the last tapped position and the current tapped position exceeds 60 vp,
885     *           gesture recognition fails. \n
886     *        4. If the value is greater than 1, the tap gesture will fail to be recognized when the number of fingers
887     *           touching the screen within 300 ms of the first finger touch is less than the required number,
888     *           or when the number of fingers lifted from the screen within 300 ms of the first finger's being lifted
889     *           is less than the required number. \n
890     *        5. When the number of fingers touching the screen exceeds the set value, the gesture can be recognized. \n
891     *        6. If the finger moves beyond the preset distance limit, gesture recognition fails. \n
892     *
893     * @param countNum Indicates the number of consecutive taps. If the value is less than 1 or is not set, the default
894     *        value <b>1</b> is used.
895     * @param fingersNum Indicates the number of fingers required to trigger a tap. The value ranges from 1 to 10.
896     *        If the value is less than 1 or is not set, the default value <b>1</b> is used.
897     * @param distanceThreshold Indicates the allowed moving distance of a finger.
898     *        The unit of this parameter is px.
899     *        If the value is less than 0, it will be converted to the default value of infinity.
900     * @return Returns the pointer to the created gesture.
901     */
902     ArkUI_GestureRecognizer* (*createTapGestureWithDistanceThreshold)(
903         int32_t countNum, int32_t fingersNum, double distanceThreshold);
904 } ArkUI_NativeGestureAPI_1;
905 
906 #ifdef __cplusplus
907 };
908 #endif
909 
910 #endif // ARKUI_NATIVE_GESTTURE_H
911 /** @} */