1 /* 2 * Copyright (c) 2023 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 ARKUI_NATIVE_NODE_EVENT_CONVERTER_H 17 #define ARKUI_NATIVE_NODE_EVENT_CONVERTER_H 18 19 #include "native_compatible.h" 20 #include "native_node.h" 21 #include "native_type.h" 22 23 #include "core/interfaces/arkoala/arkoala_api.h" 24 25 struct ArkUI_NodeEvent { 26 int32_t category; 27 int32_t kind; 28 int32_t targetId; 29 ArkUI_NodeHandle node; 30 void* userData; 31 void* origin; 32 int32_t eventId; 33 }; 34 35 enum NodeEventCategory { 36 NODE_EVENT_CATEGORY_UNKOWN = -1, 37 NODE_EVENT_CATEGORY_INPUT_EVENT, 38 NODE_EVENT_CATEGORY_COMPONENT_EVENT, 39 NODE_EVENT_CATEGORY_STRING_ASYNC_EVENT, 40 NODE_EVENT_CATEGORY_MIXED_EVENT, 41 }; 42 43 namespace OHOS::Ace::NodeModel { 44 // for error info, use int instead of ArkUINodeEventType 45 ArkUI_Int32 ConvertOriginEventType(ArkUI_NodeEventType type, int32_t nodeType); 46 ArkUI_Int32 ConvertToNodeEventType(ArkUIEventSubKind type); 47 bool IsStringEvent(ArkUI_Int32 type); 48 bool IsTouchEvent(ArkUI_Int32 type); 49 50 bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_NodeEvent* event); 51 52 void HandleInnerEvent(ArkUINodeEvent* innerEvent); 53 int32_t ConvertToCTouchActionType(int32_t originActionType); 54 int32_t ConvertToCInputEventToolType(int32_t originSourceType); 55 56 bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_CompatibleNodeEvent* event); 57 bool ConvertEventResult(ArkUI_CompatibleNodeEvent* event, ArkUINodeEvent* origin); 58 59 int32_t ConvertToCMouseActionType(int32_t originActionType); 60 int32_t ConvertToCMouseEventButtonType(int32_t originButtonType); 61 62 }; // namespace OHOS::Ace::NodeModel 63 #endif // ARKUI_NATIVE_NODE_EVENT_CONVERTER_H 64