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 #ifndef FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_INTERACTABLE_H
17 #define FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_INTERACTABLE_H
18 
19 #include "base/utils/macros.h"
20 #include "bridge/cj_frontend/cppview/view_abstract.h"
21 #include "core/event/key_event.h"
22 #include "core/gestures/raw_recognizer.h"
23 #include "core/gestures/tap_gesture.h"
24 
25 namespace OHOS::Ace::Framework {
26 
27 class ACE_EXPORT InteractableView {
28 public:
29     static void SetFocusable(bool focusable);
30     static void SetFocusNode(bool isFocusNode);
31     static void OnClick(std::function<void(const ClickInfo& clickInfo)> callback);
32     static void OnTouch(std::function<void(TouchEventInfo& touchInfo)> callback);
33     static void OnAppear(std::function<void()> callback);
34     static void OnDisAppear(std::function<void()> callback);
35     static void OnHover(std::function<void(bool)> callback);
36     static void OnKey(std::function<bool(KeyEventInfo& keyInfo)> callback);
37     static void OnDelete(std::function<void()> callback);
38     static EventMarker GetClickEventMarker(std::function<void(const ClickInfo& clickInfo)> callback);
39 
40 private:
41     static RefPtr<Gesture> GetTapGesture(std::function<void(const ClickInfo& clickInfo)> callback,
42         int32_t countNum = 1, int32_t fingerNum = 1);
43 };
44 
45 } // namespace OHOS::Ace::Framework
46 #endif // FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_INTERACTABLE_H
47