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