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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_PLATFORM_EVENT_PROXY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_PLATFORM_EVENT_PROXY_H 18 19 #include "core/components_ng/event/gesture_event_hub.h" 20 21 namespace OHOS::Ace::NG { 22 enum EventProxyFlag : uint64_t { 23 EVENT_NONE = 0X00000000, 24 EVENT_PAN_GESTURE_LEFT = 0X00000001, 25 EVENT_PAN_GESTURE_RIGHT = 0X00000002, 26 EVENT_PAN_GESTURE_UP = 0X00000004, 27 EVENT_PAN_GESTURE_DOWN = 0X00000008, 28 EVENT_CLICK = 0X00000100, 29 EVENT_LONG_PRESS = 0X00000200, 30 }; 31 32 enum EventProxyResultCode : int32_t { 33 NO_ERRORS = 0, 34 CHECK_POINTER_NULL, 35 NO_EXIST_WHEN_DELETE, 36 REMOVE_WHEN_DELETE, 37 EXIST_WHEN_ADDING, 38 ADD_WHEN_ADDING, 39 }; 40 41 class PlatformEventProxy : public AceType { 42 DECLARE_ACE_TYPE(PlatformEventProxy, AceType); 43 44 public: 45 virtual ~PlatformEventProxy() = default; 46 47 void SetHostNode(const WeakPtr<FrameNode>& host); 48 void SetEventProxyFlag(int32_t flag); 49 bool HasEventProxy(int32_t flag); 50 std::string GetCurEventProxyToString(); 51 52 EventProxyResultCode SetClickEventProxy( 53 const RefPtr<GestureEventHub>& gestureHub, bool addEvent); 54 EventProxyResultCode SetLongPressEventProxy( 55 const RefPtr<GestureEventHub>& gestureHub, bool addEvent); 56 EventProxyResultCode SetPanGestureEventProxy( 57 const RefPtr<GestureEventHub>& gestureHub, uint32_t panDirection); 58 uint32_t GetPanDirection(uint64_t flag); 59 60 private: 61 RefPtr<ClickEvent> clickEvent_; 62 RefPtr<LongPressEvent> longPressEvent_; 63 RefPtr<PanEvent> panEvent_; 64 uint32_t panDirection_ = PanDirection::NONE; 65 WeakPtr<FrameNode> host_; 66 }; 67 } // namespace OHOS::Ace::NG 68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_PLATFORM_EVENT_PROXY_H 69