1 /*
2  * Copyright (c) 2023-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 #include "core/interfaces/native/node/node_common_modifier.h"
16 
17 #include <cstddef>
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 #include "interfaces/native/native_type.h"
23 #include "interfaces/native/node/node_model.h"
24 #include "securec.h"
25 
26 #include "base/geometry/ng/vector.h"
27 #include "base/geometry/shape.h"
28 #include "base/image/pixel_map.h"
29 #include "base/log/log_wrapper.h"
30 #include "base/memory/ace_type.h"
31 #include "base/utils/system_properties.h"
32 #include "base/utils/utils.h"
33 #include "bridge/common/utils/utils.h"
34 #include "core/animation/animation_pub.h"
35 #include "core/animation/curves.h"
36 #include "core/common/ime/text_input_type.h"
37 #include "core/components/common/layout/constants.h"
38 #include "core/components/common/properties/animation_option.h"
39 #include "core/components/common/properties/color.h"
40 #include "core/components/common/properties/decoration.h"
41 #include "core/components/common/properties/shadow.h"
42 #include "core/components/theme/shadow_theme.h"
43 #include "core/components_ng/base/frame_node.h"
44 #include "core/components_ng/base/view_abstract.h"
45 #include "core/components_ng/base/view_abstract_model_ng.h"
46 #include "core/components_ng/pattern/shape/shape_abstract_model_ng.h"
47 #include "core/components_ng/pattern/text/image_span_view.h"
48 #include "core/components_ng/pattern/text/span_model_ng.h"
49 #include "core/components_ng/pattern/text/text_model_ng.h"
50 #include "core/components_ng/property/transition_property.h"
51 #include "core/image/image_source_info.h"
52 #include "core/interfaces/arkoala/arkoala_api.h"
53 #include "core/interfaces/native/node/node_drag_modifier.h"
54 #include "core/interfaces/native/node/touch_event_convertor.h"
55 
56 namespace OHOS::Ace::NG {
57 namespace {
58 constexpr VisibleType DEFAULT_VISIBILITY = static_cast<VisibleType>(0);
59 constexpr float MAX_ANGLE = 360.0f;
60 constexpr float DEFAULT_ANGLE = 180.0f;
61 constexpr double PERCENT_100 = 100.0;
62 constexpr int NUM_0 = 0;
63 constexpr int NUM_1 = 1;
64 constexpr int NUM_2 = 2;
65 constexpr int NUM_3 = 3;
66 constexpr int NUM_4 = 4;
67 constexpr int NUM_5 = 5;
68 constexpr int NUM_6 = 6;
69 constexpr int NUM_7 = 7;
70 constexpr int NUM_8 = 8;
71 constexpr int NUM_9 = 9;
72 constexpr int NUM_10 = 10;
73 constexpr int NUM_11 = 11;
74 constexpr int NUM_12 = 12;
75 constexpr int NUM_13 = 13;
76 constexpr int NUM_14 = 14;
77 constexpr int NUM_15 = 15;
78 constexpr int NUM_16 = 16;
79 constexpr int NUM_24 = 24;
80 constexpr int NUM_36 = 36;
81 constexpr int DEFAULT_LENGTH = 4;
82 constexpr double ROUND_UNIT = 360.0;
83 constexpr TextDirection DEFAULT_COMMON_DIRECTION = TextDirection::AUTO;
84 constexpr int32_t DEFAULT_COMMON_LAYOUTWEIGHT = 0;
85 constexpr int32_t MAX_ALIGN_VALUE = 8;
86 // default gridSpan is 1 on doc
87 constexpr int32_t DEFAULT_GRIDSPAN = 1;
88 constexpr uint32_t DEFAULT_ALIGN_RULES_SIZE = 6;
89 constexpr uint8_t DEFAULT_SAFE_AREA_TYPE = 0b111;
90 constexpr uint8_t DEFAULT_SAFE_AREA_EDGE = 0b1111;
91 constexpr Dimension DEFAULT_FLEX_BASIS { 0.0, DimensionUnit::AUTO };
92 constexpr int32_t DEFAULT_DISPLAY_PRIORITY = 0;
93 constexpr int32_t DEFAULT_ID = 0;
94 constexpr int32_t X_INDEX = 0;
95 constexpr int32_t Y_INDEX = 1;
96 constexpr int32_t Z_INDEX = 2;
97 constexpr int32_t ARRAY_SIZE = 3;
98 constexpr float HALF = 0.5f;
99 constexpr float DEFAULT_BIAS = 0.5f;
100 constexpr float DEFAULT_SATURATE = 1.0f;
101 constexpr float DEFAULT_BRIGHTNESS = 1.0f;
102 constexpr int32_t OUTLINE_LEFT_WIDTH_INDEX = 0;
103 constexpr int32_t OUTLINE_TOP_WIDTH_INDEX = 1;
104 constexpr int32_t OUTLINE_RIGHT_WIDTH_INDEX = 2;
105 constexpr int32_t OUTLINE_BOTTOM_WIDTH_INDEX = 3;
106 constexpr int32_t OUTLINE_WIDTH_VECTOR_SIZE = 4;
107 const int32_t ERROR_INT_CODE = -1;
108 const double DEFAULT_DASH_DIMENSION = -1;
109 const float ERROR_FLOAT_CODE = -1.0f;
110 constexpr int32_t MAX_POINTS = 10;
111 constexpr int32_t MAX_HISTORY_EVENT_COUNT = 20;
112 const std::vector<OHOS::Ace::RefPtr<OHOS::Ace::Curve>> CURVES = {
113     OHOS::Ace::Curves::LINEAR,
114     OHOS::Ace::Curves::EASE,
115     OHOS::Ace::Curves::EASE_IN,
116     OHOS::Ace::Curves::EASE_OUT,
117     OHOS::Ace::Curves::EASE_IN_OUT,
118     OHOS::Ace::Curves::FAST_OUT_SLOW_IN,
119     OHOS::Ace::Curves::LINEAR_OUT_SLOW_IN,
120     OHOS::Ace::Curves::FAST_OUT_LINEAR_IN,
121     OHOS::Ace::Curves::EXTREME_DECELERATION,
122     OHOS::Ace::Curves::SHARP,
123     OHOS::Ace::Curves::RHYTHM,
124     OHOS::Ace::Curves::SMOOTH,
125     OHOS::Ace::Curves::FRICTION,
126 };
127 
128 enum TransitionEffectType {
129     TRANSITION_EFFECT_OPACITY = 0,
130     TRANSITION_EFFECT_TRANSLATE,
131     TRANSITION_EFFECT_SCALE,
132     TRANSITION_EFFECT_ROTATE,
133     TRANSITION_EFFECT_MOVE,
134     TRANSITION_EFFECT_ASYMMETRIC,
135 };
136 
137 const std::vector<AnimationDirection> DIRECTION_LIST = {
138     AnimationDirection::NORMAL,
139     AnimationDirection::REVERSE,
140     AnimationDirection::ALTERNATE,
141     AnimationDirection::ALTERNATE_REVERSE,
142 };
143 
144 constexpr int32_t DEFAULT_DURATION = 1000;
145 std::string g_strValue;
146 
ConvertBorderStyle(int32_t value)147 BorderStyle ConvertBorderStyle(int32_t value)
148 {
149     auto style = static_cast<BorderStyle>(value);
150     if (style < BorderStyle::SOLID || style > BorderStyle::NONE) {
151         style = BorderStyle::SOLID;
152     }
153     return style;
154 }
155 
ParseAlignment(int32_t align)156 Alignment ParseAlignment(int32_t align)
157 {
158     Alignment alignment = Alignment::CENTER;
159     switch (align) {
160         case NUM_0:
161             alignment = Alignment::TOP_LEFT;
162             break;
163         case NUM_1:
164             alignment = Alignment::TOP_CENTER;
165             break;
166         case NUM_2:
167             alignment = Alignment::TOP_RIGHT;
168             break;
169         case NUM_3:
170             alignment = Alignment::CENTER_LEFT;
171             break;
172         case NUM_4:
173             alignment = Alignment::CENTER;
174             break;
175         case NUM_5:
176             alignment = Alignment::CENTER_RIGHT;
177             break;
178         case NUM_6:
179             alignment = Alignment::BOTTOM_LEFT;
180             break;
181         case NUM_7:
182             alignment = Alignment::BOTTOM_CENTER;
183             break;
184         case NUM_8:
185             alignment = Alignment::BOTTOM_RIGHT;
186             break;
187         default:
188             break;
189     }
190     return alignment;
191 }
192 
ConvertAlignmentToInt(Alignment alignment)193 int32_t ConvertAlignmentToInt(Alignment alignment)
194 {
195     if (alignment == Alignment::TOP_LEFT) {
196         return NUM_0;
197     }
198     if (alignment == Alignment::TOP_CENTER) {
199         return NUM_1;
200     }
201     if (alignment == Alignment::TOP_RIGHT) {
202         return NUM_2;
203     }
204     if (alignment == Alignment::CENTER_LEFT) {
205         return NUM_3;
206     }
207     if (alignment == Alignment::CENTER) {
208         return NUM_4;
209     }
210     if (alignment == Alignment::CENTER_RIGHT) {
211         return NUM_5;
212     }
213     if (alignment == Alignment::BOTTOM_LEFT) {
214         return NUM_6;
215     }
216     if (alignment == Alignment::BOTTOM_CENTER) {
217         return NUM_7;
218     }
219     if (alignment == Alignment::BOTTOM_RIGHT) {
220         return NUM_8;
221     }
222     return NUM_4;
223 }
224 
ParseAlignmentToIndex(Alignment align)225 int32_t ParseAlignmentToIndex(Alignment align)
226 {
227     if (align == Alignment::TOP_LEFT) {
228         return NUM_0;
229     }
230     if (align == Alignment::TOP_CENTER) {
231         return NUM_1;
232     }
233     if (align == Alignment::TOP_RIGHT) {
234         return NUM_2;
235     }
236     if (align == Alignment::CENTER_LEFT) {
237         return NUM_3;
238     }
239     if (align == Alignment::CENTER) {
240         return NUM_4;
241     }
242     if (align == Alignment::CENTER_RIGHT) {
243         return NUM_5;
244     }
245     if (align == Alignment::BOTTOM_LEFT) {
246         return NUM_6;
247     }
248     if (align == Alignment::BOTTOM_CENTER) {
249         return NUM_7;
250     }
251     if (align == Alignment::BOTTOM_RIGHT) {
252         return NUM_8;
253     }
254     return ERROR_INT_CODE;
255 }
256 
257 /**
258  * @param colors color value
259  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
260  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
261  * ...
262  * @param colorsLength colors length
263  */
SetGradientColors(NG::Gradient & gradient,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)264 void SetGradientColors(NG::Gradient& gradient, const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
265 {
266     if ((colors == nullptr) || (colorsLength % NUM_3) != 0) {
267         return;
268     }
269     for (int32_t index = 0; index < colorsLength; index += NUM_3) {
270         auto colorValue = colors[index].u32;
271         auto colorHasDimension = colors[index + NUM_1].i32;
272         auto colorDimension = colors[index + NUM_2].f32;
273         auto color = static_cast<uint32_t>(colorValue);
274         auto hasDimension = static_cast<bool>(colorHasDimension);
275         auto dimension = colorDimension;
276         NG::GradientColor gradientColor;
277         gradientColor.SetColor(Color(color));
278         gradientColor.SetHasValue(hasDimension);
279         if (hasDimension) {
280             gradientColor.SetDimension(CalcDimension(dimension * PERCENT_100, DimensionUnit::PERCENT));
281         }
282         gradient.AddColor(gradientColor);
283     }
284 }
285 
SetLinearGradientDirectionTo(std::shared_ptr<LinearGradient> & linearGradient,const GradientDirection direction)286 void SetLinearGradientDirectionTo(std::shared_ptr<LinearGradient>& linearGradient, const GradientDirection direction)
287 {
288     switch (direction) {
289         case GradientDirection::LEFT:
290             linearGradient->linearX = NG::GradientDirection::LEFT;
291             break;
292         case GradientDirection::RIGHT:
293             linearGradient->linearX = NG::GradientDirection::RIGHT;
294             break;
295         case GradientDirection::TOP:
296             linearGradient->linearY = NG::GradientDirection::TOP;
297             break;
298         case GradientDirection::BOTTOM:
299             linearGradient->linearY = NG::GradientDirection::BOTTOM;
300             break;
301         case GradientDirection::LEFT_TOP:
302             linearGradient->linearX = NG::GradientDirection::LEFT;
303             linearGradient->linearY = NG::GradientDirection::TOP;
304             break;
305         case GradientDirection::LEFT_BOTTOM:
306             linearGradient->linearX = NG::GradientDirection::LEFT;
307             linearGradient->linearY = NG::GradientDirection::BOTTOM;
308             break;
309         case GradientDirection::RIGHT_TOP:
310             linearGradient->linearX = NG::GradientDirection::RIGHT;
311             linearGradient->linearY = NG::GradientDirection::TOP;
312             break;
313         case GradientDirection::RIGHT_BOTTOM:
314             linearGradient->linearX = NG::GradientDirection::RIGHT;
315             linearGradient->linearY = NG::GradientDirection::BOTTOM;
316             break;
317         case GradientDirection::NONE:
318         case GradientDirection::START_TO_END:
319         case GradientDirection::END_TO_START:
320         default:
321             break;
322     }
323 }
324 
convertToLinearGradientDirection(std::shared_ptr<LinearGradient> linearGradient)325 GradientDirection convertToLinearGradientDirection(std::shared_ptr<LinearGradient> linearGradient)
326 {
327     auto linearX = linearGradient->linearX;
328     auto linearY = linearGradient->linearY;
329     if (!linearX.has_value() && !linearY.has_value()) {
330         return GradientDirection::BOTTOM;
331     }
332     if (linearX.has_value() && !linearY.has_value()) {
333         return linearX.value();
334     }
335     if (!linearX.has_value() && linearY.has_value()) {
336         return linearY.value();
337     }
338 
339     if (linearX.value() == NG::GradientDirection::LEFT && linearY.value() == NG::GradientDirection::TOP) {
340         return GradientDirection::LEFT_TOP;
341     }
342     if (linearX.value() == NG::GradientDirection::LEFT && linearY.value() == NG::GradientDirection::BOTTOM) {
343         return GradientDirection::LEFT_BOTTOM;
344     }
345     if (linearX.value() == NG::GradientDirection::RIGHT && linearY.value() == NG::GradientDirection::TOP) {
346         return GradientDirection::RIGHT_TOP;
347     }
348     if (linearX.value() == NG::GradientDirection::RIGHT && linearY.value() == NG::GradientDirection::BOTTOM) {
349         return GradientDirection::RIGHT_BOTTOM;
350     }
351     return GradientDirection::BOTTOM;
352 }
353 
354 /**
355  * @param values value value
356  * values[0], values[1] : angle: hasValue, angle value
357  * values[2] : direction
358  * values[3] : repeating
359  * @param valuesLength values length
360  */
SetLinearGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)361 void SetLinearGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
362 {
363     if ((values == nullptr) || (valuesLength != NUM_4)) {
364         return;
365     }
366     auto angleHasValue = values[NUM_0].i32;
367     auto angleValue = values[NUM_1].f32;
368     auto directionValue = values[NUM_2].i32;
369     auto repeating = values[NUM_3].i32;
370     auto linearGradient = gradient.GetLinearGradient();
371     if (linearGradient == nullptr) {
372         return;
373     }
374     if (static_cast<bool>(angleHasValue)) {
375         linearGradient->angle = CalcDimension(angleValue, DimensionUnit::PX);
376     }
377     SetLinearGradientDirectionTo(linearGradient, static_cast<GradientDirection>(directionValue));
378     gradient.SetRepeat(static_cast<bool>(repeating));
379 }
380 
CheckAngle(const ArkUI_Float32 angle)381 ArkUI_Float32 CheckAngle(const ArkUI_Float32 angle)
382 {
383     if (LessNotEqual(angle, 0.0f)) {
384         return 0.0f;
385     }
386     if (GreatNotEqual(angle, MAX_ANGLE)) {
387         return MAX_ANGLE;
388     }
389     return angle;
390 }
391 
392 /**
393  * @param values value value
394  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
395  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
396  * values[6], values[7] : start: hasValue, start degree value
397  * values[8], values[9] : end: hasValue, end degree value
398  * values[10], values[11] : rotation: hasValue, rotation degree value
399  * values[12] : repeating
400  * @param valuesLength values length
401  */
SetSweepGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)402 void SetSweepGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
403 {
404     if ((values == nullptr) || (valuesLength != NUM_13)) {
405         return;
406     }
407     auto centerXHasValue = values[NUM_0].i32;
408     auto centerXValue = values[NUM_1].f32;
409     auto centerXUnit = values[NUM_2].i32;
410     auto centerYHasValue = values[NUM_3].i32;
411     auto centerYValue = values[NUM_4].f32;
412     auto centerYUnit = values[NUM_5].i32;
413     auto startHasValue = values[NUM_6].i32;
414     auto startValue = values[NUM_7].f32;
415     auto endHasValue = values[NUM_8].i32;
416     auto endValue = values[NUM_9].f32;
417     auto rotationHasValue = values[NUM_10].i32;
418     auto rotationValue = values[NUM_11].f32;
419     auto repeating = values[NUM_12].i32;
420     if (static_cast<bool>(centerXHasValue)) {
421         auto unit = static_cast<DimensionUnit>(centerXUnit);
422         auto value = (unit == DimensionUnit::PERCENT) ? (centerXValue * PERCENT_100) : centerXValue;
423         gradient.GetSweepGradient()->centerX = CalcDimension(value, unit);
424     }
425     if (static_cast<bool>(centerYHasValue)) {
426         auto unit = static_cast<DimensionUnit>(centerYUnit);
427         auto value = (unit == DimensionUnit::PERCENT) ? (centerYValue * PERCENT_100) : centerYValue;
428         gradient.GetSweepGradient()->centerY = CalcDimension(value, unit);
429     }
430     if (static_cast<bool>(startHasValue)) {
431         gradient.GetSweepGradient()->startAngle = CalcDimension(CheckAngle(startValue), DimensionUnit::PX);
432     }
433     if (static_cast<bool>(endHasValue)) {
434         gradient.GetSweepGradient()->endAngle = CalcDimension(CheckAngle(endValue), DimensionUnit::PX);
435     }
436     if (static_cast<bool>(rotationHasValue)) {
437         gradient.GetSweepGradient()->rotation = CalcDimension(CheckAngle(rotationValue), DimensionUnit::PX);
438     }
439     gradient.SetRepeat(static_cast<bool>(repeating));
440 }
441 
442 /**
443  * @param values value value
444  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
445  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
446  * values[6], values[7], values[8] : radius: Dimension: hasValue, value, unit
447  * values[9] : repeating
448  * @param valuesLength values length
449  */
SetRadialGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)450 void SetRadialGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
451 {
452     if ((values == nullptr) || (valuesLength != NUM_10)) {
453         return;
454     }
455 
456     auto centerXHasValue = values[NUM_0].i32;
457     auto centerXValue = values[NUM_1].f32;
458     auto centerXUnit = values[NUM_2].i32;
459     auto centerYHasValue = values[NUM_3].i32;
460     auto centerYValue = values[NUM_4].f32;
461     auto centerYUnit = values[NUM_5].i32;
462     auto radiusHasValue = values[NUM_6].i32;
463     auto radiusValue = values[NUM_7].f32;
464     auto radiusUnit = values[NUM_8].i32;
465     auto repeating = values[NUM_9].i32;
466 
467     if (static_cast<bool>(centerXHasValue)) {
468         auto unit = static_cast<DimensionUnit>(centerXUnit);
469         auto value = (unit == DimensionUnit::PERCENT) ? (centerXValue * PERCENT_100) : centerXValue;
470         gradient.GetRadialGradient()->radialCenterX = CalcDimension(value, unit);
471     }
472     if (static_cast<bool>(centerYHasValue)) {
473         auto unit = static_cast<DimensionUnit>(centerYUnit);
474         auto value = (unit == DimensionUnit::PERCENT) ? (centerYValue * PERCENT_100) : centerYValue;
475         gradient.GetRadialGradient()->radialCenterY = CalcDimension(value, unit);
476     }
477     if (static_cast<bool>(radiusHasValue)) {
478         auto unit = static_cast<DimensionUnit>(radiusUnit);
479         auto value = CheckAngle(radiusValue);
480         gradient.GetRadialGradient()->radialVerticalSize = CalcDimension(value, unit);
481         gradient.GetRadialGradient()->radialHorizontalSize = CalcDimension(value, unit);
482     }
483     gradient.SetRepeat(static_cast<bool>(repeating));
484 }
485 
SetCalcDimension(std::optional<CalcDimension> & optDimension,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 offset)486 bool SetCalcDimension(std::optional<CalcDimension>& optDimension, const ArkUIStringAndFloat* options,
487     ArkUI_Int32 optionsLength, ArkUI_Int32 offset)
488 {
489     if ((options == nullptr) || (offset < 0) || ((offset + NUM_3) >= optionsLength)) {
490         return false;
491     }
492     auto hasValue = options[offset];
493     auto value = options[offset + NUM_1];
494     auto unit = options[offset + NUM_2];
495     if (static_cast<bool>(hasValue.value)) {
496         auto unitValue = static_cast<DimensionUnit>(unit.value);
497         if (unitValue == DimensionUnit::CALC) {
498             std::string str;
499             if (value.valueStr != nullptr) {
500                 str = value.valueStr;
501             }
502             CalcDimension calcDimension(str, unitValue);
503             optDimension = calcDimension;
504         } else {
505             CalcDimension calcDimension(value.value, unitValue);
506             optDimension = calcDimension;
507         }
508     }
509     return true;
510 }
511 
SetOptionalBorder(std::optional<Dimension> & optionalDimension,const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)512 void SetOptionalBorder(std::optional<Dimension>& optionalDimension, const ArkUI_Float32* values, ArkUI_Int32 valuesSize,
513     ArkUI_Int32& offset)
514 {
515     bool hasValue = static_cast<bool>(values[offset]);
516     if (hasValue) {
517         optionalDimension =
518             Dimension(values[offset + NUM_1], static_cast<OHOS::Ace::DimensionUnit>(values[offset + NUM_2]));
519     }
520     offset = offset + NUM_3;
521 }
522 
SetOptionalBorderColor(std::optional<Color> & optionalColor,const uint32_t * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)523 void SetOptionalBorderColor(
524     std::optional<Color>& optionalColor, const uint32_t* values, ArkUI_Int32 valuesSize, ArkUI_Int32& offset)
525 {
526     auto hasValue = values[offset];
527     if (static_cast<bool>(hasValue)) {
528         optionalColor = Color(values[offset + NUM_1]);
529     }
530     offset = offset + NUM_2;
531 }
532 
SetOptionalBorderStyle(std::optional<BorderStyle> & optionalStyle,const uint32_t * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)533 void SetOptionalBorderStyle(
534     std::optional<BorderStyle>& optionalStyle, const uint32_t* values, ArkUI_Int32 valuesSize, ArkUI_Int32& offset)
535 {
536     auto hasValue = values[offset];
537     if (static_cast<bool>(hasValue)) {
538         optionalStyle = ConvertBorderStyle(values[offset + NUM_1]);
539     }
540     offset = offset + NUM_2;
541 }
542 
SetBorderImageSlice(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)543 void SetBorderImageSlice(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
544     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
545 {
546     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
547         std::optional<CalcDimension> optDimension;
548         SetCalcDimension(optDimension, options, optionsLength, offset + index);
549         if (optDimension.has_value()) {
550             auto direction = directions[index / NUM_3];
551             borderImage->SetEdgeSlice(direction, optDimension.value());
552         }
553     }
554     offset += NUM_12;
555 }
556 
SetBorderImageRepeat(RefPtr<BorderImage> & borderImage,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)557 void SetBorderImageRepeat(RefPtr<BorderImage>& borderImage, const ArkUIStringAndFloat* options,
558     ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
559 {
560     if ((options == nullptr) || (offset < 0) || ((offset + NUM_2) >= optionsLength)) {
561         return;
562     }
563     auto hasValue = options[offset];
564     auto value = options[offset + NUM_1];
565     if (static_cast<bool>(hasValue.value)) {
566         auto repeatMode = static_cast<BorderImageRepeat>(value.value);
567         borderImage->SetRepeatMode(repeatMode);
568     }
569     offset += NUM_2;
570 }
571 
SetBorderImageWidth(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)572 void SetBorderImageWidth(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
573     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
574 {
575     for (int32_t index = 0; index < NUM_12; index += NUM_3) {
576         std::optional<CalcDimension> optDimension;
577         SetCalcDimension(optDimension, options, optionsLength, offset + index);
578         if (optDimension.has_value()) {
579             auto direction = directions[index / NUM_3];
580             borderImage->SetEdgeWidth(direction, optDimension.value());
581         }
582     }
583     offset += NUM_12;
584 }
585 
SetBorderImageOutset(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)586 void SetBorderImageOutset(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
587     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
588 {
589     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
590         std::optional<CalcDimension> optDimension;
591         SetCalcDimension(optDimension, options, optionsLength, offset + index);
592         if (optDimension.has_value()) {
593             auto direction = directions[index / NUM_3];
594             borderImage->SetEdgeOutset(direction, optDimension.value());
595         }
596     }
597     offset += NUM_12;
598 }
599 
SetBorderImageFill(RefPtr<BorderImage> & borderImage,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)600 void SetBorderImageFill(RefPtr<BorderImage>& borderImage, const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength,
601     ArkUI_Int32& offset)
602 {
603     if ((options == nullptr) || (offset < 0) || ((offset + NUM_2) >= optionsLength)) {
604         return;
605     }
606     auto hasValue = options[offset];
607     auto value = options[offset + NUM_1];
608     if (static_cast<bool>(hasValue.value)) {
609         borderImage->SetNeedFillCenter(static_cast<bool>(value.value));
610     }
611     offset += NUM_2;
612 }
613 
SetBorderImage(FrameNode * frameNode,const RefPtr<BorderImage> & borderImage,ArkUI_Uint32 bitset)614 void SetBorderImage(FrameNode* frameNode, const RefPtr<BorderImage>& borderImage, ArkUI_Uint32 bitset)
615 {
616     CHECK_NULL_VOID(frameNode);
617     CHECK_NULL_VOID(borderImage);
618     if (bitset & BorderImage::SOURCE_BIT) {
619         ViewAbstract::SetBorderImageSource(frameNode, borderImage->GetSrc());
620     }
621     if (bitset & BorderImage::OUTSET_BIT) {
622         ViewAbstract::SetHasBorderImageOutset(frameNode, true);
623     }
624     if (bitset & BorderImage::SLICE_BIT) {
625         ViewAbstract::SetHasBorderImageSlice(frameNode, true);
626     }
627     if (bitset & BorderImage::REPEAT_BIT) {
628         ViewAbstract::SetHasBorderImageRepeat(frameNode, true);
629     }
630     if (bitset & BorderImage::WIDTH_BIT) {
631         ViewAbstract::SetHasBorderImageWidth(frameNode, true);
632     }
633     ViewAbstract::SetBorderImage(frameNode, borderImage);
634 }
635 
636 /**
637  * @param values value value
638  * values[0], values[1] : angle: hasValue, angle value
639  * values[2] : direction
640  * values[3] : repeating
641  * @param valuesLength values length
642  */
SetBorderImageGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)643 void SetBorderImageGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
644 {
645     if ((values == nullptr) || (valuesLength != NUM_4)) {
646         return;
647     }
648     auto angleHasValue = values[NUM_0].i32;
649     auto angleValue = values[NUM_1].f32;
650     auto directionValue = values[NUM_2].i32;
651     auto repeating = values[NUM_3].i32;
652     auto linearGradient = gradient.GetLinearGradient();
653     if (linearGradient == nullptr) {
654         return;
655     }
656     if (static_cast<bool>(angleHasValue)) {
657         linearGradient->angle = CalcDimension(angleValue, DimensionUnit::PX);
658     }
659     SetLinearGradientDirectionTo(linearGradient, static_cast<GradientDirection>(directionValue));
660     gradient.SetRepeat(static_cast<bool>(repeating));
661 }
662 
SetBgImgPosition(const DimensionUnit & typeX,const DimensionUnit & typeY,ArkUI_Float32 valueX,ArkUI_Float32 valueY,BackgroundImagePosition & bgImgPosition)663 void SetBgImgPosition(const DimensionUnit& typeX, const DimensionUnit& typeY, ArkUI_Float32 valueX,
664     ArkUI_Float32 valueY, BackgroundImagePosition& bgImgPosition)
665 {
666     OHOS::Ace::AnimationOption option;
667     auto animatableDimensionX = AnimatableDimension(valueX, typeX, option);
668     auto animatableDimensionY = AnimatableDimension(valueY, typeY, option);
669     if (typeX == DimensionUnit::VP || typeX == DimensionUnit::FP) {
670         animatableDimensionX.SetValue(animatableDimensionX.ConvertToPx());
671         animatableDimensionX.SetUnit(DimensionUnit::PX);
672     }
673     if (typeY == DimensionUnit::VP || typeY == DimensionUnit::FP) {
674         animatableDimensionY.SetValue(animatableDimensionY.ConvertToPx());
675         animatableDimensionY.SetUnit(DimensionUnit::PX);
676     }
677     bgImgPosition.SetSizeX(animatableDimensionX);
678     bgImgPosition.SetSizeY(animatableDimensionY);
679 }
680 
SetBackgroundColor(ArkUINodeHandle node,uint32_t color)681 void SetBackgroundColor(ArkUINodeHandle node, uint32_t color)
682 {
683     auto* frameNode = reinterpret_cast<FrameNode*>(node);
684     CHECK_NULL_VOID(frameNode);
685     ViewAbstract::SetBackgroundColor(frameNode, Color(color));
686 }
687 
ResetBackgroundColor(ArkUINodeHandle node)688 void ResetBackgroundColor(ArkUINodeHandle node)
689 {
690     auto* frameNode = reinterpret_cast<FrameNode*>(node);
691     CHECK_NULL_VOID(frameNode);
692     ViewAbstract::SetBackgroundColor(frameNode, Color(Color::TRANSPARENT));
693 }
694 
SetWidth(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,ArkUI_CharPtr calcValue)695 void SetWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue)
696 {
697     auto* frameNode = reinterpret_cast<FrameNode*>(node);
698     CHECK_NULL_VOID(frameNode);
699     auto unitEnum = static_cast<OHOS::Ace::DimensionUnit>(unit);
700     if (unitEnum == DimensionUnit::CALC) {
701         ViewAbstract::SetWidth(frameNode, CalcLength(CalcLength(std::string(calcValue))));
702     } else {
703         ViewAbstract::SetWidth(frameNode, CalcLength(value, unitEnum));
704     }
705 }
706 
ResetWidth(ArkUINodeHandle node)707 void ResetWidth(ArkUINodeHandle node)
708 {
709     auto* frameNode = reinterpret_cast<FrameNode*>(node);
710     CHECK_NULL_VOID(frameNode);
711     ViewAbstract::ClearWidthOrHeight(frameNode, true);
712 }
SetHeight(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,ArkUI_CharPtr calcValue)713 void SetHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue)
714 {
715     auto* frameNode = reinterpret_cast<FrameNode*>(node);
716     CHECK_NULL_VOID(frameNode);
717     auto unitEnum = static_cast<OHOS::Ace::DimensionUnit>(unit);
718     if (unitEnum == DimensionUnit::CALC) {
719         ViewAbstract::SetHeight(frameNode, CalcLength(CalcLength(std::string(calcValue))));
720     } else {
721         ViewAbstract::SetHeight(frameNode, CalcLength(value, unitEnum));
722     }
723 }
ResetHeight(ArkUINodeHandle node)724 void ResetHeight(ArkUINodeHandle node)
725 {
726     auto* frameNode = reinterpret_cast<FrameNode*>(node);
727     CHECK_NULL_VOID(frameNode);
728     ViewAbstract::ClearWidthOrHeight(frameNode, false);
729 }
730 /**
731  * @param values radius values
732  * value[0] : radius value for TopLeft,value[1] : radius value for TopRight
733  * value[2] : radius value for BottomLeft,value[3] : radius value for BottomRight
734  * @param units radius units
735  * units[0]: radius unit for TopLeft, units[1] : radius unit for TopRight
736  * units[2]: radius unit for BottomLeft, units[3] : radius unit for TopRight
737  */
SetBorderRadius(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)738 void SetBorderRadius(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
739 {
740     auto* frameNode = reinterpret_cast<FrameNode*>(node);
741     CHECK_NULL_VOID(frameNode);
742     if (length != DEFAULT_LENGTH) {
743         return;
744     }
745     NG::BorderRadiusProperty borderRadius;
746     borderRadius.radiusTopLeft = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
747     borderRadius.radiusTopRight = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
748     borderRadius.radiusBottomLeft = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
749     borderRadius.radiusBottomRight = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]));
750     borderRadius.multiValued = true;
751     ViewAbstract::SetBorderRadius(frameNode, borderRadius);
752 }
753 
ResetBorderRadius(ArkUINodeHandle node)754 void ResetBorderRadius(ArkUINodeHandle node)
755 {
756     auto* frameNode = reinterpret_cast<FrameNode*>(node);
757     CHECK_NULL_VOID(frameNode);
758     OHOS::Ace::CalcDimension reset;
759     ViewAbstract::SetBorderRadius(frameNode, reset);
760 }
761 
762 /**
763  * @param values radius values, -1 means no this border width
764  * value[0] : BorderWidth value for left,value[1] : BorderWidth value for right
765  * value[2] : BorderWidth value for top,value[3] : BorderWidth value for bottom
766  * @param units radius units
767  * units[0]: BorderWidth unit for left, units[1] : BorderWidth unit for right
768  * units[2]: BorderWidth unit for top, units[3] : BorderWidth unit for bottom
769  */
SetBorderWidth(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)770 void SetBorderWidth(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
771 {
772     auto* frameNode = reinterpret_cast<FrameNode*>(node);
773     CHECK_NULL_VOID(frameNode);
774     if (length != DEFAULT_LENGTH) {
775         return;
776     }
777     std::optional<CalcDimension> topDimen;
778     std::optional<CalcDimension> rightDimen;
779     std::optional<CalcDimension> bottomDimen;
780     std::optional<CalcDimension> leftDimen;
781 
782     if (values[NUM_0] != -1 &&
783         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]) != OHOS::Ace::DimensionUnit::INVALID) {
784         topDimen = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
785     }
786     if (values[NUM_1] != -1 &&
787         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]) != OHOS::Ace::DimensionUnit::INVALID) {
788         rightDimen = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
789     }
790     if (values[NUM_2] != -1 &&
791         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]) != OHOS::Ace::DimensionUnit::INVALID) {
792         bottomDimen = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
793     }
794     if (values[NUM_3] != -1 &&
795         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]) != OHOS::Ace::DimensionUnit::INVALID) {
796         leftDimen = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]));
797     }
798 
799     NG::BorderWidthProperty borderWidth;
800     borderWidth.leftDimen = leftDimen;
801     borderWidth.rightDimen = rightDimen;
802     borderWidth.topDimen = topDimen;
803     borderWidth.bottomDimen = bottomDimen;
804     borderWidth.multiValued = true;
805     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
806 }
807 
ResetBorderWidth(ArkUINodeHandle node)808 void ResetBorderWidth(ArkUINodeHandle node)
809 {
810     auto* frameNode = reinterpret_cast<FrameNode*>(node);
811     CHECK_NULL_VOID(frameNode);
812     OHOS::Ace::Dimension borderWidth;
813     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
814 }
815 
SetTransform(ArkUINodeHandle node,const ArkUI_Float32 * matrix,ArkUI_Int32 length)816 void SetTransform(ArkUINodeHandle node, const ArkUI_Float32* matrix, ArkUI_Int32 length)
817 {
818     auto* frameNode = reinterpret_cast<FrameNode*>(node);
819     CHECK_NULL_VOID(frameNode);
820     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
821     if (length != matrix4Len) {
822         return;
823     }
824     NG::ViewAbstract::SetTransformMatrix(
825         frameNode, Matrix4(matrix[NUM_0], matrix[NUM_4], matrix[NUM_8], matrix[NUM_12], matrix[NUM_1], matrix[NUM_5],
826             matrix[NUM_9], matrix[NUM_13], matrix[NUM_2], matrix[NUM_6], matrix[NUM_10], matrix[NUM_14],
827                 matrix[NUM_3], matrix[NUM_7], matrix[NUM_11], matrix[NUM_15]));
828 }
829 
ResetTransform(ArkUINodeHandle node)830 void ResetTransform(ArkUINodeHandle node)
831 {
832     auto* frameNode = reinterpret_cast<FrameNode*>(node);
833     CHECK_NULL_VOID(frameNode);
834     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
835     std::vector<float> matrix(matrix4Len);
836     const int32_t initPosition = 5;
837     for (int32_t i = 0; i < matrix4Len; i = i + initPosition) {
838         double value = 1.0;
839         matrix[i] = static_cast<float>(value);
840     }
841     NG::ViewAbstract::SetTransformMatrix(
842         frameNode, Matrix4(matrix[NUM_0], matrix[NUM_4], matrix[NUM_8], matrix[NUM_12], matrix[NUM_1], matrix[NUM_5],
843             matrix[NUM_9], matrix[NUM_13], matrix[NUM_2], matrix[NUM_6], matrix[NUM_10], matrix[NUM_14],
844                 matrix[NUM_3], matrix[NUM_7], matrix[NUM_11], matrix[NUM_15]));
845 }
846 
SetBorderColor(ArkUINodeHandle node,uint32_t topColorInt,uint32_t rightColorInt,uint32_t bottomColorInt,uint32_t leftColorInt)847 void SetBorderColor(
848     ArkUINodeHandle node, uint32_t topColorInt, uint32_t rightColorInt, uint32_t bottomColorInt, uint32_t leftColorInt)
849 {
850     auto* frameNode = reinterpret_cast<FrameNode*>(node);
851     CHECK_NULL_VOID(frameNode);
852     NG::BorderColorProperty borderColors;
853     borderColors.topColor = Color(topColorInt);
854     borderColors.rightColor = Color(rightColorInt);
855     borderColors.bottomColor = Color(bottomColorInt);
856     borderColors.leftColor = Color(leftColorInt);
857     borderColors.multiValued = true;
858 
859     ViewAbstract::SetBorderColor(frameNode, borderColors);
860 }
861 
ResetBorderColor(ArkUINodeHandle node)862 void ResetBorderColor(ArkUINodeHandle node)
863 {
864     auto* frameNode = reinterpret_cast<FrameNode*>(node);
865     CHECK_NULL_VOID(frameNode);
866     ViewAbstract::SetBorderColor(frameNode, Color::BLACK);
867 }
868 
869 /**
870  * @param xValue position x value
871  * @param xUnit position x unit
872  * @param yValue position y unit
873  * @param yUnit position y unit
874  */
SetPosition(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit)875 void SetPosition(ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit)
876 {
877     auto* frameNode = reinterpret_cast<FrameNode*>(node);
878     CHECK_NULL_VOID(frameNode);
879 
880     ViewAbstract::SetPosition(frameNode, { Dimension(xValue, static_cast<OHOS::Ace::DimensionUnit>(xUnit)),
881                                              Dimension(yValue, static_cast<OHOS::Ace::DimensionUnit>(yUnit)) });
882 }
883 
ResetPosition(ArkUINodeHandle node)884 void ResetPosition(ArkUINodeHandle node)
885 {
886     auto* frameNode = reinterpret_cast<FrameNode*>(node);
887     CHECK_NULL_VOID(frameNode);
888     ViewAbstract::ResetPosition(frameNode);
889 }
890 
ParseEdges(OHOS::Ace::EdgesParam & edges,const ArkUIStringAndFloat * options)891 bool ParseEdges(OHOS::Ace::EdgesParam& edges, const ArkUIStringAndFloat* options)
892 {
893     bool result = false;
894     std::optional<CalcDimension> top;
895     std::optional<CalcDimension> left;
896     std::optional<CalcDimension> bottom;
897     std::optional<CalcDimension> right;
898     SetCalcDimension(top, options, NUM_13, NUM_0);
899     SetCalcDimension(left, options, NUM_13, NUM_3);
900     SetCalcDimension(bottom, options, NUM_13, NUM_6);
901     SetCalcDimension(right, options, NUM_13, NUM_9);
902     if (top.has_value()) {
903         result = true;
904         edges.SetTop(top.value());
905     }
906     if (left.has_value()) {
907         result = true;
908         edges.SetLeft(left.value());
909     }
910     if (bottom.has_value()) {
911         result = true;
912         edges.SetBottom(bottom.value());
913     }
914     if (right.has_value()) {
915         result = true;
916         edges.SetRight(right.value());
917     }
918     return result;
919 }
920 
SetPositionEdges(ArkUINodeHandle node,const int32_t useEdges,const ArkUIStringAndFloat * options)921 void SetPositionEdges(ArkUINodeHandle node, const int32_t useEdges, const ArkUIStringAndFloat* options)
922 {
923     auto* frameNode = reinterpret_cast<FrameNode*>(node);
924     CHECK_NULL_VOID(frameNode);
925     bool vaild = false;
926 
927     if (useEdges) {
928         OHOS::Ace::EdgesParam edges;
929         if (ParseEdges(edges, options)) {
930             ViewAbstract::SetPositionEdges(frameNode, edges);
931         } else {
932             ViewAbstract::ResetPosition(frameNode);
933         }
934     } else {
935         OffsetT<Dimension> offset;
936         std::optional<CalcDimension> x;
937         std::optional<CalcDimension> y;
938         SetCalcDimension(x, options, NUM_7, NUM_0);
939         SetCalcDimension(y, options, NUM_7, NUM_3);
940         if (x.has_value()) {
941             vaild = true;
942             offset.SetX(x.value());
943         }
944         if (y.has_value()) {
945             vaild = true;
946             offset.SetY(y.value());
947         }
948         if (vaild) {
949             ViewAbstract::SetPosition(frameNode, offset);
950         } else {
951             ViewAbstract::ResetPosition(frameNode);
952         }
953     }
954 }
955 
ResetPositionEdges(ArkUINodeHandle node)956 void ResetPositionEdges(ArkUINodeHandle node)
957 {
958     auto* frameNode = reinterpret_cast<FrameNode*>(node);
959     CHECK_NULL_VOID(frameNode);
960     if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) {
961         ViewAbstract::ResetPosition();
962     } else {
963         ViewAbstract::SetPosition(frameNode, { 0.0_vp, 0.0_vp });
964     }
965 }
966 
967 /**
968  * @param styles styles value
969  * styles[0] : styleLeft, styles[1] : styleRight, styles[2] : styleTop, styles[3] : styleBottom
970  * @param length styles length
971  */
SetBorderStyle(ArkUINodeHandle node,const ArkUI_Int32 * styles,ArkUI_Int32 length)972 void SetBorderStyle(ArkUINodeHandle node, const ArkUI_Int32* styles, ArkUI_Int32 length)
973 {
974     auto* frameNode = reinterpret_cast<FrameNode*>(node);
975     CHECK_NULL_VOID(frameNode);
976     if (length == NUM_1) {
977         ViewAbstract::SetBorderStyle(frameNode, ConvertBorderStyle(styles[NUM_0]));
978         return;
979     }
980     if (length == NUM_4) {
981         NG::BorderStyleProperty borderStyles;
982         borderStyles.styleLeft = ConvertBorderStyle(styles[NUM_3]);
983         borderStyles.styleRight = ConvertBorderStyle(styles[NUM_1]);
984         borderStyles.styleTop = ConvertBorderStyle(styles[NUM_0]);
985         borderStyles.styleBottom = ConvertBorderStyle(styles[NUM_2]);
986         borderStyles.multiValued = true;
987         ViewAbstract::SetBorderStyle(frameNode, borderStyles);
988     }
989 }
990 
ResetBorderStyle(ArkUINodeHandle node)991 void ResetBorderStyle(ArkUINodeHandle node)
992 {
993     auto* frameNode = reinterpret_cast<FrameNode*>(node);
994     CHECK_NULL_VOID(frameNode);
995     ViewAbstract::SetBorderStyle(frameNode, BorderStyle::SOLID);
996 }
997 
GetShadowFromTheme(ShadowStyle shadowStyle,Shadow & shadow)998 bool GetShadowFromTheme(ShadowStyle shadowStyle, Shadow& shadow)
999 {
1000     if (shadowStyle == ShadowStyle::None) {
1001         return true;
1002     }
1003 
1004     auto container = Container::Current();
1005     CHECK_NULL_RETURN(container, false);
1006     auto pipelineContext = container->GetPipelineContext();
1007     CHECK_NULL_RETURN(pipelineContext, false);
1008 
1009     auto shadowTheme = pipelineContext->GetTheme<ShadowTheme>();
1010     CHECK_NULL_RETURN(shadowTheme, false);
1011     auto colorMode = SystemProperties::GetColorMode();
1012     shadow = shadowTheme->GetShadow(shadowStyle, colorMode);
1013     return true;
1014 }
1015 
1016 /**
1017  * @param shadows shadow value
1018  * shadows[0] : BlurRadius, shadows[1] : 1: has ColorStrategy; 2: has Color
1019  * shadows[2] : OffsetX, offset[3] : OffsetY
1020  * shadows[4] : ShadowType, shadows[5] : Color, shadows[6] : IsFilled
1021  * @param length shadows length
1022  */
SetBackShadow(ArkUINodeHandle node,const ArkUIInt32orFloat32 * shadows,ArkUI_Int32 length)1023 void SetBackShadow(ArkUINodeHandle node, const ArkUIInt32orFloat32* shadows, ArkUI_Int32 length)
1024 {
1025     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1026     CHECK_NULL_VOID(frameNode);
1027     if (length == NUM_1) {
1028         Shadow shadow;
1029         auto shadowStyle = static_cast<ShadowStyle>(shadows[NUM_0].i32);
1030         auto style = static_cast<ShadowStyle>(shadowStyle);
1031         if (GetShadowFromTheme(style, shadow)) {
1032             ViewAbstract::SetBackShadow(frameNode, shadow);
1033         }
1034     }
1035     if (length != NUM_7) {
1036         return;
1037     }
1038     auto blurRadius = shadows[NUM_0].f32;                          // BlurRadius
1039     auto hasColorValue = static_cast<int32_t>(shadows[NUM_1].i32); // 1: has ColorStrategy; 2: has Color
1040     auto offsetX = shadows[NUM_2].f32;                             // OffsetX
1041     auto offsetY = shadows[NUM_3].f32;                             // OffsetY
1042     auto shadowType = shadows[NUM_4].i32;                          // ShadowType
1043     auto color = static_cast<uint32_t>(shadows[NUM_5].u32);        // Color
1044     auto isFilled = static_cast<uint32_t>(shadows[NUM_6].i32);     // IsFilled
1045     Shadow shadow;
1046     shadow.SetBlurRadius(blurRadius);
1047     shadow.SetOffsetX(offsetX);
1048     shadow.SetOffsetY(offsetY);
1049     if (hasColorValue == 1) { // 1: has ColorStrategy
1050         shadow.SetShadowColorStrategy(static_cast<ShadowColorStrategy>(color));
1051     } else if (hasColorValue == 2) { // 2: has Color
1052         shadow.SetColor(Color(color));
1053     }
1054     shadow.SetShadowType(static_cast<ShadowType>(shadowType));
1055     shadow.SetIsFilled(static_cast<bool>(isFilled));
1056     ViewAbstract::SetBackShadow(frameNode, shadow);
1057 }
1058 
ResetBackShadow(ArkUINodeHandle node)1059 void ResetBackShadow(ArkUINodeHandle node)
1060 {
1061     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1062     CHECK_NULL_VOID(frameNode);
1063     Shadow shadow;
1064     ViewAbstract::SetBackShadow(frameNode, shadow);
1065 }
1066 
SetHitTestBehavior(ArkUINodeHandle node,uint32_t value)1067 void SetHitTestBehavior(ArkUINodeHandle node, uint32_t value)
1068 {
1069     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1070     CHECK_NULL_VOID(frameNode);
1071     NG::HitTestMode hitTestModeNG = static_cast<NG::HitTestMode>(value);
1072     ViewAbstract::SetHitTestMode(frameNode, hitTestModeNG);
1073 }
1074 
ResetHitTestBehavior(ArkUINodeHandle node)1075 void ResetHitTestBehavior(ArkUINodeHandle node)
1076 {
1077     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1078     CHECK_NULL_VOID(frameNode);
1079     ViewAbstract::SetHitTestMode(frameNode, NG::HitTestMode::HTMDEFAULT);
1080 }
1081 
SetZIndex(ArkUINodeHandle node,ArkUI_Int32 value)1082 void SetZIndex(ArkUINodeHandle node, ArkUI_Int32 value)
1083 {
1084     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1085     CHECK_NULL_VOID(frameNode);
1086     ViewAbstract::SetZIndex(frameNode, value);
1087 }
1088 
ResetZIndex(ArkUINodeHandle node)1089 void ResetZIndex(ArkUINodeHandle node)
1090 {
1091     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1092     CHECK_NULL_VOID(frameNode);
1093     ViewAbstract::SetZIndex(frameNode, 0);
1094 }
1095 
SetOpacity(ArkUINodeHandle node,ArkUI_Float32 opacity)1096 void SetOpacity(ArkUINodeHandle node, ArkUI_Float32 opacity)
1097 {
1098     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1099     CHECK_NULL_VOID(frameNode);
1100     if (Container::LessThanAPIVersion(PlatformVersion::VERSION_ELEVEN)) {
1101         if (opacity > 1.0f || LessNotEqual(opacity, 0.0f)) {
1102             opacity = 1.0f;
1103         }
1104     } else {
1105         opacity = std::clamp(opacity, 0.0f, 1.0f);
1106     }
1107     ViewAbstract::SetOpacity(frameNode, opacity);
1108 }
1109 
ResetOpacity(ArkUINodeHandle node)1110 void ResetOpacity(ArkUINodeHandle node)
1111 {
1112     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1113     CHECK_NULL_VOID(frameNode);
1114     ViewAbstract::SetOpacity(frameNode, 1.0f);
1115 }
1116 
SetAlign(ArkUINodeHandle node,ArkUI_Int32 align)1117 void SetAlign(ArkUINodeHandle node, ArkUI_Int32 align)
1118 {
1119     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1120     CHECK_NULL_VOID(frameNode);
1121     Alignment alignment = ParseAlignment(align);
1122     ViewAbstract::SetAlign(frameNode, alignment);
1123 }
1124 
ResetAlign(ArkUINodeHandle node)1125 void ResetAlign(ArkUINodeHandle node)
1126 {
1127     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1128     CHECK_NULL_VOID(frameNode);
1129     ViewAbstract::SetAlign(frameNode, Alignment::CENTER);
1130 }
1131 
SetBackdropBlur(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize)1132 void SetBackdropBlur(
1133     ArkUINodeHandle node, ArkUI_Float32 value, const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize)
1134 {
1135     ArkUI_Float32 blur = 0.0f;
1136     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1137     CHECK_NULL_VOID(frameNode);
1138     if (value > 0) {
1139         blur = value;
1140     }
1141     BlurOption blurOption;
1142     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1143     CalcDimension dimensionRadius(blur, DimensionUnit::PX);
1144     ViewAbstract::SetBackdropBlur(frameNode, dimensionRadius, blurOption);
1145 }
1146 
ResetBackdropBlur(ArkUINodeHandle node)1147 void ResetBackdropBlur(ArkUINodeHandle node)
1148 {
1149     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1150     CHECK_NULL_VOID(frameNode);
1151     double blur = 0.0;
1152     BlurOption option;
1153     CalcDimension dimensionRadius(blur, DimensionUnit::PX);
1154     ViewAbstract::SetBackdropBlur(frameNode, dimensionRadius, option);
1155 }
1156 
SetHueRotate(ArkUINodeHandle node,ArkUI_Float32 deg)1157 void SetHueRotate(ArkUINodeHandle node, ArkUI_Float32 deg)
1158 {
1159     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1160     CHECK_NULL_VOID(frameNode);
1161     deg = std::fmod(deg, ROUND_UNIT);
1162     if (deg < 0.0f) {
1163         deg += ROUND_UNIT;
1164     }
1165     ViewAbstract::SetHueRotate(frameNode, deg);
1166 }
1167 
ResetHueRotate(ArkUINodeHandle node)1168 void ResetHueRotate(ArkUINodeHandle node)
1169 {
1170     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1171     CHECK_NULL_VOID(frameNode);
1172     ArkUI_Float32 deg = 0.0f;
1173     ViewAbstract::SetHueRotate(frameNode, deg);
1174 }
1175 
SetInvert(ArkUINodeHandle node,ArkUI_Float32 * invert,ArkUI_Int32 length)1176 void SetInvert(ArkUINodeHandle node, ArkUI_Float32* invert, ArkUI_Int32 length)
1177 {
1178     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1179     CHECK_NULL_VOID(frameNode);
1180     InvertVariant invertVariant;
1181     if (length == NUM_4) {
1182         InvertOption option;
1183         option.low_ = invert[NUM_0];
1184         option.high_ = invert[NUM_1];
1185         option.threshold_ = invert[NUM_2];
1186         option.thresholdRange_ = invert[NUM_3];
1187         invertVariant = option;
1188     } else {
1189         invertVariant = invert[NUM_0];
1190     }
1191     ViewAbstract::SetInvert(frameNode, invertVariant);
1192 }
1193 
ResetInvert(ArkUINodeHandle node)1194 void ResetInvert(ArkUINodeHandle node)
1195 {
1196     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1197     CHECK_NULL_VOID(frameNode);
1198     InvertVariant invert = 0.0f;
1199     ViewAbstract::SetInvert(frameNode, invert);
1200 }
1201 
SetSepia(ArkUINodeHandle node,ArkUI_Float32 sepia)1202 void SetSepia(ArkUINodeHandle node, ArkUI_Float32 sepia)
1203 {
1204     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1205     CHECK_NULL_VOID(frameNode);
1206     CalcDimension value = CalcDimension(sepia, DimensionUnit::VP);
1207     if (LessNotEqual(value.Value(), 0.0)) {
1208         value.SetValue(0.0);
1209     }
1210     ViewAbstract::SetSepia(frameNode, value);
1211 }
1212 
ResetSepia(ArkUINodeHandle node)1213 void ResetSepia(ArkUINodeHandle node)
1214 {
1215     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1216     CHECK_NULL_VOID(frameNode);
1217     CalcDimension value(0.0, DimensionUnit::VP);
1218     ViewAbstract::SetSepia(frameNode, value);
1219 }
1220 
SetSaturate(ArkUINodeHandle node,ArkUI_Float32 saturate)1221 void SetSaturate(ArkUINodeHandle node, ArkUI_Float32 saturate)
1222 {
1223     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1224     CHECK_NULL_VOID(frameNode);
1225     CalcDimension value = CalcDimension(saturate, DimensionUnit::VP);
1226     if (LessNotEqual(value.Value(), 0.0)) {
1227         value.SetValue(0.0);
1228     }
1229     ViewAbstract::SetSaturate(frameNode, value);
1230 }
1231 
ResetSaturate(ArkUINodeHandle node)1232 void ResetSaturate(ArkUINodeHandle node)
1233 {
1234     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1235     CHECK_NULL_VOID(frameNode);
1236     CalcDimension value(1.0, DimensionUnit::VP);
1237     ViewAbstract::SetSaturate(frameNode, value);
1238 }
1239 
SetColorBlend(ArkUINodeHandle node,uint32_t color)1240 void SetColorBlend(ArkUINodeHandle node, uint32_t color)
1241 {
1242     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1243     CHECK_NULL_VOID(frameNode);
1244     ViewAbstract::SetColorBlend(frameNode, Color(color));
1245 }
1246 
ResetColorBlend(ArkUINodeHandle node)1247 void ResetColorBlend(ArkUINodeHandle node)
1248 {
1249     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1250     CHECK_NULL_VOID(frameNode);
1251     Color colorBlend = Color::TRANSPARENT;
1252     ViewAbstract::SetColorBlend(frameNode, colorBlend);
1253 }
1254 
GetColorBlend(ArkUINodeHandle node)1255 ArkUI_Uint32 GetColorBlend(ArkUINodeHandle node)
1256 {
1257     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1258     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
1259     return ViewAbstract::GetColorBlend(frameNode).GetValue();
1260 }
1261 
SetGrayscale(ArkUINodeHandle node,ArkUI_Float64 grayScale)1262 void SetGrayscale(ArkUINodeHandle node, ArkUI_Float64 grayScale)
1263 {
1264     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1265     CHECK_NULL_VOID(frameNode);
1266     CalcDimension value = CalcDimension(grayScale, DimensionUnit::VP);
1267     if (LessNotEqual(value.Value(), 0.0)) {
1268         value.SetValue(0.0);
1269     }
1270     if (GreatNotEqual(value.Value(), 1.0)) {
1271         value.SetValue(1.0);
1272     }
1273     ViewAbstract::SetGrayScale(frameNode, value);
1274 }
1275 
ResetGrayscale(ArkUINodeHandle node)1276 void ResetGrayscale(ArkUINodeHandle node)
1277 {
1278     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1279     CHECK_NULL_VOID(frameNode);
1280     CalcDimension value(0.0, DimensionUnit::VP);
1281     ViewAbstract::SetGrayScale(frameNode, value);
1282 }
1283 
SetContrast(ArkUINodeHandle node,ArkUI_Float64 contrast)1284 void SetContrast(ArkUINodeHandle node, ArkUI_Float64 contrast)
1285 {
1286     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1287     CHECK_NULL_VOID(frameNode);
1288     CalcDimension value = CalcDimension(contrast, DimensionUnit::VP);
1289     if (LessNotEqual(value.Value(), 0.0)) {
1290         value.SetValue(0.0);
1291     }
1292     ViewAbstract::SetContrast(frameNode, value);
1293 }
1294 
ResetContrast(ArkUINodeHandle node)1295 void ResetContrast(ArkUINodeHandle node)
1296 {
1297     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1298     CHECK_NULL_VOID(frameNode);
1299     CalcDimension value(1.0, DimensionUnit::VP);
1300     ViewAbstract::SetContrast(frameNode, value);
1301 }
1302 
SetBrightness(ArkUINodeHandle node,ArkUI_Float64 brightness)1303 void SetBrightness(ArkUINodeHandle node, ArkUI_Float64 brightness)
1304 {
1305     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1306     CHECK_NULL_VOID(frameNode);
1307     CalcDimension value = CalcDimension(brightness, DimensionUnit::VP);
1308     if (LessNotEqual(value.Value(), 0.0)) {
1309         value.SetValue(0.0);
1310     }
1311     ViewAbstract::SetBrightness(frameNode, value);
1312 }
1313 
ResetBrightness(ArkUINodeHandle node)1314 void ResetBrightness(ArkUINodeHandle node)
1315 {
1316     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1317     CHECK_NULL_VOID(frameNode);
1318     CalcDimension value(1.0, DimensionUnit::VP);
1319     ViewAbstract::SetBrightness(frameNode, value);
1320 }
1321 
SetBlur(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize)1322 void SetBlur(ArkUINodeHandle node, ArkUI_Float32 value, const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize)
1323 {
1324     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1325     CHECK_NULL_VOID(frameNode);
1326     ArkUI_Float32 blur = 0.0f;
1327     BlurOption blurOption;
1328     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1329     if (value > 0) {
1330         blur = value;
1331     }
1332     CalcDimension dimensionBlur(blur, DimensionUnit::PX);
1333     ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, blurOption);
1334 }
1335 
ResetBlur(ArkUINodeHandle node)1336 void ResetBlur(ArkUINodeHandle node)
1337 {
1338     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1339     CHECK_NULL_VOID(frameNode);
1340     double blur = 0.0;
1341     BlurOption option;
1342     CalcDimension dimensionBlur(blur, DimensionUnit::PX);
1343     ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, option);
1344 }
1345 
1346 /**
1347  * @param values value value
1348  * values[0], values[1] : angle: hasValue, angle value
1349  * values[2] : direction
1350  * values[3] : repeating
1351  * @param valuesLength values length
1352  * @param colors color value
1353  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1354  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1355  * ...
1356  * @param colorsLength colors length
1357  */
SetLinearGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1358 void SetLinearGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1359     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1360 {
1361     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1362     CHECK_NULL_VOID(frameNode);
1363     if ((values == nullptr) || (valuesLength != NUM_4) || ((colorsLength % NUM_3) != 0)) {
1364         return;
1365     }
1366     NG::Gradient gradient;
1367     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1368     SetLinearGradientValues(gradient, values, valuesLength);
1369     SetGradientColors(gradient, colors, colorsLength);
1370     ViewAbstract::SetLinearGradient(frameNode, gradient);
1371 }
1372 
ResetLinearGradient(ArkUINodeHandle node)1373 void ResetLinearGradient(ArkUINodeHandle node)
1374 {
1375     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1376     CHECK_NULL_VOID(frameNode);
1377     NG::Gradient gradient;
1378     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1379     ViewAbstract::SetLinearGradient(frameNode, gradient);
1380 }
1381 
1382 /**
1383  * @param values value value
1384  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
1385  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
1386  * values[6], values[7] : start: hasValue, start degree value
1387  * values[8], values[9] : end: hasValue, end degree value
1388  * values[10], values[11] : rotation: hasValue, rotation degree value
1389  * values[12] : repeating
1390  * @param valuesLength values length
1391  * @param colors color value
1392  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1393  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1394  * ...
1395  * @param colorsLength colors length
1396  */
SetSweepGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1397 void SetSweepGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1398     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1399 {
1400     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1401     CHECK_NULL_VOID(frameNode);
1402     if ((values == nullptr) || (valuesLength != NUM_13) || ((colorsLength % NUM_3) != 0)) {
1403         return;
1404     }
1405     NG::Gradient gradient;
1406     gradient.CreateGradientWithType(NG::GradientType::SWEEP);
1407     SetSweepGradientValues(gradient, values, valuesLength);
1408     SetGradientColors(gradient, colors, colorsLength);
1409     ViewAbstract::SetSweepGradient(frameNode, gradient);
1410 }
1411 
ResetSweepGradient(ArkUINodeHandle node)1412 void ResetSweepGradient(ArkUINodeHandle node)
1413 {
1414     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1415     CHECK_NULL_VOID(frameNode);
1416     NG::Gradient gradient;
1417     gradient.CreateGradientWithType(NG::GradientType::SWEEP);
1418     ViewAbstract::SetSweepGradient(frameNode, gradient);
1419 }
1420 
1421 /**
1422  * @param values value value
1423  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
1424  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
1425  * values[6], values[7], values[8] : radius: Dimension: hasValue, value, unit
1426  * values[9] : repeating
1427  * @param valuesLength values length
1428  * @param colors color value
1429  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1430  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1431  * ...
1432  * @param colorsLength colors length
1433  */
SetRadialGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1434 void SetRadialGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1435     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1436 {
1437     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1438     CHECK_NULL_VOID(frameNode);
1439     if ((values == nullptr) || (valuesLength != NUM_10) || ((colorsLength % NUM_3) != 0)) {
1440         return;
1441     }
1442     NG::Gradient gradient;
1443     gradient.CreateGradientWithType(NG::GradientType::RADIAL);
1444     SetRadialGradientValues(gradient, values, valuesLength);
1445     SetGradientColors(gradient, colors, colorsLength);
1446     ViewAbstract::SetRadialGradient(frameNode, gradient);
1447 }
1448 
ResetRadialGradient(ArkUINodeHandle node)1449 void ResetRadialGradient(ArkUINodeHandle node)
1450 {
1451     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1452     CHECK_NULL_VOID(frameNode);
1453     NG::Gradient gradient;
1454     gradient.CreateGradientWithType(NG::GradientType::RADIAL);
1455     ViewAbstract::SetRadialGradient(frameNode, gradient);
1456 }
1457 
1458 /**
1459  * @param text text value
1460  * @param options option value
1461  * option[0], option[1]: align(hasValue, value)
1462  * option[2], option[3], option[4]: offsetX(hasValue, value, unit)
1463  * option[5], option[6], option[7]: offsetY(hasValue, value, unit)
1464  * option[8]: hasOptions
1465  * option[9]: hasOffset
1466  * @param optionsLength options length
1467  */
SetOverlay(ArkUINodeHandle node,ArkUI_CharPtr text,const ArkUI_Float32 * options,ArkUI_Int32 optionsLength)1468 void SetOverlay(ArkUINodeHandle node, ArkUI_CharPtr text, const ArkUI_Float32* options, ArkUI_Int32 optionsLength)
1469 {
1470     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1471     CHECK_NULL_VOID(frameNode);
1472     if ((options == nullptr) || (optionsLength != NUM_10)) {
1473         return;
1474     }
1475     auto alignHasValue = options[NUM_0];
1476     auto alignValue = options[NUM_1];
1477     auto offsetXHasValue = options[NUM_2];
1478     auto offsetXValue = options[NUM_3];
1479     auto offsetXUnit = options[NUM_4];
1480     auto offsetYHasValue = options[NUM_5];
1481     auto offsetYValue = options[NUM_6];
1482     auto offsetYUnit = options[NUM_7];
1483     auto hasOptions = options[NUM_8];
1484     auto hasOffset = options[NUM_9];
1485     NG::OverlayOptions overlay;
1486     if (text != nullptr) {
1487         overlay.content = text;
1488     }
1489     if (static_cast<bool>(hasOptions)) {
1490         if (static_cast<bool>(alignHasValue)) {
1491             overlay.align = ParseAlignment(static_cast<int32_t>(alignValue));
1492         } else {
1493             overlay.align = Alignment::TOP_LEFT;
1494         }
1495         if (static_cast<bool>(hasOffset)) {
1496             if (static_cast<bool>(offsetXHasValue)) {
1497                 overlay.x = CalcDimension(offsetXValue, static_cast<DimensionUnit>(offsetXUnit));
1498             }
1499             if (static_cast<bool>(offsetYHasValue)) {
1500                 overlay.y = CalcDimension(offsetYValue, static_cast<DimensionUnit>(offsetYUnit));
1501             }
1502         }
1503     } else {
1504         overlay.align = Alignment::TOP_LEFT;
1505         overlay.x = CalcDimension(0);
1506         overlay.y = CalcDimension(0);
1507     }
1508     ViewAbstract::SetOverlay(frameNode, overlay);
1509 }
1510 
ResetOverlay(ArkUINodeHandle node)1511 void ResetOverlay(ArkUINodeHandle node)
1512 {
1513     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1514     CHECK_NULL_VOID(frameNode);
1515     NG::OverlayOptions overlay;
1516     overlay.align = Alignment::TOP_LEFT;
1517     overlay.x = CalcDimension(0);
1518     overlay.y = CalcDimension(0);
1519     ViewAbstract::SetOverlay(frameNode, overlay);
1520 }
1521 
1522 /**
1523  * @param src source value
1524  * @param options option value
1525  * option[offset + 0], option[offset + 1], option[offset + 2]: sliceTop(hasValue, value, unit)
1526  * option[offset + 3], option[offset + 4], option[offset + 5]: sliceRight(hasValue, value, unit)
1527  * option[offset + 6], option[offset + 7], option[offset + 8]: sliceBottom(hasValue, value, unit)
1528  * option[offset + 9], option[offset + 10], option[offset + 11]: sliceLeft(hasValue, value, unit)
1529  * option[offset + 12], option[offset + 13]: repeat(hasValue, value)
1530  * option[offset + 14], option[offset + 15], option[offset + 16]: widthTop(hasValue, value, unit)
1531  * option[offset + 17], option[offset + 18], option[offset + 19]: widthRight(hasValue, value, unit)
1532  * option[offset + 20], option[offset + 21], option[offset + 22]: widthBottom(hasValue, value, unit)
1533  * option[offset + 23], option[offset + 24], option[offset + 25]: widthLeft(hasValue, value, unit)
1534  * option[offset + 26], option[offset + 27], option[offset + 28]: outsetTop(hasValue, value, unit)
1535  * option[offset + 29], option[offset + 30], option[offset + 31]: outsetRight(hasValue, value, unit)
1536  * option[offset + 32], option[offset + 33], option[offset + 34]: outsetBottom(hasValue, value, unit)
1537  * option[offset + 35], option[offset + 36], option[offset + 37]: outsetLeft(hasValue, value, unit)
1538  * option[offset + 38], option[offset + 39]: fill(hasValue, value)
1539  * option[offset + 40]: bitset
1540  * @param optionsLength options length
1541  */
SetBorderImage(ArkUINodeHandle node,ArkUI_CharPtr src,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength)1542 void SetBorderImage(
1543     ArkUINodeHandle node, ArkUI_CharPtr src, const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength)
1544 {
1545     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1546     CHECK_NULL_VOID(frameNode);
1547     // slice:12 double, repeat:2 double, width:12 double, outset:12 double, fill:2 double, bitset:1 double
1548     auto desireLength = NUM_12 + NUM_2 + NUM_12 + NUM_12 + NUM_2 + NUM_1;
1549     if ((options == nullptr) || (optionsLength != desireLength)) {
1550         return;
1551     }
1552     RefPtr<BorderImage> borderImage = AceType::MakeRefPtr<BorderImage>();
1553     if (src != nullptr) {
1554         borderImage->SetSrc(std::string(src));
1555     }
1556     int32_t loc = 0;
1557     std::vector<BorderImageDirection> directions = { BorderImageDirection::TOP, BorderImageDirection::RIGHT,
1558         BorderImageDirection::BOTTOM, BorderImageDirection::LEFT };
1559     SetBorderImageSlice(borderImage, directions, options, optionsLength, loc);  // read 12 double
1560     SetBorderImageRepeat(borderImage, options, optionsLength, loc);             // read 2 double
1561     SetBorderImageWidth(borderImage, directions, options, optionsLength, loc);  // read 12 double
1562     SetBorderImageOutset(borderImage, directions, options, optionsLength, loc); // read 12 double
1563     SetBorderImageFill(borderImage, options, optionsLength, loc);               // read 2 double
1564     auto bitsetValue = options[loc].value;
1565     SetBorderImage(frameNode, borderImage, static_cast<uint8_t>(bitsetValue));
1566 }
1567 
ResetBorderImage(ArkUINodeHandle node)1568 void ResetBorderImage(ArkUINodeHandle node)
1569 {
1570     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1571     CHECK_NULL_VOID(frameNode);
1572     RefPtr<BorderImage> borderImage = AceType::MakeRefPtr<BorderImage>();
1573     uint8_t imageBorderBitsets = 0;
1574     SetBorderImage(frameNode, borderImage, imageBorderBitsets);
1575 }
1576 
SetBorderImageGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1577 void SetBorderImageGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1578     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1579 {
1580     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1581     CHECK_NULL_VOID(frameNode);
1582     if ((values == nullptr) || (valuesLength != NUM_4) || ((colorsLength % NUM_3) != 0)) {
1583         return;
1584     }
1585     NG::Gradient gradient;
1586     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1587     SetBorderImageGradientValues(gradient, values, valuesLength);
1588     SetGradientColors(gradient, colors, colorsLength);
1589     ViewAbstract::SetBorderImageGradient(frameNode, gradient);
1590 }
1591 
SetForegroundBlurStyle(ArkUINodeHandle node,ArkUI_Int32 (* intArray)[3],ArkUI_Float32 scale,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize)1592 void SetForegroundBlurStyle(ArkUINodeHandle node, ArkUI_Int32 (*intArray)[3], ArkUI_Float32 scale,
1593     const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize)
1594 {
1595     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1596     CHECK_NULL_VOID(frameNode);
1597     ArkUI_Int32 blurStyle = (*intArray)[NUM_0];
1598     ArkUI_Int32 colorMode = (*intArray)[NUM_1];
1599     ArkUI_Int32 adaptiveColor = (*intArray)[NUM_2];
1600     BlurStyleOption fgBlurStyle;
1601     if (blurStyle >= 0) {
1602         if (blurStyle >= static_cast<int>(BlurStyle::NO_MATERIAL) &&
1603             blurStyle <= static_cast<int>(BlurStyle::COMPONENT_ULTRA_THICK)) {
1604             fgBlurStyle.blurStyle = static_cast<BlurStyle>(blurStyle);
1605         }
1606     }
1607     bool isHasOptions = !((colorMode < 0) && (adaptiveColor < 0) && (scale < 0) && (blurValuesSize == 0));
1608     if (isHasOptions) {
1609         if (colorMode >= static_cast<int32_t>(ThemeColorMode::SYSTEM) &&
1610             colorMode <= static_cast<int32_t>(ThemeColorMode::DARK)) {
1611             fgBlurStyle.colorMode = static_cast<ThemeColorMode>(colorMode);
1612         }
1613         if (adaptiveColor >= static_cast<int32_t>(AdaptiveColor::DEFAULT) &&
1614             adaptiveColor <= static_cast<int32_t>(AdaptiveColor::AVERAGE)) {
1615             fgBlurStyle.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColor);
1616         }
1617         if (scale >= 0) {
1618             fgBlurStyle.scale = std::clamp(scale, 0.0f, 1.0f);
1619         }
1620         BlurOption blurOption;
1621         blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1622         fgBlurStyle.blurOption = blurOption;
1623     }
1624     ViewAbstract::SetForegroundBlurStyle(frameNode, fgBlurStyle);
1625 }
1626 
ResetForegroundBlurStyle(ArkUINodeHandle node)1627 void ResetForegroundBlurStyle(ArkUINodeHandle node)
1628 {
1629     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1630     CHECK_NULL_VOID(frameNode);
1631     BlurStyleOption styleOption;
1632     ViewAbstract::SetForegroundBlurStyle(frameNode, styleOption);
1633 }
1634 
GetForegroundBlurStyle(ArkUINodeHandle node)1635 ArkUIBlurStyleOptionType GetForegroundBlurStyle(ArkUINodeHandle node)
1636 {
1637     ArkUIBlurStyleOptionType styleOptionType = { 0, 0, 0, 1.0f, 0, 0 };
1638     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1639     CHECK_NULL_RETURN(frameNode, styleOptionType);
1640     auto renderContext = frameNode->GetRenderContext();
1641     CHECK_NULL_RETURN(renderContext, styleOptionType);
1642     auto blurStyleOption = renderContext->GetFrontBlurStyle();
1643     if (!blurStyleOption.has_value()) {
1644         return styleOptionType;
1645     }
1646     styleOptionType.blurStyle = static_cast<int32_t>(blurStyleOption->blurStyle);
1647     styleOptionType.colorMode = static_cast<int32_t>(blurStyleOption->colorMode);
1648     styleOptionType.adaptiveColor = static_cast<int32_t>(blurStyleOption->adaptiveColor);
1649     styleOptionType.scale = blurStyleOption->scale;
1650     styleOptionType.grayScaleStart = blurStyleOption->blurOption.grayscale[NUM_0];
1651     styleOptionType.grayScaleEnd = blurStyleOption->blurOption.grayscale[NUM_1];
1652     return styleOptionType;
1653 }
1654 
1655 /**
1656  * @param blurRadius blurRadius value
1657  * @param stops stop value
1658  * stops[0], stops[1] : fractionStops pair[0]
1659  * stops[2], stops[3] : fractionStops pair[1] ...
1660  * @param stopsLength stops length
1661  * @param directionValue direction value
1662  */
SetLinearGradientBlur(ArkUINodeHandle node,ArkUI_Float32 blurRadius,const ArkUI_Float32 * stops,ArkUI_Uint32 stopsLength,ArkUI_Int32 directionValue)1663 void SetLinearGradientBlur(ArkUINodeHandle node, ArkUI_Float32 blurRadius, const ArkUI_Float32* stops,
1664     ArkUI_Uint32 stopsLength, ArkUI_Int32 directionValue)
1665 {
1666     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1667     CHECK_NULL_VOID(frameNode);
1668     blurRadius = std::clamp(blurRadius, 0.0f, 60.0f); // 60.0 represents largest blur radius;
1669     std::vector<std::pair<float, float>> fractionStops;
1670     if ((stopsLength & 0x1) == 0) {
1671         float tmpPos = -1.0f;
1672         for (size_t index = 0; index < stopsLength; index += NUM_2) {
1673             auto first = stops[index];
1674             auto second = stops[index + NUM_1];
1675             std::pair<float, float> fractionStop;
1676             fractionStop.first = static_cast<float>(std::clamp(first, 0.0f, 1.0f));
1677             fractionStop.second = static_cast<float>(std::clamp(second, 0.0f, 1.0f));
1678             if (fractionStop.second <= tmpPos) {
1679                 fractionStops.clear();
1680                 break;
1681             }
1682             tmpPos = fractionStop.second;
1683             fractionStops.push_back(fractionStop);
1684         }
1685     }
1686     if (static_cast<int32_t>(fractionStops.size()) <= 1) {
1687         fractionStops.clear();
1688         fractionStops.push_back(std::pair<float, float>(0.0f, 0.0f));
1689         fractionStops.push_back(std::pair<float, float>(0.0f, 1.0f));
1690     }
1691     if (directionValue < static_cast<int8_t>(GradientDirection::LEFT) ||
1692         directionValue >= static_cast<int8_t>(GradientDirection::NONE)) {
1693         directionValue = static_cast<int8_t>(GradientDirection::BOTTOM);
1694     }
1695     auto direction = static_cast<GradientDirection>(directionValue);
1696     Dimension dimensionRadius(blurRadius, DimensionUnit::PX);
1697     NG::LinearGradientBlurPara blurPara(dimensionRadius, fractionStops, direction);
1698     ViewAbstract::SetLinearGradientBlur(frameNode, blurPara);
1699 }
1700 
ResetLinearGradientBlur(ArkUINodeHandle node)1701 void ResetLinearGradientBlur(ArkUINodeHandle node)
1702 {
1703     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1704     CHECK_NULL_VOID(frameNode);
1705     std::vector<std::pair<float, float>> fractionStops;
1706     fractionStops.push_back(std::pair<float, float>(0.0f, 0.0f));
1707     fractionStops.push_back(std::pair<float, float>(0.0f, 1.0f));
1708     Dimension dimensionRadius(0.0f, DimensionUnit::PX);
1709     NG::LinearGradientBlurPara blurPara(dimensionRadius, fractionStops, GradientDirection::BOTTOM);
1710     ViewAbstract::SetLinearGradientBlur(frameNode, blurPara);
1711 }
1712 
SetBackgroundBlurStyle(ArkUINodeHandle node,ArkUI_Int32 (* intArray)[5],ArkUI_Float32 scale,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Bool isValidColor,ArkUI_Uint32 inactiveColorArg)1713 void SetBackgroundBlurStyle(ArkUINodeHandle node, ArkUI_Int32 (*intArray)[5], ArkUI_Float32 scale,
1714     const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize, ArkUI_Bool isValidColor, ArkUI_Uint32 inactiveColorArg)
1715 {
1716     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1717     CHECK_NULL_VOID(frameNode);
1718     ArkUI_Int32 blurStyle = (*intArray)[NUM_0];
1719     ArkUI_Int32 colorMode = (*intArray)[NUM_1];
1720     ArkUI_Int32 adaptiveColor = (*intArray)[NUM_2];
1721     ArkUI_Int32 policy = (*intArray)[NUM_3];
1722     ArkUI_Int32 blurType = (*intArray)[NUM_4];
1723     BlurStyleOption bgBlurStyle;
1724     if (blurStyle >= 0) {
1725         if (blurStyle >= static_cast<int>(BlurStyle::NO_MATERIAL) &&
1726             blurStyle <= static_cast<int>(BlurStyle::COMPONENT_ULTRA_THICK)) {
1727             bgBlurStyle.blurStyle = static_cast<BlurStyle>(blurStyle);
1728         }
1729     }
1730     bool isHasOptions = !((colorMode < 0) && (adaptiveColor < 0) && (scale < 0) && (blurValuesSize == 0));
1731     if (isHasOptions) {
1732         if (colorMode >= static_cast<int32_t>(ThemeColorMode::SYSTEM) &&
1733             colorMode <= static_cast<int32_t>(ThemeColorMode::DARK)) {
1734             bgBlurStyle.colorMode = static_cast<ThemeColorMode>(colorMode);
1735         }
1736         if (adaptiveColor >= static_cast<int32_t>(AdaptiveColor::DEFAULT) &&
1737             adaptiveColor <= static_cast<int32_t>(AdaptiveColor::AVERAGE)) {
1738             bgBlurStyle.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColor);
1739         }
1740         bgBlurStyle.scale = std::clamp(scale, 0.0f, 1.0f);
1741         BlurOption blurOption;
1742         blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1743         bgBlurStyle.blurOption = blurOption;
1744     }
1745     bgBlurStyle.policy = static_cast<BlurStyleActivePolicy>(policy);
1746     bgBlurStyle.blurType = static_cast<BlurType>(blurType);
1747     bgBlurStyle.isValidColor = isValidColor;
1748     Color inactiveColor(inactiveColorArg);
1749     bgBlurStyle.inactiveColor = inactiveColor;
1750     ViewAbstract::SetBackgroundBlurStyle(frameNode, bgBlurStyle);
1751 }
1752 
GetBackgroundBlurStyle(ArkUINodeHandle node)1753 ArkUIBlurStyleOptionType GetBackgroundBlurStyle(ArkUINodeHandle node)
1754 {
1755     ArkUIBlurStyleOptionType styleOptionType = { 0, 0, 0, 1.0f };
1756     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1757     CHECK_NULL_RETURN(frameNode, styleOptionType);
1758     auto renderContext = frameNode->GetRenderContext();
1759     CHECK_NULL_RETURN(renderContext, styleOptionType);
1760     auto backBlurStyleOption = renderContext->GetBackBlurStyle();
1761     if (!backBlurStyleOption.has_value()) {
1762         return styleOptionType;
1763     }
1764     styleOptionType.blurStyle = static_cast<int32_t>(backBlurStyleOption->blurStyle);
1765     styleOptionType.colorMode = static_cast<int32_t>(backBlurStyleOption->colorMode);
1766     styleOptionType.adaptiveColor = static_cast<int32_t>(backBlurStyleOption->adaptiveColor);
1767     styleOptionType.scale = backBlurStyleOption->scale;
1768     auto greyScaleVector = backBlurStyleOption->blurOption.grayscale;
1769     styleOptionType.grayScaleStart = greyScaleVector.size() > NUM_0 ? greyScaleVector[NUM_0] : 0.0f;
1770     styleOptionType.grayScaleEnd = greyScaleVector.size() > NUM_1 ? greyScaleVector[NUM_1] : 0.0f;
1771     return styleOptionType;
1772 }
1773 
ResetBackgroundBlurStyle(ArkUINodeHandle node)1774 void ResetBackgroundBlurStyle(ArkUINodeHandle node)
1775 {
1776     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1777     CHECK_NULL_VOID(frameNode);
1778     BlurStyleOption bgBlurStyle;
1779     ViewAbstract::SetBackgroundBlurStyle(frameNode, bgBlurStyle);
1780 }
1781 
SetBorderWidth(const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,int32_t & offset,NG::BorderWidthProperty & borderWidth,ArkUI_Bool isLocalizedBorderWidth,FrameNode * frameNode)1782 void SetBorderWidth(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset,
1783     NG::BorderWidthProperty& borderWidth, ArkUI_Bool isLocalizedBorderWidth, FrameNode* frameNode)
1784 {
1785     if (isLocalizedBorderWidth) {
1786         SetOptionalBorder(borderWidth.startDimen, values, valuesSize, offset);
1787         SetOptionalBorder(borderWidth.endDimen, values, valuesSize, offset);
1788     } else {
1789         SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
1790         SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
1791     }
1792     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
1793     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
1794     borderWidth.multiValued = true;
1795     if (borderWidth.leftDimen.has_value() || borderWidth.rightDimen.has_value() || borderWidth.topDimen.has_value() ||
1796         borderWidth.bottomDimen.has_value() || borderWidth.startDimen.has_value() || borderWidth.endDimen.has_value()) {
1797         ViewAbstract::SetBorderWidth(frameNode, borderWidth);
1798     }
1799 }
1800 
SetBorderBorderRadius(const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,int32_t & offset,NG::BorderRadiusProperty & borderRadius,ArkUI_Bool isLocalizedBorderRadius,FrameNode * frameNode)1801 void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset,
1802     NG::BorderRadiusProperty& borderRadius, ArkUI_Bool isLocalizedBorderRadius, FrameNode* frameNode)
1803 {
1804     if (isLocalizedBorderRadius) {
1805         SetOptionalBorder(borderRadius.radiusTopStart, values, valuesSize, offset);
1806         SetOptionalBorder(borderRadius.radiusTopEnd, values, valuesSize, offset);
1807         SetOptionalBorder(borderRadius.radiusBottomStart, values, valuesSize, offset);
1808         SetOptionalBorder(borderRadius.radiusBottomEnd, values, valuesSize, offset);
1809     } else {
1810         SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, offset);
1811         SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, offset);
1812         SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, offset);
1813         SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, offset);
1814     }
1815 
1816     borderRadius.multiValued = true;
1817     if (borderRadius.radiusTopLeft.has_value() || borderRadius.radiusTopRight.has_value() ||
1818         borderRadius.radiusBottomLeft.has_value() || borderRadius.radiusBottomRight.has_value() ||
1819         borderRadius.radiusTopStart.has_value() || borderRadius.radiusTopEnd.has_value() ||
1820         borderRadius.radiusBottomStart.has_value() || borderRadius.radiusBottomEnd.has_value()) {
1821         ViewAbstract::SetBorderRadius(frameNode, borderRadius);
1822     }
1823 }
1824 
1825 /**
1826  * @param src source borderWidth and and BorderRadius value
1827  * @param options option value
1828  * values[offset + 0], option[offset + 1], option[offset + 2]: borderWidth start/left(hasValue, value, unit)
1829  * values[offset + 3], option[offset + 4], option[offset + 5]: borderWidth end/right(hasValue, value, unit)
1830  * values[offset + 6], option[offset + 7], option[offset + 8]: borderWidth top(hasValue, value, unit)
1831  * values[offset + 9], option[offset + 10], option[offset + 11]: borderWidth bottom(hasValue, value, unit)
1832  * values[offset + 12], option[offset + 13], option[offset + 14] : BorderRadius TopStart/Left(hasValue, value, unit)
1833  * values[offset + 15], option[offset + 16], option[offset + 17] : BorderRadius TopEnd/Right(hasValue, value, unit)
1834  * values[offset + 18], option[offset + 19], option[offset + 20] : BorderRadius BottomStart/Left(hasValue, value, unit)
1835  * values[offset + 21], option[offset + 22], option[offset + 23] : BorderRadius BottomEnd/Right(hasValue, value, unit)
1836  * @param optionsLength options valuesSize
1837  * @param src source color and Style value
1838  * colorAndStyle[offset + 0], option[offset + 1]: borderColors startColor/leftColor(hasValue, value)
1839  * colorAndStyle[offset + 2], option[offset + 3]: borderColors endColor/rightColor(hasValue, value)
1840  * colorAndStyle[offset + 4], option[offset + 5]: borderColors topColor(hasValue, value)
1841  * colorAndStyle[offset + 6], option[offset + 7]: borderColors bottomColor(hasValue, value)
1842  * colorAndStyle[offset + 8], option[offset + 9]: borderStyles styleLeft(hasValue, value)
1843  * colorAndStyle[offset + 10], option[offset + 11]: borderStyles styleRight(hasValue, value)
1844  * colorAndStyle[offset + 12], option[offset + 12]: borderStyles styleTop(hasValue, value)
1845  * colorAndStyle[offset + 14], option[offset + 15]: borderStyles styleBottom(hasValue, value)
1846  * @param optionsLength options colorAndStyleSize
1847  * @param isLocalizedBorderWidth options isLocalizedBorderWidth
1848  * @param isLocalizedBorderColor options isLocalizedBorderColor
1849  * @param isLocalizedBorderRadius options isLocalizedBorderRadius
1850  */
SetBorder(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,const uint32_t * colorAndStyle,int32_t colorAndStyleSize,ArkUI_Bool isLocalizedBorderWidth,ArkUI_Bool isLocalizedBorderColor,ArkUI_Bool isLocalizedBorderRadius)1851 void SetBorder(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, const uint32_t* colorAndStyle,
1852     int32_t colorAndStyleSize, ArkUI_Bool isLocalizedBorderWidth, ArkUI_Bool isLocalizedBorderColor,
1853     ArkUI_Bool isLocalizedBorderRadius)
1854 {
1855     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1856     CHECK_NULL_VOID(frameNode);
1857     if ((values == nullptr) || (valuesSize != NUM_24) || (colorAndStyle == nullptr) || colorAndStyleSize != NUM_16) {
1858         return;
1859     }
1860 
1861     int32_t offset = NUM_0;
1862     NG::BorderWidthProperty borderWidth;
1863     SetBorderWidth(values, valuesSize, offset, borderWidth, isLocalizedBorderWidth, frameNode);
1864     NG::BorderRadiusProperty borderRadius;
1865     SetBorderBorderRadius(values, valuesSize, offset, borderRadius, isLocalizedBorderRadius, frameNode);
1866     int32_t colorAndStyleOffset = NUM_0;
1867     NG::BorderColorProperty borderColors;
1868     if (isLocalizedBorderColor) {
1869         SetOptionalBorderColor(borderColors.startColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1870         SetOptionalBorderColor(borderColors.endColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1871     } else {
1872         SetOptionalBorderColor(borderColors.leftColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1873         SetOptionalBorderColor(borderColors.rightColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1874     }
1875     SetOptionalBorderColor(borderColors.topColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1876     SetOptionalBorderColor(borderColors.bottomColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1877     borderColors.multiValued = true;
1878     ViewAbstract::SetBorderColor(frameNode, borderColors);
1879 
1880     NG::BorderStyleProperty borderStyles;
1881     SetOptionalBorderStyle(borderStyles.styleLeft, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1882     SetOptionalBorderStyle(borderStyles.styleRight, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1883     SetOptionalBorderStyle(borderStyles.styleTop, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1884     SetOptionalBorderStyle(borderStyles.styleBottom, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1885     borderStyles.multiValued = true;
1886     ViewAbstract::SetBorderStyle(frameNode, borderStyles);
1887 }
1888 
ResetBorder(ArkUINodeHandle node)1889 void ResetBorder(ArkUINodeHandle node)
1890 {
1891     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1892     CHECK_NULL_VOID(frameNode);
1893     CalcDimension borderWidth;
1894     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
1895     ViewAbstract::SetBorderColor(frameNode, Color::BLACK);
1896     ViewAbstract::SetBorderRadius(frameNode, borderWidth);
1897     ViewAbstract::SetBorderStyle(frameNode, BorderStyle::SOLID);
1898     ViewAbstract::SetDashGap(frameNode, Dimension(-1));
1899     ViewAbstract::SetDashWidth(frameNode, Dimension(-1));
1900 }
1901 
SetBackgroundImagePosition(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * types,ArkUI_Bool isAlign,ArkUI_Int32 size)1902 void SetBackgroundImagePosition(
1903     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* types, ArkUI_Bool isAlign, ArkUI_Int32 size)
1904 {
1905     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1906     CHECK_NULL_VOID(frameNode);
1907     if (size != NUM_2) {
1908         return;
1909     }
1910     BackgroundImagePosition bgImgPosition;
1911     double valueX = values[NUM_0];
1912     double valueY = values[NUM_1];
1913     DimensionUnit typeX = static_cast<OHOS::Ace::DimensionUnit>(types[NUM_0]);
1914     DimensionUnit typeY = static_cast<OHOS::Ace::DimensionUnit>(types[NUM_1]);
1915     SetBgImgPosition(typeX, typeY, valueX, valueY, bgImgPosition);
1916     bgImgPosition.SetIsAlign(isAlign);
1917     ViewAbstract::SetBackgroundImagePosition(frameNode, bgImgPosition);
1918 }
1919 
ResetBackgroundImagePosition(ArkUINodeHandle node)1920 void ResetBackgroundImagePosition(ArkUINodeHandle node)
1921 {
1922     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1923     CHECK_NULL_VOID(frameNode);
1924     BackgroundImagePosition bgImgPosition;
1925     SetBgImgPosition(DimensionUnit::PX, DimensionUnit::PX, 0.0, 0.0, bgImgPosition);
1926     ViewAbstract::SetBackgroundImagePosition(frameNode, bgImgPosition);
1927 }
1928 
SetResizableFromVec(ImageResizableSlice & resizable,const ArkUIStringAndFloat * options)1929 void SetResizableFromVec(ImageResizableSlice& resizable, const ArkUIStringAndFloat* options)
1930 {
1931     std::vector<ResizableOption> directions = { ResizableOption::TOP, ResizableOption::BOTTOM, ResizableOption::LEFT,
1932         ResizableOption::RIGHT };
1933     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
1934         std::optional<CalcDimension> optDimension;
1935         SetCalcDimension(optDimension, options, NUM_13, index);
1936         if (optDimension.has_value()) {
1937             auto direction = directions[index / NUM_3];
1938             resizable.SetEdgeSlice(direction, optDimension.value());
1939         }
1940     }
1941 }
1942 
SetBackgroundImageResizable(ArkUINodeHandle node,ArkUIStringAndFloat * options)1943 void SetBackgroundImageResizable(ArkUINodeHandle node, ArkUIStringAndFloat* options)
1944 {
1945     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1946     CHECK_NULL_VOID(frameNode);
1947     ImageResizableSlice resizable;
1948     SetResizableFromVec(resizable, options);
1949     ViewAbstract::SetBackgroundImageResizableSlice(frameNode, resizable);
1950 }
1951 
ResetBackgroundImageResizable(ArkUINodeHandle node)1952 void ResetBackgroundImageResizable(ArkUINodeHandle node)
1953 {
1954     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1955     CHECK_NULL_VOID(frameNode);
1956     ImageResizableSlice resizable;
1957     ViewAbstract::SetBackgroundImageResizableSlice(frameNode, resizable);
1958 }
1959 
SetBackgroundImageSize(ArkUINodeHandle node,ArkUI_Float32 valueWidth,ArkUI_Float32 valueHeight,ArkUI_Int32 typeWidth,ArkUI_Int32 typeHeight)1960 void SetBackgroundImageSize(ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight,
1961     ArkUI_Int32 typeWidth, ArkUI_Int32 typeHeight)
1962 {
1963     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1964     CHECK_NULL_VOID(frameNode);
1965     BackgroundImageSize bgImgSize;
1966     bgImgSize.SetSizeTypeX(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeWidth));
1967     bgImgSize.SetSizeValueX(valueWidth);
1968     bgImgSize.SetSizeTypeY(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeHeight));
1969     bgImgSize.SetSizeValueY(valueHeight);
1970     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
1971 }
1972 
GetBackgroundImageSize(ArkUINodeHandle node,ArkUI_Int32 unit)1973 ArkUIImageSizeType GetBackgroundImageSize(ArkUINodeHandle node, ArkUI_Int32 unit)
1974 {
1975     ArkUIImageSizeType imageSizeType = { 0, 0, 0, 0 };
1976     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1977     CHECK_NULL_RETURN(frameNode, imageSizeType);
1978     auto renderContext = frameNode->GetRenderContext();
1979     CHECK_NULL_RETURN(renderContext, imageSizeType);
1980     CHECK_NULL_RETURN(renderContext->GetBackground(), imageSizeType);
1981     auto imageSize = renderContext->GetBackground()->GetBackgroundImageSize();
1982     double density = unit == static_cast<ArkUI_Int32>(DimensionUnit::PX) ? 1 : PipelineBase::GetCurrentDensity();
1983     CHECK_NULL_RETURN(imageSize, imageSizeType);
1984     imageSizeType.xValue = imageSize->GetSizeValueX() / density;
1985     imageSizeType.yValue = imageSize->GetSizeValueY() / density;
1986     imageSizeType.xType = static_cast<int32_t>(imageSize->GetSizeTypeX());
1987     imageSizeType.yType = static_cast<int32_t>(imageSize->GetSizeTypeY());
1988     return imageSizeType;
1989 }
1990 
GetBackgroundImageSizeWidthStyle(ArkUINodeHandle node)1991 int32_t GetBackgroundImageSizeWidthStyle(ArkUINodeHandle node)
1992 {
1993     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1994     CHECK_NULL_RETURN(frameNode, 0);
1995     auto renderContext = frameNode->GetRenderContext();
1996     CHECK_NULL_RETURN(renderContext, 0);
1997     CHECK_NULL_RETURN(renderContext->GetBackground(), 0);
1998     auto imageSize = renderContext->GetBackground()->GetBackgroundImageSize();
1999     CHECK_NULL_RETURN(imageSize, 0);
2000     return static_cast<int32_t>(imageSize->GetSizeTypeX());
2001 }
2002 
ResetBackgroundImageSize(ArkUINodeHandle node)2003 void ResetBackgroundImageSize(ArkUINodeHandle node)
2004 {
2005     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2006     CHECK_NULL_VOID(frameNode);
2007     BackgroundImageSize bgImgSize;
2008     bgImgSize.SetSizeTypeX(BackgroundImageSizeType::AUTO);
2009     bgImgSize.SetSizeTypeY(BackgroundImageSizeType::AUTO);
2010     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
2011 }
2012 
SetBackgroundImage(ArkUINodeHandle node,ArkUI_CharPtr src,ArkUI_CharPtr bundle,ArkUI_CharPtr module,ArkUI_Int32 repeatIndex)2013 void SetBackgroundImage(
2014     ArkUINodeHandle node, ArkUI_CharPtr src, ArkUI_CharPtr bundle, ArkUI_CharPtr module, ArkUI_Int32 repeatIndex)
2015 {
2016     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2017     CHECK_NULL_VOID(frameNode);
2018     std::string srcStr(src);
2019     std::string bundleStr(bundle);
2020     std::string moduleStr(module);
2021     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { srcStr, bundleStr, moduleStr });
2022     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2023     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2024         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2025     } else {
2026         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2027     }
2028 }
2029 
SetBackgroundImagePixelMap(ArkUINodeHandle node,void * drawableDescriptor,ArkUI_Int32 repeatIndex)2030 void SetBackgroundImagePixelMap(ArkUINodeHandle node, void* drawableDescriptor, ArkUI_Int32 repeatIndex)
2031 {
2032 #ifndef ACE_UNITTEST
2033     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2034     CHECK_NULL_VOID(frameNode);
2035     RefPtr<OHOS::Ace::PixelMap> pixelmap = PixelMap::GetFromDrawable(drawableDescriptor);
2036     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { pixelmap });
2037     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2038     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2039         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2040     } else {
2041         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2042     }
2043 #endif
2044 }
2045 
SetBackgroundImagePixelMapByPixelMapPtr(ArkUINodeHandle node,void * pixelMapPtr,ArkUI_Int32 repeatIndex)2046 void SetBackgroundImagePixelMapByPixelMapPtr(ArkUINodeHandle node, void* pixelMapPtr, ArkUI_Int32 repeatIndex)
2047 {
2048     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2049     CHECK_NULL_VOID(frameNode);
2050     RefPtr<PixelMap> pixelmap = PixelMap::CreatePixelMap(pixelMapPtr);
2051     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { pixelmap });
2052     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2053     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2054         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2055     } else {
2056         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2057     }
2058 }
2059 
ResetBackgroundImage(ArkUINodeHandle node)2060 void ResetBackgroundImage(ArkUINodeHandle node)
2061 {
2062     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2063     CHECK_NULL_VOID(frameNode);
2064     std::string srcStr;
2065     std::string bundle;
2066     std::string module;
2067     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { srcStr, bundle, module });
2068     ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2069 }
2070 
SetTranslate(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)2071 void SetTranslate(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
2072 {
2073     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2074     CHECK_NULL_VOID(frameNode);
2075     if (length != NUM_3) {
2076         return;
2077     }
2078     auto translateX = CalcDimension(0.0);
2079     auto translateY = CalcDimension(0.0);
2080     auto translateZ = CalcDimension(0.0);
2081     translateX = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2082     translateY = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2083     translateZ = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
2084 
2085     ViewAbstract::SetTranslate(frameNode, TranslateOptions(translateX, translateY, translateZ));
2086 }
2087 
ResetTranslate(ArkUINodeHandle node)2088 void ResetTranslate(ArkUINodeHandle node)
2089 {
2090     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2091     CHECK_NULL_VOID(frameNode);
2092     auto x = CalcDimension(0.0);
2093     auto y = CalcDimension(0.0);
2094     auto z = CalcDimension(0.0);
2095     ViewAbstract::SetTranslate(frameNode, TranslateOptions(x, y, z));
2096 }
2097 /**
2098  * @param values
2099  * values[0] : centerX value; values[1] : centerY value;
2100  * units[0] : centerY unit; units[1] : centerY unit
2101  * values[2]: scaleX;values[3]: scaleY;values[4]: scaleZ
2102  * @param length shadows length
2103  */
SetScale(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength,const ArkUI_Int32 * units,ArkUI_Int32 unitLength)2104 void SetScale(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength, const ArkUI_Int32* units,
2105     ArkUI_Int32 unitLength)
2106 {
2107     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2108     CHECK_NULL_VOID(frameNode);
2109     if (valLength != NUM_5 && valLength != NUM_2) {
2110         return;
2111     }
2112     auto x = values[NUM_0];
2113     auto y = values[NUM_1];
2114     // NOT support Z in source code
2115     VectorF scale(x, y);
2116     ViewAbstract::SetScale(frameNode, scale);
2117     if (valLength != NUM_5) {
2118         return;
2119     }
2120     auto centerX = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2121     auto centerY = Dimension(values[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2122     auto centerZ = Dimension(0.0, OHOS::Ace::DimensionUnit::VP);
2123 
2124     DimensionOffset center(centerX, centerY);
2125     if (!NearZero(centerZ.Value())) {
2126         center.SetZ(centerZ);
2127     }
2128     ViewAbstract::SetPivot(frameNode, center);
2129 }
2130 
GetScale(ArkUINodeHandle node,ArkUIScaleType * scaleType)2131 void GetScale(ArkUINodeHandle node, ArkUIScaleType* scaleType)
2132 {
2133     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2134     CHECK_NULL_VOID(frameNode);
2135     auto scale = ViewAbstract::GetScale(frameNode);
2136     scaleType->xValue = scale.x;
2137     scaleType->yValue = scale.y;
2138 }
2139 
GetRotate(ArkUINodeHandle node,ArkUIRotateType * rotateType)2140 void GetRotate(ArkUINodeHandle node, ArkUIRotateType* rotateType)
2141 {
2142     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2143     CHECK_NULL_VOID(frameNode);
2144     auto rotate = ViewAbstract::GetRotate(frameNode);
2145     rotateType->xCoordinate = rotate.x;
2146     rotateType->yCoordinate = rotate.y;
2147     rotateType->zCoordinate = rotate.z;
2148     rotateType->angle = rotate.w;
2149     rotateType->sightDistance = rotate.v;
2150 }
2151 
GetBrightness(ArkUINodeHandle node)2152 ArkUI_Float32 GetBrightness(ArkUINodeHandle node)
2153 {
2154     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2155     CHECK_NULL_RETURN(frameNode, DEFAULT_BRIGHTNESS);
2156     return ViewAbstract::GetBrightness(frameNode).Value();
2157 }
2158 
GetSaturate(ArkUINodeHandle node)2159 ArkUI_Float32 GetSaturate(ArkUINodeHandle node)
2160 {
2161     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2162     CHECK_NULL_RETURN(frameNode, DEFAULT_SATURATE);
2163     return ViewAbstract::GetSaturate(frameNode).Value();
2164 }
2165 
GetBackgroundImagePosition(ArkUINodeHandle node,ArkUIPositionOptions * position,ArkUI_Int32 unit)2166 void GetBackgroundImagePosition(ArkUINodeHandle node, ArkUIPositionOptions* position, ArkUI_Int32 unit)
2167 {
2168     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2169     CHECK_NULL_VOID(frameNode);
2170     auto imagePosition = ViewAbstract::GetBackgroundImagePosition(frameNode);
2171     position->x = imagePosition.GetSizeX().GetNativeValue(static_cast<DimensionUnit>(unit));
2172     position->y = imagePosition.GetSizeY().GetNativeValue(static_cast<DimensionUnit>(unit));
2173 }
2174 
2175 /**
2176  * @param values
2177  * values[0]: scaleX;values[1]: scaleY;values[2]: scaleZ
2178  * @param length shadows length
2179  */
SetScaleWithoutTransformCenter(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength)2180 void SetScaleWithoutTransformCenter(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength)
2181 {
2182     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2183     CHECK_NULL_VOID(frameNode);
2184     if (valLength != NUM_3) {
2185         return;
2186     }
2187     auto x = values[NUM_0];
2188     auto y = values[NUM_1];
2189     // NOT support Z in source code
2190     if (x < 0) {
2191         x = 1;
2192     }
2193     if (y < 0) {
2194         y = 1;
2195     }
2196     VectorF scale(x, y);
2197     ViewAbstract::SetScale(frameNode, scale);
2198 }
2199 
ResetScale(ArkUINodeHandle node)2200 void ResetScale(ArkUINodeHandle node)
2201 {
2202     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2203     CHECK_NULL_VOID(frameNode);
2204 
2205     VectorF scale(1.0f, 1.0f);
2206     ViewAbstract::SetScale(frameNode, scale);
2207 
2208     DimensionOffset center(0.5_pct, 0.5_pct);
2209     auto centerZ = Dimension(0.0, OHOS::Ace::DimensionUnit::VP);
2210     if (!NearZero(centerZ.Value())) {
2211         center.SetZ(centerZ);
2212     }
2213     ViewAbstract::SetPivot(frameNode, center);
2214 }
2215 
2216 /**
2217  * @param values
2218  * values[0] : centerX value; values[1] : centerY value; values[3] : centerZ value
2219  * units[0] : centerY unit; units[1] : centerY unit; units[3] : centerZ unit
2220  * values[4]: xDirection;values[5]: yDirection;values[6]: zDirection
2221  * values[7]: angle;values[8]:perspective
2222  * @param length shadows length
2223  */
SetRotate(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength,const ArkUI_Int32 * units,ArkUI_Int32 unitLength)2224 void SetRotate(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength, const ArkUI_Int32* units,
2225     ArkUI_Int32 unitLength)
2226 {
2227     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2228     CHECK_NULL_VOID(frameNode);
2229     if (valLength != NUM_8 || unitLength != NUM_3) {
2230         return;
2231     }
2232     auto centerX = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2233     auto centerY = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2234     auto centerZ = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
2235     auto xDirection = values[NUM_3];
2236     auto yDirection = values[NUM_4];
2237     auto zDirection = values[NUM_5];
2238     auto angle = values[NUM_6];
2239     auto perspective = values[NUM_7];
2240     ViewAbstract::SetRotate(frameNode, NG::Vector5F(xDirection, yDirection, zDirection, angle, perspective));
2241 
2242     DimensionOffset center(centerX, centerY);
2243     if (!NearZero(centerZ.Value())) {
2244         center.SetZ(centerZ);
2245     }
2246     ViewAbstract::SetPivot(frameNode, center);
2247 }
2248 
2249 /**
2250  * @param values
2251  * values[0]: xDirection;values[1]: yDirection;values[2]: zDirection
2252  * values[3]: angle;values[4]:perspective
2253  * @param length shadows length
2254  */
SetRotateWithoutTransformCenter(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength)2255 void SetRotateWithoutTransformCenter(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength)
2256 {
2257     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2258     CHECK_NULL_VOID(frameNode);
2259     if (valLength != NUM_5) {
2260         return;
2261     }
2262 
2263     auto xDirection = values[NUM_0];
2264     auto yDirection = values[NUM_1];
2265     auto zDirection = values[NUM_2];
2266     auto angle = values[NUM_3];
2267     auto perspective = values[NUM_4];
2268     ViewAbstract::SetRotate(frameNode, NG::Vector5F(xDirection, yDirection, zDirection, angle, perspective));
2269 }
2270 
ResetRotate(ArkUINodeHandle node)2271 void ResetRotate(ArkUINodeHandle node)
2272 {
2273     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2274     CHECK_NULL_VOID(frameNode);
2275     NG::RotateOptions rotate(0.0f, 0.0f, 0.0f, 0.0f, 0.5_pct, 0.5_pct, 0.0f, 0.0f);
2276     ViewAbstract::SetRotate(
2277         frameNode, NG::Vector5F(rotate.xDirection, rotate.yDirection, rotate.zDirection, 0.0, rotate.perspective));
2278 
2279     DimensionOffset center(rotate.centerX, rotate.centerY);
2280     if (!NearZero(rotate.centerZ.Value())) {
2281         center.SetZ(rotate.centerZ);
2282     }
2283     ViewAbstract::SetPivot(frameNode, center);
2284 }
2285 
SetGeometryTransition(ArkUINodeHandle node,ArkUI_CharPtr id,const ArkUIGeometryTransitionOptions * options)2286 void SetGeometryTransition(ArkUINodeHandle node, ArkUI_CharPtr id, const ArkUIGeometryTransitionOptions* options)
2287 {
2288     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2289     CHECK_NULL_VOID(frameNode);
2290     std::string idStr(id);
2291     ViewAbstract::SetGeometryTransition(frameNode, idStr,
2292         static_cast<bool>(options->follow), static_cast<bool>(options->hierarchyStrategy));
2293 }
2294 
GetGeometryTransition(ArkUINodeHandle node,ArkUIGeometryTransitionOptions * options)2295 ArkUI_CharPtr GetGeometryTransition(ArkUINodeHandle node, ArkUIGeometryTransitionOptions* options)
2296 {
2297     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2298     CHECK_NULL_RETURN(frameNode, nullptr);
2299     bool followWithoutTransition = false;
2300     bool doRegisterSharedTransition = true;
2301     g_strValue = ViewAbstract::GetGeometryTransition(frameNode, &followWithoutTransition, &doRegisterSharedTransition);
2302     options->follow = followWithoutTransition;
2303     options->hierarchyStrategy = static_cast<int32_t>(doRegisterSharedTransition);
2304     return g_strValue.c_str();
2305 }
2306 
ResetGeometryTransition(ArkUINodeHandle node)2307 void ResetGeometryTransition(ArkUINodeHandle node)
2308 {
2309     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2310     CHECK_NULL_VOID(frameNode);
2311     ViewAbstract::SetGeometryTransition(frameNode, "", false, true);
2312 }
2313 
SetOffset(ArkUINodeHandle node,const ArkUI_Float32 * number,const ArkUI_Int32 * unit)2314 void SetOffset(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit)
2315 {
2316     CHECK_NULL_VOID(number);
2317     CHECK_NULL_VOID(unit);
2318     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2319     CHECK_NULL_VOID(frameNode);
2320     Dimension xVal(*(number + 0), static_cast<DimensionUnit>(*(unit + 0)));
2321     Dimension yVal(*(number + 1), static_cast<DimensionUnit>(*(unit + 1)));
2322     ViewAbstract::SetOffset(frameNode, { xVal, yVal });
2323 }
2324 
SetOffsetEdges(ArkUINodeHandle node,ArkUI_Bool useEdges,const ArkUIStringAndFloat * options)2325 void SetOffsetEdges(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options)
2326 {
2327     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2328     CHECK_NULL_VOID(frameNode);
2329 
2330     if (useEdges) {
2331         OHOS::Ace::EdgesParam edges;
2332         ParseEdges(edges, options);
2333         ViewAbstract::SetOffsetEdges(frameNode, edges);
2334     } else {
2335         OffsetT<Dimension> offset;
2336         std::optional<CalcDimension> x;
2337         std::optional<CalcDimension> y;
2338         SetCalcDimension(x, options, NUM_7, NUM_0);
2339         SetCalcDimension(y, options, NUM_7, NUM_3);
2340         if (x.has_value()) {
2341             offset.SetX(x.value());
2342         }
2343         if (y.has_value()) {
2344             offset.SetY(y.value());
2345         }
2346         ViewAbstract::SetOffset(frameNode, offset);
2347     }
2348 }
2349 
GetOffset(ArkUINodeHandle node)2350 ArkUIOffsetType GetOffset(ArkUINodeHandle node)
2351 {
2352     ArkUIOffsetType offsetVp = { 0.0f, 0.0f };
2353     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2354     CHECK_NULL_RETURN(frameNode, offsetVp);
2355     auto renderContext = frameNode->GetRenderContext();
2356     CHECK_NULL_RETURN(renderContext, offsetVp);
2357     CHECK_NULL_RETURN(renderContext->GetPositionProperty(), offsetVp);
2358     if (!renderContext->GetPositionProperty()->HasOffset()) {
2359         return offsetVp;
2360     }
2361     offsetVp.xComponent = renderContext->GetPositionProperty()->GetOffsetValue().GetX().Value();
2362     offsetVp.yComponent = renderContext->GetPositionProperty()->GetOffsetValue().GetY().Value();
2363     return offsetVp;
2364 }
2365 
ResetOffset(ArkUINodeHandle node)2366 void ResetOffset(ArkUINodeHandle node)
2367 {
2368     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2369     CHECK_NULL_VOID(frameNode);
2370     Dimension xVal(0.0, DimensionUnit::VP);
2371     Dimension yVal(0.0, DimensionUnit::VP);
2372     ViewAbstract::SetOffset(frameNode, { xVal, yVal });
2373 }
2374 
SetPadding(ArkUINodeHandle node,const struct ArkUISizeType * top,const struct ArkUISizeType * right,const struct ArkUISizeType * bottom,const struct ArkUISizeType * left)2375 void SetPadding(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right,
2376     const struct ArkUISizeType* bottom, const struct ArkUISizeType* left)
2377 {
2378     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2379     CHECK_NULL_VOID(frameNode);
2380     CalcLength topDimen;
2381     CalcLength rightDimen;
2382     CalcLength bottomDimen;
2383     CalcLength leftDimen;
2384     if (top->string != nullptr) {
2385         topDimen = CalcLength(top->string);
2386     } else {
2387         topDimen = CalcLength(top->value, static_cast<DimensionUnit>(top->unit));
2388     }
2389     if (right->string != nullptr) {
2390         rightDimen = CalcLength(right->string);
2391     } else {
2392         rightDimen = CalcLength(right->value, static_cast<DimensionUnit>(right->unit));
2393     }
2394     if (bottom->string != nullptr) {
2395         bottomDimen = CalcLength(bottom->string);
2396     } else {
2397         bottomDimen = CalcLength(bottom->value, static_cast<DimensionUnit>(bottom->unit));
2398     }
2399     if (left->string != nullptr) {
2400         leftDimen = CalcLength(left->string);
2401     } else {
2402         leftDimen = CalcLength(left->value, static_cast<DimensionUnit>(left->unit));
2403     }
2404     NG::PaddingProperty paddings;
2405     paddings.top = std::optional<CalcLength>(topDimen);
2406     paddings.bottom = std::optional<CalcLength>(bottomDimen);
2407     paddings.left = std::optional<CalcLength>(leftDimen);
2408     paddings.right = std::optional<CalcLength>(rightDimen);
2409     ViewAbstract::SetPadding(frameNode, paddings);
2410 }
2411 
ResetPadding(ArkUINodeHandle node)2412 void ResetPadding(ArkUINodeHandle node)
2413 {
2414     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2415     CHECK_NULL_VOID(frameNode);
2416     NG::PaddingProperty paddings;
2417     paddings.top = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2418     paddings.bottom = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2419     paddings.left = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2420     paddings.right = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2421     ViewAbstract::SetPadding(frameNode, paddings);
2422 }
2423 
2424 /**
2425  * @param values value value
2426  * values[0] : left, values[1] : top, values[2] : right, values[3] : bottom
2427  * @param units unit value
2428  * units[0] : left, units[1] : top, units[2] : right, units[3] : bottom
2429  * @param length values length
2430  */
SetPixelStretchEffect(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)2431 void SetPixelStretchEffect(
2432     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
2433 {
2434     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2435     CHECK_NULL_VOID(frameNode);
2436     if (length != NUM_4) {
2437         return;
2438     }
2439     auto leftValue = values[NUM_0];
2440     auto leftUnit = units[NUM_0];
2441     auto topValue = values[NUM_1];
2442     auto topUnit = units[NUM_1];
2443     auto rightValue = values[NUM_2];
2444     auto rightUnit = units[NUM_2];
2445     auto bottomValue = values[NUM_3];
2446     auto bottomUnit = units[NUM_3];
2447     Dimension left(leftValue, static_cast<DimensionUnit>(leftUnit));
2448     Dimension top(topValue, static_cast<DimensionUnit>(topUnit));
2449     Dimension right(rightValue, static_cast<DimensionUnit>(rightUnit));
2450     Dimension bottom(bottomValue, static_cast<DimensionUnit>(bottomUnit));
2451     bool illegalInput = false;
2452     if (left.Unit() == DimensionUnit::PERCENT || right.Unit() == DimensionUnit::PERCENT ||
2453         top.Unit() == DimensionUnit::PERCENT || bottom.Unit() == DimensionUnit::PERCENT) {
2454         if ((NearEqual(left.Value(), 0.0) || left.Unit() == DimensionUnit::PERCENT) &&
2455             (NearEqual(top.Value(), 0.0) || top.Unit() == DimensionUnit::PERCENT) &&
2456             (NearEqual(right.Value(), 0.0) || right.Unit() == DimensionUnit::PERCENT) &&
2457             (NearEqual(bottom.Value(), 0.0) || bottom.Unit() == DimensionUnit::PERCENT)) {
2458             left.SetUnit(DimensionUnit::PERCENT);
2459             top.SetUnit(DimensionUnit::PERCENT);
2460             right.SetUnit(DimensionUnit::PERCENT);
2461             bottom.SetUnit(DimensionUnit::PERCENT);
2462         } else {
2463             illegalInput = true;
2464         }
2465     }
2466     PixStretchEffectOption option;
2467     if ((left.IsNonNegative() && top.IsNonNegative() && right.IsNonNegative() && bottom.IsNonNegative()) ||
2468         (left.IsNonPositive() && top.IsNonPositive() && right.IsNonPositive() && bottom.IsNonPositive())) {
2469         option.left = left;
2470         option.top = top;
2471         option.right = right;
2472         option.bottom = bottom;
2473     } else {
2474         illegalInput = true;
2475     }
2476     if (illegalInput) {
2477         option.ResetValue();
2478     }
2479     ViewAbstract::SetPixelStretchEffect(frameNode, option);
2480 }
2481 
ResetPixelStretchEffect(ArkUINodeHandle node)2482 void ResetPixelStretchEffect(ArkUINodeHandle node)
2483 {
2484     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2485     CHECK_NULL_VOID(frameNode);
2486     PixStretchEffectOption option;
2487     option.ResetValue();
2488     ViewAbstract::SetPixelStretchEffect(frameNode, option);
2489 }
2490 
SetLightUpEffect(ArkUINodeHandle node,ArkUI_Float32 radio)2491 void SetLightUpEffect(ArkUINodeHandle node, ArkUI_Float32 radio)
2492 {
2493     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2494     CHECK_NULL_VOID(frameNode);
2495     radio = std::clamp(radio, 0.0f, 1.0f);
2496     ViewAbstract::SetLightUpEffect(frameNode, radio);
2497 }
2498 
ResetLightUpEffect(ArkUINodeHandle node)2499 void ResetLightUpEffect(ArkUINodeHandle node)
2500 {
2501     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2502     CHECK_NULL_VOID(frameNode);
2503     ViewAbstract::SetLightUpEffect(frameNode, 1.0);
2504 }
2505 
SetSphericalEffect(ArkUINodeHandle node,ArkUI_Float64 radio)2506 void SetSphericalEffect(ArkUINodeHandle node, ArkUI_Float64 radio)
2507 {
2508     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2509     CHECK_NULL_VOID(frameNode);
2510     radio = std::clamp(radio, 0.0, 1.0);
2511     ViewAbstract::SetSphericalEffect(frameNode, radio);
2512 }
2513 
ResetSphericalEffect(ArkUINodeHandle node)2514 void ResetSphericalEffect(ArkUINodeHandle node)
2515 {
2516     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2517     CHECK_NULL_VOID(frameNode);
2518     ViewAbstract::SetSphericalEffect(frameNode, 0.0);
2519 }
2520 
SetRenderGroup(ArkUINodeHandle node,ArkUI_Bool isRenderGroup)2521 void SetRenderGroup(ArkUINodeHandle node, ArkUI_Bool isRenderGroup)
2522 {
2523     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2524     CHECK_NULL_VOID(frameNode);
2525     ViewAbstract::SetRenderGroup(frameNode, isRenderGroup);
2526 }
2527 
ResetRenderGroup(ArkUINodeHandle node)2528 void ResetRenderGroup(ArkUINodeHandle node)
2529 {
2530     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2531     CHECK_NULL_VOID(frameNode);
2532     ViewAbstract::SetRenderGroup(frameNode, false);
2533 }
2534 
SetRenderFit(ArkUINodeHandle node,ArkUI_Int32 renderFitNumber)2535 void SetRenderFit(ArkUINodeHandle node, ArkUI_Int32 renderFitNumber)
2536 {
2537     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2538     CHECK_NULL_VOID(frameNode);
2539     auto renderFit = RenderFit::TOP_LEFT;
2540     if (renderFitNumber >= static_cast<int32_t>(RenderFit::CENTER) &&
2541         renderFitNumber <= static_cast<int32_t>(RenderFit::RESIZE_COVER_BOTTOM_RIGHT)) {
2542         renderFit = static_cast<RenderFit>(renderFitNumber);
2543     }
2544     ViewAbstract::SetRenderFit(frameNode, renderFit);
2545 }
2546 
ResetRenderFit(ArkUINodeHandle node)2547 void ResetRenderFit(ArkUINodeHandle node)
2548 {
2549     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2550     CHECK_NULL_VOID(frameNode);
2551     ViewAbstract::SetRenderFit(frameNode, RenderFit::TOP_LEFT);
2552 }
2553 
GetRenderFit(ArkUINodeHandle node)2554 ArkUI_Int32 GetRenderFit(ArkUINodeHandle node)
2555 {
2556     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2557     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
2558     return static_cast<ArkUI_Int32>(ViewAbstract::GetRenderFit(frameNode));
2559 }
2560 
SetUseEffect(ArkUINodeHandle node,ArkUI_Bool useEffect,ArkUI_Int32 effectType)2561 void SetUseEffect(ArkUINodeHandle node, ArkUI_Bool useEffect, ArkUI_Int32 effectType)
2562 {
2563     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2564     CHECK_NULL_VOID(frameNode);
2565     ViewAbstract::SetUseEffect(frameNode, useEffect, static_cast<EffectType>(effectType));
2566 }
2567 
ResetUseEffect(ArkUINodeHandle node)2568 void ResetUseEffect(ArkUINodeHandle node)
2569 {
2570     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2571     CHECK_NULL_VOID(frameNode);
2572     ViewAbstract::SetUseEffect(frameNode, false, EffectType::DEFAULT);
2573 }
2574 
SetForegroundColor(ArkUINodeHandle node,ArkUI_Bool isColor,uint32_t color)2575 void SetForegroundColor(ArkUINodeHandle node, ArkUI_Bool isColor, uint32_t color)
2576 {
2577     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2578     CHECK_NULL_VOID(frameNode);
2579     if (isColor) {
2580         ViewAbstract::SetForegroundColor(frameNode, Color(color));
2581     } else {
2582         auto strategy = static_cast<ForegroundColorStrategy>(color);
2583         ViewAbstract::SetForegroundColorStrategy(frameNode, strategy);
2584     }
2585 }
2586 
ResetForegroundColor(ArkUINodeHandle node)2587 void ResetForegroundColor(ArkUINodeHandle node)
2588 {
2589     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2590     CHECK_NULL_VOID(frameNode);
2591 }
2592 
SetMotionPath(ArkUINodeHandle node,ArkUI_CharPtr path,ArkUI_Float32 from,ArkUI_Float32 to,ArkUI_Bool rotatable)2593 void SetMotionPath(ArkUINodeHandle node, ArkUI_CharPtr path, ArkUI_Float32 from, ArkUI_Float32 to, ArkUI_Bool rotatable)
2594 {
2595     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2596     CHECK_NULL_VOID(frameNode);
2597     OHOS::Ace::MotionPathOption motionPathOption;
2598     std::string pathString = path;
2599     motionPathOption.SetPath(pathString);
2600     motionPathOption.SetBegin(from);
2601     motionPathOption.SetEnd(to);
2602     motionPathOption.SetRotate(rotatable);
2603     ViewAbstract::SetMotionPath(frameNode, motionPathOption);
2604 }
2605 
ResetMotionPath(ArkUINodeHandle node)2606 void ResetMotionPath(ArkUINodeHandle node)
2607 {
2608     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2609     CHECK_NULL_VOID(frameNode);
2610     OHOS::Ace::MotionPathOption motionPathOption = MotionPathOption();
2611     ViewAbstract::SetMotionPath(frameNode, motionPathOption);
2612 }
2613 
2614 
SetMotionBlur(ArkUINodeHandle node,ArkUI_Float32 radius,ArkUI_Float32 anchorX,ArkUI_Float32 anchorY)2615 void SetMotionBlur(ArkUINodeHandle node, ArkUI_Float32 radius, ArkUI_Float32 anchorX, ArkUI_Float32 anchorY)
2616 {
2617     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2618     CHECK_NULL_VOID(frameNode);
2619     MotionBlurOption motionBlurOption;
2620     motionBlurOption.radius = radius;
2621     motionBlurOption.anchor.x = anchorX;
2622     motionBlurOption.anchor.y = anchorY;
2623     ViewAbstract::SetMotionBlur(frameNode, motionBlurOption);
2624 }
2625 
ResetMotionBlur(ArkUINodeHandle node)2626 void ResetMotionBlur(ArkUINodeHandle node)
2627 {
2628     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2629     CHECK_NULL_VOID(frameNode);
2630     MotionBlurOption motionBlurOption;
2631     motionBlurOption.radius = 0.0;
2632     motionBlurOption.anchor.x = 0.0;
2633     motionBlurOption.anchor.y = 0.0;
2634     ViewAbstract::SetMotionBlur(frameNode, motionBlurOption);
2635 }
2636 
SetGroupDefaultFocus(ArkUINodeHandle node,ArkUI_Bool groupDefaultFocus)2637 void SetGroupDefaultFocus(ArkUINodeHandle node, ArkUI_Bool groupDefaultFocus)
2638 {
2639     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2640     CHECK_NULL_VOID(frameNode);
2641     ViewAbstract::SetGroupDefaultFocus(frameNode, groupDefaultFocus);
2642 }
2643 
ResetGroupDefaultFocus(ArkUINodeHandle node)2644 void ResetGroupDefaultFocus(ArkUINodeHandle node)
2645 {
2646     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2647     CHECK_NULL_VOID(frameNode);
2648     bool groupDefaultFocus = false;
2649     ViewAbstract::SetGroupDefaultFocus(frameNode, groupDefaultFocus);
2650 }
2651 
SetFocusOnTouch(ArkUINodeHandle node,ArkUI_Bool focusOnTouch)2652 void SetFocusOnTouch(ArkUINodeHandle node, ArkUI_Bool focusOnTouch)
2653 {
2654     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2655     CHECK_NULL_VOID(frameNode);
2656     ViewAbstract::SetFocusOnTouch(frameNode, focusOnTouch);
2657 }
2658 
ResetFocusOnTouch(ArkUINodeHandle node)2659 void ResetFocusOnTouch(ArkUINodeHandle node)
2660 {
2661     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2662     CHECK_NULL_VOID(frameNode);
2663     bool focusOnTouch = false;
2664     ViewAbstract::SetFocusOnTouch(frameNode, focusOnTouch);
2665 }
2666 
GetFocusOnTouch(ArkUINodeHandle node)2667 ArkUI_Bool GetFocusOnTouch(ArkUINodeHandle node)
2668 {
2669     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2670     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
2671     return static_cast<ArkUI_Bool>(ViewAbstract::GetFocusOnTouch(frameNode));
2672 }
2673 
SetFocusable(ArkUINodeHandle node,ArkUI_Bool focusable)2674 void SetFocusable(ArkUINodeHandle node, ArkUI_Bool focusable)
2675 {
2676     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2677     CHECK_NULL_VOID(frameNode);
2678     if (frameNode->GetTag() == "Custom") {
2679         ViewAbstract::SetFocusType(frameNode, focusable ? FocusType::SCOPE : FocusType::DISABLE);
2680     }
2681     ViewAbstract::SetFocusable(frameNode, focusable);
2682 }
2683 
ResetFocusable(ArkUINodeHandle node)2684 void ResetFocusable(ArkUINodeHandle node)
2685 {
2686     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2687     CHECK_NULL_VOID(frameNode);
2688     bool focusable = false;
2689     ViewAbstract::SetFocusable(frameNode, focusable);
2690 }
2691 
SetTouchable(ArkUINodeHandle node,ArkUI_Bool touchable)2692 void SetTouchable(ArkUINodeHandle node, ArkUI_Bool touchable)
2693 {
2694     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2695     CHECK_NULL_VOID(frameNode);
2696     ViewAbstract::SetTouchable(frameNode, touchable);
2697 }
2698 
ResetTouchable(ArkUINodeHandle node)2699 void ResetTouchable(ArkUINodeHandle node)
2700 {
2701     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2702     CHECK_NULL_VOID(frameNode);
2703     bool touchable = true;
2704     ViewAbstract::SetTouchable(frameNode, touchable);
2705 }
2706 
SetDefaultFocus(ArkUINodeHandle node,ArkUI_Bool defaultFocus)2707 void SetDefaultFocus(ArkUINodeHandle node, ArkUI_Bool defaultFocus)
2708 {
2709     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2710     CHECK_NULL_VOID(frameNode);
2711     ViewAbstract::SetDefaultFocus(frameNode, defaultFocus);
2712 }
2713 
ResetDefaultFocus(ArkUINodeHandle node)2714 void ResetDefaultFocus(ArkUINodeHandle node)
2715 {
2716     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2717     CHECK_NULL_VOID(frameNode);
2718     bool defaultFocus = false;
2719     ViewAbstract::SetDefaultFocus(frameNode, defaultFocus);
2720 }
2721 
SetDisplayPriority(ArkUINodeHandle node,ArkUI_Float32 value)2722 void SetDisplayPriority(ArkUINodeHandle node, ArkUI_Float32 value)
2723 {
2724     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2725     CHECK_NULL_VOID(frameNode);
2726     ViewAbstract::SetDisplayIndex(frameNode, static_cast<int32_t>(value));
2727 }
2728 
ResetDisplayPriority(ArkUINodeHandle node)2729 void ResetDisplayPriority(ArkUINodeHandle node)
2730 {
2731     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2732     CHECK_NULL_VOID(frameNode);
2733     ViewAbstract::SetDisplayIndex(frameNode, DEFAULT_DISPLAY_PRIORITY);
2734 }
2735 
GetDisplayPriority(ArkUINodeHandle node)2736 ArkUI_Int32 GetDisplayPriority(ArkUINodeHandle node)
2737 {
2738     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2739     CHECK_NULL_RETURN(frameNode, DEFAULT_DISPLAY_PRIORITY);
2740     return ViewAbstract::GetDisplayIndex(frameNode);
2741 }
2742 
SetMargin(ArkUINodeHandle node,const struct ArkUISizeType * top,const struct ArkUISizeType * right,const struct ArkUISizeType * bottom,const struct ArkUISizeType * left)2743 void SetMargin(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right,
2744     const struct ArkUISizeType* bottom, const struct ArkUISizeType* left)
2745 {
2746     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2747     CHECK_NULL_VOID(frameNode);
2748     CalcLength topDimen;
2749     CalcLength rightDimen;
2750     CalcLength bottomDimen;
2751     CalcLength leftDimen;
2752     if (top->string != nullptr) {
2753         topDimen = CalcLength(top->string);
2754     } else {
2755         topDimen = CalcLength(top->value, static_cast<DimensionUnit>(top->unit));
2756     }
2757     if (right->string != nullptr) {
2758         rightDimen = CalcLength(right->string);
2759     } else {
2760         rightDimen = CalcLength(right->value, static_cast<DimensionUnit>(right->unit));
2761     }
2762     if (bottom->string != nullptr) {
2763         bottomDimen = CalcLength(bottom->string);
2764     } else {
2765         bottomDimen = CalcLength(bottom->value, static_cast<DimensionUnit>(bottom->unit));
2766     }
2767     if (left->string != nullptr) {
2768         leftDimen = CalcLength(left->string);
2769     } else {
2770         leftDimen = CalcLength(left->value, static_cast<DimensionUnit>(left->unit));
2771     }
2772     NG::PaddingProperty paddings;
2773     paddings.top = std::optional<CalcLength>(topDimen);
2774     paddings.bottom = std::optional<CalcLength>(bottomDimen);
2775     paddings.left = std::optional<CalcLength>(leftDimen);
2776     paddings.right = std::optional<CalcLength>(rightDimen);
2777     ViewAbstract::SetMargin(frameNode, paddings);
2778 }
2779 
ResetMargin(ArkUINodeHandle node)2780 void ResetMargin(ArkUINodeHandle node)
2781 {
2782     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2783     CHECK_NULL_VOID(frameNode);
2784     ViewAbstract::SetMargin(frameNode, NG::CalcLength(0.0));
2785 }
2786 
SetMarkAnchor(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit)2787 void SetMarkAnchor(
2788     ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit)
2789 {
2790     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2791     CHECK_NULL_VOID(frameNode);
2792     Dimension xDimension { xValue, static_cast<DimensionUnit>(xUnit) };
2793     Dimension yDimension { yValue, static_cast<DimensionUnit>(yUnit) };
2794     OffsetT<Dimension> value = { xDimension, yDimension };
2795     ViewAbstract::MarkAnchor(frameNode, value);
2796 }
2797 
GetMarkAnchor(ArkUINodeHandle node)2798 ArkUIAnchorType GetMarkAnchor(ArkUINodeHandle node)
2799 {
2800     ArkUIAnchorType anchorType = { 0.0f, 0.0f };
2801     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2802     CHECK_NULL_RETURN(frameNode, anchorType);
2803     auto renderContext = frameNode->GetRenderContext();
2804     CHECK_NULL_RETURN(renderContext, anchorType);
2805     CHECK_NULL_RETURN(renderContext->GetPositionProperty(), anchorType);
2806     if (!renderContext->GetPositionProperty()->HasAnchor()) {
2807         return anchorType;
2808     }
2809     anchorType.xCoordinate = renderContext->GetPositionProperty()->GetAnchor()->GetX().Value();
2810     anchorType.yCoordinate = renderContext->GetPositionProperty()->GetAnchor()->GetY().Value();
2811     return anchorType;
2812 }
2813 
ResetMarkAnchor(ArkUINodeHandle node)2814 void ResetMarkAnchor(ArkUINodeHandle node)
2815 {
2816     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2817     CHECK_NULL_VOID(frameNode);
2818     ViewAbstract::MarkAnchor(frameNode, { Dimension(0.0_vp), Dimension(0.0_vp) });
2819 }
2820 
SetVisibility(ArkUINodeHandle node,ArkUI_Int32 value)2821 void SetVisibility(ArkUINodeHandle node, ArkUI_Int32 value)
2822 {
2823     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2824     CHECK_NULL_VOID(frameNode);
2825     VisibleType value_visibleType = static_cast<VisibleType>(value);
2826     ViewAbstract::SetVisibility(frameNode, value_visibleType);
2827 }
2828 
ResetVisibility(ArkUINodeHandle node)2829 void ResetVisibility(ArkUINodeHandle node)
2830 {
2831     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2832     CHECK_NULL_VOID(frameNode);
2833     ViewAbstract::SetVisibility(frameNode, DEFAULT_VISIBILITY);
2834 }
2835 
SetAccessibilityText(ArkUINodeHandle node,ArkUI_CharPtr value)2836 void SetAccessibilityText(ArkUINodeHandle node, ArkUI_CharPtr value)
2837 {
2838     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2839     CHECK_NULL_VOID(frameNode);
2840     std::string valueStr = value;
2841     ViewAbstractModelNG::SetAccessibilityText(frameNode, valueStr);
2842 }
2843 
ResetAccessibilityText(ArkUINodeHandle node)2844 void ResetAccessibilityText(ArkUINodeHandle node)
2845 {
2846     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2847     CHECK_NULL_VOID(frameNode);
2848     ViewAbstractModelNG::SetAccessibilityText(frameNode, "");
2849 }
2850 
SetAllowDrop(ArkUINodeHandle node,ArkUI_CharPtr * allowDropCharArray,ArkUI_Int32 length)2851 void SetAllowDrop(ArkUINodeHandle node, ArkUI_CharPtr* allowDropCharArray, ArkUI_Int32 length)
2852 {
2853     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2854     CHECK_NULL_VOID(frameNode);
2855     std::set<std::string> allowDropSet;
2856     allowDropSet.clear();
2857     std::string allowDropStr;
2858     for (int32_t i = 0; i < length; i++) {
2859         allowDropStr = allowDropCharArray[i];
2860         allowDropSet.insert(allowDropStr);
2861     }
2862     frameNode->SetDisallowDropForcedly(false);
2863     ViewAbstract::SetAllowDrop(frameNode, allowDropSet);
2864 }
2865 
ResetAllowDrop(ArkUINodeHandle node)2866 void ResetAllowDrop(ArkUINodeHandle node)
2867 {
2868     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2869     CHECK_NULL_VOID(frameNode);
2870     std::set<std::string> allowDrop;
2871     frameNode->SetDisallowDropForcedly(false);
2872     ViewAbstract::SetAllowDrop(frameNode, allowDrop);
2873 }
2874 
SetDisAllowDrop(ArkUINodeHandle node)2875 void SetDisAllowDrop(ArkUINodeHandle node)
2876 {
2877     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2878     CHECK_NULL_VOID(frameNode);
2879     frameNode->SetDisallowDropForcedly(true);
2880 }
2881 
SetAccessibilityLevel(ArkUINodeHandle node,ArkUI_CharPtr value)2882 void SetAccessibilityLevel(ArkUINodeHandle node, ArkUI_CharPtr value)
2883 {
2884     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2885     CHECK_NULL_VOID(frameNode);
2886     CHECK_NULL_VOID(value);
2887     std::string valueStr = value;
2888     ViewAbstractModelNG::SetAccessibilityImportance(frameNode, valueStr);
2889 }
2890 
ResetAccessibilityLevel(ArkUINodeHandle node)2891 void ResetAccessibilityLevel(ArkUINodeHandle node)
2892 {
2893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2894     CHECK_NULL_VOID(frameNode);
2895     ViewAbstractModelNG::SetAccessibilityImportance(frameNode, "");
2896 }
2897 
SetDirection(ArkUINodeHandle node,ArkUI_Int32 direction)2898 void SetDirection(ArkUINodeHandle node, ArkUI_Int32 direction)
2899 {
2900     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2901     CHECK_NULL_VOID(frameNode);
2902     ViewAbstract::SetLayoutDirection(frameNode, static_cast<TextDirection>(direction));
2903 }
2904 
ResetDirection(ArkUINodeHandle node)2905 void ResetDirection(ArkUINodeHandle node)
2906 {
2907     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2908     CHECK_NULL_VOID(frameNode);
2909     ViewAbstract::SetLayoutDirection(frameNode, DEFAULT_COMMON_DIRECTION);
2910 }
2911 
SetLayoutWeight(ArkUINodeHandle node,ArkUI_Int32 layoutWeight)2912 void SetLayoutWeight(ArkUINodeHandle node, ArkUI_Int32 layoutWeight)
2913 {
2914     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2915     CHECK_NULL_VOID(frameNode);
2916     ViewAbstract::SetLayoutWeight(frameNode, layoutWeight);
2917 }
2918 
ResetLayoutWeight(ArkUINodeHandle node)2919 void ResetLayoutWeight(ArkUINodeHandle node)
2920 {
2921     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2922     CHECK_NULL_VOID(frameNode);
2923     ViewAbstract::SetLayoutWeight(frameNode, DEFAULT_COMMON_LAYOUTWEIGHT);
2924 }
2925 
GetLayoutWeight(ArkUINodeHandle node)2926 ArkUI_Float32 GetLayoutWeight(ArkUINodeHandle node)
2927 {
2928     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2929     CHECK_NULL_RETURN(frameNode, 0.0f);
2930     return ViewAbstract::GetLayoutWeight(frameNode);
2931 }
2932 
SetMinWidth(ArkUINodeHandle node,const struct ArkUISizeType * minWidth)2933 void SetMinWidth(ArkUINodeHandle node, const struct ArkUISizeType* minWidth)
2934 {
2935     CHECK_NULL_VOID(minWidth);
2936     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2937     CHECK_NULL_VOID(frameNode);
2938     CalcLength strResult;
2939     if (minWidth->string != nullptr) {
2940         strResult = CalcLength(minWidth->string);
2941         ViewAbstract::SetMinWidth(frameNode, strResult);
2942     } else {
2943         CalcDimension result(minWidth->value, static_cast<DimensionUnit>(minWidth->unit));
2944         ViewAbstract::SetMinWidth(frameNode, CalcLength(result));
2945     }
2946 }
2947 
ResetMinWidth(ArkUINodeHandle node)2948 void ResetMinWidth(ArkUINodeHandle node)
2949 {
2950     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2951     CHECK_NULL_VOID(frameNode);
2952     ViewAbstract::ResetMinSize(frameNode, true);
2953 }
2954 
SetMaxWidth(ArkUINodeHandle node,const struct ArkUISizeType * maxWidth)2955 void SetMaxWidth(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth)
2956 {
2957     CHECK_NULL_VOID(maxWidth);
2958     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2959     CHECK_NULL_VOID(frameNode);
2960     CalcLength strResult;
2961     if (maxWidth->string != nullptr) {
2962         strResult = CalcLength(maxWidth->string);
2963         ViewAbstract::SetMaxWidth(frameNode, strResult);
2964     } else {
2965         CalcDimension result(maxWidth->value, static_cast<DimensionUnit>(maxWidth->unit));
2966         ViewAbstract::SetMaxWidth(frameNode, CalcLength(result));
2967     }
2968 }
2969 
ResetMaxWidth(ArkUINodeHandle node)2970 void ResetMaxWidth(ArkUINodeHandle node)
2971 {
2972     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2973     CHECK_NULL_VOID(frameNode);
2974     ViewAbstract::ResetMaxSize(frameNode, true);
2975 }
2976 
SetMinHeight(ArkUINodeHandle node,const struct ArkUISizeType * minHeight)2977 void SetMinHeight(ArkUINodeHandle node, const struct ArkUISizeType* minHeight)
2978 {
2979     CHECK_NULL_VOID(minHeight);
2980     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2981     CHECK_NULL_VOID(frameNode);
2982     CalcLength strResult;
2983     if (minHeight->string != nullptr) {
2984         strResult = CalcLength(minHeight->string);
2985         ViewAbstract::SetMinHeight(frameNode, strResult);
2986     } else {
2987         CalcDimension result(minHeight->value, static_cast<DimensionUnit>(minHeight->unit));
2988         ViewAbstract::SetMinHeight(frameNode, CalcLength(result));
2989     }
2990 }
2991 
ResetMinHeight(ArkUINodeHandle node)2992 void ResetMinHeight(ArkUINodeHandle node)
2993 {
2994     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2995     CHECK_NULL_VOID(frameNode);
2996     ViewAbstract::ResetMinSize(frameNode, false);
2997 }
2998 
SetMaxHeight(ArkUINodeHandle node,const struct ArkUISizeType * maxHeight)2999 void SetMaxHeight(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight)
3000 {
3001     CHECK_NULL_VOID(maxHeight);
3002     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3003     CHECK_NULL_VOID(frameNode);
3004     CalcLength strResult;
3005     if (maxHeight->string != nullptr) {
3006         strResult = CalcLength(maxHeight->string);
3007         ViewAbstract::SetMaxHeight(frameNode, strResult);
3008     } else {
3009         CalcDimension result(maxHeight->value, static_cast<DimensionUnit>(maxHeight->unit));
3010         ViewAbstract::SetMaxHeight(frameNode, CalcLength(result));
3011     }
3012 }
3013 
ResetMaxHeight(ArkUINodeHandle node)3014 void ResetMaxHeight(ArkUINodeHandle node)
3015 {
3016     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3017     CHECK_NULL_VOID(frameNode);
3018     ViewAbstract::ResetMaxSize(frameNode, false);
3019 }
3020 
SetSize(ArkUINodeHandle node,const ArkUI_Float32 * number,const ArkUI_Int32 * unit,ArkUI_CharPtr * calc)3021 void SetSize(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit, ArkUI_CharPtr* calc)
3022 {
3023     CHECK_NULL_VOID(number);
3024     CHECK_NULL_VOID(unit);
3025     int widthIndex = 0;
3026     int heightIndex = 1;
3027     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3028     CHECK_NULL_VOID(frameNode);
3029     if (*(unit + widthIndex) == static_cast<int8_t>(DimensionUnit::CALC) && *(calc + widthIndex) != nullptr) {
3030         ViewAbstract::SetWidth(frameNode, CalcLength(std::string(*(calc + widthIndex))));
3031     } else {
3032         ViewAbstract::SetWidth(
3033             frameNode, CalcLength(*(number + widthIndex), static_cast<DimensionUnit>(*(unit + widthIndex))));
3034     }
3035     if (*(unit + heightIndex) == static_cast<int8_t>(DimensionUnit::CALC) && *(calc + heightIndex) != nullptr) {
3036         ViewAbstract::SetHeight(frameNode, CalcLength(std::string(*(calc + heightIndex))));
3037     } else {
3038         ViewAbstract::SetHeight(
3039             frameNode, CalcLength(*(number + heightIndex), static_cast<DimensionUnit>(*(unit + heightIndex))));
3040     }
3041 }
3042 
ResetSize(ArkUINodeHandle node)3043 void ResetSize(ArkUINodeHandle node)
3044 {
3045     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3046     CHECK_NULL_VOID(frameNode);
3047     ViewAbstract::SetWidth(frameNode, CalcLength(0.0, DimensionUnit::VP));
3048     ViewAbstract::SetHeight(frameNode, CalcLength(0.0, DimensionUnit::VP));
3049 }
3050 
ClearWidthOrHeight(ArkUINodeHandle node,ArkUI_Bool isWidth)3051 void ClearWidthOrHeight(ArkUINodeHandle node, ArkUI_Bool isWidth)
3052 {
3053     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3054     CHECK_NULL_VOID(frameNode);
3055     ViewAbstract::ClearWidthOrHeight(frameNode, isWidth);
3056 }
3057 
SetAlignSelf(ArkUINodeHandle node,ArkUI_Int32 value)3058 void SetAlignSelf(ArkUINodeHandle node, ArkUI_Int32 value)
3059 {
3060     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3061     CHECK_NULL_VOID(frameNode);
3062     if (value >= 0 && value <= MAX_ALIGN_VALUE) {
3063         ViewAbstract::SetAlignSelf(frameNode, static_cast<FlexAlign>(value));
3064     } else {
3065         ViewAbstract::SetAlignSelf(frameNode, FlexAlign::AUTO);
3066     }
3067 }
3068 
ResetAlignSelf(ArkUINodeHandle node)3069 void ResetAlignSelf(ArkUINodeHandle node)
3070 {
3071     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3072     CHECK_NULL_VOID(frameNode);
3073     ViewAbstract::SetAlignSelf(frameNode, FlexAlign::AUTO);
3074 }
3075 
SetAspectRatio(ArkUINodeHandle node,ArkUI_Float32 value)3076 void SetAspectRatio(ArkUINodeHandle node, ArkUI_Float32 value)
3077 {
3078     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3079     CHECK_NULL_VOID(frameNode);
3080 
3081     double result = value;
3082     if (LessOrEqual(result, 0.0)) {
3083         if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
3084             ViewAbstract::ResetAspectRatio(frameNode);
3085             return;
3086         } else {
3087             result = 1.0;
3088         }
3089     }
3090 
3091     ViewAbstract::SetAspectRatio(frameNode, static_cast<float>(result));
3092 }
3093 
ResetAspectRatio(ArkUINodeHandle node)3094 void ResetAspectRatio(ArkUINodeHandle node)
3095 {
3096     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3097     CHECK_NULL_VOID(frameNode);
3098 
3099     if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
3100         ViewAbstract::ResetAspectRatio(frameNode);
3101     } else {
3102         ViewAbstract::SetAspectRatio(frameNode, static_cast<float>(1.0));
3103     }
3104 }
3105 
SetFlexGrow(ArkUINodeHandle node,ArkUI_Float32 value)3106 void SetFlexGrow(ArkUINodeHandle node, ArkUI_Float32 value)
3107 {
3108     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3109     CHECK_NULL_VOID(frameNode);
3110 
3111     double result = value;
3112     if (result < 0.0) {
3113         result = 0.0;
3114     }
3115     ViewAbstract::SetFlexGrow(frameNode, static_cast<float>(result));
3116 }
3117 
ResetFlexGrow(ArkUINodeHandle node)3118 void ResetFlexGrow(ArkUINodeHandle node)
3119 {
3120     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3121     CHECK_NULL_VOID(frameNode);
3122     ViewAbstract::SetFlexGrow(frameNode, static_cast<float>(0.0));
3123 }
3124 
SetFlexShrink(ArkUINodeHandle node,ArkUI_Float32 value)3125 void SetFlexShrink(ArkUINodeHandle node, ArkUI_Float32 value)
3126 {
3127     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3128     CHECK_NULL_VOID(frameNode);
3129 
3130     if (value < 0.0) {
3131         ViewAbstract::ResetFlexShrink(frameNode);
3132         return;
3133     }
3134     ViewAbstract::SetFlexShrink(frameNode, static_cast<float>(value));
3135 }
3136 
ResetFlexShrink(ArkUINodeHandle node)3137 void ResetFlexShrink(ArkUINodeHandle node)
3138 {
3139     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3140     CHECK_NULL_VOID(frameNode);
3141     ViewAbstract::ResetFlexShrink(frameNode);
3142 }
3143 
SetGridOffset(ArkUINodeHandle node,ArkUI_Int32 offset)3144 void SetGridOffset(ArkUINodeHandle node, ArkUI_Int32 offset)
3145 {
3146     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3147     CHECK_NULL_VOID(frameNode);
3148     ViewAbstract::SetGrid(frameNode, std::nullopt, offset, GridSizeType::UNDEFINED);
3149 }
3150 
ResetGridOffset(ArkUINodeHandle node)3151 void ResetGridOffset(ArkUINodeHandle node)
3152 {
3153     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3154     CHECK_NULL_VOID(frameNode);
3155     ViewAbstract::SetGrid(frameNode, std::nullopt, DEFAULT_GRID_OFFSET, GridSizeType::UNDEFINED);
3156 }
3157 
SetGridSpan(ArkUINodeHandle node,ArkUI_Int32 value)3158 void SetGridSpan(ArkUINodeHandle node, ArkUI_Int32 value)
3159 {
3160     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3161     CHECK_NULL_VOID(frameNode);
3162     ViewAbstract::SetGrid(frameNode, value, std::nullopt);
3163 }
3164 
ResetGridSpan(ArkUINodeHandle node)3165 void ResetGridSpan(ArkUINodeHandle node)
3166 {
3167     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3168     CHECK_NULL_VOID(frameNode);
3169     ViewAbstract::SetGrid(frameNode, DEFAULT_GRIDSPAN, std::nullopt);
3170 }
3171 
SetExpandSafeArea(ArkUINodeHandle node,ArkUI_Uint32 safeAreaType,ArkUI_Uint32 safeAreaEdge)3172 void SetExpandSafeArea(ArkUINodeHandle node, ArkUI_Uint32 safeAreaType, ArkUI_Uint32 safeAreaEdge)
3173 {
3174     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3175     CHECK_NULL_VOID(frameNode);
3176     NG::SafeAreaExpandOpts opts { .type = NG::SAFE_AREA_TYPE_ALL, .edges = NG::SAFE_AREA_EDGE_ALL };
3177     opts.type = safeAreaType;
3178     opts.edges = safeAreaEdge;
3179     ViewAbstract::UpdateSafeAreaExpandOpts(frameNode, opts);
3180 }
3181 
ResetExpandSafeArea(ArkUINodeHandle node)3182 void ResetExpandSafeArea(ArkUINodeHandle node)
3183 {
3184     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3185     CHECK_NULL_VOID(frameNode);
3186     NG::SafeAreaExpandOpts opts;
3187     opts.type = DEFAULT_SAFE_AREA_TYPE;
3188     opts.edges = DEFAULT_SAFE_AREA_EDGE;
3189     ViewAbstract::UpdateSafeAreaExpandOpts(frameNode, opts);
3190 }
3191 
SetFlexBasis(ArkUINodeHandle node,const struct ArkUIStringAndFloat * flexBasisValue)3192 void SetFlexBasis(ArkUINodeHandle node, const struct ArkUIStringAndFloat* flexBasisValue)
3193 {
3194     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3195     CHECK_NULL_VOID(frameNode);
3196     Dimension result;
3197     if (flexBasisValue->valueStr != nullptr) {
3198         result = StringUtils::StringToDimensionWithUnit(std::string(flexBasisValue->valueStr), DimensionUnit::VP);
3199         // flex basis don't support percent case.
3200         if (result.Unit() == DimensionUnit::PERCENT) {
3201             result.SetUnit(DimensionUnit::AUTO);
3202         }
3203     } else {
3204         result = Dimension(flexBasisValue->value, DimensionUnit::VP);
3205     }
3206     ViewAbstract::SetFlexBasis(frameNode, result);
3207 }
3208 
ResetFlexBasis(ArkUINodeHandle node)3209 void ResetFlexBasis(ArkUINodeHandle node)
3210 {
3211     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3212     CHECK_NULL_VOID(frameNode);
3213     ViewAbstract::SetFlexBasis(frameNode, DEFAULT_FLEX_BASIS);
3214 }
3215 
SetAlignRules(ArkUINodeHandle node,char ** anchors,const ArkUI_Int32 * direction,ArkUI_Int32 length)3216 void SetAlignRules(ArkUINodeHandle node, char** anchors, const ArkUI_Int32* direction, ArkUI_Int32 length)
3217 {
3218     CHECK_NULL_VOID(anchors);
3219     CHECK_NULL_VOID(direction);
3220     if (length != DEFAULT_ALIGN_RULES_SIZE) {
3221         return;
3222     }
3223     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3224     CHECK_NULL_VOID(frameNode);
3225     std::map<AlignDirection, AlignRule> rulesMap;
3226     for (int index = 0; index < length; index++) {
3227         AlignRule alignRule;
3228         alignRule.anchor = std::string(*(anchors + index) == nullptr ? "" : *(anchors + index));
3229         if (index < HORIZONTAL_DIRECTION_RANGE) {
3230             alignRule.horizontal = static_cast<HorizontalAlign>(*(direction + index));
3231         } else {
3232             alignRule.vertical = static_cast<VerticalAlign>(*(direction + index));
3233         }
3234         rulesMap[static_cast<AlignDirection>(index)] = alignRule;
3235     }
3236     ViewAbstract::SetAlignRules(frameNode, rulesMap);
3237     BiasPair biasPair(DEFAULT_BIAS, DEFAULT_BIAS);
3238     ViewAbstract::SetBias(frameNode, biasPair);
3239 }
3240 
SetAlignRulesWidthType(ArkUINodeHandle node,const ArkUIAlignRulesType * alignRulesType)3241 void SetAlignRulesWidthType(ArkUINodeHandle node, const ArkUIAlignRulesType* alignRulesType)
3242 {
3243     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3244     CHECK_NULL_VOID(frameNode);
3245     CHECK_NULL_VOID(alignRulesType);
3246     std::map<AlignDirection, AlignRule> rulesMap;
3247     for (int32_t i = 0; i < alignRulesType->anchorCount && i < NUM_6; i++) {
3248         std::string anchorId(alignRulesType->anchorIds[i]);
3249         if (anchorId.empty()) {
3250             continue;
3251         }
3252         AlignRule alignRule;
3253         alignRule.anchor = anchorId;
3254         if (i < NUM_3) {
3255             alignRule.horizontal = static_cast<HorizontalAlign>(alignRulesType->alignTypes[i]);
3256         } else {
3257             alignRule.vertical = static_cast<VerticalAlign>(alignRulesType->alignTypes[i]);
3258         }
3259         rulesMap[static_cast<AlignDirection>(i)] = alignRule;
3260     }
3261     ViewAbstract::SetAlignRules(frameNode, rulesMap);
3262     BiasPair biasPair(alignRulesType->biasHorizontalValue, alignRulesType->biasVerticalValue);
3263     ViewAbstract::SetBias(frameNode, biasPair);
3264 }
3265 
ResetAlignRules(ArkUINodeHandle node)3266 void ResetAlignRules(ArkUINodeHandle node)
3267 {
3268     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3269     CHECK_NULL_VOID(frameNode);
3270     ViewAbstract::ResetAlignRules(frameNode);
3271 }
3272 
GetAlignRules(ArkUINodeHandle node,ArkUI_CharPtr * anchors,ArkUI_Int32 * direction,ArkUI_Int32 length)3273 void GetAlignRules(ArkUINodeHandle node, ArkUI_CharPtr* anchors, ArkUI_Int32* direction, ArkUI_Int32 length)
3274 {
3275     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3276     CHECK_NULL_VOID(frameNode);
3277     auto alignRules = ViewAbstract::GetAlignRules(frameNode);
3278 
3279     ArkUI_Int32 index = 0;
3280     for (const AlignDirection alignDirection : { AlignDirection::LEFT, AlignDirection::MIDDLE, AlignDirection::RIGHT,
3281          AlignDirection::TOP, AlignDirection::CENTER, AlignDirection::BOTTOM, AlignDirection::START,
3282          AlignDirection::END }) {
3283         if (index >= length) {
3284             return;
3285         }
3286         auto it = alignRules.find(alignDirection);
3287         if (it != alignRules.end()) {
3288             anchors[index] = it->second.anchor.c_str();
3289             switch (alignDirection) {
3290                 case AlignDirection::LEFT:
3291                 case AlignDirection::RIGHT:
3292                 case AlignDirection::CENTER:
3293                 case AlignDirection::START:
3294                 case AlignDirection::END:
3295                     direction[index] = static_cast<ArkUI_Int32>(it->second.horizontal) - 1;
3296                     break;
3297                 case AlignDirection::TOP:
3298                 case AlignDirection::MIDDLE:
3299                 case AlignDirection::BOTTOM:
3300                     direction[index] = static_cast<ArkUI_Int32>(it->second.vertical) - 1;
3301                     break;
3302             }
3303         } else {
3304             anchors[index] = nullptr;
3305             direction[index] = -1;
3306         }
3307         ++index;
3308     }
3309 }
3310 
SetAccessibilityDescription(ArkUINodeHandle node,ArkUI_CharPtr value)3311 void SetAccessibilityDescription(ArkUINodeHandle node, ArkUI_CharPtr value)
3312 {
3313     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3314     CHECK_NULL_VOID(frameNode);
3315     CHECK_NULL_VOID(value);
3316     std::string valueStr = value;
3317     ViewAbstractModelNG::SetAccessibilityDescription(frameNode, valueStr);
3318 }
3319 
ResetAccessibilityDescription(ArkUINodeHandle node)3320 void ResetAccessibilityDescription(ArkUINodeHandle node)
3321 {
3322     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3323     CHECK_NULL_VOID(frameNode);
3324     ViewAbstractModelNG::SetAccessibilityDescription(frameNode, "");
3325 }
3326 
SetId(ArkUINodeHandle node,ArkUI_CharPtr id)3327 void SetId(ArkUINodeHandle node, ArkUI_CharPtr id)
3328 {
3329     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3330     CHECK_NULL_VOID(frameNode);
3331     std::string valueStr = id;
3332     ViewAbstract::SetInspectorId(frameNode, valueStr);
3333 }
3334 
ResetId(ArkUINodeHandle node)3335 void ResetId(ArkUINodeHandle node)
3336 {
3337     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3338     CHECK_NULL_VOID(frameNode);
3339     std::string id = "";
3340     ViewAbstract::SetInspectorId(frameNode, id);
3341 }
3342 
SetKey(ArkUINodeHandle node,ArkUI_CharPtr key)3343 void SetKey(ArkUINodeHandle node, ArkUI_CharPtr key)
3344 {
3345     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3346     CHECK_NULL_VOID(frameNode);
3347     std::string valueStr = key;
3348     ViewAbstract::SetInspectorId(frameNode, valueStr);
3349 }
3350 
ResetKey(ArkUINodeHandle node)3351 void ResetKey(ArkUINodeHandle node)
3352 {
3353     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3354     CHECK_NULL_VOID(frameNode);
3355     std::string defaultStr = "";
3356     ViewAbstract::SetInspectorId(frameNode, defaultStr);
3357 }
3358 
SetRestoreId(ArkUINodeHandle node,uint32_t id)3359 void SetRestoreId(ArkUINodeHandle node, uint32_t id)
3360 {
3361     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3362     CHECK_NULL_VOID(frameNode);
3363     ViewAbstract::SetRestoreId(frameNode, id);
3364 }
3365 
ResetRestoreId(ArkUINodeHandle node)3366 void ResetRestoreId(ArkUINodeHandle node)
3367 {
3368     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3369     CHECK_NULL_VOID(frameNode);
3370     ViewAbstract::SetRestoreId(frameNode, DEFAULT_ID);
3371 }
3372 
SetTabIndex(ArkUINodeHandle node,ArkUI_Int32 index)3373 void SetTabIndex(ArkUINodeHandle node, ArkUI_Int32 index)
3374 {
3375     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3376     CHECK_NULL_VOID(frameNode);
3377     ViewAbstract::SetTabIndex(frameNode, index);
3378 }
3379 
ResetTabIndex(ArkUINodeHandle node)3380 void ResetTabIndex(ArkUINodeHandle node)
3381 {
3382     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3383     CHECK_NULL_VOID(frameNode);
3384     int32_t index = 0;
3385     ViewAbstract::SetTabIndex(frameNode, index);
3386 }
3387 
SetObscured(ArkUINodeHandle node,const ArkUI_Int32 * reason,ArkUI_Int32 length)3388 void SetObscured(ArkUINodeHandle node, const ArkUI_Int32* reason, ArkUI_Int32 length)
3389 {
3390     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3391     CHECK_NULL_VOID(frameNode);
3392     std::vector<ObscuredReasons> reasons(length);
3393     reasons.clear();
3394     for (int32_t i = 0; i < length; i++) {
3395         reasons.emplace_back(static_cast<ObscuredReasons>(reason[i]));
3396     }
3397 
3398     ViewAbstract::SetObscured(frameNode, reasons);
3399 }
3400 
ResetObscured(ArkUINodeHandle node)3401 void ResetObscured(ArkUINodeHandle node)
3402 {
3403     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3404     CHECK_NULL_VOID(frameNode);
3405     std::vector<ObscuredReasons> reasons(0);
3406     ViewAbstract::SetObscured(frameNode, reasons);
3407 }
3408 
SetResponseRegion(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)3409 void SetResponseRegion(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
3410 {
3411     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3412     CHECK_NULL_VOID(frameNode);
3413     std::vector<DimensionRect> region;
3414     for (int32_t i = 0; i < length / NUM_4; i++) {
3415         CalcDimension xDimen =
3416             CalcDimension(values[i * NUM_4 + NUM_0], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_0]));
3417         CalcDimension yDimen =
3418             CalcDimension(values[i * NUM_4 + NUM_1], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_1]));
3419         CalcDimension widthDimen =
3420             CalcDimension(values[i * NUM_4 + NUM_2], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_2]));
3421         CalcDimension heightDimen =
3422             CalcDimension(values[i * NUM_4 + NUM_3], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_3]));
3423         DimensionOffset offsetDimen(xDimen, yDimen);
3424         DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3425         region.emplace_back(dimenRect);
3426     }
3427     if (frameNode->GetTag() == V2::TEXT_ETS_TAG) {
3428         TextModelNG::SetResponseRegion(frameNode, region);
3429     } else {
3430         ViewAbstract::SetResponseRegion(frameNode, region);
3431     }
3432 }
3433 
ResetResponseRegion(ArkUINodeHandle node)3434 void ResetResponseRegion(ArkUINodeHandle node)
3435 {
3436     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3437     CHECK_NULL_VOID(frameNode);
3438     if (frameNode->GetTag() == V2::TEXT_ETS_TAG) {
3439         TextModelNG::ClearResponseRegion(frameNode);
3440         return;
3441     }
3442     std::vector<DimensionRect> region;
3443     CalcDimension xDimen = CalcDimension(0.0, DimensionUnit::VP);
3444     CalcDimension yDimen = CalcDimension(0.0, DimensionUnit::VP);
3445     CalcDimension widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
3446     CalcDimension heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
3447     DimensionOffset offsetDimen(xDimen, yDimen);
3448     DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3449     region.emplace_back(dimenRect);
3450     ViewAbstract::SetResponseRegion(frameNode, region);
3451 }
3452 
SetForegroundEffect(ArkUINodeHandle node,ArkUI_Float32 radius)3453 void SetForegroundEffect(ArkUINodeHandle node, ArkUI_Float32 radius)
3454 {
3455     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3456     CHECK_NULL_VOID(frameNode);
3457     radius = std::max(radius, 0.0f);
3458     ViewAbstract::SetForegroundEffect(frameNode, static_cast<float>(radius));
3459 }
3460 
ResetForegroundEffect(ArkUINodeHandle node)3461 void ResetForegroundEffect(ArkUINodeHandle node)
3462 {
3463     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3464     CHECK_NULL_VOID(frameNode);
3465     ViewAbstract::SetForegroundEffect(frameNode, 0.0f);
3466 }
3467 
SetBackgroundEffect(ArkUINodeHandle node,ArkUI_Float32 radiusArg,ArkUI_Float32 saturationArg,ArkUI_Float32 brightnessArg,ArkUI_Uint32 colorArg,ArkUI_Int32 adaptiveColorArg,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Int32 policy,ArkUI_Int32 blurType,ArkUI_Bool isValidColor,ArkUI_Uint32 inactiveColorArg)3468 void SetBackgroundEffect(ArkUINodeHandle node, ArkUI_Float32 radiusArg, ArkUI_Float32 saturationArg,
3469     ArkUI_Float32 brightnessArg, ArkUI_Uint32 colorArg, ArkUI_Int32 adaptiveColorArg, const ArkUI_Float32* blurValues,
3470     ArkUI_Int32 blurValuesSize, ArkUI_Int32 policy, ArkUI_Int32 blurType, ArkUI_Bool isValidColor,
3471     ArkUI_Uint32 inactiveColorArg)
3472 {
3473     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3474     CHECK_NULL_VOID(frameNode);
3475     CalcDimension radius;
3476     radius.SetValue(radiusArg);
3477     Color color(colorArg);
3478     BlurOption blurOption;
3479     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
3480 
3481     EffectOption option;
3482     option.radius = radius;
3483     option.saturation = saturationArg;
3484     option.brightness = brightnessArg;
3485     option.color = color;
3486     option.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColorArg);
3487     option.blurOption = blurOption;
3488     option.blurType = static_cast<BlurType>(blurType);
3489     option.policy = static_cast<BlurStyleActivePolicy>(policy);
3490     Color inactiveColor(inactiveColorArg);
3491     option.inactiveColor = inactiveColor;
3492     option.isValidColor = isValidColor;
3493     ViewAbstract::SetBackgroundEffect(frameNode, option);
3494 }
3495 
ResetBackgroundEffect(ArkUINodeHandle node)3496 void ResetBackgroundEffect(ArkUINodeHandle node)
3497 {
3498     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3499     CHECK_NULL_VOID(frameNode);
3500     CalcDimension radius;
3501     radius.SetValue(0.0f);
3502     double saturation = 1.0f;
3503     double brightness = 1.0f;
3504     Color color = Color::TRANSPARENT;
3505     color.SetValue(Color::TRANSPARENT.GetValue());
3506     auto adaptiveColor = AdaptiveColor::DEFAULT;
3507     BlurOption blurOption;
3508     EffectOption effectOption = { radius, saturation, brightness, color, adaptiveColor, blurOption };
3509     ViewAbstract::SetBackgroundEffect(frameNode, effectOption);
3510 }
3511 
SetBackgroundBrightness(ArkUINodeHandle node,ArkUI_Float32 rate,ArkUI_Float32 lightUpDegree)3512 void SetBackgroundBrightness(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree)
3513 {
3514     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3515     CHECK_NULL_VOID(frameNode);
3516     ViewAbstract::SetDynamicLightUp(frameNode, rate, lightUpDegree);
3517 }
3518 
ResetBackgroundBrightness(ArkUINodeHandle node)3519 void ResetBackgroundBrightness(ArkUINodeHandle node)
3520 {
3521     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3522     CHECK_NULL_VOID(frameNode);
3523     double rate = 0.0;
3524     double lightUpDegree = 0.0;
3525     ViewAbstract::SetDynamicLightUp(frameNode, rate, lightUpDegree);
3526 }
3527 
SetBackgroundBrightnessInternal(ArkUINodeHandle node,ArkUI_Float32 rate,ArkUI_Float32 lightUpDegree,ArkUI_Float32 cubicCoeff,ArkUI_Float32 quadCoeff,ArkUI_Float32 saturation,const ArkUI_Float32 * posRGBValues,ArkUI_Int32 posRGBValuesSize,const ArkUI_Float32 * negRGBValues,ArkUI_Int32 negRGBValuesSize,ArkUI_Float32 fraction)3528 void SetBackgroundBrightnessInternal(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree,
3529     ArkUI_Float32 cubicCoeff, ArkUI_Float32 quadCoeff, ArkUI_Float32 saturation,
3530     const ArkUI_Float32* posRGBValues, ArkUI_Int32 posRGBValuesSize,
3531     const ArkUI_Float32* negRGBValues, ArkUI_Int32 negRGBValuesSize, ArkUI_Float32 fraction)
3532 {
3533     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3534     std::vector<float> posRGB;
3535     posRGB.assign(posRGBValues, posRGBValues + posRGBValuesSize);
3536     std::vector<float> negRGB;
3537     negRGB.assign(negRGBValues, negRGBValues + negRGBValuesSize);
3538     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3539         saturation, posRGB, negRGB, fraction };
3540     CHECK_NULL_VOID(frameNode);
3541     ViewAbstract::SetBgDynamicBrightness(frameNode, brightnessOption);
3542 }
3543 
ResetBackgroundBrightnessInternal(ArkUINodeHandle node)3544 void ResetBackgroundBrightnessInternal(ArkUINodeHandle node)
3545 {
3546     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3547     CHECK_NULL_VOID(frameNode);
3548     float rate = 1.0f;
3549     float lightUpDegree = 0.0f;
3550     float cubicCoeff = 0.0f;
3551     float quadCoeff = 0.0f;
3552     float saturation = 1.0f;
3553     std::vector<float> posRGB(3, 0.0);
3554     std::vector<float> negRGB(3, 0.0);
3555     float fraction = 1.0;
3556     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3557         saturation, posRGB, negRGB, fraction };
3558     ViewAbstract::SetBgDynamicBrightness(frameNode, brightnessOption);
3559 }
3560 
SetForegroundBrightness(ArkUINodeHandle node,ArkUI_Float32 rate,ArkUI_Float32 lightUpDegree,ArkUI_Float32 cubicCoeff,ArkUI_Float32 quadCoeff,ArkUI_Float32 saturation,const ArkUI_Float32 * posRGBValues,ArkUI_Int32 posRGBValuesSize,const ArkUI_Float32 * negRGBValues,ArkUI_Int32 negRGBValuesSize,ArkUI_Float32 fraction)3561 void SetForegroundBrightness(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree,
3562     ArkUI_Float32 cubicCoeff, ArkUI_Float32 quadCoeff, ArkUI_Float32 saturation,
3563     const ArkUI_Float32* posRGBValues, ArkUI_Int32 posRGBValuesSize,
3564     const ArkUI_Float32* negRGBValues, ArkUI_Int32 negRGBValuesSize, ArkUI_Float32 fraction)
3565 {
3566     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3567     std::vector<float> posRGB;
3568     posRGB.assign(posRGBValues, posRGBValues + posRGBValuesSize);
3569     std::vector<float> negRGB;
3570     negRGB.assign(negRGBValues, negRGBValues + negRGBValuesSize);
3571     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3572         saturation, posRGB, negRGB, fraction };
3573     CHECK_NULL_VOID(frameNode);
3574     ViewAbstract::SetFgDynamicBrightness(frameNode, brightnessOption);
3575 }
3576 
ResetForegroundBrightness(ArkUINodeHandle node)3577 void ResetForegroundBrightness(ArkUINodeHandle node)
3578 {
3579     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3580     CHECK_NULL_VOID(frameNode);
3581     float rate = 1.0f;
3582     float lightUpDegree = 0.0f;
3583     float cubicCoeff = 0.0f;
3584     float quadCoeff = 0.0f;
3585     float saturation = 1.0f;
3586     std::vector<float> posRGB(3, 0.0);
3587     std::vector<float> negRGB(3, 0.0);
3588     float fraction = 1.0;
3589     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3590         saturation, posRGB, negRGB, fraction };
3591     ViewAbstract::SetFgDynamicBrightness(frameNode, brightnessOption);
3592 }
3593 
ParseDragPreviewMode(NG::DragPreviewOption & previewOption,int32_t modeValue,bool & isAuto)3594 void ParseDragPreviewMode(NG::DragPreviewOption& previewOption, int32_t modeValue, bool& isAuto)
3595 {
3596     if (modeValue == static_cast<int32_t>(NG::DragPreviewMode::AUTO)) {
3597         previewOption.ResetDragPreviewMode();
3598         isAuto = true;
3599         return;
3600     } else if (modeValue == static_cast<int32_t>(NG::DragPreviewMode::DISABLE_SCALE)) {
3601         previewOption.isScaleEnabled = false;
3602     } else if (modeValue == static_cast<int32_t>(NG::DragPreviewMode::ENABLE_DEFAULT_SHADOW)) {
3603         previewOption.isDefaultShadowEnabled = true;
3604     } else if (modeValue == static_cast<int32_t>(NG::DragPreviewMode::ENABLE_DEFAULT_RADIUS)) {
3605         previewOption.isDefaultRadiusEnabled = true;
3606     }
3607     isAuto = false;
3608 }
3609 
SetDragPreviewOptions(ArkUINodeHandle node,ArkUIDragPreViewOptions dragPreviewOptions,ArkUIDragInteractionOptions dragInteractionOptions)3610 void SetDragPreviewOptions(ArkUINodeHandle node, ArkUIDragPreViewOptions dragPreviewOptions,
3611     ArkUIDragInteractionOptions dragInteractionOptions)
3612 {
3613     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3614     CHECK_NULL_VOID(frameNode);
3615     NG::DragPreviewOption option;
3616     bool isAuto = true;
3617     if (!dragPreviewOptions.isModeArray) {
3618         ParseDragPreviewMode(option, dragPreviewOptions.mode, isAuto);
3619     } else {
3620         for (int32_t i = 0; i < dragPreviewOptions.modeArrayLength; i++) {
3621             ParseDragPreviewMode(option, dragPreviewOptions.modeArray[i], isAuto);
3622             if (isAuto) {
3623                 break;
3624             }
3625         }
3626     }
3627 
3628     if (dragPreviewOptions.isBadgeNumber) {
3629         option.badgeNumber = dragPreviewOptions.badgeNumber;
3630     } else {
3631         option.isShowBadge = dragPreviewOptions.isShowBadge;
3632     }
3633     option.isNumber = dragPreviewOptions.isBadgeNumber;
3634     option.isMultiSelectionEnabled = dragInteractionOptions.isMultiSelectionEnabled;
3635     option.defaultAnimationBeforeLifting = dragInteractionOptions.defaultAnimationBeforeLifting;
3636     ViewAbstract::SetDragPreviewOptions(frameNode, option);
3637 }
3638 
ResetDragPreviewOptions(ArkUINodeHandle node)3639 void ResetDragPreviewOptions(ArkUINodeHandle node)
3640 {
3641     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3642     CHECK_NULL_VOID(frameNode);
3643     ViewAbstract::SetDragPreviewOptions(frameNode,
3644         { true, false, false, false, false, false, true, { .isShowBadge = true } });
3645 }
3646 
SetMouseResponseRegion(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)3647 void SetMouseResponseRegion(
3648     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
3649 {
3650     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3651     CHECK_NULL_VOID(frameNode);
3652     std::vector<DimensionRect> region;
3653     for (int32_t i = 0; i < length / NUM_4; i++) {
3654         CalcDimension xDimen =
3655             CalcDimension(values[i * NUM_4 + NUM_0], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_0]));
3656         CalcDimension yDimen =
3657             CalcDimension(values[i * NUM_4 + NUM_1], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_1]));
3658         CalcDimension widthDimen =
3659             CalcDimension(values[i * NUM_4 + NUM_2], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_2]));
3660         CalcDimension heightDimen =
3661             CalcDimension(values[i * NUM_4 + NUM_3], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_3]));
3662         DimensionOffset offsetDimen(xDimen, yDimen);
3663         DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3664         region.emplace_back(dimenRect);
3665     }
3666     ViewAbstract::SetMouseResponseRegion(frameNode, region);
3667 }
3668 
ResetMouseResponseRegion(ArkUINodeHandle node)3669 void ResetMouseResponseRegion(ArkUINodeHandle node)
3670 {
3671     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3672     CHECK_NULL_VOID(frameNode);
3673     std::vector<DimensionRect> region;
3674     CalcDimension xDimen = CalcDimension(0.0, DimensionUnit::VP);
3675     CalcDimension yDimen = CalcDimension(0.0, DimensionUnit::VP);
3676     CalcDimension widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
3677     CalcDimension heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
3678     DimensionOffset offsetDimen(xDimen, yDimen);
3679     DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3680     region.emplace_back(dimenRect);
3681     ViewAbstract::SetMouseResponseRegion(frameNode, region);
3682 }
3683 
SetEnabled(ArkUINodeHandle node,ArkUI_Bool value)3684 void SetEnabled(ArkUINodeHandle node, ArkUI_Bool value)
3685 {
3686     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3687     CHECK_NULL_VOID(frameNode);
3688     ViewAbstract::SetEnabled(frameNode, value);
3689 }
3690 
ResetEnabled(ArkUINodeHandle node)3691 void ResetEnabled(ArkUINodeHandle node)
3692 {
3693     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3694     CHECK_NULL_VOID(frameNode);
3695     ViewAbstract::SetEnabled(frameNode, true);
3696 }
3697 
SetUseShadowBatching(ArkUINodeHandle node,ArkUI_Bool value)3698 void SetUseShadowBatching(ArkUINodeHandle node, ArkUI_Bool value)
3699 {
3700     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3701     CHECK_NULL_VOID(frameNode);
3702     ViewAbstractModelNG::SetUseShadowBatching(frameNode, value);
3703 }
3704 
ResetUseShadowBatching(ArkUINodeHandle node)3705 void ResetUseShadowBatching(ArkUINodeHandle node)
3706 {
3707     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3708     CHECK_NULL_VOID(frameNode);
3709     ViewAbstractModelNG::SetUseShadowBatching(frameNode, false);
3710 }
3711 
SetDraggable(ArkUINodeHandle node,ArkUI_Bool value)3712 void SetDraggable(ArkUINodeHandle node, ArkUI_Bool value)
3713 {
3714     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3715     CHECK_NULL_VOID(frameNode);
3716     ViewAbstract::SetDraggable(frameNode, value);
3717 }
3718 
ResetDraggable(ArkUINodeHandle node)3719 void ResetDraggable(ArkUINodeHandle node)
3720 {
3721     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3722     CHECK_NULL_VOID(frameNode);
3723     ViewAbstract::SetDraggable(frameNode, false);
3724 }
3725 
SetAccessibilityGroup(ArkUINodeHandle node,ArkUI_Bool value)3726 void SetAccessibilityGroup(ArkUINodeHandle node, ArkUI_Bool value)
3727 {
3728     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3729     CHECK_NULL_VOID(frameNode);
3730     ViewAbstractModelNG::SetAccessibilityGroup(frameNode, value);
3731 }
3732 
ResetAccessibilityGroup(ArkUINodeHandle node)3733 void ResetAccessibilityGroup(ArkUINodeHandle node)
3734 {
3735     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3736     CHECK_NULL_VOID(frameNode);
3737     ViewAbstractModelNG::SetAccessibilityGroup(frameNode, false);
3738 }
3739 
SetHoverEffect(ArkUINodeHandle node,ArkUI_Int32 hoverEffectValue)3740 void SetHoverEffect(ArkUINodeHandle node, ArkUI_Int32 hoverEffectValue)
3741 {
3742     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3743     CHECK_NULL_VOID(frameNode);
3744     OHOS::Ace::HoverEffectType hoverEffect = OHOS::Ace::HoverEffectType::AUTO;
3745     hoverEffect = static_cast<OHOS::Ace::HoverEffectType>(hoverEffectValue);
3746     ViewAbstract::SetHoverEffect(frameNode, hoverEffect);
3747 }
3748 
ResetHoverEffect(ArkUINodeHandle node)3749 void ResetHoverEffect(ArkUINodeHandle node)
3750 {
3751     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3752     CHECK_NULL_VOID(frameNode);
3753     ViewAbstract::SetHoverEffect(frameNode, OHOS::Ace::HoverEffectType::AUTO);
3754 }
3755 
SetClickEffect(ArkUINodeHandle node,const int32_t levelValue,ArkUI_Float32 scaleValue)3756 void SetClickEffect(ArkUINodeHandle node, const int32_t levelValue, ArkUI_Float32 scaleValue)
3757 {
3758     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3759     CHECK_NULL_VOID(frameNode);
3760     OHOS::Ace::ClickEffectLevel level = OHOS::Ace::ClickEffectLevel::UNDEFINED;
3761     level = static_cast<OHOS::Ace::ClickEffectLevel>(levelValue);
3762     ViewAbstract::SetClickEffectLevel(frameNode, level, scaleValue);
3763 }
3764 
ResetClickEffect(ArkUINodeHandle node)3765 void ResetClickEffect(ArkUINodeHandle node)
3766 {
3767     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3768     CHECK_NULL_VOID(frameNode);
3769     ViewAbstract::SetClickEffectLevel(frameNode, OHOS::Ace::ClickEffectLevel::UNDEFINED, 0.9f);
3770 }
3771 
SetKeyBoardShortCut(ArkUINodeHandle node,ArkUI_CharPtr value,const ArkUI_Int32 * keysIntArray,ArkUI_Int32 length)3772 void SetKeyBoardShortCut(ArkUINodeHandle node, ArkUI_CharPtr value, const ArkUI_Int32* keysIntArray, ArkUI_Int32 length)
3773 {
3774     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3775     CHECK_NULL_VOID(frameNode);
3776     std::string valueStr = value;
3777     std::vector<OHOS::Ace::ModifierKey> keysVector(length);
3778     keysVector.clear();
3779     for (int32_t i = 0; i < length; i++) {
3780         keysVector.emplace_back(static_cast<OHOS::Ace::ModifierKey>(keysIntArray[i]));
3781     }
3782     ViewAbstractModelNG::SetKeyboardShortcut(frameNode, valueStr, keysVector, nullptr);
3783 }
3784 
ResetKeyBoardShortCut(ArkUINodeHandle node)3785 void ResetKeyBoardShortCut(ArkUINodeHandle node)
3786 {
3787     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3788     CHECK_NULL_VOID(frameNode);
3789     ViewAbstractModelNG::SetKeyboardShortcut(frameNode, "", std::vector<OHOS::Ace::ModifierKey>(), nullptr);
3790 }
3791 
SetPointLightPosition(ArkUINodeHandle node,const struct ArkUISizeType * positionX,const struct ArkUISizeType * positionY,const struct ArkUISizeType * positionZ)3792 void SetPointLightPosition(ArkUINodeHandle node, const struct ArkUISizeType* positionX,
3793     const struct ArkUISizeType* positionY, const struct ArkUISizeType* positionZ)
3794 {
3795 #ifdef POINT_LIGHT_ENABLE
3796     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3797     CHECK_NULL_VOID(frameNode);
3798     CHECK_NULL_VOID(positionX);
3799     CHECK_NULL_VOID(positionY);
3800     CHECK_NULL_VOID(positionZ);
3801     CalcDimension lightPositionX(positionX->value, static_cast<DimensionUnit>(positionX->unit));
3802     CalcDimension lightPositionY(positionY->value, static_cast<DimensionUnit>(positionY->unit));
3803     CalcDimension lightPositionZ(positionZ->value, static_cast<DimensionUnit>(positionZ->unit));
3804     ViewAbstract::SetLightPosition(frameNode, lightPositionX, lightPositionY, lightPositionZ);
3805 #endif
3806 }
3807 
ResetPointLightPosition(ArkUINodeHandle node)3808 void ResetPointLightPosition(ArkUINodeHandle node)
3809 {
3810 #ifdef POINT_LIGHT_ENABLE
3811     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3812     CHECK_NULL_VOID(frameNode);
3813     CalcDimension lightPositionX(0.0f, DimensionUnit::VP);
3814     CalcDimension lightPositionY(0.0f, DimensionUnit::VP);
3815     CalcDimension lightPositionZ(0.0f, DimensionUnit::VP);
3816     ViewAbstract::SetLightPosition(frameNode, lightPositionX, lightPositionY, lightPositionZ);
3817 #endif
3818 }
3819 
SetPointLightIntensity(ArkUINodeHandle node,ArkUI_Float32 intensity)3820 void SetPointLightIntensity(ArkUINodeHandle node, ArkUI_Float32 intensity)
3821 {
3822 #ifdef POINT_LIGHT_ENABLE
3823     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3824     CHECK_NULL_VOID(frameNode);
3825     ViewAbstract::SetLightIntensity(frameNode, static_cast<float>(intensity));
3826 #endif
3827 }
3828 
ResetPointLightIntensity(ArkUINodeHandle node)3829 void ResetPointLightIntensity(ArkUINodeHandle node)
3830 {
3831 #ifdef POINT_LIGHT_ENABLE
3832     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3833     CHECK_NULL_VOID(frameNode);
3834     ViewAbstract::SetLightIntensity(frameNode, 0.0f);
3835 #endif
3836 }
3837 
SetPointLightColor(ArkUINodeHandle node,ArkUI_Uint32 color)3838 void SetPointLightColor(ArkUINodeHandle node, ArkUI_Uint32 color)
3839 {
3840 #ifdef POINT_LIGHT_ENABLE
3841     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3842     CHECK_NULL_VOID(frameNode);
3843     Color colorValue(color);
3844     ViewAbstract::SetLightColor(frameNode, colorValue);
3845 #endif
3846 }
3847 
ResetPointLightColor(ArkUINodeHandle node)3848 void ResetPointLightColor(ArkUINodeHandle node)
3849 {
3850 #ifdef POINT_LIGHT_ENABLE
3851     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3852     CHECK_NULL_VOID(frameNode);
3853     ViewAbstract::SetLightColor(frameNode, Color::WHITE);
3854 #endif
3855 }
3856 
SetPointLightIlluminated(ArkUINodeHandle node,ArkUI_Uint32 illuminated,const struct ArkUISizeType * illuminatedBorderWidth)3857 void SetPointLightIlluminated(
3858     ArkUINodeHandle node, ArkUI_Uint32 illuminated, const struct ArkUISizeType* illuminatedBorderWidth)
3859 {
3860 #ifdef POINT_LIGHT_ENABLE
3861     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3862     CHECK_NULL_VOID(frameNode);
3863     ViewAbstract::SetLightIlluminated(frameNode, static_cast<uint32_t>(illuminated));
3864     Dimension borderWidthValue(illuminatedBorderWidth->value, static_cast<DimensionUnit>(illuminatedBorderWidth->unit));
3865     ViewAbstract::SetIlluminatedBorderWidth(frameNode, borderWidthValue);
3866 #endif
3867 }
3868 
ResetPointLightIlluminated(ArkUINodeHandle node)3869 void ResetPointLightIlluminated(ArkUINodeHandle node)
3870 {
3871 #ifdef POINT_LIGHT_ENABLE
3872     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3873     CHECK_NULL_VOID(frameNode);
3874     ViewAbstract::SetLightIlluminated(frameNode, 0);
3875     Dimension borderWidthValue(0.0f, DimensionUnit::VP);
3876     ViewAbstract::SetIlluminatedBorderWidth(frameNode, borderWidthValue);
3877 #endif
3878 }
3879 
SetPointLightBloom(ArkUINodeHandle node,ArkUI_Float32 bloom,ArkUI_Float32 bloomRadius,ArkUI_Uint32 bloomColor)3880 void SetPointLightBloom(ArkUINodeHandle node, ArkUI_Float32 bloom, ArkUI_Float32 bloomRadius, ArkUI_Uint32 bloomColor)
3881 {
3882 #ifdef POINT_LIGHT_ENABLE
3883     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3884     CHECK_NULL_VOID(frameNode);
3885     ViewAbstract::SetBloom(frameNode, static_cast<float>(bloom));
3886     Shadow shadow;
3887     shadow.SetBlurRadius(bloom * static_cast<float>(bloomRadius));
3888     Color bloomColorValue(bloomColor);
3889     shadow.SetColor(bloomColorValue);
3890     ViewAbstract::SetBackShadow(frameNode, shadow);
3891 #endif
3892 }
3893 
ResetPointLightBloom(ArkUINodeHandle node)3894 void ResetPointLightBloom(ArkUINodeHandle node)
3895 {
3896 #ifdef POINT_LIGHT_ENABLE
3897     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3898     CHECK_NULL_VOID(frameNode);
3899     ViewAbstract::SetBloom(frameNode, 0.0f);
3900     Shadow shadow;
3901     shadow.SetBlurRadius(0);
3902     ViewAbstract::SetBackShadow(frameNode, shadow);
3903 #endif
3904 }
3905 
SetClip(ArkUINodeHandle node,ArkUI_Int32 isClip)3906 void SetClip(ArkUINodeHandle node, ArkUI_Int32 isClip)
3907 {
3908     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3909     CHECK_NULL_VOID(frameNode);
3910     ViewAbstract::SetClipEdge(frameNode, static_cast<bool>(isClip));
3911 }
3912 
SetClipShape(ArkUINodeHandle node,ArkUI_CharPtr type,const ArkUI_Float32 * attribute,ArkUI_Int32 length,ArkUI_Int32 unit)3913 void SetClipShape(
3914     ArkUINodeHandle node, ArkUI_CharPtr type, const ArkUI_Float32* attribute, ArkUI_Int32 length, ArkUI_Int32 unit)
3915 {
3916     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3917     CHECK_NULL_VOID(frameNode);
3918     if (std::strcmp(type, "rect") == 0) {
3919         auto shape = AceType::MakeRefPtr<ShapeRect>();
3920         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
3921         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
3922         auto radiusWidth = Dimension(attribute[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(unit));
3923         auto radiusHeight = Dimension(attribute[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(unit));
3924         shape->SetWidth(width);
3925         shape->SetHeight(height);
3926         shape->SetRadiusWidth(radiusWidth);
3927         shape->SetRadiusHeight(radiusHeight);
3928         if (length > NUM_4) {
3929             auto topLeftRadius = length > NUM_4
3930                                      ? Dimension(attribute[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(unit))
3931                                      : Dimension(0);
3932             auto bottomLeftRadius = length > NUM_5
3933                                         ? Dimension(attribute[NUM_5], static_cast<OHOS::Ace::DimensionUnit>(unit))
3934                                         : Dimension(0);
3935             auto topRightRadius = length > NUM_6
3936                                       ? Dimension(attribute[NUM_6], static_cast<OHOS::Ace::DimensionUnit>(unit))
3937                                       : Dimension(0);
3938             auto bottomRightRadius = length > NUM_7
3939                                          ? Dimension(attribute[NUM_7], static_cast<OHOS::Ace::DimensionUnit>(unit))
3940                                          : Dimension(0);
3941             shape->SetTopLeftRadius(Radius(topLeftRadius));
3942             shape->SetBottomLeftRadius(Radius(bottomLeftRadius));
3943             shape->SetTopRightRadius(Radius(topRightRadius));
3944             shape->SetBottomRightRadius(Radius(bottomRightRadius));
3945         }
3946         ViewAbstract::SetClipShape(frameNode, shape);
3947     }
3948     if (std::strcmp(type, "circle") == 0) {
3949         auto shape = AceType::MakeRefPtr<Circle>();
3950         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
3951         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
3952         shape->SetWidth(width);
3953         shape->SetHeight(height);
3954         ViewAbstract::SetClipShape(frameNode, shape);
3955     }
3956     if (std::strcmp(type, "ellipse") == 0) {
3957         auto shape = AceType::MakeRefPtr<Ellipse>();
3958         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
3959         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
3960         shape->SetWidth(width);
3961         shape->SetHeight(height);
3962         ViewAbstract::SetClipShape(frameNode, shape);
3963     }
3964 }
3965 
SetClipPath(ArkUINodeHandle node,ArkUI_CharPtr type,const ArkUI_Float32 (* attribute)[2],ArkUI_CharPtr commands,ArkUI_Int32 unit)3966 void SetClipPath(ArkUINodeHandle node, ArkUI_CharPtr type, const ArkUI_Float32 (*attribute)[2], ArkUI_CharPtr commands,
3967     ArkUI_Int32 unit)
3968 {
3969     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3970     CHECK_NULL_VOID(frameNode);
3971     auto path = AceType::MakeRefPtr<Path>();
3972     auto width = Dimension((*attribute)[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
3973     auto height = Dimension((*attribute)[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
3974     std::string pathCommands(commands);
3975     path->SetWidth(width);
3976     path->SetHeight(height);
3977     path->SetValue(StringUtils::TrimStr(pathCommands));
3978     ViewAbstract::SetClipShape(frameNode, path);
3979 }
3980 
ResetClip(ArkUINodeHandle node)3981 void ResetClip(ArkUINodeHandle node)
3982 {
3983     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3984     CHECK_NULL_VOID(frameNode);
3985     ViewAbstract::SetClipEdge(frameNode, false);
3986 }
3987 
SetAnimationOption(std::shared_ptr<AnimationOption> & option,const ArkUIAnimationOptionType * animationOption)3988 void SetAnimationOption(std::shared_ptr<AnimationOption>& option, const ArkUIAnimationOptionType* animationOption)
3989 {
3990     option->SetDuration(animationOption->duration);
3991     option->SetCurve(CURVES[std::clamp(animationOption->curve, 0, static_cast<int32_t>(CURVES.size() - 1))]);
3992     option->SetDelay(animationOption->delay);
3993     option->SetIteration(animationOption->iteration);
3994     option->SetAnimationDirection(static_cast<AnimationDirection>(animationOption->playMode));
3995     option->SetTempo(animationOption->tempo);
3996 }
3997 
SetTransitionCenter(ArkUINodeHandle node,ArkUI_Float32 centerXValue,ArkUI_Int32 centerXUnit,ArkUI_Float32 centerYValue,int32_t centerYUnit,ArkUI_Float32 centerZValue,ArkUI_Int32 centerZUnit)3998 void SetTransitionCenter(ArkUINodeHandle node, ArkUI_Float32 centerXValue, ArkUI_Int32 centerXUnit,
3999     ArkUI_Float32 centerYValue, int32_t centerYUnit, ArkUI_Float32 centerZValue, ArkUI_Int32 centerZUnit)
4000 {
4001     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4002     CHECK_NULL_VOID(frameNode);
4003     Dimension centerXDimension(centerXValue, static_cast<DimensionUnit>(centerXUnit));
4004     Dimension centerYDimension(centerYValue, static_cast<DimensionUnit>(centerYUnit));
4005     Dimension centerZDimension(centerZValue, static_cast<DimensionUnit>(centerZUnit));
4006     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4007     auto renderContext = frameNode->GetRenderContext();
4008     if (renderContext) {
4009         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4010     }
4011     if (!oneCenterTransition) {
4012         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4013     }
4014     oneCenterTransition->SetCenterX(centerXDimension);
4015     oneCenterTransition->SetCenterY(centerYDimension);
4016     oneCenterTransition->SetCenterZ(centerZDimension);
4017     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4018     while (chainEffect) {
4019         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4020             auto rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4021             NG::RotateOptions rotate(rotateEffect->GetEffect().xDirection, rotateEffect->GetEffect().yDirection,
4022                 rotateEffect->GetEffect().zDirection, rotateEffect->GetEffect().angle,
4023                 oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY(), oneCenterTransition->GetCenterZ(),
4024                 rotateEffect->GetEffect().perspective);
4025             rotateEffect->SetRotateEffect(rotate);
4026         } else if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4027             auto scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4028             NG::ScaleOptions scale(scaleEffect->GetEffect().xScale, scaleEffect->GetEffect().yScale,
4029                 scaleEffect->GetEffect().zScale, oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY());
4030             scaleEffect->SetScaleEffect(scale);
4031         }
4032         chainEffect = chainEffect->GetNext();
4033     }
4034     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4035     chainEffect = oneCenterTransition->GetTransitionEffect();
4036     if (chainEffect) {
4037         ViewAbstract::SetChainedTransition(frameNode, chainEffect);
4038     }
4039     DimensionOffset offset(centerXDimension, centerYDimension);
4040     offset.SetZ(centerZDimension);
4041     ViewAbstract::SetPivot(frameNode, offset);
4042 }
4043 
GetTransformCenter(ArkUINodeHandle node)4044 ArkUITransformCenterType GetTransformCenter(ArkUINodeHandle node)
4045 {
4046     ArkUITransformCenterType transformCenter = { 0.0f, 0.0f, 0.0f };
4047     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4048     CHECK_NULL_RETURN(frameNode, transformCenter);
4049     CHECK_NULL_RETURN(frameNode->GetGeometryNode(), transformCenter);
4050     auto renderContext = frameNode->GetRenderContext();
4051     CHECK_NULL_RETURN(renderContext, transformCenter);
4052     auto oneCenterTransform = renderContext->GetOneCenterTransitionOption();
4053     auto width = frameNode->GetGeometryNode() ? frameNode->GetGeometryNode()->GetFrameSize().Width() : 0.0f;
4054     auto height = frameNode->GetGeometryNode() ? frameNode->GetGeometryNode()->GetFrameSize().Height() : 0.0f;
4055     Dimension centerXDimension(HALF, DimensionUnit::PERCENT);
4056     Dimension centerYDimension(HALF, DimensionUnit::PERCENT);
4057     Dimension centerZDimension(0, DimensionUnit::VP);
4058     if (renderContext && oneCenterTransform) {
4059         centerXDimension.SetValue(oneCenterTransform->GetCenterX().Value());
4060         centerXDimension.SetUnit(oneCenterTransform->GetCenterX().Unit());
4061         centerYDimension.SetValue(oneCenterTransform->GetCenterY().Value());
4062         centerYDimension.SetUnit(oneCenterTransform->GetCenterY().Unit());
4063         centerZDimension.SetValue(oneCenterTransform->GetCenterZ().Value());
4064         centerZDimension.SetUnit(oneCenterTransform->GetCenterZ().Unit());
4065     }
4066     if (centerXDimension.Unit() == DimensionUnit::PERCENT) {
4067         Dimension centerXPx(width * centerXDimension.Value(), DimensionUnit::PX);
4068         centerXDimension.SetValue(centerXPx.ConvertToVp());
4069         centerXDimension.SetUnit(DimensionUnit::VP);
4070     }
4071     if (centerYDimension.Unit() == DimensionUnit::PERCENT) {
4072         Dimension centerYPx(height * centerYDimension.Value(), DimensionUnit::PX);
4073         centerYDimension.SetValue(centerYPx.ConvertToVp());
4074         centerYDimension.SetUnit(DimensionUnit::VP);
4075     }
4076     if (centerZDimension.Unit() == DimensionUnit::PERCENT) {
4077         centerZDimension.SetValue(0.0f);
4078         centerZDimension.SetUnit(DimensionUnit::VP);
4079     }
4080     transformCenter.centerX = centerXDimension.Value();
4081     transformCenter.centerY = centerYDimension.Value();
4082     transformCenter.centerZ = centerZDimension.Value();
4083     return transformCenter;
4084 }
4085 
ResetTransformCenter(RefPtr<OneCenterTransitionOptionType> & oneCenterTransition)4086 void ResetTransformCenter(RefPtr<OneCenterTransitionOptionType>& oneCenterTransition)
4087 {
4088     Dimension centerXDimension(HALF, DimensionUnit::PERCENT);
4089     Dimension centerYDimension(HALF, DimensionUnit::PERCENT);
4090     Dimension centerZDimension(0, DimensionUnit::VP);
4091     oneCenterTransition->SetCenterX(centerXDimension);
4092     oneCenterTransition->SetCenterY(centerYDimension);
4093     oneCenterTransition->SetCenterZ(centerZDimension);
4094 }
4095 
SetOpacityTransition(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUIAnimationOptionType * animationOption)4096 void SetOpacityTransition(ArkUINodeHandle node, ArkUI_Float32 value, const ArkUIAnimationOptionType* animationOption)
4097 {
4098     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4099     CHECK_NULL_VOID(frameNode);
4100     double opacity = value;
4101     if (opacity > 1.0 || LessNotEqual(opacity, 0.0)) {
4102         opacity = 1.0;
4103     }
4104     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4105     auto renderContext = frameNode->GetRenderContext();
4106     if (renderContext) {
4107         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4108     }
4109     if (!oneCenterTransition) {
4110         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4111         ResetTransformCenter(oneCenterTransition);
4112     }
4113     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4114     RefPtr<NG::ChainedOpacityEffect> opacityEffect;
4115     while (chainEffect) {
4116         if (chainEffect->GetType() == ChainedTransitionEffectType::OPACITY) {
4117             opacityEffect = AceType::DynamicCast<NG::ChainedOpacityEffect>(chainEffect);
4118             break;
4119         }
4120         chainEffect = chainEffect->GetNext();
4121     }
4122     auto option = std::make_shared<AnimationOption>();
4123     SetAnimationOption(option, animationOption);
4124     if (!opacityEffect) {
4125         opacityEffect = AceType::MakeRefPtr<NG::ChainedOpacityEffect>(opacity);
4126         opacityEffect->SetAnimationOption(option);
4127         opacityEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4128         oneCenterTransition->SetTransitionEffect(opacityEffect);
4129     } else {
4130         opacityEffect->SetOpacity(opacity);
4131         opacityEffect->SetAnimationOption(option);
4132     }
4133     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4134     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4135 }
4136 
findCurveIndex(const RefPtr<Curve> curve)4137 int32_t findCurveIndex(const RefPtr<Curve> curve)
4138 {
4139     CHECK_NULL_RETURN(curve, 0);
4140     auto iterator = std::find(CURVES.begin(), CURVES.end(), curve);
4141     if (iterator == CURVES.end()) {
4142         return 0;
4143     }
4144     return iterator - CURVES.begin();
4145 }
4146 
ParseAnimationOptionToStruct(const std::shared_ptr<AnimationOption> animationOption,ArkUIAnimationOptionType & animationType)4147 void ParseAnimationOptionToStruct(
4148     const std::shared_ptr<AnimationOption> animationOption, ArkUIAnimationOptionType& animationType)
4149 {
4150     CHECK_NULL_VOID(animationOption);
4151     animationType.duration = animationOption->GetDuration();
4152     animationType.curve = findCurveIndex(animationOption->GetCurve());
4153     animationType.delay = animationOption->GetDelay();
4154     animationType.iteration = animationOption->GetIteration();
4155     animationType.playMode = static_cast<int32_t>(animationOption->GetAnimationDirection());
4156     animationType.tempo = animationOption->GetTempo();
4157 }
4158 
GetOpacityTransition(ArkUINodeHandle node)4159 ArkUIOpacityTransitionType GetOpacityTransition(ArkUINodeHandle node)
4160 {
4161     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4162     ArkUIOpacityTransitionType opacityAnimationStruct = { 1.0f, animationType };
4163     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4164     CHECK_NULL_RETURN(frameNode, opacityAnimationStruct);
4165     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4166     auto renderContext = frameNode->GetRenderContext();
4167     if (renderContext) {
4168         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4169     }
4170     CHECK_NULL_RETURN(oneCenterTransition, opacityAnimationStruct);
4171     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4172     RefPtr<NG::ChainedOpacityEffect> opacityEffect;
4173     while (chainEffect) {
4174         if (chainEffect->GetType() == ChainedTransitionEffectType::OPACITY) {
4175             opacityEffect = AceType::DynamicCast<NG::ChainedOpacityEffect>(chainEffect);
4176             break;
4177         }
4178         chainEffect = chainEffect->GetNext();
4179     }
4180     CHECK_NULL_RETURN(opacityEffect, opacityAnimationStruct);
4181     opacityAnimationStruct.opacity = opacityEffect->GetEffect();
4182     ParseAnimationOptionToStruct(opacityEffect->GetAnimationOption(), opacityAnimationStruct.animation);
4183     return opacityAnimationStruct;
4184 }
4185 
SetRotateTransition(ArkUINodeHandle node,ArkUI_Float32 * arrayValue,ArkUI_Int32 length,ArkUI_Float32 perspective,ArkUI_Float32 angle,const ArkUIAnimationOptionType * animationOption)4186 void SetRotateTransition(ArkUINodeHandle node, ArkUI_Float32* arrayValue, ArkUI_Int32 length, ArkUI_Float32 perspective,
4187     ArkUI_Float32 angle, const ArkUIAnimationOptionType* animationOption)
4188 {
4189     CHECK_NULL_VOID(arrayValue);
4190     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4191     CHECK_NULL_VOID(frameNode);
4192     if (length < ARRAY_SIZE) {
4193         return;
4194     }
4195     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4196     auto renderContext = frameNode->GetRenderContext();
4197     if (renderContext) {
4198         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4199     }
4200     if (!oneCenterTransition) {
4201         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4202         ResetTransformCenter(oneCenterTransition);
4203     }
4204     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4205     RefPtr<NG::ChainedRotateEffect> rotateEffect;
4206     while (chainEffect) {
4207         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4208             rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4209             break;
4210         }
4211         chainEffect = chainEffect->GetNext();
4212     }
4213     auto option = std::make_shared<AnimationOption>();
4214     SetAnimationOption(option, animationOption);
4215     NG::RotateOptions rotate(arrayValue[X_INDEX], arrayValue[Y_INDEX], arrayValue[Z_INDEX], angle,
4216         oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY(), oneCenterTransition->GetCenterZ(),
4217         perspective);
4218     if (!rotateEffect) {
4219         rotateEffect = AceType::MakeRefPtr<NG::ChainedRotateEffect>(rotate);
4220         rotateEffect->SetAnimationOption(option);
4221         rotateEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4222         oneCenterTransition->SetTransitionEffect(rotateEffect);
4223     } else {
4224         rotateEffect->SetRotateEffect(rotate);
4225         rotateEffect->SetAnimationOption(option);
4226     }
4227     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4228     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4229 }
4230 
GetRotateTransition(ArkUINodeHandle node)4231 ArkUIRotateTransitionType GetRotateTransition(ArkUINodeHandle node)
4232 {
4233     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4234     ArkUIRotateTransitionType rotateAnimationStruct = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, animationType };
4235     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4236     CHECK_NULL_RETURN(frameNode, rotateAnimationStruct);
4237     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4238     auto renderContext = frameNode->GetRenderContext();
4239     if (renderContext) {
4240         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4241     }
4242     CHECK_NULL_RETURN(oneCenterTransition, rotateAnimationStruct);
4243     RefPtr<NG::ChainedRotateEffect> rotateEffect;
4244     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4245     while (chainEffect) {
4246         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4247             rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4248             break;
4249         }
4250         chainEffect = chainEffect->GetNext();
4251     }
4252     CHECK_NULL_RETURN(rotateEffect, rotateAnimationStruct);
4253     auto xRotation = rotateEffect->GetEffect().xDirection;
4254     auto yRotation = rotateEffect->GetEffect().yDirection;
4255     auto zRotation = rotateEffect->GetEffect().zDirection;
4256     auto angle = rotateEffect->GetEffect().angle;
4257     auto perspective = rotateEffect->GetEffect().perspective;
4258     rotateAnimationStruct.xRotation = xRotation;
4259     rotateAnimationStruct.yRotation = yRotation;
4260     rotateAnimationStruct.zRotation = zRotation;
4261     rotateAnimationStruct.angle = angle;
4262     rotateAnimationStruct.perspective = perspective;
4263     ParseAnimationOptionToStruct(rotateEffect->GetAnimationOption(), rotateAnimationStruct.animation);
4264     return rotateAnimationStruct;
4265 }
4266 
SetScaleTransition(ArkUINodeHandle node,ArkUI_Float32 * arrayValue,ArkUI_Int32 length,const ArkUIAnimationOptionType * animationOption)4267 void SetScaleTransition(ArkUINodeHandle node, ArkUI_Float32* arrayValue, ArkUI_Int32 length,
4268     const ArkUIAnimationOptionType* animationOption)
4269 {
4270     CHECK_NULL_VOID(arrayValue);
4271     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4272     CHECK_NULL_VOID(frameNode);
4273     if (length < ARRAY_SIZE) {
4274         return;
4275     }
4276     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4277     auto renderContext = frameNode->GetRenderContext();
4278     if (renderContext) {
4279         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4280     }
4281     if (!oneCenterTransition) {
4282         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4283         ResetTransformCenter(oneCenterTransition);
4284     }
4285     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4286     RefPtr<NG::ChainedScaleEffect> scaleEffect;
4287     while (chainEffect) {
4288         if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4289             scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4290             break;
4291         }
4292         chainEffect = chainEffect->GetNext();
4293     }
4294     auto option = std::make_shared<AnimationOption>();
4295     SetAnimationOption(option, animationOption);
4296     NG::ScaleOptions scale(arrayValue[X_INDEX], arrayValue[Y_INDEX], arrayValue[Z_INDEX],
4297         oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY());
4298     if (!scaleEffect) {
4299         scaleEffect = AceType::MakeRefPtr<NG::ChainedScaleEffect>(scale);
4300         scaleEffect->SetAnimationOption(option);
4301         scaleEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4302         oneCenterTransition->SetTransitionEffect(scaleEffect);
4303     } else {
4304         scaleEffect->SetScaleEffect(scale);
4305         scaleEffect->SetAnimationOption(option);
4306     }
4307     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4308     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4309 }
4310 
GetScaleTransition(ArkUINodeHandle node)4311 ArkUIScaleTransitionType GetScaleTransition(ArkUINodeHandle node)
4312 {
4313     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4314     ArkUIScaleTransitionType scaleAnimationStruct = { 1.0f, 1.0f, 1.0f, animationType };
4315     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4316     CHECK_NULL_RETURN(frameNode, scaleAnimationStruct);
4317     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4318     auto renderContext = frameNode->GetRenderContext();
4319     if (renderContext) {
4320         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4321     }
4322     CHECK_NULL_RETURN(oneCenterTransition, scaleAnimationStruct);
4323     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4324     RefPtr<NG::ChainedScaleEffect> scaleEffect;
4325     while (chainEffect) {
4326         if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4327             scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4328             break;
4329         }
4330         chainEffect = chainEffect->GetNext();
4331     }
4332     CHECK_NULL_RETURN(scaleEffect, scaleAnimationStruct);
4333     auto xScale = scaleEffect->GetEffect().xScale;
4334     auto yScale = scaleEffect->GetEffect().yScale;
4335     auto zScale = scaleEffect->GetEffect().zScale;
4336     scaleAnimationStruct.xScale = xScale;
4337     scaleAnimationStruct.yScale = yScale;
4338     scaleAnimationStruct.zScale = zScale;
4339     ParseAnimationOptionToStruct(scaleEffect->GetAnimationOption(), scaleAnimationStruct.animation);
4340     return scaleAnimationStruct;
4341 }
4342 
SetTranslateTransition(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit,ArkUI_Float32 zValue,ArkUI_Int32 zUnit,const ArkUIAnimationOptionType * animationOption)4343 void SetTranslateTransition(ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue,
4344     ArkUI_Int32 yUnit, ArkUI_Float32 zValue, ArkUI_Int32 zUnit, const ArkUIAnimationOptionType* animationOption)
4345 {
4346     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4347     CHECK_NULL_VOID(frameNode);
4348     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4349     auto renderContext = frameNode->GetRenderContext();
4350     if (renderContext) {
4351         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4352     }
4353     if (!oneCenterTransition) {
4354         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4355         ResetTransformCenter(oneCenterTransition);
4356     }
4357     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4358     RefPtr<NG::ChainedTranslateEffect> translateEffect;
4359     while (chainEffect) {
4360         if (chainEffect->GetType() == ChainedTransitionEffectType::TRANSLATE) {
4361             translateEffect = AceType::DynamicCast<NG::ChainedTranslateEffect>(chainEffect);
4362             break;
4363         }
4364         chainEffect = chainEffect->GetNext();
4365     }
4366 
4367     auto option = std::make_shared<AnimationOption>();
4368     SetAnimationOption(option, animationOption);
4369     Dimension xDimension(xValue, static_cast<DimensionUnit>(xUnit));
4370     Dimension yDimension(yValue, static_cast<DimensionUnit>(yUnit));
4371     Dimension zDimension(zValue, static_cast<DimensionUnit>(zUnit));
4372     NG::TranslateOptions translate(xDimension, yDimension, zDimension);
4373     if (!translateEffect) {
4374         translateEffect = AceType::MakeRefPtr<NG::ChainedTranslateEffect>(translate);
4375         translateEffect->SetAnimationOption(option);
4376         translateEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4377         oneCenterTransition->SetTransitionEffect(translateEffect);
4378     } else {
4379         translateEffect->SetTranslateEffect(translate);
4380         translateEffect->SetAnimationOption(option);
4381     }
4382     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4383     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4384 }
4385 
GetTranslateTransition(ArkUINodeHandle node)4386 ArkUITranslateTransitionType GetTranslateTransition(ArkUINodeHandle node)
4387 {
4388     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4389     ArkUITranslateTransitionType translateAnimationStruct = { 0.0f, 0.0f, 0.0f, animationType };
4390     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4391     CHECK_NULL_RETURN(frameNode, translateAnimationStruct);
4392     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4393     auto renderContext = frameNode->GetRenderContext();
4394     if (renderContext) {
4395         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4396     }
4397     CHECK_NULL_RETURN(oneCenterTransition, translateAnimationStruct);
4398     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4399     RefPtr<NG::ChainedTranslateEffect> translateEffect;
4400     while (chainEffect) {
4401         if (chainEffect->GetType() == ChainedTransitionEffectType::TRANSLATE) {
4402             translateEffect = AceType::DynamicCast<NG::ChainedTranslateEffect>(chainEffect);
4403             break;
4404         }
4405         chainEffect = chainEffect->GetNext();
4406     }
4407     CHECK_NULL_RETURN(translateEffect, translateAnimationStruct);
4408     auto xTransition = translateEffect->GetEffect().x.Value();
4409     auto yTransition = translateEffect->GetEffect().y.Value();
4410     auto zTransition = translateEffect->GetEffect().z.Value();
4411     translateAnimationStruct.xTransition = xTransition;
4412     translateAnimationStruct.yTransition = yTransition;
4413     translateAnimationStruct.zTransition = zTransition;
4414     ParseAnimationOptionToStruct(translateEffect->GetAnimationOption(), translateAnimationStruct.animation);
4415     return translateAnimationStruct;
4416 }
4417 
SetMoveTransition(ArkUINodeHandle node,ArkUI_Int32 value,const ArkUIAnimationOptionType * animationOption)4418 void SetMoveTransition(ArkUINodeHandle node, ArkUI_Int32 value, const ArkUIAnimationOptionType* animationOption)
4419 {
4420     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4421     CHECK_NULL_VOID(frameNode);
4422     auto edgeType = static_cast<TransitionEdge>(value);
4423     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4424     auto renderContext = frameNode->GetRenderContext();
4425     if (renderContext) {
4426         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4427     }
4428     if (!oneCenterTransition) {
4429         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4430         ResetTransformCenter(oneCenterTransition);
4431     }
4432     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4433     RefPtr<NG::ChainedMoveEffect> moveEffect;
4434     while (chainEffect) {
4435         if (chainEffect->GetType() == ChainedTransitionEffectType::MOVE) {
4436             moveEffect = AceType::DynamicCast<NG::ChainedMoveEffect>(chainEffect);
4437             break;
4438         }
4439         chainEffect = chainEffect->GetNext();
4440     }
4441     auto option = std::make_shared<AnimationOption>();
4442     SetAnimationOption(option, animationOption);
4443     if (!moveEffect) {
4444         moveEffect = AceType::MakeRefPtr<NG::ChainedMoveEffect>(edgeType);
4445         moveEffect->SetAnimationOption(option);
4446         moveEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4447         oneCenterTransition->SetTransitionEffect(moveEffect);
4448     } else {
4449         moveEffect->SetAnimationOption(option);
4450     }
4451     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4452     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4453 }
4454 
GetMoveTransition(ArkUINodeHandle node)4455 ArkUIMoveTransitionType GetMoveTransition(ArkUINodeHandle node)
4456 {
4457     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4458     ArkUIMoveTransitionType moveAnimationStruct = { 0, animationType };
4459     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4460     CHECK_NULL_RETURN(frameNode, moveAnimationStruct);
4461     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4462     auto renderContext = frameNode->GetRenderContext();
4463     if (renderContext) {
4464         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4465     }
4466     CHECK_NULL_RETURN(oneCenterTransition, moveAnimationStruct);
4467     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4468     RefPtr<NG::ChainedMoveEffect> moveEffect;
4469     while (chainEffect) {
4470         if (chainEffect->GetType() == ChainedTransitionEffectType::MOVE) {
4471             moveEffect = AceType::DynamicCast<NG::ChainedMoveEffect>(chainEffect);
4472             break;
4473         }
4474         chainEffect = chainEffect->GetNext();
4475     }
4476     CHECK_NULL_RETURN(moveEffect, moveAnimationStruct);
4477     moveAnimationStruct.edgeType = static_cast<ArkUI_Int32>(moveEffect->GetEffect());
4478     ParseAnimationOptionToStruct(moveEffect->GetAnimationOption(), moveAnimationStruct.animation);
4479     return moveAnimationStruct;
4480 }
4481 
SetMaskShape(ArkUINodeHandle node,ArkUI_CharPtr type,ArkUI_Uint32 fill,ArkUI_Uint32 stroke,ArkUI_Float32 strokeWidth,const ArkUI_Float32 * attribute,ArkUI_Int32 length,ArkUI_Int32 unit)4482 void SetMaskShape(ArkUINodeHandle node, ArkUI_CharPtr type, ArkUI_Uint32 fill, ArkUI_Uint32 stroke,
4483     ArkUI_Float32 strokeWidth, const ArkUI_Float32* attribute, ArkUI_Int32 length, ArkUI_Int32 unit)
4484 {
4485     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4486     CHECK_NULL_VOID(frameNode);
4487     std::string shapeType(type);
4488     auto strokeWidth_ = Dimension(strokeWidth, static_cast<OHOS::Ace::DimensionUnit>(unit));
4489     if (shapeType == "rect") {
4490         auto shape = AceType::MakeRefPtr<ShapeRect>();
4491         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4492         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4493         auto radiusWidth = Dimension(attribute[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(unit));
4494         auto radiusHeight = Dimension(attribute[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(unit));
4495         shape->SetWidth(width);
4496         shape->SetHeight(height);
4497         shape->SetRadiusWidth(radiusWidth);
4498         shape->SetRadiusHeight(radiusHeight);
4499         shape->SetColor(Color(fill));
4500         shape->SetStrokeColor(stroke);
4501         shape->SetStrokeWidth(strokeWidth);
4502         if (length > NUM_4) {
4503             auto topLeftRadius = length > NUM_4
4504                                      ? Dimension(attribute[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(unit))
4505                                      : Dimension(0);
4506             auto bottomLeftRadius = length > NUM_5
4507                                         ? Dimension(attribute[NUM_5], static_cast<OHOS::Ace::DimensionUnit>(unit))
4508                                         : Dimension(0);
4509             auto topRightRadius = length > NUM_6
4510                                       ? Dimension(attribute[NUM_6], static_cast<OHOS::Ace::DimensionUnit>(unit))
4511                                       : Dimension(0);
4512             auto bottomRightRadius = length > NUM_7
4513                                          ? Dimension(attribute[NUM_7], static_cast<OHOS::Ace::DimensionUnit>(unit))
4514                                          : Dimension(0);
4515             shape->SetTopLeftRadius(Radius(topLeftRadius));
4516             shape->SetBottomLeftRadius(Radius(bottomLeftRadius));
4517             shape->SetTopRightRadius(Radius(topRightRadius));
4518             shape->SetBottomRightRadius(Radius(bottomRightRadius));
4519         }
4520         ViewAbstract::SetMask(frameNode, shape);
4521     } else if (shapeType == "circle") {
4522         auto shape = AceType::MakeRefPtr<Circle>();
4523         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(1));
4524         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(1));
4525         shape->SetWidth(width);
4526         shape->SetHeight(height);
4527         shape->SetColor(Color(fill));
4528         shape->SetStrokeColor(stroke);
4529         shape->SetStrokeWidth(strokeWidth);
4530         ViewAbstract::SetMask(frameNode, shape);
4531     } else if (shapeType == "ellipse") {
4532         auto shape = AceType::MakeRefPtr<Ellipse>();
4533         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(1));
4534         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(1));
4535         shape->SetWidth(width);
4536         shape->SetHeight(height);
4537         shape->SetColor(Color(fill));
4538         shape->SetStrokeColor(stroke);
4539         shape->SetStrokeWidth(strokeWidth);
4540         ViewAbstract::SetMask(frameNode, shape);
4541     } else {
4542         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "type are invalid");
4543         return;
4544     }
4545 }
4546 
SetMaskPath(ArkUINodeHandle node,ArkUI_CharPtr type,ArkUI_Uint32 fill,ArkUI_Uint32 stroke,ArkUI_Float32 strokeWidth,const ArkUI_Float32 (* attribute)[2],ArkUI_CharPtr commands,ArkUI_Int32 unit)4547 void SetMaskPath(ArkUINodeHandle node, ArkUI_CharPtr type, ArkUI_Uint32 fill, ArkUI_Uint32 stroke,
4548     ArkUI_Float32 strokeWidth, const ArkUI_Float32 (*attribute)[2], ArkUI_CharPtr commands, ArkUI_Int32 unit)
4549 {
4550     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4551     auto strokeWidth_ = Dimension(strokeWidth, static_cast<OHOS::Ace::DimensionUnit>(unit));
4552     CHECK_NULL_VOID(frameNode);
4553     auto path = AceType::MakeRefPtr<Path>();
4554     auto width = Dimension((*attribute)[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4555     auto height = Dimension((*attribute)[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4556     std::string pathCommands(commands);
4557     path->SetWidth(width);
4558     path->SetHeight(height);
4559     path->SetValue(StringUtils::TrimStr(pathCommands));
4560     path->SetColor(Color(fill));
4561     path->SetStrokeColor(stroke);
4562     path->SetStrokeWidth(strokeWidth);
4563     ViewAbstract::SetMask(frameNode, path);
4564 }
4565 
SetProgressMask(ArkUINodeHandle node,const ArkUI_Float32 * attribute,ArkUI_Uint32 color)4566 void SetProgressMask(ArkUINodeHandle node, const ArkUI_Float32* attribute, ArkUI_Uint32 color)
4567 {
4568     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4569     CHECK_NULL_VOID(frameNode);
4570     auto progressMask = AceType::MakeRefPtr<NG::ProgressMaskProperty>();
4571     int value = attribute[NUM_0];
4572     int total = attribute[NUM_1];
4573     progressMask->SetValue(value);
4574     progressMask->SetMaxValue(total);
4575     progressMask->SetColor(Color(color));
4576     ViewAbstract::SetProgressMask(frameNode, progressMask);
4577 }
4578 
ResetMask(ArkUINodeHandle node)4579 void ResetMask(ArkUINodeHandle node)
4580 {
4581     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4582     CHECK_NULL_VOID(frameNode);
4583     ViewAbstract::SetMask(frameNode, nullptr);
4584 }
4585 
SetOutlineColor(ArkUINodeHandle node,const uint32_t * values,int32_t valuesSize)4586 void SetOutlineColor(ArkUINodeHandle node, const uint32_t* values, int32_t valuesSize)
4587 {
4588     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4589     CHECK_NULL_VOID(frameNode);
4590     int32_t colorOffset = NUM_0;
4591     NG::BorderColorProperty borderColors;
4592     SetOptionalBorderColor(borderColors.topColor, values, valuesSize, colorOffset);
4593     SetOptionalBorderColor(borderColors.rightColor, values, valuesSize, colorOffset);
4594     SetOptionalBorderColor(borderColors.bottomColor, values, valuesSize, colorOffset);
4595     SetOptionalBorderColor(borderColors.leftColor, values, valuesSize, colorOffset);
4596     borderColors.multiValued = true;
4597     ViewAbstract::SetOuterBorderColor(frameNode, borderColors);
4598 }
4599 
ResetOutlineColor(ArkUINodeHandle node)4600 void ResetOutlineColor(ArkUINodeHandle node)
4601 {
4602     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4603     CHECK_NULL_VOID(frameNode);
4604     ViewAbstract::SetOuterBorderColor(frameNode, Color::BLACK);
4605 }
4606 
GetOutlineColor(ArkUINodeHandle node,ArkUI_Uint32 (* values)[4])4607 void GetOutlineColor(ArkUINodeHandle node, ArkUI_Uint32 (*values)[4])
4608 {
4609     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4610     CHECK_NULL_VOID(frameNode);
4611     auto colors = ViewAbstract::GetOuterBorderColor(frameNode);
4612     (*values)[NUM_0] = colors.topColor->GetValue();
4613     (*values)[NUM_1] = colors.rightColor->GetValue();
4614     (*values)[NUM_2] = colors.bottomColor->GetValue();
4615     (*values)[NUM_3] = colors.leftColor->GetValue();
4616 }
4617 
GetSize(ArkUINodeHandle node,ArkUI_Float32 (* values)[2],ArkUI_Int32 unit)4618 void GetSize(ArkUINodeHandle node, ArkUI_Float32 (*values)[2], ArkUI_Int32 unit)
4619 {
4620     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4621     CHECK_NULL_VOID(frameNode);
4622     (*values)[NUM_0] = ViewAbstract::GetWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
4623     (*values)[NUM_1] = ViewAbstract::GetHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
4624 }
4625 
GetRenderGroup(ArkUINodeHandle node)4626 ArkUI_Bool GetRenderGroup(ArkUINodeHandle node)
4627 {
4628     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4629     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
4630     return static_cast<ArkUI_Bool>(ViewAbstract::GetRenderGroup(frameNode));
4631 }
4632 
SetOutlineRadius(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize)4633 void SetOutlineRadius(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize)
4634 {
4635     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4636     CHECK_NULL_VOID(frameNode);
4637     int32_t radiusOffset = NUM_0;
4638 
4639     NG::BorderRadiusProperty borderRadius;
4640     SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, radiusOffset);
4641     SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, radiusOffset);
4642     SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, radiusOffset);
4643     SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, radiusOffset);
4644     borderRadius.multiValued = true;
4645     ViewAbstract::SetOuterBorderRadius(frameNode, borderRadius);
4646 }
4647 
ResetOutlineRadius(ArkUINodeHandle node)4648 void ResetOutlineRadius(ArkUINodeHandle node)
4649 {
4650     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4651     CHECK_NULL_VOID(frameNode);
4652     Dimension value;
4653     ViewAbstract::SetOuterBorderRadius(frameNode, value);
4654 }
4655 
SetOutlineWidth(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize)4656 void SetOutlineWidth(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize)
4657 {
4658     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4659     CHECK_NULL_VOID(frameNode);
4660     int32_t offset = NUM_0;
4661     NG::BorderWidthProperty borderWidth;
4662 
4663     SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
4664     SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
4665     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
4666     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
4667     borderWidth.multiValued = true;
4668     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4669 }
4670 
SetOutlineWidthFloat(ArkUINodeHandle node,ArkUI_Float32 left,ArkUI_Float32 top,ArkUI_Float32 right,ArkUI_Float32 bottom)4671 void SetOutlineWidthFloat(ArkUINodeHandle node, ArkUI_Float32 left, ArkUI_Float32 top,
4672     ArkUI_Float32 right, ArkUI_Float32 bottom)
4673 {
4674     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4675     CHECK_NULL_VOID(frameNode);
4676     NG::BorderWidthProperty borderWidth;
4677     borderWidth.leftDimen = Dimension(left, DimensionUnit::VP);
4678     borderWidth.topDimen = Dimension(top, DimensionUnit::VP);
4679     borderWidth.rightDimen = Dimension(right, DimensionUnit::VP);
4680     borderWidth.bottomDimen = Dimension(bottom, DimensionUnit::VP);
4681     borderWidth.multiValued = true;
4682     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4683 }
4684 
GetOutlineWidthFloat(ArkUINodeHandle node,ArkUI_Float32 * borderWidthVector,ArkUI_Int32 borderWidthSize)4685 void GetOutlineWidthFloat(ArkUINodeHandle node, ArkUI_Float32* borderWidthVector, ArkUI_Int32 borderWidthSize)
4686 {
4687     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4688     CHECK_NULL_VOID(frameNode);
4689     if (borderWidthSize < OUTLINE_WIDTH_VECTOR_SIZE) {
4690         return;
4691     }
4692     NG::BorderWidthProperty borderWidth = ViewAbstract::GetOuterBorderWidth(frameNode);
4693     borderWidthVector[OUTLINE_LEFT_WIDTH_INDEX] = borderWidth.leftDimen.has_value() ?
4694         borderWidth.leftDimen->Value() : 0.0f;
4695     borderWidthVector[OUTLINE_TOP_WIDTH_INDEX] = borderWidth.topDimen.has_value() ?
4696         borderWidth.topDimen->Value() : 0.0f;
4697     borderWidthVector[OUTLINE_RIGHT_WIDTH_INDEX] = borderWidth.rightDimen.has_value() ?
4698         borderWidth.rightDimen->Value() : 0.0f;
4699     borderWidthVector[OUTLINE_BOTTOM_WIDTH_INDEX] = borderWidth.bottomDimen.has_value() ?
4700         borderWidth.bottomDimen->Value() : 0.0f;
4701 }
4702 
ResetOutlineWidth(ArkUINodeHandle node)4703 void ResetOutlineWidth(ArkUINodeHandle node)
4704 {
4705     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4706     CHECK_NULL_VOID(frameNode);
4707     Dimension value;
4708     ViewAbstract::SetOuterBorderWidth(frameNode, value);
4709 }
4710 
SetOutlineStyle(ArkUINodeHandle node,const uint32_t * values,int32_t valuesSize)4711 void SetOutlineStyle(ArkUINodeHandle node, const uint32_t* values, int32_t valuesSize)
4712 {
4713     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4714     CHECK_NULL_VOID(frameNode);
4715     int32_t styleOffset = NUM_0;
4716     NG::BorderStyleProperty borderStyles;
4717     SetOptionalBorderStyle(borderStyles.styleLeft, values, valuesSize, styleOffset);
4718     SetOptionalBorderStyle(borderStyles.styleRight, values, valuesSize, styleOffset);
4719     SetOptionalBorderStyle(borderStyles.styleTop, values, valuesSize, styleOffset);
4720     SetOptionalBorderStyle(borderStyles.styleBottom, values, valuesSize, styleOffset);
4721     borderStyles.multiValued = true;
4722     ViewAbstract::SetOuterBorderStyle(frameNode, borderStyles);
4723 }
4724 
ResetOutlineStyle(ArkUINodeHandle node)4725 void ResetOutlineStyle(ArkUINodeHandle node)
4726 {
4727     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4728     CHECK_NULL_VOID(frameNode);
4729     ViewAbstract::SetOuterBorderStyle(frameNode, BorderStyle::SOLID);
4730 }
4731 /**
4732  * @param src source OutlineWidth and and OutlineRadius value
4733  * @param options option value
4734  * values[offset + 0], option[offset + 1], option[offset + 2]: OutlineWidth left(hasValue, value, unit)
4735  * values[offset + 3], option[offset + 4], option[offset + 5]: OutlineWidth right(hasValue, value, unit)
4736  * values[offset + 6], option[offset + 7], option[offset + 8]: OutlineWidth top(hasValue, value, unit)
4737  * values[offset + 9], option[offset + 10], option[offset + 11]: OutlineWidth bottom(hasValue, value, unit)
4738  * values[offset + 12], option[offset + 13], option[offset + 14] : OutlineRadius TopLeft(hasValue, value, unit)
4739  * values[offset + 15], option[offset + 16], option[offset + 17] : OutlineRadius TopRight(hasValue, value, unit)
4740  * values[offset + 18], option[offset + 19], option[offset + 20] : OutlineRadius BottomLeft(hasValue, value, unit)
4741  * values[offset + 21], option[offset + 22], option[offset + 23] : OutlineRadius BottomRight(hasValue, value, unit)
4742  * @param optionsLength options valuesSize
4743  * @param src source color and Style value
4744  * colorAndStyle[offset + 0], option[offset + 1]: OutlineColors leftColor(hasValue, value)
4745  * colorAndStyle[offset + 2], option[offset + 3]: OutlineColors rightColor(hasValue, value)
4746  * colorAndStyle[offset + 4], option[offset + 5]: OutlineColors topColor(hasValue, value)
4747  * colorAndStyle[offset + 6], option[offset + 7]: OutlineColors bottomColor(hasValue, value)
4748  * colorAndStyle[offset + 8], option[offset + 9]: OutlineStyles styleLeft(hasValue, value)
4749  * colorAndStyle[offset + 10], option[offset + 11]: OutlineStyles styleRight(hasValue, value)
4750  * colorAndStyle[offset + 12], option[offset + 12]: OutlineStyles styleTop(hasValue, value)
4751  * colorAndStyle[offset + 14], option[offset + 15]: OutlineStyles styleBottom(hasValue, value)
4752  * @param optionsLength options colorAndStyleSize
4753  */
SetOutline(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize,const uint32_t * colorAndStyle,int32_t colorAndStyleSize)4754 void SetOutline(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize, const uint32_t* colorAndStyle,
4755     int32_t colorAndStyleSize)
4756 {
4757     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4758     CHECK_NULL_VOID(frameNode);
4759     if ((values == nullptr) || (valuesSize != NUM_24) || (colorAndStyle == nullptr) || colorAndStyleSize != NUM_16) {
4760         return;
4761     }
4762 
4763     int32_t offset = NUM_0; // offset for outline width and outline radius
4764     NG::BorderWidthProperty borderWidth;
4765     SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
4766     SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
4767     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
4768     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
4769     borderWidth.multiValued = true;
4770     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4771 
4772     NG::BorderRadiusProperty borderRadius;
4773     SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, offset);
4774     SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, offset);
4775     SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, offset);
4776     SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, offset);
4777     borderRadius.multiValued = true;
4778     ViewAbstract::SetOuterBorderRadius(frameNode, borderRadius);
4779 
4780     int32_t colorAndStyleOffset = NUM_0; // offset for outline color and outline style
4781     NG::BorderColorProperty borderColors;
4782     SetOptionalBorderColor(borderColors.leftColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4783     SetOptionalBorderColor(borderColors.rightColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4784     SetOptionalBorderColor(borderColors.topColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4785     SetOptionalBorderColor(borderColors.bottomColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4786     borderColors.multiValued = true;
4787     ViewAbstract::SetOuterBorderColor(frameNode, borderColors);
4788 
4789     NG::BorderStyleProperty borderStyles;
4790     SetOptionalBorderStyle(borderStyles.styleLeft, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4791     SetOptionalBorderStyle(borderStyles.styleRight, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4792     SetOptionalBorderStyle(borderStyles.styleTop, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4793     SetOptionalBorderStyle(borderStyles.styleBottom, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
4794     borderStyles.multiValued = true;
4795     ViewAbstract::SetOuterBorderStyle(frameNode, borderStyles);
4796 }
4797 
ResetOutline(ArkUINodeHandle node)4798 void ResetOutline(ArkUINodeHandle node)
4799 {
4800     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4801     CHECK_NULL_VOID(frameNode);
4802     CalcDimension borderWidth;
4803     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4804     ViewAbstract::SetOuterBorderColor(frameNode, Color::BLACK);
4805     ViewAbstract::SetOuterBorderRadius(frameNode, borderWidth);
4806     ViewAbstract::SetOuterBorderStyle(frameNode, BorderStyle::SOLID);
4807 }
GetFocusable(ArkUINodeHandle node)4808 ArkUI_Bool GetFocusable(ArkUINodeHandle node)
4809 {
4810     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4811     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
4812     return static_cast<ArkUI_Bool>(ViewAbstract::GetFocusable(frameNode));
4813 }
4814 
GetDefaultFocus(ArkUINodeHandle node)4815 ArkUI_Bool GetDefaultFocus(ArkUINodeHandle node)
4816 {
4817     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4818     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
4819     return static_cast<ArkUI_Bool>(ViewAbstract::GetDefaultFocus(frameNode));
4820 }
4821 
GetResponseRegion(ArkUINodeHandle node,ArkUI_Float32 (* values)[32])4822 ArkUI_Int32 GetResponseRegion(ArkUINodeHandle node, ArkUI_Float32 (*values)[32])
4823 {
4824     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4825     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
4826     std::vector<DimensionRect> responseRegions = ViewAbstract::GetResponseRegion(frameNode);
4827     //set int default
4828     int index = 0;
4829     for (auto& element : responseRegions) {
4830         (*values)[index++] = element.GetOffset().GetX().Value();
4831         (*values)[index++] = element.GetOffset().GetY().Value();
4832         (*values)[index++] = element.GetWidth().Value() * PERCENT_100;
4833         (*values)[index++] = element.GetHeight().Value() * PERCENT_100;
4834     }
4835     //values size
4836     return index;
4837 }
4838 
GetOverlay(ArkUINodeHandle node,ArkUIOverlayOptions * options,ArkUI_Int32 unit)4839 ArkUI_CharPtr GetOverlay(ArkUINodeHandle node, ArkUIOverlayOptions* options, ArkUI_Int32 unit)
4840 {
4841     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4842     CHECK_NULL_RETURN(frameNode, nullptr);
4843     NG::OverlayOptions overlayOptions = ViewAbstract::GetOverlay(frameNode);
4844     options->align = ParseAlignmentToIndex(overlayOptions.align);
4845     options->x = overlayOptions.x.GetNativeValue(static_cast<DimensionUnit>(unit));
4846     options->y = overlayOptions.y.GetNativeValue(static_cast<DimensionUnit>(unit));
4847     options->content = overlayOptions.content.c_str();
4848     g_strValue = overlayOptions.content;
4849     return g_strValue.c_str();
4850 }
4851 
GetAccessibilityGroup(ArkUINodeHandle node)4852 ArkUI_Bool GetAccessibilityGroup(ArkUINodeHandle node)
4853 {
4854     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4855     CHECK_NULL_RETURN(frameNode, false);
4856     return static_cast<ArkUI_Bool>(ViewAbstractModelNG::GetAccessibilityGroup(frameNode));
4857 }
4858 
GetAccessibilityText(ArkUINodeHandle node)4859 ArkUI_CharPtr GetAccessibilityText(ArkUINodeHandle node)
4860 {
4861     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4862     CHECK_NULL_RETURN(frameNode, nullptr);
4863     g_strValue = ViewAbstractModelNG::GetAccessibilityText(frameNode);
4864     return g_strValue.c_str();
4865 }
4866 
GetAccessibilityDescription(ArkUINodeHandle node)4867 ArkUI_CharPtr GetAccessibilityDescription(ArkUINodeHandle node)
4868 {
4869     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4870     CHECK_NULL_RETURN(frameNode, nullptr);
4871     g_strValue = ViewAbstractModelNG::GetAccessibilityDescription(frameNode);
4872     return g_strValue.c_str();
4873 }
4874 
GetAccessibilityLevel(ArkUINodeHandle node)4875 ArkUI_CharPtr GetAccessibilityLevel(ArkUINodeHandle node)
4876 {
4877     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4878     CHECK_NULL_RETURN(frameNode, nullptr);
4879     g_strValue = ViewAbstractModelNG::GetAccessibilityImportance(frameNode);
4880     return g_strValue.c_str();
4881 }
4882 
SetNeedFocus(ArkUINodeHandle node,ArkUI_Bool value)4883 void SetNeedFocus(ArkUINodeHandle node, ArkUI_Bool value)
4884 {
4885     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4886     CHECK_NULL_VOID(frameNode);
4887     ViewAbstract::SetNeedFocus(frameNode, value);
4888 }
4889 
GetNeedFocus(ArkUINodeHandle node)4890 ArkUI_Bool GetNeedFocus(ArkUINodeHandle node)
4891 {
4892     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4893     CHECK_NULL_RETURN(frameNode, false);
4894     return static_cast<ArkUI_Bool>(ViewAbstract::GetNeedFocus(frameNode));
4895 }
4896 
SetBlendMode(ArkUINodeHandle node,int32_t blendMode,ArkUI_Int32 blendApplyTypeValue)4897 void SetBlendMode(ArkUINodeHandle node, int32_t blendMode, ArkUI_Int32 blendApplyTypeValue)
4898 {
4899     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4900     CHECK_NULL_VOID(frameNode);
4901     ViewAbstractModelNG::SetBlendMode(frameNode, static_cast<OHOS::Ace::BlendMode>(blendMode));
4902     ViewAbstractModelNG::SetBlendApplyType(frameNode, static_cast<OHOS::Ace::BlendApplyType>(blendApplyTypeValue));
4903 }
4904 
ResetBlendMode(ArkUINodeHandle node)4905 void ResetBlendMode(ArkUINodeHandle node)
4906 {
4907     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4908     CHECK_NULL_VOID(frameNode);
4909     ViewAbstractModelNG::SetBlendMode(frameNode, OHOS::Ace::BlendMode::NONE);
4910     ViewAbstractModelNG::SetBlendApplyType(frameNode, OHOS::Ace::BlendApplyType::FAST);
4911 }
4912 
SetMonopolizeEvents(ArkUINodeHandle node,ArkUI_Bool value)4913 void SetMonopolizeEvents(ArkUINodeHandle node, ArkUI_Bool value)
4914 {
4915     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4916     CHECK_NULL_VOID(frameNode);
4917     ViewAbstractModelNG::SetMonopolizeEvents(frameNode, value);
4918 }
4919 
ResetMonopolizeEvents(ArkUINodeHandle node)4920 void ResetMonopolizeEvents(ArkUINodeHandle node)
4921 {
4922     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4923     CHECK_NULL_VOID(frameNode);
4924     ViewAbstractModelNG::SetMonopolizeEvents(frameNode, false);
4925 }
4926 
SetConstraintSize(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units)4927 void SetConstraintSize(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units)
4928 {
4929     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4930     CHECK_NULL_VOID(frameNode);
4931     ViewAbstract::SetMinWidth(frameNode, CalcLength(values[NUM_0], static_cast<DimensionUnit>(units[NUM_0])));
4932     ViewAbstract::SetMaxWidth(frameNode, CalcLength(values[NUM_1], static_cast<DimensionUnit>(units[NUM_1])));
4933     ViewAbstract::SetMinHeight(frameNode, CalcLength(values[NUM_2], static_cast<DimensionUnit>(units[NUM_2])));
4934     ViewAbstract::SetMaxHeight(frameNode, CalcLength(values[NUM_3], static_cast<DimensionUnit>(units[NUM_3])));
4935 }
4936 
ResetConstraintSize(ArkUINodeHandle node)4937 void ResetConstraintSize(ArkUINodeHandle node)
4938 {
4939     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4940     CHECK_NULL_VOID(frameNode);
4941     ViewAbstract::ResetMaxSize(frameNode, true);
4942     ViewAbstract::ResetMinSize(frameNode, true);
4943     ViewAbstract::ResetMaxSize(frameNode, false);
4944     ViewAbstract::ResetMinSize(frameNode, false);
4945 }
4946 
BindCustomPopup(FrameNode * frameNode,ArkUIPopupParam * value,UINode * customNode)4947 void BindCustomPopup(FrameNode* frameNode, ArkUIPopupParam* value, UINode* customNode)
4948 {
4949     auto popupParam = AceType::MakeRefPtr<PopupParam>();
4950     std::function<void(bool)> onStateChangeFunc =
4951         (value->onStateChange == nullptr) ? std::function<void(bool)>([](bool) -> void {})
4952         : ([stateChangeCallBack = value->onStateChange, id = value->onStateChangeId](bool input) -> void {
4953             stateChangeCallBack(id, input);
4954         });
4955     auto onStateChangeCallback = [onStateChangeFunc](const std::string& param) {
4956         auto paramData = JsonUtil::ParseJsonString(param);
4957         onStateChangeFunc(paramData->GetBool("isVisible"));
4958     };
4959 
4960     popupParam->SetIsShow(value->isShow);
4961     popupParam->SetUseCustomComponent(value->useCustomComponent);
4962     popupParam->SetPlacement(static_cast<Placement>(value->placement));
4963     popupParam->SetMaskColor(Color(value->maskColor));
4964     popupParam->SetBackgroundColor(Color(value->backgroundColor));
4965     popupParam->SetEnableArrow(value->enableArrow);
4966     popupParam->SetHasAction(!value->autoCancel);
4967     popupParam->SetOnStateChange(onStateChangeCallback);
4968     if (popupParam->IsShow()) {
4969         ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode),
4970             AceType::Claim(customNode));
4971     } else {
4972         ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
4973     }
4974 }
4975 
BindBasePopup(FrameNode * frameNode,ArkUIPopupParam * value)4976 void BindBasePopup(FrameNode* frameNode, ArkUIPopupParam* value)
4977 {
4978     auto popupParam = AceType::MakeRefPtr<PopupParam>();
4979 
4980     std::function<void(bool)> onStateChangeFunc =
4981         (value->onStateChange == nullptr) ? std::function<void(bool)>([](bool) -> void {})
4982         : ([stateChangeCallBack = value->onStateChange, id = value->onStateChangeId](bool input) -> void {
4983             stateChangeCallBack(id, input);
4984         });
4985     std::function<void()> primaryActionFunc =
4986         (value->primaryAction == nullptr) ? std::function<void()>([]() -> void {})
4987         : ([primaryActionCallBack = value->primaryAction, id = value->primaryActionId]() -> void {
4988             primaryActionCallBack(id);
4989         });
4990     std::function<void()> secondaryActionFunc =
4991         (value->secondaryAction == nullptr) ? std::function<void()>([]() -> void {})
4992         : ([secondaryActionCallBack = value->secondaryAction, id = value->secondaryActionId]() -> void {
4993             secondaryActionCallBack(id);
4994         });
4995     auto onStateChangeCallback = [onStateChangeFunc](const std::string& param) {
4996         auto paramData = JsonUtil::ParseJsonString(param);
4997         onStateChangeFunc(paramData->GetBool("isVisible"));
4998     };
4999     popupParam->SetIsShow(value->isShow);
5000     popupParam->SetMessage(value->message);
5001     popupParam->SetPlacement(static_cast<Placement>(value->placement));
5002     popupParam->SetOnStateChange(onStateChangeCallback);
5003     std::string primaryString = value->primaryString;
5004     if (!primaryString.empty()) {
5005         ButtonProperties propertiesPrimary;
5006         propertiesPrimary.value = primaryString;
5007         auto touchPrimaryCallback = [primaryActionFunc](TouchEventInfo&) {primaryActionFunc();};
5008         auto onNewClick = [primaryActionFunc](const GestureEvent& info) {primaryActionFunc();};
5009         propertiesPrimary.touchFunc = touchPrimaryCallback;
5010         propertiesPrimary.action = AceType::MakeRefPtr<NG::ClickEvent>(onNewClick);
5011         propertiesPrimary.showButton = true;
5012         popupParam->SetPrimaryButtonProperties(propertiesPrimary);
5013     }
5014 
5015     std::string secondaryString = value->secondaryString;
5016     if (!secondaryString.empty()) {
5017         ButtonProperties propertiesSecondary;
5018         propertiesSecondary.value = secondaryString;
5019         auto touchSecondaryCallback = [secondaryActionFunc](TouchEventInfo&) {secondaryActionFunc();};
5020         auto onNewClick = [secondaryActionFunc](const GestureEvent& info) {secondaryActionFunc();};
5021         propertiesSecondary.touchFunc = touchSecondaryCallback;
5022         propertiesSecondary.action = AceType::MakeRefPtr<NG::ClickEvent>(onNewClick);
5023         propertiesSecondary.showButton = true;
5024         popupParam->SetSecondaryButtonProperties(propertiesSecondary);
5025     }
5026     ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
5027 }
5028 
SetBindPopup(ArkUINodeHandle node,ArkUIPopupParam * value,ArkUINodeHandle customNode)5029 void SetBindPopup(ArkUINodeHandle node, ArkUIPopupParam* value, ArkUINodeHandle customNode)
5030 {
5031     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5032     CHECK_NULL_VOID(frameNode);
5033 
5034     if (customNode != nullptr) {
5035         BindCustomPopup(frameNode, value, reinterpret_cast<UINode*>(customNode));
5036     } else {
5037         BindBasePopup(frameNode, value);
5038     }
5039 }
5040 
ResetBindPopup(ArkUINodeHandle node)5041 void ResetBindPopup(ArkUINodeHandle node)
5042 {
5043     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5044     CHECK_NULL_VOID(frameNode);
5045     auto popupParam = AceType::MakeRefPtr<PopupParam>();
5046     popupParam->SetIsShow(false);
5047     ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
5048 }
5049 
GetOpacity(ArkUINodeHandle node)5050 ArkUI_Float32 GetOpacity(ArkUINodeHandle node)
5051 {
5052     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5053     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5054     return ViewAbstract::GetOpacity(frameNode);
5055 }
5056 
GetBorderWidth(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 unit)5057 void GetBorderWidth(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 unit)
5058 {
5059     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5060     CHECK_NULL_VOID(frameNode);
5061     auto width = ViewAbstract::GetBorderWidth(frameNode);
5062     (*values)[NUM_0] = width.topDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5063     (*values)[NUM_1] = width.rightDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5064     (*values)[NUM_2] = width.bottomDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5065     (*values)[NUM_3] = width.leftDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5066 }
5067 
GetBorderWidthDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5068 void GetBorderWidthDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5069 {
5070     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5071     CHECK_NULL_VOID(frameNode);
5072     auto borderWidth = ViewAbstract::GetLayoutBorderWidth(frameNode);
5073     (*values)[NUM_0] = borderWidth.topDimen->Value();
5074     (*units)[NUM_0] = static_cast<ArkUI_Int32>(borderWidth.topDimen->Unit());
5075     (*values)[NUM_1] = borderWidth.rightDimen->Value();
5076     (*units)[NUM_1] = static_cast<ArkUI_Int32>(borderWidth.rightDimen->Unit());
5077     (*values)[NUM_2] = borderWidth.bottomDimen->Value();
5078     (*units)[NUM_2] = static_cast<ArkUI_Int32>(borderWidth.bottomDimen->Unit());
5079     (*values)[NUM_3] = borderWidth.leftDimen->Value();
5080     (*units)[NUM_3] = static_cast<ArkUI_Int32>(borderWidth.leftDimen->Unit());
5081 }
5082 
GetBorderRadius(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 unit)5083 void GetBorderRadius(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 unit)
5084 {
5085     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5086     CHECK_NULL_VOID(frameNode);
5087     auto radius = ViewAbstract::GetBorderRadius(frameNode);
5088     (*values)[NUM_0] = radius.radiusTopLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
5089     (*values)[NUM_1] = radius.radiusTopRight->GetNativeValue(static_cast<DimensionUnit>(unit));
5090     (*values)[NUM_2] = radius.radiusBottomLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
5091     (*values)[NUM_3] = radius.radiusBottomRight->GetNativeValue(static_cast<DimensionUnit>(unit));
5092 }
5093 
GetBorderColor(ArkUINodeHandle node,ArkUI_Uint32 (* values)[4])5094 void GetBorderColor(ArkUINodeHandle node, ArkUI_Uint32 (*values)[4])
5095 {
5096     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5097     CHECK_NULL_VOID(frameNode);
5098     auto colors = ViewAbstract::GetBorderColor(frameNode);
5099     (*values)[NUM_0] = colors.topColor->GetValue();
5100     (*values)[NUM_1] = colors.rightColor->GetValue();
5101     (*values)[NUM_2] = colors.bottomColor->GetValue();
5102     (*values)[NUM_3] = colors.leftColor->GetValue();
5103 }
5104 
GetBorderStyle(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5105 void GetBorderStyle(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5106 {
5107     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5108     CHECK_NULL_VOID(frameNode);
5109     auto styles = ViewAbstract::GetBorderStyle(frameNode);
5110     (*values)[NUM_0] = static_cast<ArkUI_Int32>(styles.styleTop.value());
5111     (*values)[NUM_1] = static_cast<ArkUI_Int32>(styles.styleRight.value());
5112     (*values)[NUM_2] = static_cast<ArkUI_Int32>(styles.styleBottom.value());
5113     (*values)[NUM_3] = static_cast<ArkUI_Int32>(styles.styleLeft.value());
5114 }
5115 
GetZIndex(ArkUINodeHandle node)5116 ArkUI_Int32 GetZIndex(ArkUINodeHandle node)
5117 {
5118     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5119     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5120     return ViewAbstract::GetZIndex(frameNode);
5121 }
5122 
GetVisibility(ArkUINodeHandle node)5123 ArkUI_Int32 GetVisibility(ArkUINodeHandle node)
5124 {
5125     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5126     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5127     return static_cast<ArkUI_Int32>(ViewAbstract::GetVisibility(frameNode));
5128 }
5129 
GetClip(ArkUINodeHandle node)5130 ArkUI_Int32 GetClip(ArkUINodeHandle node)
5131 {
5132     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5133     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5134     return static_cast<ArkUI_Int32>(ViewAbstract::GetClip(frameNode));
5135 }
5136 
GetClipShape(ArkUINodeHandle node,ArkUIClipShapeOptions * options,ArkUI_Int32 unit)5137 void GetClipShape(ArkUINodeHandle node, ArkUIClipShapeOptions* options, ArkUI_Int32 unit)
5138 {
5139     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5140     CHECK_NULL_VOID(frameNode);
5141     auto basicShape = ViewAbstract::GetClipShape(frameNode);
5142     options->width = basicShape->GetWidth().GetNativeValue(static_cast<DimensionUnit>(unit));
5143     options->height = basicShape->GetHeight().GetNativeValue(static_cast<DimensionUnit>(unit));
5144     options->type = static_cast<ArkUI_Int32>(basicShape->GetBasicShapeType());
5145     switch (basicShape->GetBasicShapeType()) {
5146         case BasicShapeType::PATH: {
5147             auto path = AceType::DynamicCast<Path>(basicShape);
5148             options->commands = path->GetValue().c_str();
5149             break;
5150         }
5151         case BasicShapeType::RECT: {
5152             auto shapeRect = AceType::DynamicCast<ShapeRect>(basicShape);
5153             //radiusWidth
5154             options->radiusWidth =
5155                 shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5156             //radiusHeight
5157             options->radiusHeight =
5158                 shapeRect->GetTopLeftRadius().GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5159             //topLeftRadius
5160             options->topLeftRadius =
5161                 shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5162             //bottomLeftRadius
5163             options->bottomLeftRadius =
5164                 shapeRect->GetBottomLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5165             //topRightRadius
5166             options->topRightRadius =
5167                 shapeRect->GetTopRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5168             //bottomRightRadius
5169             options->bottomRightRadius =
5170                 shapeRect->GetBottomRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5171             break;
5172         }
5173         default:
5174             break;
5175     }
5176 }
5177 
GetTransform(ArkUINodeHandle node,ArkUI_Float32 (* values)[16])5178 void GetTransform(ArkUINodeHandle node, ArkUI_Float32 (*values)[16])
5179 {
5180     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5181     CHECK_NULL_VOID(frameNode);
5182     auto transforms = ViewAbstract::GetTransform(frameNode);
5183     for (int i = 0; i < NUM_16; i++) {
5184         (*values)[i] = transforms[i];
5185     }
5186 }
5187 
GetHitTestBehavior(ArkUINodeHandle node)5188 ArkUI_Int32 GetHitTestBehavior(ArkUINodeHandle node)
5189 {
5190     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5191     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5192     return static_cast<ArkUI_Int32>(ViewAbstract::GetHitTestBehavior(frameNode));
5193 }
5194 
GetPosition(ArkUINodeHandle node,ArkUIPositionOptions * values,ArkUI_Int32 unit)5195 void GetPosition(ArkUINodeHandle node, ArkUIPositionOptions* values, ArkUI_Int32 unit)
5196 {
5197     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5198     CHECK_NULL_VOID(frameNode);
5199     auto positions = ViewAbstract::GetPosition(frameNode);
5200     values->x = positions.GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5201     values->y = positions.GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5202 }
5203 
GetShadow(ArkUINodeHandle node)5204 ArkUI_Int32 GetShadow(ArkUINodeHandle node)
5205 {
5206     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5207     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5208     int style = static_cast<ArkUI_Int32>(ViewAbstract::GetShadow(frameNode)->GetStyle());
5209     return style;
5210 }
5211 
GetCustomShadow(ArkUINodeHandle node,ArkUICustomShadowOptions * options)5212 void GetCustomShadow(ArkUINodeHandle node, ArkUICustomShadowOptions* options)
5213 {
5214     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5215     CHECK_NULL_VOID(frameNode);
5216     auto shadow = ViewAbstract::GetShadow(frameNode);
5217     options->color = shadow->GetColor().GetValue();
5218     options->shadowType = static_cast<ArkUI_Int32>(shadow->GetShadowType());
5219     options->colorStrategy = static_cast<ArkUI_Int32>(shadow->GetShadowColorStrategy());
5220     options->offsetX = shadow->GetOffset().GetX();
5221     options->offsetY = shadow->GetOffset().GetY();
5222     options->radius = shadow->GetBlurRadius();
5223     options->fill = static_cast<ArkUI_Int32>(shadow->GetIsFilled());
5224 }
5225 
GetSweepGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[6],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stops)[10],ArkUI_Int32 unit)5226 ArkUI_Int32 GetSweepGradient(ArkUINodeHandle node, ArkUI_Float32 (*values)[6], ArkUI_Uint32 (*colors)[10],
5227     ArkUI_Float32 (*stops)[10], ArkUI_Int32 unit)
5228 {
5229     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5230     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5231     auto gradient = ViewAbstract::GetSweepGradient(frameNode);
5232     auto sweepGradient = gradient.GetSweepGradient();
5233 
5234     (*values)[NUM_0] = sweepGradient->centerX->GetNativeValue(static_cast<DimensionUnit>(unit));
5235     (*values)[NUM_1] = sweepGradient->centerY->GetNativeValue(static_cast<DimensionUnit>(unit));
5236     (*values)[NUM_2] = sweepGradient->startAngle->Value();
5237     (*values)[NUM_3] = sweepGradient->endAngle->Value();
5238     (*values)[NUM_4] = sweepGradient->rotation->Value();
5239     (*values)[NUM_5] = gradient.GetRepeat();
5240 
5241     std::vector<GradientColor> gradientColors = gradient.GetColors();
5242     //0 start index
5243     int index = 0;
5244     for (auto& gradientColor : gradientColors) {
5245         (*colors)[index] = gradientColor.GetColor().GetValue();
5246         (*stops)[index] = gradientColor.GetDimension().Value();
5247         index++;
5248     }
5249     return index;
5250 }
5251 
GetRadialGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stops)[10],ArkUI_Int32 unit)5252 ArkUI_Int32 GetRadialGradient(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Uint32 (*colors)[10],
5253     ArkUI_Float32 (*stops)[10], ArkUI_Int32 unit)
5254 {
5255     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5256     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5257     auto gradient = ViewAbstract::GetRadialGradient(frameNode);
5258     auto radialGradient = gradient.GetRadialGradient();
5259 
5260     CHECK_NULL_RETURN(radialGradient, ERROR_INT_CODE);
5261     (*values)[NUM_0] = radialGradient->radialCenterX->GetNativeValue(static_cast<DimensionUnit>(unit));
5262     (*values)[NUM_1] = radialGradient->radialCenterY->GetNativeValue(static_cast<DimensionUnit>(unit));
5263     (*values)[NUM_2] =
5264         gradient.GetRadialGradient()->radialHorizontalSize->GetNativeValue(static_cast<DimensionUnit>(unit));
5265     (*values)[NUM_3] = gradient.GetRepeat();
5266 
5267     std::vector<GradientColor> gradientColors = gradient.GetColors();
5268     //0 start index
5269     int index = 0;
5270     for (auto& gradientColor : gradientColors) {
5271         (*colors)[index] = gradientColor.GetColor().GetValue();
5272         (*stops)[index] = gradientColor.GetDimension().Value();
5273         index++;
5274     }
5275     return index;
5276 }
5277 
GetMask(ArkUINodeHandle node,ArkUIMaskOptions * options,ArkUI_Int32 unit)5278 void GetMask(ArkUINodeHandle node, ArkUIMaskOptions* options, ArkUI_Int32 unit)
5279 {
5280     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5281     CHECK_NULL_VOID(frameNode);
5282     auto basicShape = ViewAbstract::GetMask(frameNode);
5283     if (basicShape == nullptr) {
5284         auto process = ViewAbstract::GetMaskProgress(frameNode);
5285         CHECK_NULL_VOID(process);
5286         options->type = static_cast<ArkUI_Int32>(ArkUI_MaskType::ARKUI_MASK_TYPE_PROGRESS);
5287         options->value = process->GetValue();
5288         options->color = process->GetColor().GetValue();
5289         options->maxValue = process->GetMaxValue();
5290         return;
5291     }
5292     options->type = static_cast<ArkUI_Int32>(basicShape->GetBasicShapeType());
5293     options->fill = basicShape->GetColor().GetValue();
5294     options->strokeColor = basicShape->GetStrokeColor();
5295     options->strokeWidth = basicShape->GetStrokeWidth();
5296     options->width = basicShape->GetWidth().GetNativeValue(static_cast<DimensionUnit>(unit));
5297     options->height = basicShape->GetHeight().GetNativeValue(static_cast<DimensionUnit>(unit));
5298     if (basicShape->GetBasicShapeType() == BasicShapeType::PATH) {
5299         auto path = AceType::DynamicCast<Path>(basicShape);
5300         options->commands = path->GetValue().c_str();
5301     } else if (basicShape->GetBasicShapeType() == BasicShapeType::RECT) {
5302         auto shapeRect = AceType::DynamicCast<ShapeRect>(basicShape);
5303         options->radiusWidth =
5304             shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5305         options->radiusHeight =
5306             shapeRect->GetTopLeftRadius().GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5307         options->topLeftRadius =
5308             shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5309         options->bottomLeftRadius =
5310             shapeRect->GetBottomLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5311         options->topRightRadius =
5312             shapeRect->GetTopRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5313         options->bottomRightRadius =
5314             shapeRect->GetBottomRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5315     }
5316 }
5317 
GetBlendMode(ArkUINodeHandle node,ArkUIBlendModeOptions * options)5318 void GetBlendMode(ArkUINodeHandle node, ArkUIBlendModeOptions* options)
5319 {
5320     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5321     CHECK_NULL_VOID(frameNode);
5322     options->blendMode = static_cast<ArkUI_Int32>(ViewAbstract::GetBlendMode(frameNode));
5323     options->blendApplyType = static_cast<ArkUI_Int32>(ViewAbstract::GetBlendApplyType(frameNode));
5324 }
5325 
GetDirection(ArkUINodeHandle node)5326 ArkUI_Int32 GetDirection(ArkUINodeHandle node)
5327 {
5328     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5329     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5330     int direction = static_cast<ArkUI_Int32>(ViewAbstract::GetDirection(frameNode));
5331     return direction;
5332 }
5333 
GetAlignSelf(ArkUINodeHandle node)5334 ArkUI_Int32 GetAlignSelf(ArkUINodeHandle node)
5335 {
5336     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5337     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5338     int alignSelf = static_cast<ArkUI_Int32>(ViewAbstract::GetAlignSelf(frameNode));
5339     return alignSelf;
5340 }
5341 
GetFlexGrow(ArkUINodeHandle node)5342 ArkUI_Float32 GetFlexGrow(ArkUINodeHandle node)
5343 {
5344     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5345     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5346     return ViewAbstract::GetFlexGrow(frameNode);
5347 }
5348 
GetFlexShrink(ArkUINodeHandle node)5349 ArkUI_Float32 GetFlexShrink(ArkUINodeHandle node)
5350 {
5351     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5352     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5353     return ViewAbstract::GetFlexShrink(frameNode);
5354 }
5355 
GetFlexBasis(ArkUINodeHandle node)5356 ArkUI_Float32 GetFlexBasis(ArkUINodeHandle node)
5357 {
5358     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5359     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5360     return ViewAbstract::GetFlexBasis(frameNode).Value();
5361 }
5362 
GetConstraintSize(ArkUINodeHandle node,ArkUIConstraintSizeOptions * options,ArkUI_Int32 unit)5363 void GetConstraintSize(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options, ArkUI_Int32 unit)
5364 {
5365     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5366     CHECK_NULL_VOID(frameNode);
5367     options->minWidth = ViewAbstract::GetMinWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5368     options->maxWidth = ViewAbstract::GetMaxWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5369     options->minHeight = ViewAbstract::GetMinHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5370     options->maxHeight = ViewAbstract::GetMaxHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5371 }
5372 
GetGrayScale(ArkUINodeHandle node)5373 ArkUI_Float32 GetGrayScale(ArkUINodeHandle node)
5374 {
5375     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5376     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5377     return ViewAbstract::GetGrayScale(frameNode).Value();
5378 }
5379 
GetInvert(ArkUINodeHandle node)5380 ArkUI_Float32 GetInvert(ArkUINodeHandle node)
5381 {
5382     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5383     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5384     return std::get<float>(ViewAbstract::GetInvert(frameNode));
5385 }
5386 
GetSepia(ArkUINodeHandle node)5387 ArkUI_Float32 GetSepia(ArkUINodeHandle node)
5388 {
5389     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5390     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5391     return ViewAbstract::GetSepia(frameNode).Value();
5392 }
5393 
GetContrast(ArkUINodeHandle node)5394 ArkUI_Float32 GetContrast(ArkUINodeHandle node)
5395 {
5396     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5397     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5398     return ViewAbstract::GetContrast(frameNode).Value();
5399 }
5400 
GetForegroundColor(ArkUINodeHandle node)5401 ArkUI_Uint32 GetForegroundColor(ArkUINodeHandle node)
5402 {
5403     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5404     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5405     return ViewAbstract::GetForegroundColor(frameNode).GetValue();
5406 }
5407 
GetBlur(ArkUINodeHandle node)5408 ArkUI_Float32 GetBlur(ArkUINodeHandle node)
5409 {
5410     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5411     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5412     return ViewAbstract::GetFrontBlur(frameNode).Value();
5413 }
5414 
GetLinearGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[3],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stop)[10])5415 ArkUI_Int32 GetLinearGradient(
5416     ArkUINodeHandle node, ArkUI_Float32 (*values)[3], ArkUI_Uint32 (*colors)[10], ArkUI_Float32 (*stop)[10])
5417 {
5418     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5419     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5420     auto gradient = ViewAbstract::GetLinearGradient(frameNode);
5421     auto angle = gradient.GetLinearGradient()->angle;
5422     //0 angle
5423     (*values)[0] = angle.has_value() ? angle.value().Value() : DEFAULT_ANGLE;
5424     //1 Direction
5425     (*values)[1] = static_cast<int32_t>(convertToLinearGradientDirection(gradient.GetLinearGradient()));
5426     //2 Repeat
5427     (*values)[2] = gradient.GetRepeat();
5428 
5429     std::vector<GradientColor> gradientColors = gradient.GetColors();
5430     //0 start index
5431     int index = 0;
5432     for (auto& gradientColor : gradientColors) {
5433         (*colors)[index] = gradientColor.GetColor().GetValue();
5434         (*stop)[index] = gradientColor.GetDimension().Value();
5435         index++;
5436     }
5437     return index;
5438 }
5439 
GetAlign(ArkUINodeHandle node)5440 ArkUI_Int32 GetAlign(ArkUINodeHandle node)
5441 {
5442     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5443     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5444     return ConvertAlignmentToInt(ViewAbstract::GetAlign(frameNode));
5445 }
5446 
GetWidth(ArkUINodeHandle node,ArkUI_Int32 unit)5447 ArkUI_Float32 GetWidth(ArkUINodeHandle node, ArkUI_Int32 unit)
5448 {
5449     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5450     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5451     return ViewAbstract::GetWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5452 }
5453 
GetHeight(ArkUINodeHandle node,ArkUI_Int32 unit)5454 ArkUI_Float32 GetHeight(ArkUINodeHandle node, ArkUI_Int32 unit)
5455 {
5456     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5457     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5458     return ViewAbstract::GetHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5459 }
5460 
GetBackgroundColor(ArkUINodeHandle node)5461 ArkUI_Uint32 GetBackgroundColor(ArkUINodeHandle node)
5462 {
5463     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5464     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5465     return ViewAbstract::GetBackgroundColor(frameNode).GetValue();
5466 }
5467 
GetBackgroundImage(ArkUINodeHandle node,ArkUIBackgroundImage * options)5468 void GetBackgroundImage(ArkUINodeHandle node, ArkUIBackgroundImage* options)
5469 {
5470     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5471     CHECK_NULL_VOID(frameNode);
5472     g_strValue = ViewAbstract::GetBackgroundImageSrc(frameNode);
5473     options->src = g_strValue.c_str();
5474     options->repeat = static_cast<int>(ViewAbstract::GetBackgroundImageRepeat(frameNode));
5475 }
5476 
GetPadding(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 length,ArkUI_Int32 unit)5477 void GetPadding(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 length, ArkUI_Int32 unit)
5478 {
5479     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5480     CHECK_NULL_VOID(frameNode);
5481     auto padding = ViewAbstract::GetPadding(frameNode);
5482     (*values)[NUM_0] = padding.top->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5483     (*values)[NUM_1] = padding.right->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5484     (*values)[NUM_2] = padding.bottom->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5485     (*values)[NUM_3] = padding.left->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5486     length = NUM_4;
5487 }
5488 
GetPaddingDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5489 void GetPaddingDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5490 {
5491     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5492     CHECK_NULL_VOID(frameNode);
5493     auto padding = ViewAbstract::GetPadding(frameNode);
5494     (*values)[NUM_0] = padding.top->GetDimension().Value();
5495     (*units)[NUM_0] = static_cast<ArkUI_Int32>(padding.top->GetDimension().Unit());
5496     (*values)[NUM_1] = padding.right->GetDimension().Value();
5497     (*units)[NUM_1] = static_cast<ArkUI_Int32>(padding.right->GetDimension().Unit());
5498     (*values)[NUM_2] = padding.bottom->GetDimension().Value();
5499     (*units)[NUM_2] = static_cast<ArkUI_Int32>(padding.bottom->GetDimension().Unit());
5500     (*values)[NUM_3] = padding.left->GetDimension().Value();
5501     (*units)[NUM_3] = static_cast<ArkUI_Int32>(padding.left->GetDimension().Unit());
5502 }
5503 
GetConfigSize(ArkUINodeHandle node,ArkUI_Float32 (* values)[2],ArkUI_Int32 (* units)[2])5504 void GetConfigSize(ArkUINodeHandle node, ArkUI_Float32 (*values)[2], ArkUI_Int32 (*units)[2])
5505 {
5506     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5507     CHECK_NULL_VOID(frameNode);
5508     auto size = ViewAbstract::GetConfigSize(frameNode);
5509     (*values)[NUM_0] = size->Width()->GetDimension().Value();
5510     (*units)[NUM_0] = static_cast<ArkUI_Int32>(size->Width()->GetDimension().Unit());
5511     (*values)[NUM_1] = size->Height()->GetDimension().Value();
5512     (*units)[NUM_1] = static_cast<ArkUI_Int32>(size->Height()->GetDimension().Unit());
5513 }
5514 
GetKey(ArkUINodeHandle node)5515 ArkUI_CharPtr GetKey(ArkUINodeHandle node)
5516 {
5517     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5518     CHECK_NULL_RETURN(frameNode, nullptr);
5519     g_strValue = ViewAbstract::GetKey(frameNode);
5520     return g_strValue.c_str();
5521 }
5522 
GetEnabled(ArkUINodeHandle node)5523 int GetEnabled(ArkUINodeHandle node)
5524 {
5525     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5526     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5527     return static_cast<ArkUI_Int32>(ViewAbstract::GetEnabled(frameNode));
5528 }
5529 
GetMargin(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 length,ArkUI_Int32 unit)5530 void GetMargin(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 length, ArkUI_Int32 unit)
5531 {
5532     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5533     CHECK_NULL_VOID(frameNode);
5534     auto margin = ViewAbstract::GetMargin(frameNode);
5535     (*values)[NUM_0] = margin.top->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5536     (*values)[NUM_1] = margin.right->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5537     (*values)[NUM_2] = margin.bottom->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5538     (*values)[NUM_3] = margin.left->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5539     length = NUM_4;
5540 }
5541 
GetMarginDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5542 void GetMarginDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5543 {
5544     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5545     CHECK_NULL_VOID(frameNode);
5546     auto margin = ViewAbstract::GetMargin(frameNode);
5547     (*values)[NUM_0] = margin.top->GetDimension().Value();
5548     (*units)[NUM_0] = static_cast<ArkUI_Int32>(margin.top->GetDimension().Unit());
5549     (*values)[NUM_1] = margin.right->GetDimension().Value();
5550     (*units)[NUM_1] = static_cast<ArkUI_Int32>(margin.right->GetDimension().Unit());
5551     (*values)[NUM_2] = margin.bottom->GetDimension().Value();
5552     (*units)[NUM_2] = static_cast<ArkUI_Int32>(margin.bottom->GetDimension().Unit());
5553     (*values)[NUM_3] = margin.left->GetDimension().Value();
5554     (*units)[NUM_3] = static_cast<ArkUI_Int32>(margin.left->GetDimension().Unit());
5555 }
5556 
GetTranslate(ArkUINodeHandle node,ArkUI_Float32 (* values)[3],ArkUI_Int32 unit)5557 void GetTranslate(ArkUINodeHandle node, ArkUI_Float32 (*values)[3], ArkUI_Int32 unit)
5558 {
5559     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5560     CHECK_NULL_VOID(frameNode);
5561     auto translate = ViewAbstract::GetTranslate(frameNode);
5562     (*values)[NUM_0] = translate.x.GetNativeValue(static_cast<DimensionUnit>(unit));
5563     (*values)[NUM_1] = translate.y.GetNativeValue(static_cast<DimensionUnit>(unit));
5564     (*values)[NUM_2] = translate.z.GetNativeValue(static_cast<DimensionUnit>(unit));
5565 }
5566 
GetAspectRatio(ArkUINodeHandle node)5567 ArkUI_Float32 GetAspectRatio(ArkUINodeHandle node)
5568 {
5569     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5570     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5571     return ViewAbstract::GetAspectRatio(frameNode);
5572 }
5573 
SetBackgroundImageSizeWithUnit(ArkUINodeHandle node,ArkUI_Float32 valueWidth,ArkUI_Float32 valueHeight,ArkUI_Int32 unit)5574 void SetBackgroundImageSizeWithUnit(
5575     ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight, ArkUI_Int32 unit)
5576 {
5577     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5578     CHECK_NULL_VOID(frameNode);
5579     BackgroundImageSize bgImgSize;
5580     CalcDimension width(valueWidth, static_cast<DimensionUnit>(unit));
5581     CalcDimension height(valueHeight, static_cast<DimensionUnit>(unit));
5582     bgImgSize.SetSizeTypeX(OHOS::Ace::BackgroundImageSizeType::LENGTH);
5583     bgImgSize.SetSizeValueX(width.GetNativeValue(DimensionUnit::PX));
5584     bgImgSize.SetSizeTypeY(OHOS::Ace::BackgroundImageSizeType::LENGTH);
5585     bgImgSize.SetSizeValueY(height.GetNativeValue(DimensionUnit::PX));
5586     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
5587 }
5588 
SetChainStyle(ArkUINodeHandle node,ArkUI_Int32 direction,ArkUI_Int32 style)5589 void SetChainStyle(ArkUINodeHandle node, ArkUI_Int32 direction, ArkUI_Int32 style)
5590 {
5591     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5592     CHECK_NULL_VOID(frameNode);
5593     ChainInfo chainInfo;
5594     chainInfo.direction = static_cast<LineDirection>(direction);
5595     chainInfo.style = static_cast<ChainStyle>(style);
5596     ViewAbstract::SetChainStyle(frameNode, chainInfo);
5597 }
5598 
GetChainStyle(ArkUINodeHandle node,ArkUI_Int32 (* values)[2])5599 void GetChainStyle(ArkUINodeHandle node, ArkUI_Int32 (*values)[2])
5600 {
5601     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5602     CHECK_NULL_VOID(frameNode);
5603     auto chainInfo = ViewAbstract::GetChainStyle(frameNode);
5604     // 0 index is direction
5605     if (chainInfo.direction.has_value()) {
5606         (*values)[0] = static_cast<ArkUI_Int32>(chainInfo.direction.value());
5607     } else {
5608         (*values)[0] = -1;
5609     }
5610     // 1 index is style
5611     if (chainInfo.style.has_value()) {
5612         (*values)[1] = static_cast<ArkUI_Int32>(chainInfo.style.value());
5613     } else {
5614         (*values)[1] = -1;
5615     }
5616 }
5617 
ResetChainStyle(ArkUINodeHandle node)5618 void ResetChainStyle(ArkUINodeHandle node)
5619 {
5620     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5621     CHECK_NULL_VOID(frameNode);
5622     ViewAbstract::ResetChainStyle(frameNode);
5623 }
5624 
SetBias(ArkUINodeHandle node,ArkUI_Float32 horizontal,ArkUI_Float32 vertical)5625 void SetBias(ArkUINodeHandle node, ArkUI_Float32 horizontal, ArkUI_Float32 vertical)
5626 {
5627     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5628     CHECK_NULL_VOID(frameNode);
5629     BiasPair pair1(horizontal, vertical);
5630     ViewAbstract::SetBias(frameNode, pair1);
5631 }
5632 
GetBias(ArkUINodeHandle node,ArkUI_Float32 * values)5633 void GetBias(ArkUINodeHandle node, ArkUI_Float32* values)
5634 {
5635     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5636     CHECK_NULL_VOID(frameNode);
5637     auto bias = ViewAbstract::GetBias(frameNode);
5638     //horizontal
5639     values[0] = bias.first;
5640     //vertical
5641     values[1] = bias.second;
5642 }
5643 
ResetBias(ArkUINodeHandle node)5644 void ResetBias(ArkUINodeHandle node)
5645 {
5646     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5647     CHECK_NULL_VOID(frameNode);
5648     ViewAbstract::ResetBias(frameNode);
5649 }
SetOnVisibleAreaChange(ArkUINodeHandle node,ArkUI_Int64 extraParam,ArkUI_Float32 * values,ArkUI_Int32 size)5650 void SetOnVisibleAreaChange(ArkUINodeHandle node, ArkUI_Int64 extraParam, ArkUI_Float32* values, ArkUI_Int32 size)
5651 {
5652     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5653     CHECK_NULL_VOID(frameNode);
5654     int32_t nodeId = frameNode->GetId();
5655     std::vector<double> ratioList(values, values + size);
5656     auto onEvent = [nodeId, extraParam](bool visible, double ratio) {
5657         ArkUINodeEvent event;
5658         event.kind = COMPONENT_ASYNC_EVENT;
5659         event.nodeId = nodeId;
5660         event.extraParam = static_cast<intptr_t>(extraParam);
5661         event.componentAsyncEvent.subKind = ON_VISIBLE_AREA_CHANGE;
5662         event.componentAsyncEvent.data[0].i32 = visible;
5663         event.componentAsyncEvent.data[1].f32 = static_cast<ArkUI_Float32>(ratio);
5664         SendArkUIAsyncEvent(&event);
5665     };
5666     ViewAbstract::SetOnVisibleChange(frameNode, onEvent, ratioList);
5667 }
5668 
SetLayoutRect(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5669 void SetLayoutRect(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5670 {
5671     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5672     auto rect =
5673         NG::RectF((*values)[0], (*values)[1], (*values)[2], (*values)[3]); // 2:index of width, 3:index of height
5674     ViewAbstract::SetLayoutRect(frameNode, rect);
5675 }
5676 
GetLayoutRect(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5677 void GetLayoutRect(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5678 {
5679     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5680     auto rect = ViewAbstract::GetLayoutRect(frameNode);
5681     (*values)[0] = rect.GetX();
5682     (*values)[1] = rect.GetY();
5683     (*values)[2] = rect.Width(); // 2:index of width
5684     (*values)[3] = rect.Height(); // 3:index of height
5685 }
5686 
ResetLayoutRect(ArkUINodeHandle node)5687 void ResetLayoutRect(ArkUINodeHandle node)
5688 {
5689     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5690     ViewAbstract::ResetLayoutRect(frameNode);
5691 }
5692 
SetSystemBarEffect(ArkUINodeHandle node,ArkUI_Bool enable)5693 void SetSystemBarEffect(ArkUINodeHandle node, ArkUI_Bool enable)
5694 {
5695     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5696     CHECK_NULL_VOID(frameNode);
5697     ViewAbstract::SetSystemBarEffect(frameNode, enable);
5698 }
5699 
SetFocusScopeId(ArkUINodeHandle node,ArkUI_CharPtr id,ArkUI_Bool isGroup,ArkUI_Bool arrowKeyStepOut)5700 void SetFocusScopeId(ArkUINodeHandle node, ArkUI_CharPtr id, ArkUI_Bool isGroup, ArkUI_Bool arrowKeyStepOut)
5701 {
5702     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5703     CHECK_NULL_VOID(frameNode);
5704     std::string idStr = id;
5705     ViewAbstract::SetFocusScopeId(frameNode, idStr, isGroup, arrowKeyStepOut);
5706 }
5707 
ResetFocusScopeId(ArkUINodeHandle node)5708 void ResetFocusScopeId(ArkUINodeHandle node)
5709 {
5710     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5711     CHECK_NULL_VOID(frameNode);
5712     std::string id = "";
5713     bool isGroup = false;
5714     bool arrowKeyStepOut = true;
5715     ViewAbstract::SetFocusScopeId(frameNode, id, isGroup, arrowKeyStepOut);
5716 }
5717 
SetFocusScopePriority(ArkUINodeHandle node,ArkUI_CharPtr scopeId,ArkUI_Int32 priority)5718 void SetFocusScopePriority(ArkUINodeHandle node, ArkUI_CharPtr scopeId, ArkUI_Int32 priority)
5719 {
5720     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5721     CHECK_NULL_VOID(frameNode);
5722     std::string scopeIdStr = scopeId;
5723     ViewAbstract::SetFocusScopePriority(frameNode, scopeIdStr, priority);
5724 }
5725 
ResetFocusScopePriority(ArkUINodeHandle node)5726 void ResetFocusScopePriority(ArkUINodeHandle node)
5727 {
5728     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5729     CHECK_NULL_VOID(frameNode);
5730     std::string scopeId = "";
5731     int32_t priority = 0;
5732     ViewAbstract::SetFocusScopePriority(frameNode, scopeId, priority);
5733 }
5734 
GetAccessibilityID(ArkUINodeHandle node)5735 ArkUI_Int32 GetAccessibilityID(ArkUINodeHandle node)
5736 {
5737     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5738     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5739     ArkUI_Int32 value = frameNode->GetAccessibilityId();
5740     return value;
5741 }
5742 
SetAccessibilityState(ArkUINodeHandle node,const ArkUIAccessibilityState & state)5743 void SetAccessibilityState(ArkUINodeHandle node, const ArkUIAccessibilityState& state)
5744 {
5745     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5746     CHECK_NULL_VOID(frameNode);
5747     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5748     CHECK_NULL_VOID(accessibilityProperty);
5749     if (state.isDisabled.isSet) {
5750         accessibilityProperty->SetUserDisabled(state.isDisabled.value);
5751     }
5752     if (state.isSelected.isSet) {
5753         accessibilityProperty->SetUserSelected(state.isSelected.value);
5754     }
5755     if (state.checkedType.isSet) {
5756         accessibilityProperty->SetUserCheckedType(state.checkedType.value);
5757     }
5758 }
5759 
GetAccessibilityState(ArkUINodeHandle node,ArkUIAccessibilityState & state)5760 void GetAccessibilityState(ArkUINodeHandle node, ArkUIAccessibilityState& state)
5761 {
5762     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5763     CHECK_NULL_VOID(frameNode);
5764     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5765     CHECK_NULL_VOID(accessibilityProperty);
5766     state.isDisabled.isSet = accessibilityProperty->HasUserDisabled();
5767     state.isDisabled.value = accessibilityProperty->IsUserDisabled();
5768     state.isSelected.isSet = accessibilityProperty->HasUserSelected();
5769     state.isSelected.value = accessibilityProperty->IsUserSelected();
5770     state.checkedType.isSet = accessibilityProperty->HasUserCheckedType();
5771     state.checkedType.value = accessibilityProperty->GetUserCheckedType();
5772 }
5773 
ResetAccessibilityState(ArkUINodeHandle node)5774 void ResetAccessibilityState(ArkUINodeHandle node)
5775 {
5776     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5777     CHECK_NULL_VOID(frameNode);
5778     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5779     CHECK_NULL_VOID(accessibilityProperty);
5780     if (accessibilityProperty->HasUserDisabled()) {
5781         accessibilityProperty->SetUserDisabled(false);
5782     }
5783     if (accessibilityProperty->HasUserSelected()) {
5784         accessibilityProperty->SetUserSelected(false);
5785     }
5786     if (accessibilityProperty->HasUserCheckedType()) {
5787         accessibilityProperty->SetUserCheckedType(0);
5788     }
5789 }
5790 
SetAccessibilityValue(ArkUINodeHandle node,const ArkUIAccessibilityValue & value)5791 void SetAccessibilityValue(ArkUINodeHandle node, const ArkUIAccessibilityValue& value)
5792 {
5793     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5794     CHECK_NULL_VOID(frameNode);
5795     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5796     CHECK_NULL_VOID(accessibilityProperty);
5797     if (value.min.isSet) {
5798         accessibilityProperty->SetUserMinValue(value.min.value);
5799     }
5800     if (value.max.isSet) {
5801         accessibilityProperty->SetUserMaxValue(value.max.value);
5802     }
5803     if (value.current.isSet) {
5804         accessibilityProperty->SetUserCurrentValue(value.current.value);
5805     }
5806     if (value.text.isSet) {
5807         accessibilityProperty->SetUserTextValue(value.text.value);
5808     }
5809 }
5810 
GetAccessibilityValue(ArkUINodeHandle node,ArkUIAccessibilityValue & value)5811 void GetAccessibilityValue(ArkUINodeHandle node, ArkUIAccessibilityValue& value)
5812 {
5813     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5814     CHECK_NULL_VOID(frameNode);
5815     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5816     CHECK_NULL_VOID(accessibilityProperty);
5817     value.min.isSet = accessibilityProperty->HasUserMinValue();
5818     value.min.value = accessibilityProperty->GetUserMinValue();
5819     value.max.isSet = accessibilityProperty->HasUserMaxValue();
5820     value.max.value = accessibilityProperty->GetUserMaxValue();
5821     value.current.isSet = accessibilityProperty->HasUserCurrentValue();
5822     value.current.value = accessibilityProperty->GetUserCurrentValue();
5823     value.text.isSet = accessibilityProperty->HasUserTextValue();
5824     g_strValue = accessibilityProperty->GetUserTextValue();
5825     value.text.value = g_strValue.c_str();
5826 }
5827 
ResetAccessibilityValue(ArkUINodeHandle node)5828 void ResetAccessibilityValue(ArkUINodeHandle node)
5829 {
5830     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5831     CHECK_NULL_VOID(frameNode);
5832     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5833     CHECK_NULL_VOID(accessibilityProperty);
5834     if (accessibilityProperty->HasUserMinValue()) {
5835         accessibilityProperty->SetUserMinValue(-1);
5836     }
5837     if (accessibilityProperty->HasUserMaxValue()) {
5838         accessibilityProperty->SetUserMaxValue(-1);
5839     }
5840     if (accessibilityProperty->HasUserCurrentValue()) {
5841         accessibilityProperty->SetUserCurrentValue(-1);
5842     }
5843     if (accessibilityProperty->HasUserTextValue()) {
5844         accessibilityProperty->SetUserTextValue("");
5845     }
5846 }
5847 
SetAccessibilityActions(ArkUINodeHandle node,ArkUI_Uint32 actions)5848 void SetAccessibilityActions(ArkUINodeHandle node, ArkUI_Uint32 actions)
5849 {
5850     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5851     CHECK_NULL_VOID(frameNode);
5852     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5853     accessibilityProperty->SetAccessibilityActions(actions);
5854 }
5855 
ResetAccessibilityActions(ArkUINodeHandle node)5856 void ResetAccessibilityActions(ArkUINodeHandle node)
5857 {
5858     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5859     CHECK_NULL_VOID(frameNode);
5860     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5861     accessibilityProperty->ResetAccessibilityActions();
5862 }
5863 
GetAccessibilityActions(ArkUINodeHandle node)5864 ArkUI_Uint32 GetAccessibilityActions(ArkUINodeHandle node)
5865 {
5866     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5867     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5868     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5869     return accessibilityProperty->GetAccessibilityActions();
5870 }
5871 
SetAccessibilityRole(ArkUINodeHandle node,ArkUI_CharPtr role)5872 void SetAccessibilityRole(ArkUINodeHandle node, ArkUI_CharPtr role)
5873 {
5874     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5875     CHECK_NULL_VOID(frameNode);
5876     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5877     accessibilityProperty->SetAccessibilityRole(std::string(role));
5878 }
5879 
ResetAccessibilityRole(ArkUINodeHandle node)5880 void ResetAccessibilityRole(ArkUINodeHandle node)
5881 {
5882     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5883     CHECK_NULL_VOID(frameNode);
5884     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5885     accessibilityProperty->ResetAccessibilityRole();
5886 }
5887 
GetAccessibilityRole(ArkUINodeHandle node)5888 ArkUI_CharPtr GetAccessibilityRole(ArkUINodeHandle node)
5889 {
5890     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5891     CHECK_NULL_RETURN(frameNode, nullptr);
5892     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5893     g_strValue = accessibilityProperty->GetAccessibilityRole();
5894     return g_strValue.c_str();
5895 }
5896 
ConvertCeilPixelRoundPolicy(ArkUI_Int32 index)5897 PixelRoundPolicy ConvertCeilPixelRoundPolicy(ArkUI_Int32 index)
5898 {
5899     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
5900     switch (index) {
5901         case 0:
5902             ret = PixelRoundPolicy::FORCE_CEIL_START;
5903             break;
5904         case 1:
5905             ret = PixelRoundPolicy::FORCE_CEIL_TOP;
5906             break;
5907         case 2: // 2:index of end
5908             ret = PixelRoundPolicy::FORCE_CEIL_END;
5909             break;
5910         case 3: // 3:index of bottom
5911             ret = PixelRoundPolicy::FORCE_CEIL_BOTTOM;
5912             break;
5913         default:
5914             break;
5915     }
5916     return ret;
5917 }
5918 
ConvertFloorPixelRoundPolicy(ArkUI_Int32 index)5919 PixelRoundPolicy ConvertFloorPixelRoundPolicy(ArkUI_Int32 index)
5920 {
5921     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
5922     switch (index) {
5923         case 0:
5924             ret = PixelRoundPolicy::FORCE_FLOOR_START;
5925             break;
5926         case 1:
5927             ret = PixelRoundPolicy::FORCE_FLOOR_TOP;
5928             break;
5929         case 2: // 2:index of end
5930             ret = PixelRoundPolicy::FORCE_FLOOR_END;
5931             break;
5932         case 3: // 3:index of bottom
5933             ret = PixelRoundPolicy::FORCE_FLOOR_BOTTOM;
5934             break;
5935         default:
5936             break;
5937     }
5938     return ret;
5939 }
5940 
ConvertNoPixelRoundPolicy(ArkUI_Int32 index)5941 PixelRoundPolicy ConvertNoPixelRoundPolicy(ArkUI_Int32 index)
5942 {
5943     switch (index) {
5944         case 0:
5945             return PixelRoundPolicy::NO_FORCE_ROUND_START;
5946         case 1:
5947             return PixelRoundPolicy::NO_FORCE_ROUND_TOP;
5948         case 2: // 2:index of end
5949             return PixelRoundPolicy::NO_FORCE_ROUND_END;
5950         case 3: // 3:index of bottom
5951             return PixelRoundPolicy::NO_FORCE_ROUND_BOTTOM;
5952         default:
5953             return PixelRoundPolicy::ALL_FORCE_ROUND;
5954     }
5955 }
5956 
ConvertPixelRoundPolicy(ArkUI_Int32 value,ArkUI_Int32 index)5957 uint16_t ConvertPixelRoundPolicy(ArkUI_Int32 value, ArkUI_Int32 index)
5958 {
5959     auto tmp = static_cast<PixelRoundCalcPolicy>(value);
5960     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
5961     if (tmp == PixelRoundCalcPolicy::FORCE_CEIL) {
5962         ret = ConvertCeilPixelRoundPolicy(index);
5963     } else if (tmp == PixelRoundCalcPolicy::FORCE_FLOOR) {
5964         ret = ConvertFloorPixelRoundPolicy(index);
5965     } else if (tmp == PixelRoundCalcPolicy::NO_FORCE_ROUND) {
5966         ret = ConvertNoPixelRoundPolicy(index);
5967     }
5968     return static_cast<uint16_t>(ret);
5969 }
5970 
SetPixelRound(ArkUINodeHandle node,const ArkUI_Int32 * values,ArkUI_Int32 length)5971 void SetPixelRound(ArkUINodeHandle node, const ArkUI_Int32* values, ArkUI_Int32 length)
5972 {
5973     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5974     CHECK_NULL_VOID(frameNode);
5975 
5976     uint16_t value = 0;
5977     for (ArkUI_Int32 index = 0; index < length; index++) {
5978         value |= ConvertPixelRoundPolicy(values[index], index);
5979     }
5980     ViewAbstract::SetPixelRound(frameNode, value);
5981 }
5982 
ResetPixelRound(ArkUINodeHandle node)5983 void ResetPixelRound(ArkUINodeHandle node)
5984 {
5985     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5986     CHECK_NULL_VOID(frameNode);
5987     ViewAbstract::SetPixelRound(frameNode, static_cast<uint16_t>(PixelRoundCalcPolicy::NO_FORCE_ROUND));
5988 }
5989 
ParseTransition(ArkUITransitionEffectOption * option)5990 RefPtr<NG::ChainedTransitionEffect> ParseTransition(ArkUITransitionEffectOption* option)
5991 {
5992     CHECK_NULL_RETURN(option, nullptr);
5993     auto type = static_cast<TransitionEffectType>(option->type);
5994     RefPtr<NG::ChainedTransitionEffect> transitionEffect;
5995     switch (type) {
5996         case TransitionEffectType::TRANSITION_EFFECT_OPACITY: {
5997             transitionEffect = AceType::MakeRefPtr<NG::ChainedOpacityEffect>(option->opacity);
5998             break;
5999         }
6000 
6001         case TransitionEffectType::TRANSITION_EFFECT_TRANSLATE: {
6002             CalcDimension x(option->translate.x, DimensionUnit::VP);
6003             CalcDimension y(option->translate.y, DimensionUnit::VP);
6004             CalcDimension z(option->translate.z, DimensionUnit::VP);
6005             NG::TranslateOptions translate(x, y, z);
6006             transitionEffect = AceType::MakeRefPtr<NG::ChainedTranslateEffect>(translate);
6007             break;
6008         }
6009 
6010         case TransitionEffectType::TRANSITION_EFFECT_SCALE: {
6011             CalcDimension centerX(option->scale.centerX, DimensionUnit::PERCENT);
6012             CalcDimension centerY(option->scale.centerY, DimensionUnit::PERCENT);
6013             NG::ScaleOptions scale(option->scale.x, option->scale.y, option->scale.z, centerX, centerY);
6014             transitionEffect = AceType::MakeRefPtr<NG::ChainedScaleEffect>(scale);
6015             break;
6016         }
6017 
6018         case TransitionEffectType::TRANSITION_EFFECT_ROTATE: {
6019             CalcDimension centerX(option->rotate.centerX, DimensionUnit::PERCENT);
6020             CalcDimension centerY(option->rotate.centerY, DimensionUnit::PERCENT);
6021             CalcDimension centerZ(option->rotate.centerZ, DimensionUnit::PERCENT);
6022             NG::RotateOptions rotate(option->rotate.x, option->rotate.y, option->rotate.z, option->rotate.angle,
6023                 centerX, centerY, centerZ, option->rotate.perspective);
6024             transitionEffect = AceType::MakeRefPtr<NG::ChainedRotateEffect>(rotate);
6025             break;
6026         }
6027 
6028         case TransitionEffectType::TRANSITION_EFFECT_MOVE: {
6029             transitionEffect =
6030                 AceType::MakeRefPtr<NG::ChainedMoveEffect>(static_cast<NG::TransitionEdge>(option->move));
6031             break;
6032         }
6033 
6034         case TransitionEffectType::TRANSITION_EFFECT_ASYMMETRIC: {
6035             RefPtr<NG::ChainedTransitionEffect> appearEffect;
6036             RefPtr<NG::ChainedTransitionEffect> disappearEffect;
6037             if (option->appear) {
6038                 appearEffect = ParseTransition(option->appear);
6039             }
6040             if (option->disappear) {
6041                 disappearEffect = ParseTransition(option->disappear);
6042             }
6043             transitionEffect = AceType::MakeRefPtr<NG::ChainedAsymmetricEffect>(appearEffect, disappearEffect);
6044             break;
6045         }
6046     }
6047 
6048     CHECK_NULL_RETURN(transitionEffect, nullptr);
6049 
6050     if (option->hasAnimation) {
6051         auto animation = option->animation;
6052         AnimationOption animationOption;
6053         animationOption.SetDuration(animation.duration);
6054         animationOption.SetDelay(animation.delay);
6055         animationOption.SetIteration(animation.iterations);
6056         animationOption.SetTempo(animation.tempo);
6057         animationOption.SetAnimationDirection(DIRECTION_LIST[
6058             static_cast<ArkUI_Uint32>(animation.playMode) > DIRECTION_LIST.size() ? 0 : animation.playMode]);
6059 
6060         // curve
6061         if (animation.iCurve) {
6062             auto curve = reinterpret_cast<Curve*>(animation.iCurve);
6063             animationOption.SetCurve(AceType::Claim(curve));
6064         } else {
6065             if (animation.curve < 0 || static_cast<ArkUI_Uint32>(animation.curve) >= CURVES.size()) {
6066                 animationOption.SetCurve(OHOS::Ace::Curves::EASE_IN_OUT);
6067             } else {
6068                 animationOption.SetCurve(CURVES[animation.curve]);
6069             }
6070         }
6071 
6072         if (animation.expectedFrameRateRange) {
6073             RefPtr<FrameRateRange> frameRateRange =
6074                 AceType::MakeRefPtr<FrameRateRange>(animation.expectedFrameRateRange->min,
6075                     animation.expectedFrameRateRange->max, animation.expectedFrameRateRange->expected);
6076             animationOption.SetFrameRateRange(frameRateRange);
6077         }
6078         auto animationOptionResult = std::make_shared<AnimationOption>(animationOption);
6079         transitionEffect->SetAnimationOption(animationOptionResult);
6080     }
6081 
6082     if (option->combine) {
6083         transitionEffect->SetNext(ParseTransition(option->combine));
6084     }
6085     return transitionEffect;
6086 }
6087 
SetTransition(ArkUINodeHandle node,ArkUITransitionEffectOption * option)6088 void SetTransition(ArkUINodeHandle node, ArkUITransitionEffectOption* option)
6089 {
6090     CHECK_NULL_VOID(option);
6091     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6092     CHECK_NULL_VOID(frameNode);
6093 
6094     auto transitionEffectOption = ParseTransition(option);
6095     CHECK_NULL_VOID(transitionEffectOption);
6096     ViewAbstract::SetChainedTransition(frameNode, transitionEffectOption);
6097 }
6098 
SetDragPreview(ArkUINodeHandle node,ArkUIDragPreview dragPreview)6099 void SetDragPreview(ArkUINodeHandle node, ArkUIDragPreview dragPreview)
6100 {
6101     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6102     CHECK_NULL_VOID(frameNode);
6103     NG::DragDropInfo dragPreviewInfo;
6104     dragPreviewInfo.inspectorId = dragPreview.inspectorId;
6105     ViewAbstract::SetDragPreview(frameNode, dragPreviewInfo);
6106 }
6107 
ResetDragPreview(ArkUINodeHandle node)6108 void ResetDragPreview(ArkUINodeHandle node)
6109 {
6110     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6111     CHECK_NULL_VOID(frameNode);
6112     NG::DragDropInfo dragPreviewInfo;
6113     ViewAbstract::SetDragPreview(frameNode, dragPreviewInfo);
6114 }
6115 
SetBorderDashParams(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valuesSize)6116 void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize)
6117 {
6118     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6119     CHECK_NULL_VOID(frameNode);
6120     if ((values == nullptr) || (valuesSize != NUM_36)) {
6121         return;
6122     }
6123     auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
6124     int32_t offset = NUM_0;
6125     NG::BorderWidthProperty borderDashGap;
6126     SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6127     SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6128     SetOptionalBorder(borderDashGap.topDimen, values, valuesSize, offset);
6129     SetOptionalBorder(borderDashGap.bottomDimen, values, valuesSize, offset);
6130     if (isRightToLeft) {
6131         SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6132         SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6133     } else {
6134         SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6135         SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6136     }
6137     borderDashGap.multiValued = true;
6138     if (borderDashGap.leftDimen.has_value() || borderDashGap.rightDimen.has_value() ||
6139         borderDashGap.topDimen.has_value() || borderDashGap.bottomDimen.has_value()) {
6140         ViewAbstract::SetDashGap(frameNode, borderDashGap);
6141     } else {
6142         ViewAbstract::SetDashGap(frameNode, Dimension(DEFAULT_DASH_DIMENSION));
6143     }
6144 
6145     NG::BorderWidthProperty borderDashWidth;
6146     SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6147     SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6148     SetOptionalBorder(borderDashWidth.topDimen, values, valuesSize, offset);
6149     SetOptionalBorder(borderDashWidth.bottomDimen, values, valuesSize, offset);
6150     if (isRightToLeft) {
6151         SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6152         SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6153     } else {
6154         SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6155         SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6156     }
6157     borderDashWidth.multiValued = true;
6158     if (borderDashWidth.leftDimen.has_value() || borderDashWidth.rightDimen.has_value() ||
6159         borderDashWidth.topDimen.has_value() || borderDashWidth.bottomDimen.has_value()) {
6160         ViewAbstract::SetDashWidth(frameNode, borderDashWidth);
6161     } else {
6162         ViewAbstract::SetDashWidth(frameNode, Dimension(DEFAULT_DASH_DIMENSION));
6163     }
6164 }
6165 
GetExpandSafeArea(ArkUINodeHandle node,ArkUI_Uint32 (* values)[2])6166 void GetExpandSafeArea(ArkUINodeHandle node, ArkUI_Uint32 (*values)[2])
6167 {
6168     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6169     CHECK_NULL_VOID(frameNode);
6170     (*values)[NUM_0] = ViewAbstract::GetSafeAreaExpandType(frameNode);
6171     (*values)[NUM_1] = ViewAbstract::GetSafeAreaExpandEdges(frameNode);
6172 }
6173 
SetFocusBoxStyle(ArkUINodeHandle node,ArkUI_Float32 valueMargin,ArkUI_Int32 marginUnit,ArkUI_Float32 valueStrokeWidth,ArkUI_Int32 widthUnit,ArkUI_Uint32 valueColor,ArkUI_Uint32 hasValue)6174 void SetFocusBoxStyle(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Int32 marginUnit,
6175     ArkUI_Float32 valueStrokeWidth, ArkUI_Int32 widthUnit, ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue)
6176 {
6177     CHECK_NULL_VOID(node);
6178     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6179     auto marginUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(marginUnit);
6180     auto widthUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(widthUnit);
6181     NG::FocusBoxStyle style;
6182     if ((hasValue >> 2) & 1) { // 2: margin
6183         CalcDimension margin = CalcDimension(valueMargin, DimensionUnit::FP);
6184         if (marginUnitEnum >= OHOS::Ace::DimensionUnit::PX && marginUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
6185             marginUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
6186             margin.SetUnit(marginUnitEnum);
6187         }
6188         style.margin = margin;
6189     }
6190     if ((hasValue >> 1) & 1) { // 1: strokeWidth
6191         CalcDimension strokeWidth = CalcDimension(valueStrokeWidth, DimensionUnit::FP);
6192         if (widthUnitEnum >= OHOS::Ace::DimensionUnit::PX && widthUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
6193             widthUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
6194             strokeWidth.SetUnit(widthUnitEnum);
6195         }
6196         style.strokeWidth = strokeWidth;
6197     }
6198     if ((hasValue >> 0) & 1) { // 0: strokeColor
6199         Color strokeColor(valueColor);
6200         style.strokeColor = strokeColor;
6201     }
6202     ViewAbstract::SetFocusBoxStyle(frameNode, style);
6203 }
6204 
ResetFocusBoxStyle(ArkUINodeHandle node)6205 void ResetFocusBoxStyle(ArkUINodeHandle node)
6206 {
6207     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6208     CHECK_NULL_VOID(frameNode);
6209     NG::FocusBoxStyle style;
6210     ViewAbstract::SetFocusBoxStyle(frameNode, style);
6211 }
6212 
GetNodeUniqueId(ArkUINodeHandle node)6213 ArkUI_Int32 GetNodeUniqueId(ArkUINodeHandle node)
6214 {
6215     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6216     CHECK_NULL_RETURN(frameNode, -1);
6217     return frameNode->GetId();
6218 }
6219 
SetBlendModeByBlender(ArkUINodeHandle node,ArkUINodeHandle blender,ArkUI_Int32 blendApplyTypeValue)6220 void SetBlendModeByBlender(ArkUINodeHandle node, ArkUINodeHandle blender, ArkUI_Int32 blendApplyTypeValue)
6221 {
6222     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6223     CHECK_NULL_VOID(frameNode);
6224     OHOS::Rosen::BrightnessBlender* brightnessBlender = reinterpret_cast<OHOS::Rosen::BrightnessBlender*>(blender);
6225     ViewAbstractModelNG::SetBrightnessBlender(frameNode, brightnessBlender);
6226     ViewAbstractModelNG::SetBlendApplyType(frameNode, static_cast<OHOS::Ace::BlendApplyType>(blendApplyTypeValue));
6227 }
6228 
SetTabStop(ArkUINodeHandle node,ArkUI_Bool tabstop)6229 void SetTabStop(ArkUINodeHandle node, ArkUI_Bool tabstop)
6230 {
6231     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6232     CHECK_NULL_VOID(frameNode);
6233     ViewAbstract::SetTabStop(frameNode, tabstop);
6234 }
6235 
ResetTabStop(ArkUINodeHandle node)6236 void ResetTabStop(ArkUINodeHandle node)
6237 {
6238     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6239     CHECK_NULL_VOID(frameNode);
6240     bool tabstop = false;
6241     ViewAbstract::SetTabStop(frameNode, tabstop);
6242 }
6243 
GetTabStop(ArkUINodeHandle node)6244 ArkUI_Bool GetTabStop(ArkUINodeHandle node)
6245 {
6246     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6247     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
6248     return static_cast<ArkUI_Bool>(ViewAbstract::GetTabStop(frameNode));
6249 }
6250 } // namespace
6251 
6252 namespace NodeModifier {
6253 namespace {
6254 OHOS::Ace::TouchEventInfo globalEventInfo("global");
6255 }
6256 
GetCommonModifier()6257 const ArkUICommonModifier* GetCommonModifier()
6258 {
6259     static const ArkUICommonModifier modifier = { SetBackgroundColor, ResetBackgroundColor, SetWidth, ResetWidth,
6260         SetHeight, ResetHeight, SetBorderRadius, ResetBorderRadius, SetBorderWidth, ResetBorderWidth, SetTransform,
6261         ResetTransform, SetBorderColor, ResetBorderColor, SetPosition, ResetPosition, SetPositionEdges,
6262         ResetPositionEdges, SetBorderStyle, ResetBorderStyle, SetBackShadow, ResetBackShadow, SetHitTestBehavior,
6263         ResetHitTestBehavior, SetZIndex, ResetZIndex, SetOpacity, ResetOpacity, SetAlign, ResetAlign, SetBackdropBlur,
6264         ResetBackdropBlur, SetHueRotate, ResetHueRotate, SetInvert, ResetInvert, SetSepia, ResetSepia, SetSaturate,
6265         ResetSaturate, SetColorBlend, ResetColorBlend, SetGrayscale, ResetGrayscale, SetContrast, ResetContrast,
6266         SetBrightness, ResetBrightness, SetBlur, ResetBlur, SetLinearGradient, ResetLinearGradient, SetSweepGradient,
6267         ResetSweepGradient, SetRadialGradient, ResetRadialGradient, SetOverlay, ResetOverlay, SetBorderImage,
6268         ResetBorderImage, SetBorderImageGradient, SetForegroundBlurStyle, ResetForegroundBlurStyle,
6269         SetLinearGradientBlur, ResetLinearGradientBlur, SetBackgroundBlurStyle, ResetBackgroundBlurStyle, SetBorder,
6270         ResetBorder, SetBackgroundImagePosition, ResetBackgroundImagePosition, SetBackgroundImageSize,
6271         ResetBackgroundImageSize, SetBackgroundImage, ResetBackgroundImage, SetTranslate, ResetTranslate, SetScale,
6272         SetScaleWithoutTransformCenter, ResetScale, SetRotate, SetRotateWithoutTransformCenter, ResetRotate,
6273         SetGeometryTransition, ResetGeometryTransition, SetPixelStretchEffect, ResetPixelStretchEffect,
6274         SetLightUpEffect, ResetLightUpEffect, SetSphericalEffect, ResetSphericalEffect, SetRenderGroup,
6275         ResetRenderGroup, SetRenderFit, ResetRenderFit, SetUseEffect, ResetUseEffect, SetForegroundColor,
6276         ResetForegroundColor, SetMotionPath, ResetMotionPath, SetMotionBlur, ResetMotionBlur, SetGroupDefaultFocus,
6277         ResetGroupDefaultFocus, SetFocusOnTouch, ResetFocusOnTouch, SetFocusable, ResetFocusable, SetTouchable,
6278         ResetTouchable, SetDefaultFocus, ResetDefaultFocus, SetDisplayPriority, ResetDisplayPriority, SetOffset,
6279         SetOffsetEdges, ResetOffset, SetPadding, ResetPadding, SetMargin, ResetMargin, SetMarkAnchor, ResetMarkAnchor,
6280         SetVisibility, ResetVisibility, SetAccessibilityText, ResetAccessibilityText, SetAllowDrop, ResetAllowDrop,
6281         SetAccessibilityLevel, ResetAccessibilityLevel, SetDirection, ResetDirection, SetLayoutWeight,
6282         ResetLayoutWeight, SetMinWidth, ResetMinWidth, SetMaxWidth, ResetMaxWidth, SetMinHeight, ResetMinHeight,
6283         SetMaxHeight, ResetMaxHeight, SetSize, ResetSize, ClearWidthOrHeight, SetAlignSelf, ResetAlignSelf,
6284         SetAspectRatio, ResetAspectRatio, SetFlexGrow, ResetFlexGrow, SetFlexShrink, ResetFlexShrink, SetGridOffset,
6285         ResetGridOffset, SetGridSpan, ResetGridSpan, SetExpandSafeArea, ResetExpandSafeArea, SetFlexBasis,
6286         ResetFlexBasis, SetAlignRules, ResetAlignRules, SetAccessibilityDescription, ResetAccessibilityDescription,
6287         SetId, ResetId, SetKey, ResetKey, SetRestoreId, ResetRestoreId, SetTabIndex, ResetTabIndex, SetObscured,
6288         ResetObscured, SetResponseRegion, ResetResponseRegion, SetForegroundEffect, ResetForegroundEffect,
6289         SetBackgroundEffect, ResetBackgroundEffect, SetBackgroundBrightness, ResetBackgroundBrightness,
6290         SetBackgroundBrightnessInternal, ResetBackgroundBrightnessInternal, SetForegroundBrightness,
6291         ResetForegroundBrightness, SetDragPreviewOptions, ResetDragPreviewOptions, SetMouseResponseRegion,
6292         ResetMouseResponseRegion, SetEnabled, ResetEnabled, SetUseShadowBatching, ResetUseShadowBatching, SetDraggable,
6293         ResetDraggable, SetAccessibilityGroup, ResetAccessibilityGroup, SetHoverEffect, ResetHoverEffect,
6294         SetClickEffect, ResetClickEffect, SetKeyBoardShortCut, ResetKeyBoardShortCut, SetPointLightPosition,
6295         ResetPointLightPosition, SetPointLightIntensity, ResetPointLightIntensity, SetPointLightColor,
6296         ResetPointLightColor, SetPointLightIlluminated, ResetPointLightIlluminated, SetPointLightBloom,
6297         ResetPointLightBloom, SetClip, SetClipShape, SetClipPath, ResetClip, SetTransitionCenter, SetOpacityTransition,
6298         SetRotateTransition, SetScaleTransition, SetTranslateTransition, SetMaskShape, SetMaskPath, SetProgressMask,
6299         SetBlendMode, ResetBlendMode, SetMonopolizeEvents, ResetMonopolizeEvents, SetConstraintSize,
6300         ResetConstraintSize, SetOutlineColor, ResetOutlineColor, SetOutlineRadius, ResetOutlineRadius, SetOutlineWidth,
6301         ResetOutlineWidth, SetOutlineStyle, ResetOutlineStyle, SetOutline, ResetOutline, SetBindPopup, ResetBindPopup,
6302         GetFocusable, GetDefaultFocus, GetResponseRegion, GetOverlay, GetAccessibilityGroup, GetAccessibilityText,
6303         GetAccessibilityDescription, GetAccessibilityLevel, SetNeedFocus, GetNeedFocus, GetOpacity, GetBorderWidth,
6304         GetBorderWidthDimension, GetBorderRadius, GetBorderColor, GetBorderStyle, GetZIndex, GetVisibility, GetClip,
6305         GetClipShape, GetTransform, GetHitTestBehavior, GetPosition, GetShadow, GetCustomShadow, GetSweepGradient,
6306         GetRadialGradient, GetMask, GetBlendMode, GetDirection, GetAlignSelf, GetTransformCenter, GetOpacityTransition,
6307         GetRotateTransition, GetScaleTransition, GetTranslateTransition, GetOffset, GetMarkAnchor, GetAlignRules,
6308         GetBackgroundBlurStyle, GetBackgroundImageSize, GetBackgroundImageSizeWidthStyle, SetOutlineWidthFloat,
6309         GetOutlineWidthFloat, GetDisplayPriority, SetAlignRulesWidthType, GetLayoutWeight, GetScale, GetRotate,
6310         GetBrightness, GetSaturate, GetBackgroundImagePosition, GetFlexGrow, GetFlexShrink, GetFlexBasis,
6311         GetConstraintSize, GetGrayScale, GetInvert, GetSepia, GetContrast, GetForegroundColor, GetBlur,
6312         GetLinearGradient, GetAlign, GetWidth, GetHeight, GetBackgroundColor, GetBackgroundImage, GetPadding,
6313         GetPaddingDimension, GetConfigSize, GetKey, GetEnabled, GetMargin, GetMarginDimension, GetTranslate,
6314         SetMoveTransition, GetMoveTransition, ResetMask, GetAspectRatio, SetBackgroundImageResizable,
6315         ResetBackgroundImageResizable, SetBackgroundImageSizeWithUnit, GetRenderFit, GetOutlineColor, GetSize,
6316         GetRenderGroup, SetOnVisibleAreaChange, GetGeometryTransition, SetChainStyle, GetChainStyle, ResetChainStyle,
6317         SetBias, GetBias, ResetBias, GetColorBlend, GetForegroundBlurStyle,
6318         SetBackgroundImagePixelMap, SetBackgroundImagePixelMapByPixelMapPtr,
6319         SetLayoutRect, GetLayoutRect, ResetLayoutRect, GetFocusOnTouch, SetSystemBarEffect,
6320         GetAccessibilityID, SetAccessibilityState, GetAccessibilityState, ResetAccessibilityState,
6321         SetAccessibilityValue, GetAccessibilityValue, ResetAccessibilityValue, SetAccessibilityActions,
6322         ResetAccessibilityActions, GetAccessibilityActions, SetAccessibilityRole, ResetAccessibilityRole,
6323         GetAccessibilityRole, SetFocusScopeId, ResetFocusScopeId, SetFocusScopePriority, ResetFocusScopePriority,
6324         SetPixelRound, ResetPixelRound, SetBorderDashParams, GetExpandSafeArea, SetTransition, SetDragPreview,
6325         ResetDragPreview, SetFocusBoxStyle, ResetFocusBoxStyle, GetNodeUniqueId, SetDisAllowDrop,
6326         SetBlendModeByBlender, SetTabStop, ResetTabStop, GetTabStop};
6327 
6328     return &modifier;
6329 }
6330 
GetCJUICommonModifier()6331 const CJUICommonModifier* GetCJUICommonModifier()
6332 {
6333     static const CJUICommonModifier modifier = { SetBackgroundColor, ResetBackgroundColor, SetWidth, ResetWidth,
6334         SetHeight, ResetHeight, SetBorderRadius, ResetBorderRadius, SetBorderWidth, ResetBorderWidth, SetTransform,
6335         ResetTransform, SetBorderColor, ResetBorderColor, SetPosition, ResetPosition, SetPositionEdges,
6336         ResetPositionEdges, SetBorderStyle, ResetBorderStyle, SetBackShadow, ResetBackShadow, SetHitTestBehavior,
6337         ResetHitTestBehavior, SetZIndex, ResetZIndex, SetOpacity, ResetOpacity, SetAlign, ResetAlign, SetBackdropBlur,
6338         ResetBackdropBlur, SetHueRotate, ResetHueRotate, SetInvert, ResetInvert, SetSepia, ResetSepia, SetSaturate,
6339         ResetSaturate, SetColorBlend, ResetColorBlend, SetGrayscale, ResetGrayscale, SetContrast, ResetContrast,
6340         SetBrightness, ResetBrightness, SetBlur, ResetBlur, SetLinearGradient, ResetLinearGradient, SetSweepGradient,
6341         ResetSweepGradient, SetRadialGradient, ResetRadialGradient, SetOverlay, ResetOverlay, SetBorderImage,
6342         ResetBorderImage, SetBorderImageGradient, SetForegroundBlurStyle, ResetForegroundBlurStyle,
6343         SetLinearGradientBlur, ResetLinearGradientBlur, SetBackgroundBlurStyle, ResetBackgroundBlurStyle, SetBorder,
6344         ResetBorder, SetBackgroundImagePosition, ResetBackgroundImagePosition, SetBackgroundImageSize,
6345         ResetBackgroundImageSize, SetBackgroundImage, ResetBackgroundImage, SetTranslate, ResetTranslate, SetScale,
6346         SetScaleWithoutTransformCenter, ResetScale, SetRotate, SetRotateWithoutTransformCenter, ResetRotate,
6347         SetGeometryTransition, ResetGeometryTransition, SetPixelStretchEffect, ResetPixelStretchEffect,
6348         SetLightUpEffect, ResetLightUpEffect, SetSphericalEffect, ResetSphericalEffect, SetRenderGroup,
6349         ResetRenderGroup, SetRenderFit, ResetRenderFit, SetUseEffect, ResetUseEffect, SetForegroundColor,
6350         ResetForegroundColor, SetMotionPath, ResetMotionPath, SetMotionBlur, ResetMotionBlur, SetGroupDefaultFocus,
6351         ResetGroupDefaultFocus, SetFocusOnTouch, ResetFocusOnTouch, SetFocusable, ResetFocusable, SetTouchable,
6352         ResetTouchable, SetDefaultFocus, ResetDefaultFocus, SetDisplayPriority, ResetDisplayPriority, SetOffset,
6353         SetOffsetEdges, ResetOffset, SetPadding, ResetPadding, SetMargin, ResetMargin, SetMarkAnchor, ResetMarkAnchor,
6354         SetVisibility, ResetVisibility, SetAccessibilityText, ResetAccessibilityText, SetAllowDrop, ResetAllowDrop,
6355         SetAccessibilityLevel, ResetAccessibilityLevel, SetDirection, ResetDirection, SetLayoutWeight,
6356         ResetLayoutWeight, SetMinWidth, ResetMinWidth, SetMaxWidth, ResetMaxWidth, SetMinHeight, ResetMinHeight,
6357         SetMaxHeight, ResetMaxHeight, SetSize, ResetSize, ClearWidthOrHeight, SetAlignSelf, ResetAlignSelf,
6358         SetAspectRatio, ResetAspectRatio, SetFlexGrow, ResetFlexGrow, SetFlexShrink, ResetFlexShrink, SetGridOffset,
6359         ResetGridOffset, SetGridSpan, ResetGridSpan, SetExpandSafeArea, ResetExpandSafeArea, SetFlexBasis,
6360         ResetFlexBasis, SetAlignRules, ResetAlignRules, SetAccessibilityDescription, ResetAccessibilityDescription,
6361         SetId, ResetId, SetKey, ResetKey, SetRestoreId, ResetRestoreId, SetTabIndex, ResetTabIndex, SetObscured,
6362         ResetObscured, SetResponseRegion, ResetResponseRegion, SetForegroundEffect, ResetForegroundEffect,
6363         SetBackgroundEffect, ResetBackgroundEffect, SetBackgroundBrightness, ResetBackgroundBrightness,
6364         SetBackgroundBrightnessInternal, ResetBackgroundBrightnessInternal, SetForegroundBrightness,
6365         ResetForegroundBrightness, SetDragPreviewOptions, ResetDragPreviewOptions, SetMouseResponseRegion,
6366         ResetMouseResponseRegion, SetEnabled, ResetEnabled, SetUseShadowBatching, ResetUseShadowBatching, SetDraggable,
6367         ResetDraggable, SetAccessibilityGroup, ResetAccessibilityGroup, SetHoverEffect, ResetHoverEffect,
6368         SetClickEffect, ResetClickEffect, SetKeyBoardShortCut, ResetKeyBoardShortCut, SetPointLightPosition,
6369         ResetPointLightPosition, SetPointLightIntensity, ResetPointLightIntensity, SetPointLightColor,
6370         ResetPointLightColor, SetPointLightIlluminated, ResetPointLightIlluminated, SetPointLightBloom,
6371         ResetPointLightBloom, SetClip, SetClipShape, SetClipPath, ResetClip, SetTransitionCenter, SetOpacityTransition,
6372         SetRotateTransition, SetScaleTransition, SetTranslateTransition, SetMaskShape, SetMaskPath, SetProgressMask,
6373         SetBlendMode, ResetBlendMode, SetMonopolizeEvents, ResetMonopolizeEvents, SetConstraintSize,
6374         ResetConstraintSize, SetOutlineColor, ResetOutlineColor, SetOutlineRadius, ResetOutlineRadius, SetOutlineWidth,
6375         ResetOutlineWidth, SetOutlineStyle, ResetOutlineStyle, SetOutline, ResetOutline, SetBindPopup, ResetBindPopup,
6376         GetFocusable, GetDefaultFocus, GetResponseRegion, GetOverlay, GetAccessibilityGroup, GetAccessibilityText,
6377         GetAccessibilityDescription, GetAccessibilityLevel, SetNeedFocus, GetNeedFocus, GetOpacity, GetBorderWidth,
6378         GetBorderWidthDimension, GetBorderRadius, GetBorderColor, GetBorderStyle, GetZIndex, GetVisibility, GetClip,
6379         GetClipShape, GetTransform, GetHitTestBehavior, GetPosition, GetShadow, GetCustomShadow, GetSweepGradient,
6380         GetRadialGradient, GetMask, GetBlendMode, GetDirection, GetAlignSelf, GetTransformCenter, GetOpacityTransition,
6381         GetRotateTransition, GetScaleTransition, GetTranslateTransition, GetOffset, GetMarkAnchor, GetAlignRules,
6382         GetBackgroundBlurStyle, GetBackgroundImageSize, GetBackgroundImageSizeWidthStyle, SetOutlineWidthFloat,
6383         GetOutlineWidthFloat, GetDisplayPriority, SetAlignRulesWidthType, GetLayoutWeight, GetScale, GetRotate,
6384         GetBrightness, GetSaturate, GetBackgroundImagePosition, GetFlexGrow, GetFlexShrink, GetFlexBasis,
6385         GetConstraintSize, GetGrayScale, GetInvert, GetSepia, GetContrast, GetForegroundColor, GetBlur,
6386         GetLinearGradient, GetAlign, GetWidth, GetHeight, GetBackgroundColor, GetBackgroundImage, GetPadding,
6387         GetPaddingDimension, GetConfigSize, GetKey, GetEnabled, GetMargin, GetMarginDimension, GetTranslate,
6388         SetMoveTransition, GetMoveTransition, ResetMask, GetAspectRatio, SetBackgroundImageResizable,
6389         ResetBackgroundImageResizable, SetBackgroundImageSizeWithUnit, GetRenderFit, GetOutlineColor, GetSize,
6390         GetRenderGroup, SetOnVisibleAreaChange, GetGeometryTransition, SetChainStyle, GetChainStyle, ResetChainStyle,
6391         SetBias, GetBias, ResetBias, GetColorBlend, GetForegroundBlurStyle,
6392         SetBackgroundImagePixelMap, SetBackgroundImagePixelMapByPixelMapPtr,
6393         SetLayoutRect, GetLayoutRect, ResetLayoutRect, GetFocusOnTouch, SetSystemBarEffect,
6394         GetAccessibilityID, SetAccessibilityState, GetAccessibilityState, ResetAccessibilityState,
6395         SetAccessibilityValue, GetAccessibilityValue, ResetAccessibilityValue, SetAccessibilityActions,
6396         ResetAccessibilityActions, GetAccessibilityActions, SetAccessibilityRole, ResetAccessibilityRole,
6397         GetAccessibilityRole, SetFocusScopeId, ResetFocusScopeId, SetFocusScopePriority, ResetFocusScopePriority,
6398         SetPixelRound, ResetPixelRound, SetBorderDashParams, GetExpandSafeArea, SetTransition, SetDragPreview,
6399         ResetDragPreview };
6400 
6401     return &modifier;
6402 }
6403 
SetOnAppear(ArkUINodeHandle node,void * extraParam)6404 void SetOnAppear(ArkUINodeHandle node, void* extraParam)
6405 {
6406     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6407     CHECK_NULL_VOID(frameNode);
6408     int32_t nodeId = frameNode->GetId();
6409     auto onAppear = [frameNode, nodeId, extraParam]() {
6410         ArkUINodeEvent event;
6411         event.kind = COMPONENT_ASYNC_EVENT;
6412         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6413         event.nodeId = nodeId;
6414         event.componentAsyncEvent.subKind = ON_APPEAR;
6415         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6416         SendArkUIAsyncEvent(&event);
6417     };
6418     ViewAbstract::SetOnAppear(frameNode, std::move(onAppear));
6419 }
6420 
SetOnDisappear(ArkUINodeHandle node,void * extraParam)6421 void SetOnDisappear(ArkUINodeHandle node, void* extraParam)
6422 {
6423     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6424     CHECK_NULL_VOID(frameNode);
6425     int32_t nodeId = frameNode->GetId();
6426     auto onDisappear = [frameNode, nodeId, extraParam]() {
6427         ArkUINodeEvent event;
6428         event.kind = COMPONENT_ASYNC_EVENT;
6429         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6430         event.nodeId = nodeId;
6431         event.componentAsyncEvent.subKind = ON_DISAPPEAR;
6432         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6433         SendArkUIAsyncEvent(&event);
6434     };
6435     ViewAbstract::SetOnDisappear(frameNode, std::move(onDisappear));
6436 }
6437 
SetOnAttach(ArkUINodeHandle node,void * extraParam)6438 void SetOnAttach(ArkUINodeHandle node, void* extraParam)
6439 {
6440     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6441     CHECK_NULL_VOID(frameNode);
6442     int32_t nodeId = frameNode->GetId();
6443     auto onAttach = [frameNode, nodeId, extraParam]() {
6444         ArkUINodeEvent event;
6445         event.kind = COMPONENT_ASYNC_EVENT;
6446         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6447         event.nodeId = nodeId;
6448         event.componentAsyncEvent.subKind = ON_ATTACH;
6449         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6450         SendArkUIAsyncEvent(&event);
6451     };
6452     ViewAbstract::SetOnAttach(frameNode, std::move(onAttach));
6453 }
6454 
SetOnDetach(ArkUINodeHandle node,void * extraParam)6455 void SetOnDetach(ArkUINodeHandle node, void* extraParam)
6456 {
6457     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6458     CHECK_NULL_VOID(frameNode);
6459     int32_t nodeId = frameNode->GetId();
6460     auto onDetach = [frameNode, nodeId, extraParam]() {
6461         ArkUINodeEvent event;
6462         event.kind = COMPONENT_ASYNC_EVENT;
6463         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6464         event.nodeId = nodeId;
6465         event.componentAsyncEvent.subKind = ON_DETACH;
6466         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6467         SendArkUIAsyncEvent(&event);
6468     };
6469     ViewAbstract::SetOnDetach(frameNode, std::move(onDetach));
6470 }
6471 
SetOnFocus(ArkUINodeHandle node,void * extraParam)6472 void SetOnFocus(ArkUINodeHandle node, void* extraParam)
6473 {
6474     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6475     CHECK_NULL_VOID(frameNode);
6476     int32_t nodeId = frameNode->GetId();
6477     auto onEvent = [nodeId, extraParam]() {
6478         ArkUINodeEvent event;
6479         event.kind = COMPONENT_ASYNC_EVENT;
6480         event.nodeId = nodeId;
6481         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6482         event.componentAsyncEvent.subKind = ON_FOCUS;
6483         SendArkUIAsyncEvent(&event);
6484     };
6485     ViewAbstract::SetOnFocus(frameNode, std::move(onEvent));
6486 }
6487 
SetOnBlur(ArkUINodeHandle node,void * extraParam)6488 void SetOnBlur(ArkUINodeHandle node, void* extraParam)
6489 {
6490     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6491     CHECK_NULL_VOID(frameNode);
6492     int32_t nodeId = frameNode->GetId();
6493     auto onEvent = [nodeId, extraParam]() {
6494         ArkUINodeEvent event;
6495         event.kind = COMPONENT_ASYNC_EVENT;
6496         event.nodeId = nodeId;
6497         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6498         event.componentAsyncEvent.subKind = ON_BLUR;
6499         SendArkUIAsyncEvent(&event);
6500     };
6501     ViewAbstract::SetOnBlur(frameNode, std::move(onEvent));
6502 }
6503 
SetOnAreaChange(ArkUINodeHandle node,void * extraParam)6504 void SetOnAreaChange(ArkUINodeHandle node, void* extraParam)
6505 {
6506     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6507     CHECK_NULL_VOID(frameNode);
6508     int32_t nodeId = frameNode->GetId();
6509     auto onAreaChanged = [nodeId, frameNode, extraParam](
6510                              const Rect& oldRect, const Offset& oldOrigin, const Rect& rect, const Offset& origin) {
6511         ArkUINodeEvent event;
6512         event.kind = COMPONENT_ASYNC_EVENT;
6513         event.nodeId = nodeId;
6514         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6515         event.componentAsyncEvent.subKind = ON_AREA_CHANGE;
6516         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6517         auto oldLocalOffset = oldRect.GetOffset();
6518         event.componentAsyncEvent.data[0].f32 = PipelineBase::Px2VpWithCurrentDensity(oldRect.Width());
6519         event.componentAsyncEvent.data[1].f32 = PipelineBase::Px2VpWithCurrentDensity(oldRect.Height());
6520         event.componentAsyncEvent.data[2].f32 = PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetX());
6521         event.componentAsyncEvent.data[3].f32 = PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetY());
6522         event.componentAsyncEvent.data[4].f32 =
6523             PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetX() + oldOrigin.GetX());
6524         event.componentAsyncEvent.data[5].f32 =
6525             PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetY() + oldOrigin.GetY());
6526 
6527         auto localOffset = rect.GetOffset();
6528         event.componentAsyncEvent.data[6].f32 = PipelineBase::Px2VpWithCurrentDensity(rect.Width());
6529         event.componentAsyncEvent.data[7].f32 = PipelineBase::Px2VpWithCurrentDensity(rect.Height());
6530         event.componentAsyncEvent.data[8].f32 = PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX());
6531         event.componentAsyncEvent.data[9].f32 = PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY());
6532         event.componentAsyncEvent.data[10].f32 =
6533             PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX() + origin.GetX());
6534         event.componentAsyncEvent.data[11].f32 =
6535             PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY() + origin.GetY());
6536         SendArkUIAsyncEvent(&event);
6537     };
6538     auto areaChangeCallback = [areaChangeFunc = std::move(onAreaChanged)](const RectF& oldRect,
6539                                   const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) {
6540         areaChangeFunc(Rect(oldRect.GetX(), oldRect.GetY(), oldRect.Width(), oldRect.Height()),
6541             Offset(oldOrigin.GetX(), oldOrigin.GetY()), Rect(rect.GetX(), rect.GetY(), rect.Width(), rect.Height()),
6542             Offset(origin.GetX(), origin.GetY()));
6543     };
6544     ViewAbstract::SetOnAreaChanged(frameNode, std::move(areaChangeCallback));
6545 }
6546 
SetOnClick(ArkUINodeHandle node,void * extraParam)6547 void SetOnClick(ArkUINodeHandle node, void* extraParam)
6548 {
6549     auto* uiNode = reinterpret_cast<UINode*>(node);
6550     CHECK_NULL_VOID(uiNode);
6551     int32_t nodeId = uiNode->GetId();
6552     auto onEvent = [nodeId, extraParam](GestureEvent& info) {
6553         ArkUINodeEvent event;
6554         event.kind = COMPONENT_ASYNC_EVENT;
6555         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6556         event.nodeId = nodeId;
6557         event.componentAsyncEvent.subKind = ON_CLICK;
6558         auto target = info.GetTarget();
6559         event.touchEvent.target = { target.id.c_str(), target.type.c_str(),
6560             { static_cast<ArkUI_Int32>(target.area.GetOffset().GetX().Value()),
6561                 static_cast<ArkUI_Int32>(target.area.GetOffset().GetY().Value()),
6562                 static_cast<ArkUI_Int32>(target.area.GetWidth().Value()),
6563                 static_cast<ArkUI_Int32>(target.area.GetHeight().Value()) },
6564             { static_cast<ArkUI_Int32>(target.origin.GetX().Value()),
6565                 static_cast<ArkUI_Int32>(target.origin.GetY().Value()) } };
6566         Offset globalOffset = info.GetGlobalLocation();
6567         Offset localOffset = info.GetLocalLocation();
6568         Offset screenOffset = info.GetScreenLocation();
6569         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
6570         //x
6571         event.componentAsyncEvent.data[0].f32 =
6572             usePx ? PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX()) : localOffset.GetX();
6573         //y
6574         event.componentAsyncEvent.data[1].f32 =
6575             usePx ? PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY()) : localOffset.GetY();
6576         //timestamp
6577         event.componentAsyncEvent.data[2].f32 = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
6578         //source
6579         event.componentAsyncEvent.data[3].i32 = static_cast<int32_t>(info.GetSourceDevice());
6580         //windowX
6581         event.componentAsyncEvent.data[4].f32 =
6582             usePx ? PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX()) : globalOffset.GetX();
6583         //windowY
6584         event.componentAsyncEvent.data[5].f32 =
6585             usePx ? PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY()) : globalOffset.GetY();
6586         //displayX
6587         event.componentAsyncEvent.data[6].f32 =
6588             usePx ? PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX()) : screenOffset.GetX();
6589         //displayY
6590         event.componentAsyncEvent.data[7].f32 =
6591             usePx ? PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY()) : screenOffset.GetY();
6592         SendArkUIAsyncEvent(&event);
6593     };
6594     if (uiNode->GetTag() == V2::SPAN_ETS_TAG) {
6595         SpanModelNG::SetOnClick(uiNode, std::move(onEvent));
6596     } else if (uiNode->GetTag() == V2::TEXT_ETS_TAG) {
6597         TextModelNG::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onEvent));
6598     }  else {
6599         ViewAbstract::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onEvent));
6600     }
6601 }
6602 
SetOnKeyEvent(ArkUINodeHandle node,void * extraParam)6603 void SetOnKeyEvent(ArkUINodeHandle node, void* extraParam)
6604 {
6605     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6606     CHECK_NULL_VOID(frameNode);
6607     int32_t nodeId = frameNode->GetId();
6608     auto onKeyEvent = [frameNode, nodeId, extraParam](KeyEventInfo& info) -> bool {
6609         ArkUINodeEvent event;
6610         event.kind = ArkUIEventCategory::KEY_INPUT_EVENT;
6611         event.nodeId = nodeId;
6612         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6613         event.keyEvent.subKind = ArkUIEventSubKind::ON_KEY_EVENT;
6614         event.keyEvent.type = static_cast<int32_t>(info.GetKeyType());
6615         event.keyEvent.keyCode = static_cast<int32_t>(info.GetKeyCode());
6616         event.keyEvent.keyText = info.GetKeyText();
6617         event.keyEvent.keySource = static_cast<int32_t>(info.GetKeySource());
6618         event.keyEvent.deviceId = info.GetDeviceId();
6619         event.keyEvent.unicode = info.GetUnicode();
6620         event.keyEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
6621 
6622         std::vector<int32_t> pressKeyCodeList;
6623         auto pressedKeyCodes = info.GetPressedKeyCodes();
6624         event.keyEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
6625         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
6626             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
6627         }
6628         event.keyEvent.pressedKeyCodes = pressKeyCodeList.data();
6629         event.keyEvent.intentionCode = static_cast<int32_t>(info.GetKeyIntention());
6630 
6631         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6632         SendArkUIAsyncEvent(&event);
6633         info.SetStopPropagation(event.keyEvent.stopPropagation);
6634         return event.keyEvent.isConsumed;
6635     };
6636     ViewAbstract::SetOnKeyEvent(frameNode, onKeyEvent);
6637 }
6638 
SetOnKeyPreIme(ArkUINodeHandle node,void * extraParam)6639 void SetOnKeyPreIme(ArkUINodeHandle node, void* extraParam)
6640 {
6641     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6642     CHECK_NULL_VOID(frameNode);
6643     int32_t nodeId = frameNode->GetId();
6644     auto onPreImeEvent = [frameNode, nodeId, extraParam](KeyEventInfo& info) -> bool {
6645         ArkUINodeEvent event;
6646         event.kind = ArkUIEventCategory::KEY_INPUT_EVENT;
6647         event.nodeId = nodeId;
6648         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6649         event.keyEvent.subKind = ON_KEY_PREIME;
6650         event.keyEvent.type = static_cast<int32_t>(info.GetKeyType());
6651         event.keyEvent.keyCode = static_cast<int32_t>(info.GetKeyCode());
6652         event.keyEvent.keyText = info.GetKeyText();
6653         event.keyEvent.keySource = static_cast<int32_t>(info.GetKeySource());
6654         event.keyEvent.deviceId = info.GetDeviceId();
6655         event.keyEvent.unicode = info.GetUnicode();
6656         event.keyEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
6657 
6658         std::vector<int32_t> pressKeyCodeList;
6659         auto pressedKeyCodes = info.GetPressedKeyCodes();
6660         event.keyEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
6661         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
6662             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
6663         }
6664         event.keyEvent.pressedKeyCodes = pressKeyCodeList.data();
6665         event.keyEvent.intentionCode = static_cast<int32_t>(info.GetKeyIntention());
6666 
6667         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
6668         SendArkUIAsyncEvent(&event);
6669         info.SetStopPropagation(event.keyEvent.stopPropagation);
6670         return event.keyEvent.isConsumed;
6671     };
6672     NG::ViewAbstractModelNG::SetOnKeyPreIme(frameNode, std::move(onPreImeEvent));
6673 }
6674 
ResetOnKeyEvent(ArkUINodeHandle node)6675 void ResetOnKeyEvent(ArkUINodeHandle node)
6676 {
6677     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6678     CHECK_NULL_VOID(frameNode);
6679     ViewAbstract::DisableOnKeyEvent(frameNode);
6680 }
6681 
ResetOnKeyPreIme(ArkUINodeHandle node)6682 void ResetOnKeyPreIme(ArkUINodeHandle node)
6683 {
6684     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6685     CHECK_NULL_VOID(frameNode);
6686     NG::ViewAbstractModelNG::DisableOnKeyPreIme(frameNode);
6687 }
6688 
ConvertTouchLocationInfoToPoint(const TouchLocationInfo & locationInfo,ArkUITouchPoint & touchPoint,bool usePx)6689 void ConvertTouchLocationInfoToPoint(const TouchLocationInfo& locationInfo, ArkUITouchPoint& touchPoint, bool usePx)
6690 {
6691     const OHOS::Ace::Offset& globalLocation = locationInfo.GetGlobalLocation();
6692     const OHOS::Ace::Offset& localLocation = locationInfo.GetLocalLocation();
6693     const OHOS::Ace::Offset& screenLocation = locationInfo.GetScreenLocation();
6694     touchPoint.id = locationInfo.GetFingerId();
6695     double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
6696     touchPoint.nodeX = localLocation.GetX() / density;
6697     touchPoint.nodeY = localLocation.GetY() / density;
6698     touchPoint.windowX = globalLocation.GetX() / density;
6699     touchPoint.windowY = globalLocation.GetY() / density;
6700     touchPoint.screenX = screenLocation.GetX() / density;
6701     touchPoint.screenY = screenLocation.GetY() / density;
6702     touchPoint.pressure = locationInfo.GetForce();
6703     touchPoint.contactAreaWidth = locationInfo.GetSize();
6704     touchPoint.contactAreaHeight = locationInfo.GetSize();
6705     touchPoint.tiltX = locationInfo.GetTiltX().value_or(0.0f);
6706     touchPoint.tiltY = locationInfo.GetTiltY().value_or(0.0f);
6707     touchPoint.toolType = static_cast<int32_t>(locationInfo.GetSourceTool());
6708     touchPoint.pressedTime = locationInfo.GetTimeStamp().time_since_epoch().count();
6709 }
6710 
ConvertTouchPointsToPoints(std::vector<TouchPoint> & touchPointes,std::array<ArkUITouchPoint,MAX_POINTS> & points,const TouchLocationInfo & historyLoaction,bool usePx)6711 void ConvertTouchPointsToPoints(std::vector<TouchPoint>& touchPointes,
6712     std::array<ArkUITouchPoint, MAX_POINTS>& points, const TouchLocationInfo& historyLoaction, bool usePx)
6713 {
6714     if (touchPointes.empty()) {
6715         return;
6716     }
6717     size_t i = 0;
6718     for (auto& touchPoint : touchPointes) {
6719         if (i >= MAX_POINTS) {
6720             break;
6721         }
6722         double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
6723         points[i].id = touchPoint.id;
6724         points[i].nodeX = NearEqual(density, 0.0) ? 0.0f :
6725             historyLoaction.GetLocalLocation().GetX() / density;
6726         points[i].nodeY = NearEqual(density, 0.0) ? 0.0f :
6727             historyLoaction.GetLocalLocation().GetY() / density;
6728         points[i].windowX = NearEqual(density, 0.0) ? 0.0f :
6729             historyLoaction.GetGlobalLocation().GetX() / density;
6730         points[i].windowY = NearEqual(density, 0.0) ? 0.0f :
6731             historyLoaction.GetGlobalLocation().GetY() / density;
6732         points[i].screenX = NearEqual(density, 0.0) ? 0.0f :
6733             historyLoaction.GetScreenLocation().GetX() / density;
6734         points[i].screenY = NearEqual(density, 0.0) ? 0.0f :
6735             historyLoaction.GetScreenLocation().GetY() / density;
6736         points[i].contactAreaWidth = touchPoint.size;
6737         points[i].contactAreaHeight = touchPoint.size;
6738         points[i].pressure = touchPoint.force;
6739         points[i].tiltX = touchPoint.tiltX.value_or(0.0f);
6740         points[i].tiltY = touchPoint.tiltY.value_or(0.0f);
6741         points[i].pressedTime = touchPoint.downTime.time_since_epoch().count();
6742         points[i].toolType = static_cast<int32_t>(historyLoaction.GetSourceTool());
6743         i++;
6744     }
6745 }
6746 
SetOnTouch(ArkUINodeHandle node,void * extraParam)6747 void SetOnTouch(ArkUINodeHandle node, void* extraParam)
6748 {
6749     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6750     CHECK_NULL_VOID(frameNode);
6751     int32_t nodeId = frameNode->GetId();
6752     auto onEvent = [nodeId, extraParam](TouchEventInfo& eventInfo) {
6753         globalEventInfo = eventInfo;
6754         ArkUINodeEvent event;
6755         event.kind = TOUCH_EVENT;
6756         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6757         event.nodeId = nodeId;
6758         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
6759         auto target = eventInfo.GetTarget();
6760         event.touchEvent.target.id = target.id.c_str();
6761         event.touchEvent.target.type = target.type.c_str();
6762         event.touchEvent.target.area = {
6763             static_cast<ArkUI_Int32>(target.area.GetOffset().GetX().Value()),
6764             static_cast<ArkUI_Int32>(target.area.GetOffset().GetY().Value()),
6765             static_cast<ArkUI_Int32>(target.area.GetWidth().Value()),
6766             static_cast<ArkUI_Int32>(target.area.GetHeight().Value())
6767         };
6768         event.touchEvent.target.origin = {
6769             static_cast<ArkUI_Int32>(target.origin.GetX().Value()),
6770             static_cast<ArkUI_Int32>(target.origin.GetY().Value())
6771         };
6772         const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
6773         if (changeTouch.size() > 0) {
6774             TouchLocationInfo front = changeTouch.front();
6775             event.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
6776             ConvertTouchLocationInfoToPoint(front, event.touchEvent.actionTouchPoint, usePx);
6777         }
6778         event.touchEvent.timeStamp = eventInfo.GetTimeStamp().time_since_epoch().count();
6779         event.touchEvent.sourceType = static_cast<int32_t>(eventInfo.GetSourceDevice());
6780         std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
6781         if (!eventInfo.GetTouches().empty()) {
6782             size_t index = 0;
6783             for (auto& touchLocationInfo : eventInfo.GetTouches()) {
6784                 if (index >= MAX_POINTS) {
6785                     break;
6786                 }
6787                 ConvertTouchLocationInfoToPoint(touchLocationInfo, touchPoints[index++], usePx);
6788             }
6789             event.touchEvent.touchPointes = &touchPoints[0];
6790             event.touchEvent.touchPointSize =
6791                 eventInfo.GetTouches().size() < MAX_POINTS ? eventInfo.GetTouches().size() : MAX_POINTS;
6792         } else {
6793             event.touchEvent.touchPointes = nullptr;
6794             event.touchEvent.touchPointSize = 0;
6795         }
6796         event.touchEvent.subKind = ON_TOUCH;
6797         std::array<ArkUIHistoryTouchEvent, MAX_HISTORY_EVENT_COUNT> allHistoryEvents;
6798         std::array<std::array<ArkUITouchPoint, MAX_POINTS>, MAX_HISTORY_EVENT_COUNT> allHistoryPoints;
6799         if (!eventInfo.GetHistoryPointerEvent().empty() &&
6800             eventInfo.GetHistoryPointerEvent().size() == eventInfo.GetHistory().size()) {
6801             auto historyLoacationIterator = std::begin(eventInfo.GetHistory());
6802             auto historyMMIPointerEventIterator = std::begin(eventInfo.GetHistoryPointerEvent());
6803             for (size_t i = 0; i < eventInfo.GetHistory().size() && i < MAX_HISTORY_EVENT_COUNT; i++) {
6804                 if (!(*historyMMIPointerEventIterator)) {
6805                     historyLoacationIterator++;
6806                     historyMMIPointerEventIterator++;
6807                     continue;
6808                 }
6809                 auto tempTouchEvent = NG::ConvertToTouchEvent((*historyMMIPointerEventIterator));
6810                 allHistoryEvents[i].action = static_cast<int32_t>(tempTouchEvent.type);
6811                 allHistoryEvents[i].sourceType = static_cast<int32_t>(tempTouchEvent.sourceType);
6812                 allHistoryEvents[i].timeStamp = tempTouchEvent.time.time_since_epoch().count();
6813                 double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
6814                 allHistoryEvents[i].actionTouchPoint.nodeX =
6815                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetLocalLocation().GetX() / density;
6816                 allHistoryEvents[i].actionTouchPoint.nodeY =
6817                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetLocalLocation().GetY() / density;
6818                 allHistoryEvents[i].actionTouchPoint.windowX =
6819                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetGlobalLocation().GetX() / density;
6820                 allHistoryEvents[i].actionTouchPoint.windowY =
6821                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetGlobalLocation().GetY() / density;
6822                 allHistoryEvents[i].actionTouchPoint.screenX = tempTouchEvent.screenX;
6823                 allHistoryEvents[i].actionTouchPoint.screenY = tempTouchEvent.screenY;
6824                 allHistoryEvents[i].actionTouchPoint.pressure = tempTouchEvent.force;
6825                 ConvertTouchPointsToPoints(
6826                     tempTouchEvent.pointers, allHistoryPoints[i], *historyLoacationIterator, usePx);
6827                 if (tempTouchEvent.pointers.size() > 0) {
6828                     allHistoryEvents[i].touchPointes = &(allHistoryPoints[i][0]);
6829                 }
6830                 allHistoryEvents[i].touchPointSize =
6831                     tempTouchEvent.pointers.size() < MAX_POINTS ? tempTouchEvent.pointers.size() : MAX_POINTS;
6832                 historyLoacationIterator++;
6833                 historyMMIPointerEventIterator++;
6834             }
6835             event.touchEvent.historyEvents = &allHistoryEvents[0];
6836             event.touchEvent.historySize = eventInfo.GetHistoryPointerEvent().size() < MAX_HISTORY_EVENT_COUNT
6837                                                ? eventInfo.GetHistoryPointerEvent().size()
6838                                                : MAX_HISTORY_EVENT_COUNT;
6839         } else {
6840             event.touchEvent.historyEvents = nullptr;
6841             event.touchEvent.historySize = 0;
6842         }
6843         event.touchEvent.stopPropagation = false;
6844         SendArkUIAsyncEvent(&event);
6845         eventInfo.SetStopPropagation(event.touchEvent.stopPropagation);
6846     };
6847     ViewAbstract::SetOnTouch(frameNode, std::move(onEvent));
6848 }
6849 
SetOnTouchIntercept(ArkUINodeHandle node,void * extraParam)6850 void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam)
6851 {
6852     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6853     CHECK_NULL_VOID(frameNode);
6854     int32_t nodeId = frameNode->GetId();
6855     auto onTouchIntercept = [nodeId, extraParam](TouchEventInfo& eventInfo) -> NG::HitTestMode {
6856         globalEventInfo = eventInfo;
6857         ArkUINodeEvent touchEvent;
6858         touchEvent.kind = TOUCH_EVENT;
6859         touchEvent.extraParam = reinterpret_cast<intptr_t>(extraParam);
6860         touchEvent.nodeId = nodeId;
6861         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
6862         const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
6863         if (changeTouch.size() > 0) {
6864             TouchLocationInfo front = changeTouch.front();
6865             touchEvent.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
6866             ConvertTouchLocationInfoToPoint(front, touchEvent.touchEvent.actionTouchPoint, usePx);
6867         }
6868         touchEvent.touchEvent.timeStamp = eventInfo.GetTimeStamp().time_since_epoch().count();
6869         touchEvent.touchEvent.sourceType = static_cast<int32_t>(eventInfo.GetSourceDevice());
6870         std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
6871         if (!eventInfo.GetTouches().empty()) {
6872             size_t index = 0;
6873             for (auto& touchLocationInfo: eventInfo.GetTouches()) {
6874                 if (index >= MAX_POINTS) {
6875                     break;
6876                 }
6877                 ConvertTouchLocationInfoToPoint(touchLocationInfo, touchPoints[index++], usePx);
6878             }
6879             touchEvent.touchEvent.touchPointes = &touchPoints[0];
6880             touchEvent.touchEvent.touchPointSize = eventInfo.GetTouches().size() < MAX_POINTS ?
6881             eventInfo.GetTouches().size() : MAX_POINTS;
6882         } else {
6883             touchEvent.touchEvent.touchPointes = nullptr;
6884             touchEvent.touchEvent.touchPointSize = 0;
6885         }
6886         touchEvent.touchEvent.historyEvents = nullptr;
6887         touchEvent.touchEvent.historySize = 0;
6888         touchEvent.touchEvent.subKind = ON_TOUCH_INTERCEPT;
6889         touchEvent.touchEvent.interceptResult = 0;
6890         SendArkUIAsyncEvent(&touchEvent);
6891         return static_cast<NG::HitTestMode>(touchEvent.touchEvent.interceptResult);
6892     };
6893     ViewAbstract::SetOnTouchIntercept(frameNode, std::move(onTouchIntercept));
6894 }
6895 
SetOnHover(ArkUINodeHandle node,void * extraParam)6896 void SetOnHover(ArkUINodeHandle node, void* extraParam)
6897 {
6898     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6899     CHECK_NULL_VOID(frameNode);
6900     int32_t nodeId = frameNode->GetId();
6901     auto onEvent = [nodeId, extraParam](bool isHover, HoverInfo& info) {
6902         ArkUINodeEvent event;
6903         event.kind = COMPONENT_ASYNC_EVENT;
6904         event.nodeId = nodeId;
6905         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6906         event.componentAsyncEvent.subKind = ON_HOVER;
6907         event.componentAsyncEvent.data[0].i32 = isHover;
6908         SendArkUIAsyncEvent(&event);
6909     };
6910     ViewAbstract::SetOnHover(frameNode, onEvent);
6911 }
6912 
SetOnMouse(ArkUINodeHandle node,void * extraParam)6913 void SetOnMouse(ArkUINodeHandle node, void* extraParam)
6914 {
6915     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6916     CHECK_NULL_VOID(frameNode);
6917     int32_t nodeId = frameNode->GetId();
6918     auto onEvent = [nodeId, extraParam](MouseInfo& info) {
6919         ArkUINodeEvent event;
6920         event.kind = MOUSE_INPUT_EVENT;
6921         event.nodeId = nodeId;
6922         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6923         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
6924         double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
6925         event.mouseEvent.subKind = ON_MOUSE;
6926         event.mouseEvent.actionTouchPoint.nodeX = info.GetLocalLocation().GetX() / density;
6927         event.mouseEvent.actionTouchPoint.nodeY = info.GetLocalLocation().GetY() / density;
6928         event.mouseEvent.button = static_cast<int32_t>(info.GetButton());
6929         event.mouseEvent.action = static_cast<int32_t>(info.GetAction());
6930         event.mouseEvent.timeStamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
6931         event.mouseEvent.actionTouchPoint.windowX = info.GetGlobalLocation().GetX() / density;
6932         event.mouseEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY() / density;
6933         event.mouseEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX() / density;
6934         event.mouseEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY() / density;
6935         SendArkUIAsyncEvent(&event);
6936     };
6937     ViewAbstract::SetOnMouse(frameNode, onEvent);
6938 }
6939 
SetOnAccessibilityActions(ArkUINodeHandle node,void * extraParam)6940 void SetOnAccessibilityActions(ArkUINodeHandle node, void* extraParam)
6941 {
6942     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6943     CHECK_NULL_VOID(frameNode);
6944     int32_t nodeId = frameNode->GetId();
6945     auto onEvent = [nodeId, extraParam](uint32_t actionType) {
6946         ArkUINodeEvent event;
6947         event.kind = COMPONENT_ASYNC_EVENT;
6948         event.nodeId = nodeId;
6949         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
6950         event.componentAsyncEvent.subKind = ON_ACCESSIBILITY_ACTIONS;
6951         event.componentAsyncEvent.data[0].u32 = actionType;
6952         SendArkUIAsyncEvent(&event);
6953     };
6954     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6955     accessibilityProperty->SetActions(onEvent);
6956 }
6957 
ResetOnAppear(ArkUINodeHandle node)6958 void ResetOnAppear(ArkUINodeHandle node)
6959 {
6960     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6961     CHECK_NULL_VOID(frameNode);
6962     ViewAbstract::DisableOnAppear(frameNode);
6963 }
6964 
ResetOnDisappear(ArkUINodeHandle node)6965 void ResetOnDisappear(ArkUINodeHandle node)
6966 {
6967     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6968     CHECK_NULL_VOID(frameNode);
6969     ViewAbstract::DisableOnDisappear(frameNode);
6970 }
6971 
ResetOnAttach(ArkUINodeHandle node)6972 void ResetOnAttach(ArkUINodeHandle node)
6973 {
6974     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6975     CHECK_NULL_VOID(frameNode);
6976     ViewAbstract::DisableOnAttach(frameNode);
6977 }
6978 
ResetOnDetach(ArkUINodeHandle node)6979 void ResetOnDetach(ArkUINodeHandle node)
6980 {
6981     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6982     CHECK_NULL_VOID(frameNode);
6983     ViewAbstract::DisableOnDetach(frameNode);
6984 }
6985 
ResetOnFocus(ArkUINodeHandle node)6986 void ResetOnFocus(ArkUINodeHandle node)
6987 {
6988     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6989     CHECK_NULL_VOID(frameNode);
6990     ViewAbstract::DisableOnFocus(frameNode);
6991 }
6992 
ResetOnBlur(ArkUINodeHandle node)6993 void ResetOnBlur(ArkUINodeHandle node)
6994 {
6995     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6996     CHECK_NULL_VOID(frameNode);
6997     ViewAbstract::DisableOnBlur(frameNode);
6998 }
6999 
ResetOnAreaChange(ArkUINodeHandle node)7000 void ResetOnAreaChange(ArkUINodeHandle node)
7001 {
7002     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7003     CHECK_NULL_VOID(frameNode);
7004     ViewAbstract::ResetAreaChanged(frameNode);
7005 }
7006 
ResetOnVisibleAreaChange(ArkUINodeHandle node)7007 void ResetOnVisibleAreaChange(ArkUINodeHandle node)
7008 {
7009     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7010     CHECK_NULL_VOID(frameNode);
7011     ViewAbstract::ResetVisibleChange(frameNode);
7012 }
7013 
ResetOnClick(ArkUINodeHandle node)7014 void ResetOnClick(ArkUINodeHandle node)
7015 {
7016     auto* uiNode = reinterpret_cast<UINode*>(node);
7017     CHECK_NULL_VOID(uiNode);
7018     if (uiNode->GetTag() == V2::SPAN_ETS_TAG) {
7019         SpanModelNG::ClearOnClick(uiNode);
7020     } else if (uiNode->GetTag() == V2::TEXT_ETS_TAG) {
7021         auto* frameNode = reinterpret_cast<FrameNode*>(node);
7022         TextModelNG::ClearOnClick(frameNode);
7023     } else {
7024         auto* frameNode = reinterpret_cast<FrameNode*>(node);
7025         ViewAbstract::DisableOnClick(frameNode);
7026     }
7027 }
7028 
ResetOnTouch(ArkUINodeHandle node)7029 void ResetOnTouch(ArkUINodeHandle node)
7030 {
7031     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7032     CHECK_NULL_VOID(frameNode);
7033     ViewAbstract::DisableOnTouch(frameNode);
7034 }
7035 
ResetOnTouchIntercept(ArkUINodeHandle node)7036 void ResetOnTouchIntercept(ArkUINodeHandle node)
7037 {
7038     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7039     CHECK_NULL_VOID(frameNode);
7040     ViewAbstract::SetOnTouchIntercept(frameNode, nullptr);
7041 }
7042 
ResetOnHover(ArkUINodeHandle node)7043 void ResetOnHover(ArkUINodeHandle node)
7044 {
7045     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7046     CHECK_NULL_VOID(frameNode);
7047     ViewAbstract::DisableOnHover(frameNode);
7048 }
7049 
ResetOnMouse(ArkUINodeHandle node)7050 void ResetOnMouse(ArkUINodeHandle node)
7051 {
7052     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7053     CHECK_NULL_VOID(frameNode);
7054     ViewAbstract::DisableOnMouse(frameNode);
7055 }
7056 } // namespace NodeModifier
7057 } // namespace OHOS::Ace::NG