123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ci
1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_MODEL_H
1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_MODEL_H
1823b3eb3cSopenharmony_ci
1923b3eb3cSopenharmony_ci#include <cstdint>
2023b3eb3cSopenharmony_ci#include <set>
2123b3eb3cSopenharmony_ci#include <vector>
2223b3eb3cSopenharmony_ci#include <string>
2323b3eb3cSopenharmony_ci
2423b3eb3cSopenharmony_ci#include "native_compatible.h"
2523b3eb3cSopenharmony_ci#include "native_node.h"
2623b3eb3cSopenharmony_ci#include "native_type.h"
2723b3eb3cSopenharmony_ci
2823b3eb3cSopenharmony_ci#include "frameworks/core/interfaces/arkoala/arkoala_api.h"
2923b3eb3cSopenharmony_ci
3023b3eb3cSopenharmony_ci#ifdef __cplusplus
3123b3eb3cSopenharmony_ciextern "C" {
3223b3eb3cSopenharmony_ci#endif
3323b3eb3cSopenharmony_ci
3423b3eb3cSopenharmony_cistruct ArkUI_Node {
3523b3eb3cSopenharmony_ci    int32_t type;
3623b3eb3cSopenharmony_ci    ArkUINodeHandle uiNodeHandle = nullptr;
3723b3eb3cSopenharmony_ci    void* extraData = nullptr;
3823b3eb3cSopenharmony_ci    void* extraCustomData = nullptr;
3923b3eb3cSopenharmony_ci    ArkUI_LengthMetricUnit lengthMetricUnit = ARKUI_LENGTH_METRIC_UNIT_DEFAULT;
4023b3eb3cSopenharmony_ci    void* eventListeners = nullptr;
4123b3eb3cSopenharmony_ci    void* barrierOption = nullptr;
4223b3eb3cSopenharmony_ci    void* guidelineOption = nullptr;
4323b3eb3cSopenharmony_ci    void* alignRuleOption = nullptr;
4423b3eb3cSopenharmony_ci    void* userData = nullptr;
4523b3eb3cSopenharmony_ci    void* swiperIndicator = nullptr;
4623b3eb3cSopenharmony_ci    void* imageFrameInfos = nullptr;
4723b3eb3cSopenharmony_ci    void* drawableDescriptor = nullptr;
4823b3eb3cSopenharmony_ci    int32_t linearGradientDirection = -1;
4923b3eb3cSopenharmony_ci    void* customEventListeners = nullptr;
5023b3eb3cSopenharmony_ci    void* altDrawableDescriptor = nullptr;
5123b3eb3cSopenharmony_ci    ArkUI_AttributeItem* areaChangeRadio = nullptr;
5223b3eb3cSopenharmony_ci    void* transitionOption = nullptr;
5323b3eb3cSopenharmony_ci};
5423b3eb3cSopenharmony_ci
5523b3eb3cSopenharmony_cistruct ArkUI_Context {
5623b3eb3cSopenharmony_ci    int32_t id;
5723b3eb3cSopenharmony_ci};
5823b3eb3cSopenharmony_ci
5923b3eb3cSopenharmony_cistruct ArkUI_GuidelineStyle {
6023b3eb3cSopenharmony_ci    std::string id;
6123b3eb3cSopenharmony_ci    ArkUI_Axis direction;
6223b3eb3cSopenharmony_ci    float start;
6323b3eb3cSopenharmony_ci    bool hasStart;
6423b3eb3cSopenharmony_ci    float end;
6523b3eb3cSopenharmony_ci    bool hasEnd;
6623b3eb3cSopenharmony_ci};
6723b3eb3cSopenharmony_ci
6823b3eb3cSopenharmony_cistruct ArkUI_GuidelineOption {
6923b3eb3cSopenharmony_ci    std::vector<ArkUI_GuidelineStyle> styles;
7023b3eb3cSopenharmony_ci};
7123b3eb3cSopenharmony_ci
7223b3eb3cSopenharmony_cistruct ArkUI_BarrierStyle {
7323b3eb3cSopenharmony_ci    std::string id;
7423b3eb3cSopenharmony_ci    ArkUI_BarrierDirection direction;
7523b3eb3cSopenharmony_ci    std::vector<std::string> referencedId;
7623b3eb3cSopenharmony_ci};
7723b3eb3cSopenharmony_ci
7823b3eb3cSopenharmony_cistruct ArkUI_BarrierOption {
7923b3eb3cSopenharmony_ci    std::vector<ArkUI_BarrierStyle> styles;
8023b3eb3cSopenharmony_ci};
8123b3eb3cSopenharmony_ci
8223b3eb3cSopenharmony_cistruct ArkUI_HorizontalAlignRule {
8323b3eb3cSopenharmony_ci    bool hasValue;
8423b3eb3cSopenharmony_ci    std::string anchor;
8523b3eb3cSopenharmony_ci    ArkUI_HorizontalAlignment align;
8623b3eb3cSopenharmony_ci};
8723b3eb3cSopenharmony_ci
8823b3eb3cSopenharmony_cistruct ArkUI_VerticalAlignRule {
8923b3eb3cSopenharmony_ci    bool hasValue;
9023b3eb3cSopenharmony_ci    std::string anchor;
9123b3eb3cSopenharmony_ci    ArkUI_VerticalAlignment align;
9223b3eb3cSopenharmony_ci};
9323b3eb3cSopenharmony_ci
9423b3eb3cSopenharmony_cistruct ArkUI_AlignmentRuleOption {
9523b3eb3cSopenharmony_ci    ArkUI_HorizontalAlignRule left;
9623b3eb3cSopenharmony_ci    ArkUI_HorizontalAlignRule middle;
9723b3eb3cSopenharmony_ci    ArkUI_HorizontalAlignRule right;
9823b3eb3cSopenharmony_ci    ArkUI_VerticalAlignRule top;
9923b3eb3cSopenharmony_ci    ArkUI_VerticalAlignRule center;
10023b3eb3cSopenharmony_ci    ArkUI_VerticalAlignRule bottom;
10123b3eb3cSopenharmony_ci    float biasHorizontal;
10223b3eb3cSopenharmony_ci    float biasVertical;
10323b3eb3cSopenharmony_ci};
10423b3eb3cSopenharmony_ci
10523b3eb3cSopenharmony_ciconstexpr int BASIC_COMPONENT_NUM = 20;
10623b3eb3cSopenharmony_ci
10723b3eb3cSopenharmony_ci#ifdef __cplusplus
10823b3eb3cSopenharmony_ci};
10923b3eb3cSopenharmony_ci#endif
11023b3eb3cSopenharmony_ci
11123b3eb3cSopenharmony_cistruct ArkUIFullNodeAPI;
11223b3eb3cSopenharmony_ci
11323b3eb3cSopenharmony_cinamespace OHOS::Ace::NodeModel {
11423b3eb3cSopenharmony_ci
11523b3eb3cSopenharmony_ciinline bool UsePXUnit(ArkUI_NodeHandle nodePtr)
11623b3eb3cSopenharmony_ci{
11723b3eb3cSopenharmony_ci    return nodePtr && (nodePtr->lengthMetricUnit == ARKUI_LENGTH_METRIC_UNIT_PX);
11823b3eb3cSopenharmony_ci}
11923b3eb3cSopenharmony_ci
12023b3eb3cSopenharmony_cibool InitialFullImpl();
12123b3eb3cSopenharmony_ciArkUIFullNodeAPI* GetFullImpl();
12223b3eb3cSopenharmony_ciArkUI_NodeHandle CreateNode(ArkUI_NodeType type);
12323b3eb3cSopenharmony_civoid DisposeNode(ArkUI_NodeHandle nativePtr);
12423b3eb3cSopenharmony_cibool IsValidArkUINode(ArkUI_NodeHandle nodePtr);
12523b3eb3cSopenharmony_ci
12623b3eb3cSopenharmony_ciint32_t AddChild(ArkUI_NodeHandle parentNode, ArkUI_NodeHandle childNode);
12723b3eb3cSopenharmony_ciint32_t RemoveChild(ArkUI_NodeHandle parentNode, ArkUI_NodeHandle childNode);
12823b3eb3cSopenharmony_ciint32_t InsertChildAfter(ArkUI_NodeHandle parentNode, ArkUI_NodeHandle childNode, ArkUI_NodeHandle siblingNode);
12923b3eb3cSopenharmony_ciint32_t InsertChildBefore(ArkUI_NodeHandle parentNode, ArkUI_NodeHandle childNode, ArkUI_NodeHandle siblingNode);
13023b3eb3cSopenharmony_ciint32_t InsertChildAt(ArkUI_NodeHandle parentNode, ArkUI_NodeHandle childNode, int32_t position);
13123b3eb3cSopenharmony_ci
13223b3eb3cSopenharmony_ci// deprecated.
13323b3eb3cSopenharmony_ci[[deprecated]] void SetAttribute(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute, const char* value);
13423b3eb3cSopenharmony_ci
13523b3eb3cSopenharmony_ciint32_t SetAttribute(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute, const ArkUI_AttributeItem* value);
13623b3eb3cSopenharmony_ciconst ArkUI_AttributeItem* GetAttribute(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute);
13723b3eb3cSopenharmony_ciint32_t ResetAttribute(ArkUI_NodeHandle node, ArkUI_NodeAttributeType attribute);
13823b3eb3cSopenharmony_ci
13923b3eb3cSopenharmony_ciint32_t RegisterNodeEvent(ArkUI_NodeHandle nodePtr, ArkUI_NodeEventType eventType, int32_t targetId);
14023b3eb3cSopenharmony_ciint32_t RegisterNodeEvent(ArkUI_NodeHandle nodePtr, ArkUI_NodeEventType eventType, int32_t targetId, void* userData);
14123b3eb3cSopenharmony_civoid UnregisterNodeEvent(ArkUI_NodeHandle nodePtr, ArkUI_NodeEventType eventType);
14223b3eb3cSopenharmony_civoid RegisterOnEvent(void (*eventReceiver)(ArkUI_NodeEvent* event));
14323b3eb3cSopenharmony_civoid RegisterOnEvent(void (*eventReceiver)(ArkUI_CompatibleNodeEvent* event));
14423b3eb3cSopenharmony_civoid UnregisterOnEvent();
14523b3eb3cSopenharmony_ciint32_t CheckEvent(ArkUI_NodeEvent* event);
14623b3eb3cSopenharmony_civoid HandleInnerNodeEvent(ArkUINodeEvent* innerEvent);
14723b3eb3cSopenharmony_ciint32_t GetNativeNodeEventType(ArkUINodeEvent* innerEvent);
14823b3eb3cSopenharmony_civoid HandleNodeEvent(ArkUI_NodeEvent* event);
14923b3eb3cSopenharmony_civoid TriggerNodeEvent(ArkUI_NodeEvent* event, std::set<void (*)(ArkUI_NodeEvent*)>* eventListenersSet);
15023b3eb3cSopenharmony_civoid ApplyModifierFinish(ArkUI_NodeHandle nodePtr);
15123b3eb3cSopenharmony_civoid MarkDirty(ArkUI_NodeHandle nodePtr, ArkUI_NodeDirtyFlag dirtyFlag);
15223b3eb3cSopenharmony_ci
15323b3eb3cSopenharmony_ciint32_t SetUserData(ArkUI_NodeHandle node, void* userData);
15423b3eb3cSopenharmony_civoid* GetUserData(ArkUI_NodeHandle node);
15523b3eb3cSopenharmony_ciint32_t SetLengthMetricUnit(ArkUI_NodeHandle nodePtr, ArkUI_LengthMetricUnit unit);
15623b3eb3cSopenharmony_ciint32_t AddNodeEventReceiver(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event));
15723b3eb3cSopenharmony_ciint32_t RemoveNodeEventReceiver(ArkUI_NodeHandle node, void (*eventReceiver)(ArkUI_NodeEvent* event));
15823b3eb3cSopenharmony_civoid* GetParseJsMedia();
15923b3eb3cSopenharmony_ci}; // namespace OHOS::Ace::NodeModel
16023b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_MODEL_H
161