• 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H
18 
19 #include "frameworks/bridge/declarative_frontend/jsview/js_pan_handler.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/js_touch_handler.h"
21 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
22 #include "frameworks/core/gestures/tap_gesture.h"
23 #include "frameworks/core/pipeline/base/component.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class JSInteractableView {
28 public:
29     static void JsOnTouch(const JSCallbackInfo& args);
30     static void JsOnPan(const JSCallbackInfo& args);
31     static void JsOnClick(const JSCallbackInfo& info);
32     static void JsTouchable(const JSCallbackInfo& info);
33     static void JsOnHover(const JSCallbackInfo& args);
34     static EventMarker GetClickEventMarker(const JSCallbackInfo& info);
35     static void JsOnKey(const JSCallbackInfo& args);
36     static void SetFocusable(bool focusable);
37     static void SetFocusNode(bool isFocusNode);
38 
39     static void JsOnAppear(const JSCallbackInfo& info);
40     static void JsOnDisAppear(const JSCallbackInfo& info);
41 
42     static void JsOnDelete(const JSCallbackInfo& info);
43     static void JsOnAccessibility(const JSCallbackInfo& info);
44     static void JsCommonRemoteMessage(const JSCallbackInfo& info);
45 
46     static void UpdateEventTarget(NodeId nodeId, BaseEventInfo& info);
47 
48 protected:
49     static void JsRemoteMessage(const JSCallbackInfo& info, EventMarker& eventMarker);
50 
51 private:
52     static RefPtr<Gesture> GetTapGesture(
53         const JSCallbackInfo& info, int32_t countNum = DEFAULT_TAP_COUNTS, int32_t fingerNum = DEFAULT_TAP_FINGERS);
54     static EventMarker GetEventMarker(const JSCallbackInfo& info, const std::vector<std::string>& keys);
55     static RefPtr<Gesture> GetRemoteMessageTapGesture(const JSCallbackInfo& info);
56     static std::function<void()> GetRemoteMessageEventCallback(const JSCallbackInfo& info);
57     static void SplitString(const std::string& str, char tag, std::vector<std::string>& strList);
58 }; // class JSInteractableView
59 
60 } // namespace OHOS::Ace::Framework
61 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_INTERACTABLE_VIEW_H
62