1 /* 2 * Copyright (c) 2021-2022 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_DECLARATION_COMMON_EVENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_DECLARATION_COMMON_EVENT_H 18 19 #include <string> 20 21 #include "core/event/ace_event_handler.h" 22 #include "core/gestures/raw_recognizer.h" 23 #include "core/pipeline/pipeline_context.h" 24 25 namespace OHOS::Ace { 26 27 enum class EventTag { 28 COMMON_RAW_EVENT = 0, 29 COMMON_GESTURE_EVENT, 30 COMMON_REMOTE_MESSAGE_GESTURE_EVENT, 31 COMMON_FOCUS_EVENT, 32 COMMON_KEY_EVENT, 33 COMMON_MOUSE_EVENT, 34 COMMON_SWIPE_EVENT, 35 COMMON_ATTACH_EVENT, 36 COMMON_CROWN_EVENT, 37 SPECIALIZED_EVENT, 38 SPECIALIZED_REMOTE_MESSAGE_EVENT, 39 UNKNOWN, 40 DEFAULT, 41 }; 42 43 struct EventParam { 44 virtual void FireEvent(const WeakPtr<PipelineContext>& context); 45 bool isRefreshed = false; 46 EventMarker eventMarker; 47 }; 48 49 struct TouchEventParam : EventParam { 50 TouchEventInfo touchEvent = TouchEventInfo("unknown"); 51 void FireEvent(const WeakPtr<PipelineContext>& context) override; 52 }; 53 54 struct SwipeEvent : EventParam {}; 55 56 struct Event { IsValidEvent57 bool IsValid() const 58 { 59 return tag != EventTag::UNKNOWN; 60 } 61 IsSharedEvent62 bool IsShared() const 63 { 64 return isShared; 65 } 66 67 bool isShared = true; 68 EventTag tag = EventTag::DEFAULT; 69 }; 70 71 struct CommonRawEvent : Event { 72 TouchEventParam touchStart; 73 TouchEventParam touchMove; 74 TouchEventParam touchCancel; 75 TouchEventParam touchEnd; 76 TouchEventParam captureTouchStart; 77 TouchEventParam captureTouchMove; 78 TouchEventParam captureTouchCancel; 79 TouchEventParam captureTouchEnd; 80 TouchEventParam catchBubbleTouchStart; 81 TouchEventParam catchBubbleTouchMove; 82 TouchEventParam catchBubbleTouchCancel; 83 TouchEventParam catchBubbleTouchEnd; 84 TouchEventParam catchCaptureTouchStart; 85 TouchEventParam catchCaptureTouchMove; 86 TouchEventParam catchCaptureTouchCancel; 87 TouchEventParam catchCaptureTouchEnd; 88 }; 89 90 struct CommonGestureEvent : Event { 91 EventParam click; 92 EventParam doubleClick; 93 EventParam longPress; 94 EventParam pinchStart; 95 EventParam pinchUpdate; 96 EventParam pinchEnd; 97 EventParam pinchCancel; 98 EventParam dragStart; 99 EventParam drag; 100 EventParam dragEnd; 101 EventParam dragEnter; 102 EventParam dragOver; 103 EventParam dragLeave; 104 EventParam dragDrop; 105 }; 106 107 struct CommonFocusEvent : Event { 108 EventParam focus; 109 EventParam blur; 110 }; 111 112 struct CommonKeyEvent : Event { 113 EventParam key; 114 }; 115 116 struct CommonMouseEvent : Event { 117 EventParam mouse; 118 EventParam mouseHover; 119 EventParam mouseHoverExit; 120 }; 121 122 struct CommonSwipeEvent : Event { 123 EventParam swipe; 124 EventParam catchBubbleSwipe; 125 EventParam captureSwipe; 126 }; 127 128 struct CommonAttachEvent : Event { 129 EventParam attached; 130 EventParam detached; 131 }; 132 133 struct CommonCrownEvent : Event { 134 EventParam rotate; 135 }; 136 137 } // namespace OHOS::Ace 138 139 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_DECLARATION_COMMON_EVENT_H 140