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