• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef INTERFACES_NATIVE_NODE_GESTURE_IMPL_H
16 #define INTERFACES_NATIVE_NODE_GESTURE_IMPL_H
17 
18 #include <cstdint>
19 
20 #include "native_gesture.h"
21 #include "native_node.h"
22 #include "native_type.h"
23 
24 #include "frameworks/core/interfaces/arkoala/arkoala_api.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct ArkUI_GestureRecognizer {
31     int32_t type = -1;
32     ArkUIGesture* gesture = nullptr;
33     void* extraData = nullptr;
34     void* attachNode = nullptr;
35     bool capi = true;
36     void* recognizer = nullptr;
37     ArkUIGestureEventTargetInfo targetInfo = {};
38 };
39 
40 struct ArkUI_GestureEventTargetInfo {
41     void* uiNode = nullptr;
42 };
43 
44 #ifdef __cplusplus
45 };
46 
47 // the ArkUI_GestureEvent struct actually same as ArkUIAPIEventGestureAsyncEvent;
48 struct ArkUI_GestureEvent {
49     ArkUIAPIEventGestureAsyncEvent eventData;
50     void* attachNode;
51 };
52 
53 struct ArkUI_GestureInterruptInfo {
54     ArkUIGestureInterruptInfo interruptData;
55 };
56 
57 struct ArkUI_ParallelInnerGestureEvent {
58     ArkUIGestureRecognizer* current = nullptr;
59     ArkUIGestureRecognizer** responseLinkRecognizer = nullptr;
60     void* userData = nullptr;
61     int32_t count;
62 };
63 
64 #endif
65 
66 namespace OHOS::Ace::GestureModel {
67 
68 ArkUI_GestureRecognizer* CreateTapGesture(int32_t count, int32_t fingers);
69 
70 ArkUI_GestureRecognizer* CreateTapGestureWithDistanceThreshold(
71     int32_t count, int32_t fingers, double distanceThreshold);
72 
73 ArkUI_GestureRecognizer* CreateLongPressGesture(int32_t fingers, bool repeatResult, int32_t duration);
74 
75 ArkUI_GestureRecognizer* CreatePanGesture(int32_t fingersNum, ArkUI_GestureDirectionMask mask, double distanceNum);
76 
77 ArkUI_GestureRecognizer* CreatePinchGesture(int32_t fingers, double distance);
78 
79 ArkUI_GestureRecognizer* CreateRotationGesture(int32_t fingers, double angle);
80 
81 ArkUI_GestureRecognizer* CreateSwipeGesture(int32_t fingers, ArkUI_GestureDirectionMask directions, double speed);
82 
83 void DisposeGesture(ArkUI_GestureRecognizer* recognizer);
84 
85 int32_t SetGestureEventTarget(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventActionTypeMask mask,
86     void* extraParam, void (*targetReceiver)(ArkUI_GestureEvent* event, void* extraParam));
87 
88 int32_t AddGestureToNode(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer, ArkUI_GesturePriority priorityNum,
89     ArkUI_GestureMask mask);
90 
91 int32_t RemoveGestureFromNode(ArkUI_NodeHandle node, ArkUI_GestureRecognizer* recognizer);
92 
93 ArkUI_GestureRecognizerType GetGestureType(ArkUI_GestureRecognizer* recognizer);
94 
95 ArkUI_GestureRecognizer* CreateGroupGesture(ArkUI_GroupGestureMode gestureMode);
96 
97 int32_t AddChildGesture(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child);
98 
99 int32_t RemoveChildGesture(ArkUI_GestureRecognizer* group, ArkUI_GestureRecognizer* child);
100 
101 void HandleGestureEvent(ArkUINodeEvent* event);
102 
103 int32_t SetGestureInterrupterToNode(
104     ArkUI_NodeHandle node, ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info));
105 
106 int32_t SetGestureInterrupterToNodeWithUserData(ArkUI_NodeHandle node, void* userData,
107     ArkUI_GestureInterruptResult (*interrupter)(ArkUI_GestureInterruptInfo* info));
108 
109 int32_t SetInnerGestureParallelTo(ArkUI_NodeHandle node, void* userData,
110     ArkUI_GestureRecognizer* (*parallelInnerGesture)(ArkUI_ParallelInnerGestureEvent* event));
111 
112 }; // namespace OHOS::Ace::GestureModel
113 #endif // INTERFACES_NATIVE_NODE_GESTURE_IMPL_H