• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #ifndef FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_GESTURE_H
17 #define FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_GESTURE_H
18 
19 #include "core/components_ng/pattern/gesture/gesture_model.h"
20 #include "core/event/ace_event_handler.h"
21 #include "core/gestures/gesture_info.h"
22 
23 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
24 
25 namespace OHOS::Ace::Framework {
26 class JSGesture : public virtual AceType {
27     DECLARE_ACE_TYPE(JSGesture, AceType);
28 
29 public:
30     JSGesture() = default;
31     ~JSGesture() override = default;
32 
33     enum class JSGestureEvent { ACTION, START, UPDATE, END, CANCEL };
34 
35     static void JSBind(BindingTarget globalObj);
36 
37     static void Create(const JSCallbackInfo& info);
38     static void Pop();
39     static void Finish();
40 
41     static void JsHandlerOnAction(const JSCallbackInfo& args);
42     static void JsHandlerOnActionStart(const JSCallbackInfo& args);
43     static void JsHandlerOnActionUpdate(const JSCallbackInfo& args);
44     static void JsHandlerOnActionEnd(const JSCallbackInfo& args);
45     static void JsHandlerOnActionCancel(const JSCallbackInfo& args);
46     static void JsHandlerOnGestureEvent(Ace::GestureEventAction action, const JSCallbackInfo& args);
47     static void SetTag(const JSCallbackInfo& args);
48 }; // JSGesture
49 
50 class JSTapGesture : public JSGesture {
51     DECLARE_ACE_TYPE(JSTapGesture, JSGesture);
52 
53 public:
54     JSTapGesture() = default;
55     ~JSTapGesture() override = default;
56 
57     static void Create(const JSCallbackInfo& args);
58 };
59 
60 class JSLongPressGesture : public JSGesture {
61     DECLARE_ACE_TYPE(JSLongPressGesture, JSGesture);
62 
63 public:
64     JSLongPressGesture() = default;
65     ~JSLongPressGesture() override = default;
66 
67     static void Create(const JSCallbackInfo& args);
68 };
69 
70 class JSPanGestureOption final : public Referenced {
71 public:
72     JSPanGestureOption() = default;
73     ~JSPanGestureOption() override = default;
74 
75     static void JSBind(BindingTarget globalObj);
76     static void Constructor(const JSCallbackInfo& args);
77     static void Destructor(JSPanGestureOption* panGestureOption);
78     void SetDirection(const JSCallbackInfo& args);
79     void SetDistance(const JSCallbackInfo& args);
80     void SetFingers(const JSCallbackInfo& args);
81 
SetPanGestureOption(const RefPtr<PanGestureOption> & panGestureOption)82     void SetPanGestureOption(const RefPtr<PanGestureOption>& panGestureOption)
83     {
84         panGestureOption_ = panGestureOption;
85     }
86 
GetPanGestureOption()87     RefPtr<PanGestureOption> GetPanGestureOption() const
88     {
89         return panGestureOption_;
90     }
91 
92 private:
93     RefPtr<PanGestureOption> panGestureOption_;
94 };
95 
96 class JSPanGesture : public JSGesture {
97     DECLARE_ACE_TYPE(JSPanGesture, JSGesture);
98 
99 public:
100     JSPanGesture() = default;
101     ~JSPanGesture() override = default;
102 
103     static void Create(const JSCallbackInfo& args);
104 };
105 
106 class JSSwipeGesture : public JSGesture {
107     DECLARE_ACE_TYPE(JSSwipeGesture, JSGesture);
108 public:
109     JSSwipeGesture() = default;
110     ~JSSwipeGesture() override = default;
111 
112     static void Create(const JSCallbackInfo& args);
113 };
114 
115 class JSPinchGesture : public JSGesture {
116     DECLARE_ACE_TYPE(JSPinchGesture, JSGesture);
117 
118 public:
119     JSPinchGesture() = default;
120     ~JSPinchGesture() override = default;
121 
122     static void Create(const JSCallbackInfo& args);
123 };
124 
125 class JSRotationGesture : public JSGesture {
126     DECLARE_ACE_TYPE(JSRotationGesture, JSGesture);
127 
128 public:
129     JSRotationGesture() = default;
130     ~JSRotationGesture() override = default;
131 
132     static void Create(const JSCallbackInfo& args);
133 };
134 
135 class JSGestureGroup : public JSGesture {
136     DECLARE_ACE_TYPE(JSGestureGroup, JSGesture);
137 
138 public:
139     JSGestureGroup() = default;
140     ~JSGestureGroup() override = default;
141 
142     static void Create(const JSCallbackInfo& args);
143 };
144 
145 class JSParallelGesture : public JSGesture {
146     DECLARE_ACE_TYPE(JSParallelGesture, JSGesture)
147 public:
148     static void Create();
149     static void JSBind(BindingTarget globalObj);
150 };
151 
152 class JSTimeoutGesture : public JSGesture {
153     DECLARE_ACE_TYPE(JSTimeoutGesture, JSGesture)
154 public:
155     static void Create(const JSCallbackInfo& args);
156     static void Pop();
157     static void JSBind(BindingTarget globalObj);
158 };
159 } // namespace OHOS::Ace::Framework
160 #endif // FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_GESTURE_H
161 
162