• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_EXTENED_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_EXTENED_H
18 
19 #include "drawable_descriptor.h"
20 #include "native_node.h"
21 #include "native_type.h"
22 #include "resource.h"
23 
24 #include "core/components_v2/inspector/inspector_constants.h"
25 #include "frameworks/core/interfaces/arkoala/arkoala_api.h"
26 #include "interfaces/inner_api/drawable_descriptor/drawable_descriptor.h"
27 #include "pixelmap_native_impl.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 struct ArkUI_LayoutConstraint {
33     /** 元素最小宽度。 */
34     int32_t minWidth;
35     /** 元素最小高度。 */
36     int32_t minHeight;
37     /** 元素最大宽度。 */
38     int32_t maxWidth;
39     /** 元素最小宽度。 */
40     int32_t maxHeight;
41     /** 元素宽度百分比基准。 */
42     int32_t percentReferWidth;
43     /** 元素高度百分比基准。*/
44     int32_t percentReferHeight;
45 };
46 
47 /**
48  * @brief 定义自定义组件回调事件的参数类型。
49  *
50  * @since 12
51  */
52 struct ArkUI_CustomNodeAsyncEvent {
53     /** 数据数组对象。*/
54     ArkUI_NumberValue data[MAX_COMPONENT_EVENT_ARG_NUM];
55 };
56 
57 /**
58  * 定义组件绘制上下文类型结构。
59  *
60  * @since 12
61  */
62 struct ArkUI_DrawContext {
63     /** 画布宽度。*/
64     int32_t width;
65     /** 画布高度。*/
66     int32_t height;
67     /** 绘制的画布。*/
68     void* canvas;
69 };
70 
71 /**
72  * @brief 定义自定义组件事件的通用结构类型。
73  *
74  * @since 12
75  */
76 struct ArkUI_NodeCustomEvent {
77     int32_t targetId;
78     ArkUI_NodeHandle node;
79     ArkUICustomNodeEvent* event;
80     ArkUI_LayoutConstraint constraint;
81     void* userData;
82 };
83 
84 struct ArkUI_OptionalFloat {
85     int32_t isSet;
86     float value;
87 };
88 
89 struct ArkUI_OptionalInt {
90     int32_t isSet;
91     int32_t value;
92 };
93 
94 struct ArkUI_OptionalUint {
95     int32_t isSet;
96     uint32_t value;
97 };
98 
99 struct ArkUI_OptionalCharPtr {
100     int32_t isSet;
101     const char* value;
102 };
103 
104 struct ArkUI_SwiperIndicator {
105     ArkUI_SwiperIndicatorType type;
106     ArkUI_OptionalFloat dimLeft;
107     ArkUI_OptionalFloat dimTop;
108     ArkUI_OptionalFloat dimRight;
109     ArkUI_OptionalFloat dimBottom;
110     ArkUI_OptionalFloat dimSpace;
111     ArkUI_OptionalFloat itemWidth;
112     ArkUI_OptionalFloat itemHeight;
113     ArkUI_OptionalFloat selectedItemWidth;
114     ArkUI_OptionalFloat selectedItemHeight;
115     ArkUI_OptionalInt maskValue;
116     ArkUI_OptionalUint colorValue;
117     ArkUI_OptionalUint selectedColorValue;
118     ArkUI_OptionalInt maxDisplayCount;
119     ArkUI_OptionalInt ignoreSizeValue;
120 };
121 
122 struct ArkUI_SwiperDigitIndicator {
123     ArkUI_SwiperIndicatorType type;
124     ArkUI_OptionalFloat dimLeft;
125     ArkUI_OptionalFloat dimTop;
126     ArkUI_OptionalFloat dimRight;
127     ArkUI_OptionalFloat dimBottom;
128     ArkUI_OptionalUint fontColor;
129     ArkUI_OptionalUint selectedFontColor;
130     ArkUI_OptionalFloat fontSize;
131     ArkUI_OptionalFloat selectedFontSize;
132     ArkUI_OptionalUint fontWeight;
133     ArkUI_OptionalUint selectedFontWeight;
134     ArkUI_OptionalInt ignoreSizeValue;
135 };
136 
137 struct ArkUI_SwiperArrowStyle {
138     ArkUI_OptionalInt showBackground;
139     ArkUI_OptionalInt showSidebarMiddle;
140     ArkUI_OptionalFloat backgroundSize;
141     ArkUI_OptionalUint backgroundColor;
142     ArkUI_OptionalFloat arrowSize;
143     ArkUI_OptionalUint arrowColor;
144 };
145 
146 struct ArkUI_DrawableDescriptor {
147     OH_PixelmapNativeHandle pixelMap;
148     OH_PixelmapNativeHandle* pixelMapArray;
149     ArkUI_Int32 size;
150     std::shared_ptr<OHOS::Ace::Napi::DrawableDescriptor> drawableDescriptor;
151     std::shared_ptr<OHOS::Ace::Napi::AnimatedDrawableDescriptor> animatedDrawableDescriptor;
152     std::shared_ptr<OHOS::Ace::Napi::LayeredDrawableDescriptor> layeredDrawableDescriptor;
153     std::shared_ptr<ArkUI_Resource> resource;
154 };
155 
156 struct ArkUI_AccessibilityState {
157     ArkUI_OptionalInt isDisabled;
158     ArkUI_OptionalInt isSelected;
159     ArkUI_OptionalInt checkedType;
160 };
161 
162 struct ArkUI_AccessibilityValue {
163     ArkUI_OptionalInt min;
164     ArkUI_OptionalInt max;
165     ArkUI_OptionalInt current;
166     ArkUI_OptionalInt rangeMin;
167     ArkUI_OptionalInt rangeMax;
168     ArkUI_OptionalInt rangeCurrent;
169     ArkUI_OptionalCharPtr text;
170 };
171 
172 struct ArkUI_CustomSpanMeasureInfo {
173     float fontSize;
174 };
175 
176 struct ArkUI_CustomSpanMetrics {
177     float width;
178     float height;
179 };
180 
181 struct ArkUI_CustomSpanDrawInfo {
182     float optionsX;
183     float optionsLineTop;
184     float optionsLineBottom;
185     float optionsBaseLine;
186 };
187 
188 struct ArkUI_CustomProperty {
189     char* value;
190 };
191 
192 struct ArkUI_HostWindowInfo {
193     char* name;
194 };
195 
196 struct ArkUI_ActiveChildrenInfo {
197     ArkUI_NodeHandle* nodeList;
198     int32_t nodeCount;
199 };
200 
201 struct ArkUI_CrossLanguageOption {
202     bool attributeSetting;
203 };
204 
205 struct ArkUI_VisibleAreaEventOptions {
206     std::vector<float> ratios;
207     int32_t expectedUpdateInterval;
208 };
209 
210 #ifdef __cplusplus
211 };
212 #endif
213 
214 namespace OHOS::Ace::NodeModel {
215 
216 void NodeAddExtraData(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType, int32_t targetId, void* userData);
217 int32_t RegisterNodeCustomEvent(
218     ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType, int32_t targetId, void* userData);
219 void NodeRemoveExtraData(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType);
220 void UnregisterNodeCustomEvent(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType eventType);
221 void RegisterNodeCustomReceiver(void (*eventReceiver)(ArkUI_NodeCustomEvent* event));
222 void UnregisterNodeCustomEventReceiver();
223 void HandleInnerCustomEvent(ArkUICustomNodeEvent* origin);
224 void HandleCustomEvent(ArkUI_NodeCustomEvent* event);
225 int32_t AddNodeCustomEventReceiver(ArkUI_NodeHandle nodePtr, void (*eventReceiver)(ArkUI_NodeCustomEvent* event));
226 int32_t RemoveNodeCustomEventReceiver(ArkUI_NodeHandle nodePtr,
227     void (*eventReceiver)(ArkUI_NodeCustomEvent* event));
228 int32_t SetMeasuredSize(ArkUI_NodeHandle node, int32_t width, int32_t height);
229 int32_t SetLayoutPosition(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY);
230 int32_t GetLayoutConstraint(ArkUI_NodeHandle node, ArkUI_LayoutConstraint* layoutConstraint);
231 ArkUI_IntSize GetMeasuredSize(ArkUI_NodeHandle node);
232 ArkUI_IntOffset GetLayoutPosition(ArkUI_NodeHandle node);
233 int32_t MeasureNode(ArkUI_NodeHandle node, ArkUI_LayoutConstraint* constraint);
234 int32_t LayoutNode(ArkUI_NodeHandle node, int32_t positionX, int32_t positionY);
235 
236 uint32_t GetTotalChildCount(ArkUI_NodeHandle node);
237 ArkUI_NodeHandle GetChildAt(ArkUI_NodeHandle node, int32_t position);
238 ArkUI_NodeHandle GetFirstChild(ArkUI_NodeHandle node);
239 ArkUI_NodeHandle GetLastChild(ArkUI_NodeHandle node);
240 ArkUI_NodeHandle GetPreviousSibling(ArkUI_NodeHandle node);
241 ArkUI_NodeHandle GetNextSibling(ArkUI_NodeHandle node);
242 ArkUI_NodeHandle GetParent(ArkUI_NodeHandle node);
243 int32_t RemoveAllChildren(ArkUI_NodeHandle parentNode);
244 } // namespace OHOS::Ace::NodeModel
245 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_EXTENED_H