• 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 "interfaces/native/node/node_model.h"
18 
19 #include "base/utils/system_properties.h"
20 #include "base/utils/utils.h"
21 #include "bridge/common/utils/utils.h"
22 #include "core/animation/animation_pub.h"
23 #include "core/animation/curves.h"
24 #include "core/common/ime/text_input_type.h"
25 #include "core/components/common/layout/constants.h"
26 #include "core/components/common/properties/animation_option.h"
27 #include "core/components/common/properties/color.h"
28 #include "core/components/common/properties/decoration.h"
29 #include "core/components/common/properties/shadow.h"
30 #include "core/components/theme/shadow_theme.h"
31 #include "core/components_ng/base/frame_node.h"
32 #include "core/components_ng/base/view_abstract.h"
33 #include "core/components_ng/base/view_abstract_model_ng.h"
34 #include "core/components_ng/pattern/shape/shape_abstract_model_ng.h"
35 #include "core/components_ng/pattern/text/image_span_view.h"
36 #include "core/components_ng/pattern/text/span_model_ng.h"
37 #include "core/components_ng/pattern/text/text_model_ng.h"
38 #include "core/components_ng/pattern/toggle/toggle_model_ng.h"
39 #include "core/components_ng/pattern/checkbox/checkbox_model_ng.h"
40 #include "core/components_ng/pattern/radio/radio_model_ng.h"
41 #include "core/components_ng/property/transition_property.h"
42 #include "core/components_ng/property/grid_property.h"
43 #include "core/event/axis_event.h"
44 #include "core/image/image_source_info.h"
45 #include "core/interfaces/arkoala/arkoala_api.h"
46 #include "core/interfaces/native/node/node_api.h"
47 #include "core/interfaces/native/node/node_drag_modifier.h"
48 #include "core/interfaces/native/node/touch_event_convertor.h"
49 #include "core/interfaces/native/node/view_model.h"
50 
51 namespace OHOS::Ace::NG {
52 namespace {
53 constexpr VisibleType DEFAULT_VISIBILITY = static_cast<VisibleType>(0);
54 constexpr float MAX_ANGLE = 360.0f;
55 constexpr float DEFAULT_ANGLE = 180.0f;
56 constexpr double PERCENT_100 = 100.0;
57 constexpr int NUM_0 = 0;
58 constexpr int NUM_1 = 1;
59 constexpr int NUM_2 = 2;
60 constexpr int NUM_3 = 3;
61 constexpr int NUM_4 = 4;
62 constexpr int NUM_5 = 5;
63 constexpr int NUM_6 = 6;
64 constexpr int NUM_7 = 7;
65 constexpr int NUM_8 = 8;
66 constexpr int NUM_9 = 9;
67 constexpr int NUM_10 = 10;
68 constexpr int NUM_11 = 11;
69 constexpr int NUM_12 = 12;
70 constexpr int NUM_13 = 13;
71 constexpr int NUM_14 = 14;
72 constexpr int NUM_15 = 15;
73 constexpr int NUM_16 = 16;
74 constexpr int NUM_24 = 24;
75 constexpr int NUM_36 = 36;
76 constexpr int DEFAULT_LENGTH = 4;
77 constexpr double ROUND_UNIT = 360.0;
78 constexpr TextDirection DEFAULT_COMMON_DIRECTION = TextDirection::AUTO;
79 constexpr int32_t DEFAULT_COMMON_LAYOUTWEIGHT = 0;
80 constexpr int32_t MAX_ALIGN_VALUE = 8;
81 // default gridSpan is 1 on doc
82 constexpr int32_t DEFAULT_GRIDSPAN = 1;
83 constexpr uint32_t DEFAULT_ALIGN_RULES_SIZE = 6;
84 constexpr uint8_t DEFAULT_SAFE_AREA_TYPE = 0b111;
85 constexpr uint8_t DEFAULT_SAFE_AREA_EDGE = 0b1111;
86 constexpr Dimension DEFAULT_FLEX_BASIS { 0.0, DimensionUnit::AUTO };
87 constexpr int32_t DEFAULT_DISPLAY_PRIORITY = 0;
88 constexpr int32_t DEFAULT_ID = 0;
89 constexpr int32_t X_INDEX = 0;
90 constexpr int32_t Y_INDEX = 1;
91 constexpr int32_t Z_INDEX = 2;
92 constexpr int32_t ARRAY_SIZE = 3;
93 constexpr float HALF = 0.5f;
94 constexpr float DEFAULT_BIAS = 0.5f;
95 constexpr float DEFAULT_SATURATE = 1.0f;
96 constexpr float DEFAULT_BRIGHTNESS = 1.0f;
97 constexpr int32_t OUTLINE_LEFT_WIDTH_INDEX = 0;
98 constexpr int32_t OUTLINE_TOP_WIDTH_INDEX = 1;
99 constexpr int32_t OUTLINE_RIGHT_WIDTH_INDEX = 2;
100 constexpr int32_t OUTLINE_BOTTOM_WIDTH_INDEX = 3;
101 constexpr int32_t OUTLINE_WIDTH_VECTOR_SIZE = 4;
102 const int32_t ERROR_INT_CODE = -1;
103 const double DEFAULT_DASH_DIMENSION = -1;
104 const float ERROR_FLOAT_CODE = -1.0f;
105 constexpr int32_t MAX_POINTS = 10;
106 constexpr int32_t MAX_HISTORY_EVENT_COUNT = 20;
107 constexpr int32_t ERROR_CODE_NO_ERROR = 0;
108 constexpr Dimension ARROW_ZERO_PERCENT = 0.0_pct;
109 constexpr Dimension ARROW_HALF_PERCENT = 0.5_pct;
110 constexpr Dimension ARROW_ONE_HUNDRED_PERCENT = 1.0_pct;
111 const std::vector<OHOS::Ace::RefPtr<OHOS::Ace::Curve>> CURVES = {
112     OHOS::Ace::Curves::LINEAR,
113     OHOS::Ace::Curves::EASE,
114     OHOS::Ace::Curves::EASE_IN,
115     OHOS::Ace::Curves::EASE_OUT,
116     OHOS::Ace::Curves::EASE_IN_OUT,
117     OHOS::Ace::Curves::FAST_OUT_SLOW_IN,
118     OHOS::Ace::Curves::LINEAR_OUT_SLOW_IN,
119     OHOS::Ace::Curves::FAST_OUT_LINEAR_IN,
120     OHOS::Ace::Curves::EXTREME_DECELERATION,
121     OHOS::Ace::Curves::SHARP,
122     OHOS::Ace::Curves::RHYTHM,
123     OHOS::Ace::Curves::SMOOTH,
124     OHOS::Ace::Curves::FRICTION,
125 };
126 
127 enum TransitionEffectType {
128     TRANSITION_EFFECT_OPACITY = 0,
129     TRANSITION_EFFECT_TRANSLATE,
130     TRANSITION_EFFECT_SCALE,
131     TRANSITION_EFFECT_ROTATE,
132     TRANSITION_EFFECT_MOVE,
133     TRANSITION_EFFECT_ASYMMETRIC,
134 };
135 
136 const std::vector<AnimationDirection> DIRECTION_LIST = {
137     AnimationDirection::NORMAL,
138     AnimationDirection::REVERSE,
139     AnimationDirection::ALTERNATE,
140     AnimationDirection::ALTERNATE_REVERSE,
141 };
142 
143 constexpr int32_t DEFAULT_DURATION = 1000;
144 std::string g_strValue;
145 
ConvertBorderStyle(int32_t value)146 BorderStyle ConvertBorderStyle(int32_t value)
147 {
148     auto style = static_cast<BorderStyle>(value);
149     if (style < BorderStyle::SOLID || style > BorderStyle::NONE) {
150         style = BorderStyle::SOLID;
151     }
152     return style;
153 }
154 
ParseAlignment(int32_t align)155 Alignment ParseAlignment(int32_t align)
156 {
157     Alignment alignment = Alignment::CENTER;
158     switch (align) {
159         case NUM_0:
160             alignment = Alignment::TOP_LEFT;
161             break;
162         case NUM_1:
163             alignment = Alignment::TOP_CENTER;
164             break;
165         case NUM_2:
166             alignment = Alignment::TOP_RIGHT;
167             break;
168         case NUM_3:
169             alignment = Alignment::CENTER_LEFT;
170             break;
171         case NUM_4:
172             alignment = Alignment::CENTER;
173             break;
174         case NUM_5:
175             alignment = Alignment::CENTER_RIGHT;
176             break;
177         case NUM_6:
178             alignment = Alignment::BOTTOM_LEFT;
179             break;
180         case NUM_7:
181             alignment = Alignment::BOTTOM_CENTER;
182             break;
183         case NUM_8:
184             alignment = Alignment::BOTTOM_RIGHT;
185             break;
186         default:
187             break;
188     }
189     return alignment;
190 }
191 
ConvertAlignmentToInt(Alignment alignment)192 int32_t ConvertAlignmentToInt(Alignment alignment)
193 {
194     if (alignment == Alignment::TOP_LEFT) {
195         return NUM_0;
196     }
197     if (alignment == Alignment::TOP_CENTER) {
198         return NUM_1;
199     }
200     if (alignment == Alignment::TOP_RIGHT) {
201         return NUM_2;
202     }
203     if (alignment == Alignment::CENTER_LEFT) {
204         return NUM_3;
205     }
206     if (alignment == Alignment::CENTER) {
207         return NUM_4;
208     }
209     if (alignment == Alignment::CENTER_RIGHT) {
210         return NUM_5;
211     }
212     if (alignment == Alignment::BOTTOM_LEFT) {
213         return NUM_6;
214     }
215     if (alignment == Alignment::BOTTOM_CENTER) {
216         return NUM_7;
217     }
218     if (alignment == Alignment::BOTTOM_RIGHT) {
219         return NUM_8;
220     }
221     return NUM_4;
222 }
223 
ParseAlignmentToIndex(Alignment align)224 int32_t ParseAlignmentToIndex(Alignment align)
225 {
226     if (align == Alignment::TOP_LEFT) {
227         return NUM_0;
228     }
229     if (align == Alignment::TOP_CENTER) {
230         return NUM_1;
231     }
232     if (align == Alignment::TOP_RIGHT) {
233         return NUM_2;
234     }
235     if (align == Alignment::CENTER_LEFT) {
236         return NUM_3;
237     }
238     if (align == Alignment::CENTER) {
239         return NUM_4;
240     }
241     if (align == Alignment::CENTER_RIGHT) {
242         return NUM_5;
243     }
244     if (align == Alignment::BOTTOM_LEFT) {
245         return NUM_6;
246     }
247     if (align == Alignment::BOTTOM_CENTER) {
248         return NUM_7;
249     }
250     if (align == Alignment::BOTTOM_RIGHT) {
251         return NUM_8;
252     }
253     return ERROR_INT_CODE;
254 }
255 
256 /**
257  * @param colors color value
258  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
259  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
260  * ...
261  * @param colorsLength colors length
262  */
SetGradientColors(NG::Gradient & gradient,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)263 void SetGradientColors(NG::Gradient& gradient, const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
264 {
265     if ((colors == nullptr) || (colorsLength % NUM_3) != 0) {
266         return;
267     }
268     for (int32_t index = 0; index < colorsLength; index += NUM_3) {
269         auto colorValue = colors[index].u32;
270         auto colorHasDimension = colors[index + NUM_1].i32;
271         auto colorDimension = colors[index + NUM_2].f32;
272         auto color = static_cast<uint32_t>(colorValue);
273         auto hasDimension = static_cast<bool>(colorHasDimension);
274         auto dimension = colorDimension;
275         NG::GradientColor gradientColor;
276         gradientColor.SetColor(Color(color));
277         gradientColor.SetHasValue(hasDimension);
278         if (hasDimension) {
279             gradientColor.SetDimension(CalcDimension(dimension * PERCENT_100, DimensionUnit::PERCENT));
280         }
281         gradient.AddColor(gradientColor);
282     }
283 }
284 
SetLinearGradientDirectionTo(std::shared_ptr<LinearGradient> & linearGradient,const GradientDirection direction)285 void SetLinearGradientDirectionTo(std::shared_ptr<LinearGradient>& linearGradient, const GradientDirection direction)
286 {
287     switch (direction) {
288         case GradientDirection::LEFT:
289             linearGradient->linearX = NG::GradientDirection::LEFT;
290             break;
291         case GradientDirection::RIGHT:
292             linearGradient->linearX = NG::GradientDirection::RIGHT;
293             break;
294         case GradientDirection::TOP:
295             linearGradient->linearY = NG::GradientDirection::TOP;
296             break;
297         case GradientDirection::BOTTOM:
298             linearGradient->linearY = NG::GradientDirection::BOTTOM;
299             break;
300         case GradientDirection::LEFT_TOP:
301             linearGradient->linearX = NG::GradientDirection::LEFT;
302             linearGradient->linearY = NG::GradientDirection::TOP;
303             break;
304         case GradientDirection::LEFT_BOTTOM:
305             linearGradient->linearX = NG::GradientDirection::LEFT;
306             linearGradient->linearY = NG::GradientDirection::BOTTOM;
307             break;
308         case GradientDirection::RIGHT_TOP:
309             linearGradient->linearX = NG::GradientDirection::RIGHT;
310             linearGradient->linearY = NG::GradientDirection::TOP;
311             break;
312         case GradientDirection::RIGHT_BOTTOM:
313             linearGradient->linearX = NG::GradientDirection::RIGHT;
314             linearGradient->linearY = NG::GradientDirection::BOTTOM;
315             break;
316         case GradientDirection::NONE:
317         case GradientDirection::START_TO_END:
318         case GradientDirection::END_TO_START:
319         default:
320             break;
321     }
322 }
323 
convertToLinearGradientDirection(std::shared_ptr<LinearGradient> linearGradient)324 GradientDirection convertToLinearGradientDirection(std::shared_ptr<LinearGradient> linearGradient)
325 {
326     auto linearX = linearGradient->linearX;
327     auto linearY = linearGradient->linearY;
328     if (!linearX.has_value() && !linearY.has_value()) {
329         return GradientDirection::BOTTOM;
330     }
331     if (linearX.has_value() && !linearY.has_value()) {
332         return linearX.value();
333     }
334     if (!linearX.has_value() && linearY.has_value()) {
335         return linearY.value();
336     }
337 
338     if (linearX.value() == NG::GradientDirection::LEFT && linearY.value() == NG::GradientDirection::TOP) {
339         return GradientDirection::LEFT_TOP;
340     }
341     if (linearX.value() == NG::GradientDirection::LEFT && linearY.value() == NG::GradientDirection::BOTTOM) {
342         return GradientDirection::LEFT_BOTTOM;
343     }
344     if (linearX.value() == NG::GradientDirection::RIGHT && linearY.value() == NG::GradientDirection::TOP) {
345         return GradientDirection::RIGHT_TOP;
346     }
347     if (linearX.value() == NG::GradientDirection::RIGHT && linearY.value() == NG::GradientDirection::BOTTOM) {
348         return GradientDirection::RIGHT_BOTTOM;
349     }
350     return GradientDirection::BOTTOM;
351 }
352 
353 /**
354  * @param values value value
355  * values[0], values[1] : angle: hasValue, angle value
356  * values[2] : direction
357  * values[3] : repeating
358  * @param valuesLength values length
359  */
SetLinearGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)360 void SetLinearGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
361 {
362     if ((values == nullptr) || (valuesLength != NUM_4)) {
363         return;
364     }
365     auto angleHasValue = values[NUM_0].i32;
366     auto angleValue = values[NUM_1].f32;
367     auto directionValue = values[NUM_2].i32;
368     auto repeating = values[NUM_3].i32;
369     auto linearGradient = gradient.GetLinearGradient();
370     if (linearGradient == nullptr) {
371         return;
372     }
373     if (static_cast<bool>(angleHasValue)) {
374         linearGradient->angle = CalcDimension(angleValue, DimensionUnit::PX);
375     }
376     SetLinearGradientDirectionTo(linearGradient, static_cast<GradientDirection>(directionValue));
377     gradient.SetRepeat(static_cast<bool>(repeating));
378 }
379 
CheckAngle(const ArkUI_Float32 angle)380 ArkUI_Float32 CheckAngle(const ArkUI_Float32 angle)
381 {
382     if (LessNotEqual(angle, 0.0f)) {
383         return 0.0f;
384     }
385     if (GreatNotEqual(angle, MAX_ANGLE)) {
386         return MAX_ANGLE;
387     }
388     return angle;
389 }
390 
391 /**
392  * @param values value value
393  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
394  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
395  * values[6], values[7] : start: hasValue, start degree value
396  * values[8], values[9] : end: hasValue, end degree value
397  * values[10], values[11] : rotation: hasValue, rotation degree value
398  * values[12] : repeating
399  * @param valuesLength values length
400  */
SetSweepGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)401 void SetSweepGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
402 {
403     if ((values == nullptr) || (valuesLength != NUM_13)) {
404         return;
405     }
406     auto centerXHasValue = values[NUM_0].i32;
407     auto centerXValue = values[NUM_1].f32;
408     auto centerXUnit = values[NUM_2].i32;
409     auto centerYHasValue = values[NUM_3].i32;
410     auto centerYValue = values[NUM_4].f32;
411     auto centerYUnit = values[NUM_5].i32;
412     auto startHasValue = values[NUM_6].i32;
413     auto startValue = values[NUM_7].f32;
414     auto endHasValue = values[NUM_8].i32;
415     auto endValue = values[NUM_9].f32;
416     auto rotationHasValue = values[NUM_10].i32;
417     auto rotationValue = values[NUM_11].f32;
418     auto repeating = values[NUM_12].i32;
419     if (static_cast<bool>(centerXHasValue)) {
420         auto unit = static_cast<DimensionUnit>(centerXUnit);
421         auto value = (unit == DimensionUnit::PERCENT) ? (centerXValue * PERCENT_100) : centerXValue;
422         gradient.GetSweepGradient()->centerX = CalcDimension(value, unit);
423     }
424     if (static_cast<bool>(centerYHasValue)) {
425         auto unit = static_cast<DimensionUnit>(centerYUnit);
426         auto value = (unit == DimensionUnit::PERCENT) ? (centerYValue * PERCENT_100) : centerYValue;
427         gradient.GetSweepGradient()->centerY = CalcDimension(value, unit);
428     }
429     if (static_cast<bool>(startHasValue)) {
430         gradient.GetSweepGradient()->startAngle = CalcDimension(CheckAngle(startValue), DimensionUnit::PX);
431     }
432     if (static_cast<bool>(endHasValue)) {
433         gradient.GetSweepGradient()->endAngle = CalcDimension(CheckAngle(endValue), DimensionUnit::PX);
434     }
435     if (static_cast<bool>(rotationHasValue)) {
436         gradient.GetSweepGradient()->rotation = CalcDimension(CheckAngle(rotationValue), DimensionUnit::PX);
437     }
438     gradient.SetRepeat(static_cast<bool>(repeating));
439 }
440 
441 /**
442  * @param values value value
443  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
444  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
445  * values[6], values[7], values[8] : radius: Dimension: hasValue, value, unit
446  * values[9] : repeating
447  * @param valuesLength values length
448  */
SetRadialGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)449 void SetRadialGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
450 {
451     if ((values == nullptr) || (valuesLength != NUM_10)) {
452         return;
453     }
454 
455     auto centerXHasValue = values[NUM_0].i32;
456     auto centerXValue = values[NUM_1].f32;
457     auto centerXUnit = values[NUM_2].i32;
458     auto centerYHasValue = values[NUM_3].i32;
459     auto centerYValue = values[NUM_4].f32;
460     auto centerYUnit = values[NUM_5].i32;
461     auto radiusHasValue = values[NUM_6].i32;
462     auto radiusValue = values[NUM_7].f32;
463     auto radiusUnit = values[NUM_8].i32;
464     auto repeating = values[NUM_9].i32;
465 
466     if (static_cast<bool>(centerXHasValue)) {
467         auto unit = static_cast<DimensionUnit>(centerXUnit);
468         auto value = (unit == DimensionUnit::PERCENT) ? (centerXValue * PERCENT_100) : centerXValue;
469         gradient.GetRadialGradient()->radialCenterX = CalcDimension(value, unit);
470     }
471     if (static_cast<bool>(centerYHasValue)) {
472         auto unit = static_cast<DimensionUnit>(centerYUnit);
473         auto value = (unit == DimensionUnit::PERCENT) ? (centerYValue * PERCENT_100) : centerYValue;
474         gradient.GetRadialGradient()->radialCenterY = CalcDimension(value, unit);
475     }
476     if (static_cast<bool>(radiusHasValue)) {
477         auto unit = static_cast<DimensionUnit>(radiusUnit);
478         auto value = CheckAngle(radiusValue);
479         gradient.GetRadialGradient()->radialVerticalSize = CalcDimension(value, unit);
480         gradient.GetRadialGradient()->radialHorizontalSize = CalcDimension(value, unit);
481     }
482     gradient.SetRepeat(static_cast<bool>(repeating));
483 }
484 
SetCalcDimension(std::optional<CalcDimension> & optDimension,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 offset)485 bool SetCalcDimension(std::optional<CalcDimension>& optDimension, const ArkUIStringAndFloat* options,
486     ArkUI_Int32 optionsLength, ArkUI_Int32 offset)
487 {
488     if ((options == nullptr) || (offset < 0) || ((offset + NUM_3) >= optionsLength)) {
489         return false;
490     }
491     auto hasValue = options[offset];
492     auto value = options[offset + NUM_1];
493     auto unit = options[offset + NUM_2];
494     if (static_cast<bool>(hasValue.value)) {
495         auto unitValue = static_cast<DimensionUnit>(unit.value);
496         if (unitValue == DimensionUnit::CALC) {
497             std::string str;
498             if (value.valueStr != nullptr) {
499                 str = value.valueStr;
500             }
501             CalcDimension calcDimension(str, unitValue);
502             optDimension = calcDimension;
503         } else {
504             CalcDimension calcDimension(value.value, unitValue);
505             optDimension = calcDimension;
506         }
507     }
508     return true;
509 }
510 
SetOptionalBorder(std::optional<Dimension> & optionalDimension,const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)511 void SetOptionalBorder(std::optional<Dimension>& optionalDimension, const ArkUI_Float32* values, ArkUI_Int32 valuesSize,
512     ArkUI_Int32& offset)
513 {
514     bool hasValue = static_cast<bool>(values[offset]);
515     if (hasValue) {
516         optionalDimension =
517             Dimension(values[offset + NUM_1], static_cast<OHOS::Ace::DimensionUnit>(values[offset + NUM_2]));
518     }
519     offset = offset + NUM_3;
520 }
521 
SetOptionalBorderColor(std::optional<Color> & optionalColor,const uint32_t * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)522 void SetOptionalBorderColor(
523     std::optional<Color>& optionalColor, const uint32_t* values, ArkUI_Int32 valuesSize, ArkUI_Int32& offset)
524 {
525     auto hasValue = values[offset];
526     if (static_cast<bool>(hasValue)) {
527         optionalColor = Color(values[offset + NUM_1]);
528     }
529     offset = offset + NUM_2;
530 }
531 
SetOptionalBorderStyle(std::optional<BorderStyle> & optionalStyle,const uint32_t * values,ArkUI_Int32 valuesSize,ArkUI_Int32 & offset)532 void SetOptionalBorderStyle(
533     std::optional<BorderStyle>& optionalStyle, const uint32_t* values, ArkUI_Int32 valuesSize, ArkUI_Int32& offset)
534 {
535     auto hasValue = values[offset];
536     if (static_cast<bool>(hasValue)) {
537         optionalStyle = ConvertBorderStyle(values[offset + NUM_1]);
538     }
539     offset = offset + NUM_2;
540 }
541 
SetBorderImageSlice(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)542 void SetBorderImageSlice(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
543     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
544 {
545     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
546         std::optional<CalcDimension> optDimension;
547         SetCalcDimension(optDimension, options, optionsLength, offset + index);
548         if (optDimension.has_value()) {
549             auto direction = directions[index / NUM_3];
550             borderImage->SetEdgeSlice(direction, optDimension.value());
551         }
552     }
553     offset += NUM_12;
554 }
555 
SetBorderImageRepeat(RefPtr<BorderImage> & borderImage,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)556 void SetBorderImageRepeat(RefPtr<BorderImage>& borderImage, const ArkUIStringAndFloat* options,
557     ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
558 {
559     if ((options == nullptr) || (offset < 0) || ((offset + NUM_2) >= optionsLength)) {
560         return;
561     }
562     auto hasValue = options[offset];
563     auto value = options[offset + NUM_1];
564     if (static_cast<bool>(hasValue.value)) {
565         auto repeatMode = static_cast<BorderImageRepeat>(value.value);
566         borderImage->SetRepeatMode(repeatMode);
567     }
568     offset += NUM_2;
569 }
570 
SetBorderImageWidth(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)571 void SetBorderImageWidth(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
572     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
573 {
574     for (int32_t index = 0; index < NUM_12; index += NUM_3) {
575         std::optional<CalcDimension> optDimension;
576         SetCalcDimension(optDimension, options, optionsLength, offset + index);
577         if (optDimension.has_value()) {
578             auto direction = directions[index / NUM_3];
579             borderImage->SetEdgeWidth(direction, optDimension.value());
580         }
581     }
582     offset += NUM_12;
583 }
584 
SetBorderImageOutset(RefPtr<BorderImage> & borderImage,const std::vector<BorderImageDirection> & directions,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)585 void SetBorderImageOutset(RefPtr<BorderImage>& borderImage, const std::vector<BorderImageDirection>& directions,
586     const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength, ArkUI_Int32& offset)
587 {
588     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
589         std::optional<CalcDimension> optDimension;
590         SetCalcDimension(optDimension, options, optionsLength, offset + index);
591         if (optDimension.has_value()) {
592             auto direction = directions[index / NUM_3];
593             borderImage->SetEdgeOutset(direction, optDimension.value());
594         }
595     }
596     offset += NUM_12;
597 }
598 
SetBorderImageFill(RefPtr<BorderImage> & borderImage,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength,ArkUI_Int32 & offset)599 void SetBorderImageFill(RefPtr<BorderImage>& borderImage, const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength,
600     ArkUI_Int32& offset)
601 {
602     if ((options == nullptr) || (offset < 0) || ((offset + NUM_2) >= optionsLength)) {
603         return;
604     }
605     auto hasValue = options[offset];
606     auto value = options[offset + NUM_1];
607     if (static_cast<bool>(hasValue.value)) {
608         borderImage->SetNeedFillCenter(static_cast<bool>(value.value));
609     }
610     offset += NUM_2;
611 }
612 
SetBorderImage(FrameNode * frameNode,const RefPtr<BorderImage> & borderImage,ArkUI_Uint32 bitset)613 void SetBorderImage(FrameNode* frameNode, const RefPtr<BorderImage>& borderImage, ArkUI_Uint32 bitset)
614 {
615     CHECK_NULL_VOID(frameNode);
616     CHECK_NULL_VOID(borderImage);
617     if (bitset & BorderImage::SOURCE_BIT) {
618         ViewAbstract::SetBorderImageSource(frameNode, borderImage->GetSrc());
619     }
620     if (bitset & BorderImage::OUTSET_BIT) {
621         ViewAbstract::SetHasBorderImageOutset(frameNode, true);
622     }
623     if (bitset & BorderImage::SLICE_BIT) {
624         ViewAbstract::SetHasBorderImageSlice(frameNode, true);
625     }
626     if (bitset & BorderImage::REPEAT_BIT) {
627         ViewAbstract::SetHasBorderImageRepeat(frameNode, true);
628     }
629     if (bitset & BorderImage::WIDTH_BIT) {
630         ViewAbstract::SetHasBorderImageWidth(frameNode, true);
631     }
632     ViewAbstract::SetBorderImage(frameNode, borderImage);
633 }
634 
635 /**
636  * @param values value value
637  * values[0], values[1] : angle: hasValue, angle value
638  * values[2] : direction
639  * values[3] : repeating
640  * @param valuesLength values length
641  */
SetBorderImageGradientValues(NG::Gradient & gradient,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength)642 void SetBorderImageGradientValues(NG::Gradient& gradient, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength)
643 {
644     if ((values == nullptr) || (valuesLength != NUM_4)) {
645         return;
646     }
647     auto angleHasValue = values[NUM_0].i32;
648     auto angleValue = values[NUM_1].f32;
649     auto directionValue = values[NUM_2].i32;
650     auto repeating = values[NUM_3].i32;
651     auto linearGradient = gradient.GetLinearGradient();
652     if (linearGradient == nullptr) {
653         return;
654     }
655     if (static_cast<bool>(angleHasValue)) {
656         linearGradient->angle = CalcDimension(angleValue, DimensionUnit::PX);
657     }
658     SetLinearGradientDirectionTo(linearGradient, static_cast<GradientDirection>(directionValue));
659     gradient.SetRepeat(static_cast<bool>(repeating));
660 }
661 
SetBgImgPosition(const DimensionUnit & typeX,const DimensionUnit & typeY,ArkUI_Float32 valueX,ArkUI_Float32 valueY,BackgroundImagePosition & bgImgPosition)662 void SetBgImgPosition(const DimensionUnit& typeX, const DimensionUnit& typeY, ArkUI_Float32 valueX,
663     ArkUI_Float32 valueY, BackgroundImagePosition& bgImgPosition)
664 {
665     OHOS::Ace::AnimationOption option;
666     auto animatableDimensionX = AnimatableDimension(valueX, typeX, option);
667     auto animatableDimensionY = AnimatableDimension(valueY, typeY, option);
668     if (typeX == DimensionUnit::VP || typeX == DimensionUnit::FP) {
669         animatableDimensionX.SetValue(animatableDimensionX.ConvertToPx());
670         animatableDimensionX.SetUnit(DimensionUnit::PX);
671     }
672     if (typeY == DimensionUnit::VP || typeY == DimensionUnit::FP) {
673         animatableDimensionY.SetValue(animatableDimensionY.ConvertToPx());
674         animatableDimensionY.SetUnit(DimensionUnit::PX);
675     }
676     bgImgPosition.SetSizeX(animatableDimensionX);
677     bgImgPosition.SetSizeY(animatableDimensionY);
678 }
679 
SetBackgroundColor(ArkUINodeHandle node,uint32_t color)680 void SetBackgroundColor(ArkUINodeHandle node, uint32_t color)
681 {
682     auto* frameNode = reinterpret_cast<FrameNode*>(node);
683     CHECK_NULL_VOID(frameNode);
684     ViewAbstract::SetBackgroundColor(frameNode, Color(color));
685 }
686 
ResetBackgroundColor(ArkUINodeHandle node)687 void ResetBackgroundColor(ArkUINodeHandle node)
688 {
689     auto* frameNode = reinterpret_cast<FrameNode*>(node);
690     CHECK_NULL_VOID(frameNode);
691     ViewAbstract::SetBackgroundColor(frameNode, Color(Color::TRANSPARENT));
692 }
693 
SetWidth(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,ArkUI_CharPtr calcValue)694 void SetWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue)
695 {
696     auto* frameNode = reinterpret_cast<FrameNode*>(node);
697     CHECK_NULL_VOID(frameNode);
698     auto unitEnum = static_cast<OHOS::Ace::DimensionUnit>(unit);
699     if (unitEnum == DimensionUnit::CALC) {
700         ViewAbstract::SetWidth(frameNode, CalcLength(CalcLength(std::string(calcValue))));
701     } else {
702         ViewAbstract::SetWidth(frameNode, CalcLength(value, unitEnum));
703     }
704 }
705 
ResetWidth(ArkUINodeHandle node)706 void ResetWidth(ArkUINodeHandle node)
707 {
708     auto* frameNode = reinterpret_cast<FrameNode*>(node);
709     CHECK_NULL_VOID(frameNode);
710     ViewAbstract::ClearWidthOrHeight(frameNode, true);
711 }
SetHeight(ArkUINodeHandle node,ArkUI_Float32 value,ArkUI_Int32 unit,ArkUI_CharPtr calcValue)712 void SetHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, ArkUI_CharPtr calcValue)
713 {
714     auto* frameNode = reinterpret_cast<FrameNode*>(node);
715     CHECK_NULL_VOID(frameNode);
716     auto unitEnum = static_cast<OHOS::Ace::DimensionUnit>(unit);
717     if (unitEnum == DimensionUnit::CALC) {
718         ViewAbstract::SetHeight(frameNode, CalcLength(CalcLength(std::string(calcValue))));
719     } else {
720         ViewAbstract::SetHeight(frameNode, CalcLength(value, unitEnum));
721     }
722 }
ResetHeight(ArkUINodeHandle node)723 void ResetHeight(ArkUINodeHandle node)
724 {
725     auto* frameNode = reinterpret_cast<FrameNode*>(node);
726     CHECK_NULL_VOID(frameNode);
727     ViewAbstract::ClearWidthOrHeight(frameNode, false);
728 }
729 /**
730  * @param values radius values
731  * value[0] : radius value for TopLeft,value[1] : radius value for TopRight
732  * value[2] : radius value for BottomLeft,value[3] : radius value for BottomRight
733  * @param units radius units
734  * units[0]: radius unit for TopLeft, units[1] : radius unit for TopRight
735  * units[2]: radius unit for BottomLeft, units[3] : radius unit for TopRight
736  */
SetBorderRadius(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)737 void SetBorderRadius(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
738 {
739     auto* frameNode = reinterpret_cast<FrameNode*>(node);
740     CHECK_NULL_VOID(frameNode);
741     if (length != DEFAULT_LENGTH) {
742         return;
743     }
744     NG::BorderRadiusProperty borderRadius;
745     borderRadius.radiusTopLeft = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
746     borderRadius.radiusTopRight = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
747     borderRadius.radiusBottomLeft = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
748     borderRadius.radiusBottomRight = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]));
749     borderRadius.multiValued = true;
750     ViewAbstract::SetBorderRadius(frameNode, borderRadius);
751 }
752 
ResetBorderRadius(ArkUINodeHandle node)753 void ResetBorderRadius(ArkUINodeHandle node)
754 {
755     auto* frameNode = reinterpret_cast<FrameNode*>(node);
756     CHECK_NULL_VOID(frameNode);
757     OHOS::Ace::CalcDimension reset;
758     ViewAbstract::SetBorderRadius(frameNode, reset);
759 }
760 
761 /**
762  * @param values radius values, -1 means no this border width
763  * value[0] : BorderWidth value for left,value[1] : BorderWidth value for right
764  * value[2] : BorderWidth value for top,value[3] : BorderWidth value for bottom
765  * @param units radius units
766  * units[0]: BorderWidth unit for left, units[1] : BorderWidth unit for right
767  * units[2]: BorderWidth unit for top, units[3] : BorderWidth unit for bottom
768  */
SetBorderWidth(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)769 void SetBorderWidth(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
770 {
771     auto* frameNode = reinterpret_cast<FrameNode*>(node);
772     CHECK_NULL_VOID(frameNode);
773     if (length != DEFAULT_LENGTH) {
774         return;
775     }
776     std::optional<CalcDimension> topDimen;
777     std::optional<CalcDimension> rightDimen;
778     std::optional<CalcDimension> bottomDimen;
779     std::optional<CalcDimension> leftDimen;
780 
781     if (values[NUM_0] != -1 &&
782         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]) != OHOS::Ace::DimensionUnit::INVALID) {
783         topDimen = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
784     }
785     if (values[NUM_1] != -1 &&
786         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]) != OHOS::Ace::DimensionUnit::INVALID) {
787         rightDimen = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
788     }
789     if (values[NUM_2] != -1 &&
790         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]) != OHOS::Ace::DimensionUnit::INVALID) {
791         bottomDimen = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
792     }
793     if (values[NUM_3] != -1 &&
794         static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]) != OHOS::Ace::DimensionUnit::INVALID) {
795         leftDimen = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_3]));
796     }
797 
798     NG::BorderWidthProperty borderWidth;
799     borderWidth.leftDimen = leftDimen;
800     borderWidth.rightDimen = rightDimen;
801     borderWidth.topDimen = topDimen;
802     borderWidth.bottomDimen = bottomDimen;
803     borderWidth.multiValued = true;
804     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
805 }
806 
ResetBorderWidth(ArkUINodeHandle node)807 void ResetBorderWidth(ArkUINodeHandle node)
808 {
809     auto* frameNode = reinterpret_cast<FrameNode*>(node);
810     CHECK_NULL_VOID(frameNode);
811     OHOS::Ace::Dimension borderWidth;
812     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
813 }
814 
SetTransform(ArkUINodeHandle node,const ArkUI_Float32 * matrix,ArkUI_Int32 length)815 void SetTransform(ArkUINodeHandle node, const ArkUI_Float32* matrix, ArkUI_Int32 length)
816 {
817     auto* frameNode = reinterpret_cast<FrameNode*>(node);
818     CHECK_NULL_VOID(frameNode);
819     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
820     if (length != matrix4Len) {
821         return;
822     }
823     NG::ViewAbstract::SetTransformMatrix(
824         frameNode, Matrix4(matrix[NUM_0], matrix[NUM_4], matrix[NUM_8], matrix[NUM_12], matrix[NUM_1], matrix[NUM_5],
825             matrix[NUM_9], matrix[NUM_13], matrix[NUM_2], matrix[NUM_6], matrix[NUM_10], matrix[NUM_14],
826                 matrix[NUM_3], matrix[NUM_7], matrix[NUM_11], matrix[NUM_15]));
827 }
828 
ResetTransform(ArkUINodeHandle node)829 void ResetTransform(ArkUINodeHandle node)
830 {
831     auto* frameNode = reinterpret_cast<FrameNode*>(node);
832     CHECK_NULL_VOID(frameNode);
833     const auto matrix4Len = Matrix4::DIMENSION * Matrix4::DIMENSION;
834     std::vector<float> matrix(matrix4Len);
835     const int32_t initPosition = 5;
836     for (int32_t i = 0; i < matrix4Len; i = i + initPosition) {
837         double value = 1.0;
838         matrix[i] = static_cast<float>(value);
839     }
840     NG::ViewAbstract::SetTransformMatrix(
841         frameNode, Matrix4(matrix[NUM_0], matrix[NUM_4], matrix[NUM_8], matrix[NUM_12], matrix[NUM_1], matrix[NUM_5],
842             matrix[NUM_9], matrix[NUM_13], matrix[NUM_2], matrix[NUM_6], matrix[NUM_10], matrix[NUM_14],
843                 matrix[NUM_3], matrix[NUM_7], matrix[NUM_11], matrix[NUM_15]));
844 }
845 
SetBorderColor(ArkUINodeHandle node,uint32_t topColorInt,uint32_t rightColorInt,uint32_t bottomColorInt,uint32_t leftColorInt)846 void SetBorderColor(
847     ArkUINodeHandle node, uint32_t topColorInt, uint32_t rightColorInt, uint32_t bottomColorInt, uint32_t leftColorInt)
848 {
849     auto* frameNode = reinterpret_cast<FrameNode*>(node);
850     CHECK_NULL_VOID(frameNode);
851     NG::BorderColorProperty borderColors;
852     borderColors.topColor = Color(topColorInt);
853     borderColors.rightColor = Color(rightColorInt);
854     borderColors.bottomColor = Color(bottomColorInt);
855     borderColors.leftColor = Color(leftColorInt);
856     borderColors.multiValued = true;
857 
858     ViewAbstract::SetBorderColor(frameNode, borderColors);
859 }
860 
ResetBorderColor(ArkUINodeHandle node)861 void ResetBorderColor(ArkUINodeHandle node)
862 {
863     auto* frameNode = reinterpret_cast<FrameNode*>(node);
864     CHECK_NULL_VOID(frameNode);
865     ViewAbstract::SetBorderColor(frameNode, Color::BLACK);
866 }
867 
868 /**
869  * @param xValue position x value
870  * @param xUnit position x unit
871  * @param yValue position y unit
872  * @param yUnit position y unit
873  */
SetPosition(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit)874 void SetPosition(ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit)
875 {
876     auto* frameNode = reinterpret_cast<FrameNode*>(node);
877     CHECK_NULL_VOID(frameNode);
878 
879     ViewAbstract::SetPosition(frameNode, { Dimension(xValue, static_cast<OHOS::Ace::DimensionUnit>(xUnit)),
880                                              Dimension(yValue, static_cast<OHOS::Ace::DimensionUnit>(yUnit)) });
881 }
882 
ResetPosition(ArkUINodeHandle node)883 void ResetPosition(ArkUINodeHandle node)
884 {
885     auto* frameNode = reinterpret_cast<FrameNode*>(node);
886     CHECK_NULL_VOID(frameNode);
887     ViewAbstract::ResetPosition(frameNode);
888 }
889 
ParseEdges(OHOS::Ace::EdgesParam & edges,const ArkUIStringAndFloat * options)890 bool ParseEdges(OHOS::Ace::EdgesParam& edges, const ArkUIStringAndFloat* options)
891 {
892     bool result = false;
893     std::optional<CalcDimension> top;
894     std::optional<CalcDimension> left;
895     std::optional<CalcDimension> bottom;
896     std::optional<CalcDimension> right;
897     SetCalcDimension(top, options, NUM_13, NUM_0);
898     SetCalcDimension(left, options, NUM_13, NUM_3);
899     SetCalcDimension(bottom, options, NUM_13, NUM_6);
900     SetCalcDimension(right, options, NUM_13, NUM_9);
901     if (top.has_value()) {
902         result = true;
903         edges.SetTop(top.value());
904     }
905     if (left.has_value()) {
906         result = true;
907         edges.SetLeft(left.value());
908     }
909     if (bottom.has_value()) {
910         result = true;
911         edges.SetBottom(bottom.value());
912     }
913     if (right.has_value()) {
914         result = true;
915         edges.SetRight(right.value());
916     }
917     return result;
918 }
919 
SetPositionEdges(ArkUINodeHandle node,const int32_t useEdges,const ArkUIStringAndFloat * options)920 void SetPositionEdges(ArkUINodeHandle node, const int32_t useEdges, const ArkUIStringAndFloat* options)
921 {
922     auto* frameNode = reinterpret_cast<FrameNode*>(node);
923     CHECK_NULL_VOID(frameNode);
924     bool vaild = false;
925 
926     if (useEdges) {
927         OHOS::Ace::EdgesParam edges;
928         if (ParseEdges(edges, options)) {
929             ViewAbstract::SetPositionEdges(frameNode, edges);
930         } else {
931             ViewAbstract::ResetPosition(frameNode);
932         }
933     } else {
934         OffsetT<Dimension> offset;
935         std::optional<CalcDimension> x;
936         std::optional<CalcDimension> y;
937         SetCalcDimension(x, options, NUM_7, NUM_0);
938         SetCalcDimension(y, options, NUM_7, NUM_3);
939         if (x.has_value()) {
940             vaild = true;
941             offset.SetX(x.value());
942         }
943         if (y.has_value()) {
944             vaild = true;
945             offset.SetY(y.value());
946         }
947         if (vaild) {
948             ViewAbstract::SetPosition(frameNode, offset);
949         } else {
950             ViewAbstract::ResetPosition(frameNode);
951         }
952     }
953 }
954 
ResetPositionEdges(ArkUINodeHandle node)955 void ResetPositionEdges(ArkUINodeHandle node)
956 {
957     auto* frameNode = reinterpret_cast<FrameNode*>(node);
958     CHECK_NULL_VOID(frameNode);
959     if (AceApplicationInfo::GetInstance().GreatOrEqualTargetAPIVersion(PlatformVersion::VERSION_TWELVE)) {
960         ViewAbstract::ResetPosition();
961     } else {
962         ViewAbstract::SetPosition(frameNode, { 0.0_vp, 0.0_vp });
963     }
964 }
965 
966 /**
967  * @param styles styles value
968  * styles[0] : styleLeft, styles[1] : styleRight, styles[2] : styleTop, styles[3] : styleBottom
969  * @param length styles length
970  */
SetBorderStyle(ArkUINodeHandle node,const ArkUI_Int32 * styles,ArkUI_Int32 length)971 void SetBorderStyle(ArkUINodeHandle node, const ArkUI_Int32* styles, ArkUI_Int32 length)
972 {
973     auto* frameNode = reinterpret_cast<FrameNode*>(node);
974     CHECK_NULL_VOID(frameNode);
975     if (length == NUM_1) {
976         ViewAbstract::SetBorderStyle(frameNode, ConvertBorderStyle(styles[NUM_0]));
977         return;
978     }
979     if (length == NUM_4) {
980         NG::BorderStyleProperty borderStyles;
981         borderStyles.styleLeft = ConvertBorderStyle(styles[NUM_3]);
982         borderStyles.styleRight = ConvertBorderStyle(styles[NUM_1]);
983         borderStyles.styleTop = ConvertBorderStyle(styles[NUM_0]);
984         borderStyles.styleBottom = ConvertBorderStyle(styles[NUM_2]);
985         borderStyles.multiValued = true;
986         ViewAbstract::SetBorderStyle(frameNode, borderStyles);
987     }
988 }
989 
ResetBorderStyle(ArkUINodeHandle node)990 void ResetBorderStyle(ArkUINodeHandle node)
991 {
992     auto* frameNode = reinterpret_cast<FrameNode*>(node);
993     CHECK_NULL_VOID(frameNode);
994     ViewAbstract::SetBorderStyle(frameNode, BorderStyle::SOLID);
995 }
996 
GetShadowFromTheme(ShadowStyle shadowStyle,Shadow & shadow)997 bool GetShadowFromTheme(ShadowStyle shadowStyle, Shadow& shadow)
998 {
999     if (shadowStyle == ShadowStyle::None) {
1000         return true;
1001     }
1002 
1003     auto container = Container::Current();
1004     CHECK_NULL_RETURN(container, false);
1005     auto pipelineContext = container->GetPipelineContext();
1006     CHECK_NULL_RETURN(pipelineContext, false);
1007 
1008     auto shadowTheme = pipelineContext->GetTheme<ShadowTheme>();
1009     CHECK_NULL_RETURN(shadowTheme, false);
1010     auto colorMode = container->GetColorMode();
1011     shadow = shadowTheme->GetShadow(shadowStyle, colorMode);
1012     return true;
1013 }
1014 
1015 /**
1016  * @param shadows shadow value
1017  * shadows[0] : BlurRadius, shadows[1] : 1: has ColorStrategy; 2: has Color
1018  * shadows[2] : OffsetX, offset[3] : OffsetY
1019  * shadows[4] : ShadowType, shadows[5] : Color, shadows[6] : IsFilled
1020  * @param length shadows length
1021  */
SetBackShadow(ArkUINodeHandle node,const ArkUIInt32orFloat32 * shadows,ArkUI_Int32 length)1022 void SetBackShadow(ArkUINodeHandle node, const ArkUIInt32orFloat32* shadows, ArkUI_Int32 length)
1023 {
1024     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1025     CHECK_NULL_VOID(frameNode);
1026     if (length == NUM_1) {
1027         Shadow shadow;
1028         auto shadowStyle = static_cast<ShadowStyle>(shadows[NUM_0].i32);
1029         auto style = static_cast<ShadowStyle>(shadowStyle);
1030         if (GetShadowFromTheme(style, shadow)) {
1031             ViewAbstract::SetBackShadow(frameNode, shadow);
1032         }
1033     }
1034     if (length != NUM_7) {
1035         return;
1036     }
1037     auto blurRadius = shadows[NUM_0].f32;                          // BlurRadius
1038     auto hasColorValue = static_cast<int32_t>(shadows[NUM_1].i32); // 1: has ColorStrategy; 2: has Color
1039     auto offsetX = shadows[NUM_2].f32;                             // OffsetX
1040     auto offsetY = shadows[NUM_3].f32;                             // OffsetY
1041     auto shadowType = shadows[NUM_4].i32;                          // ShadowType
1042     auto color = static_cast<uint32_t>(shadows[NUM_5].u32);        // Color
1043     auto isFilled = static_cast<uint32_t>(shadows[NUM_6].i32);     // IsFilled
1044     Shadow shadow;
1045     shadow.SetBlurRadius(blurRadius);
1046     shadow.SetOffsetX(offsetX);
1047     shadow.SetOffsetY(offsetY);
1048     if (hasColorValue == 1) { // 1: has ColorStrategy
1049         shadow.SetShadowColorStrategy(static_cast<ShadowColorStrategy>(color));
1050     } else if (hasColorValue == 2) { // 2: has Color
1051         shadow.SetColor(Color(color));
1052     }
1053     shadow.SetShadowType(static_cast<ShadowType>(shadowType));
1054     shadow.SetIsFilled(static_cast<bool>(isFilled));
1055     ViewAbstract::SetBackShadow(frameNode, shadow);
1056 }
1057 
ResetBackShadow(ArkUINodeHandle node)1058 void ResetBackShadow(ArkUINodeHandle node)
1059 {
1060     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1061     CHECK_NULL_VOID(frameNode);
1062     Shadow shadow;
1063     ViewAbstract::SetBackShadow(frameNode, shadow);
1064 }
1065 
SetHitTestBehavior(ArkUINodeHandle node,uint32_t value)1066 void SetHitTestBehavior(ArkUINodeHandle node, uint32_t value)
1067 {
1068     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1069     CHECK_NULL_VOID(frameNode);
1070     NG::HitTestMode hitTestModeNG = static_cast<NG::HitTestMode>(value);
1071     ViewAbstract::SetHitTestMode(frameNode, hitTestModeNG);
1072 }
1073 
ResetHitTestBehavior(ArkUINodeHandle node)1074 void ResetHitTestBehavior(ArkUINodeHandle node)
1075 {
1076     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1077     CHECK_NULL_VOID(frameNode);
1078     ViewAbstract::SetHitTestMode(frameNode, NG::HitTestMode::HTMDEFAULT);
1079 }
1080 
SetZIndex(ArkUINodeHandle node,ArkUI_Int32 value)1081 void SetZIndex(ArkUINodeHandle node, ArkUI_Int32 value)
1082 {
1083     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1084     CHECK_NULL_VOID(frameNode);
1085     ViewAbstract::SetZIndex(frameNode, value);
1086 }
1087 
ResetZIndex(ArkUINodeHandle node)1088 void ResetZIndex(ArkUINodeHandle node)
1089 {
1090     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1091     CHECK_NULL_VOID(frameNode);
1092     ViewAbstract::SetZIndex(frameNode, 0);
1093 }
1094 
SetOpacity(ArkUINodeHandle node,ArkUI_Float32 opacity)1095 void SetOpacity(ArkUINodeHandle node, ArkUI_Float32 opacity)
1096 {
1097     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1098     CHECK_NULL_VOID(frameNode);
1099     if (Container::LessThanAPIVersion(PlatformVersion::VERSION_ELEVEN)) {
1100         if (opacity > 1.0f || LessNotEqual(opacity, 0.0f)) {
1101             opacity = 1.0f;
1102         }
1103     } else {
1104         opacity = std::clamp(opacity, 0.0f, 1.0f);
1105     }
1106     ViewAbstract::SetOpacity(frameNode, opacity);
1107 }
1108 
ResetOpacity(ArkUINodeHandle node)1109 void ResetOpacity(ArkUINodeHandle node)
1110 {
1111     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1112     CHECK_NULL_VOID(frameNode);
1113     ViewAbstract::SetOpacity(frameNode, 1.0f);
1114 }
1115 
SetAlign(ArkUINodeHandle node,ArkUI_Int32 align)1116 void SetAlign(ArkUINodeHandle node, ArkUI_Int32 align)
1117 {
1118     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1119     CHECK_NULL_VOID(frameNode);
1120     Alignment alignment = ParseAlignment(align);
1121     ViewAbstract::SetAlign(frameNode, alignment);
1122 }
1123 
ResetAlign(ArkUINodeHandle node)1124 void ResetAlign(ArkUINodeHandle node)
1125 {
1126     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1127     CHECK_NULL_VOID(frameNode);
1128     ViewAbstract::SetAlign(frameNode, Alignment::CENTER);
1129 }
1130 
SetBackdropBlur(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Bool disableSystemAdaptation)1131 void SetBackdropBlur(ArkUINodeHandle node, ArkUI_Float32 value, const ArkUI_Float32* blurValues,
1132     ArkUI_Int32 blurValuesSize, ArkUI_Bool disableSystemAdaptation)
1133 {
1134     ArkUI_Float32 blur = 0.0f;
1135     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1136     CHECK_NULL_VOID(frameNode);
1137     if (value > 0) {
1138         blur = value;
1139     }
1140     BlurOption blurOption;
1141     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1142     CalcDimension dimensionRadius(blur, DimensionUnit::PX);
1143     SysOptions sysOptions;
1144     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
1145     ViewAbstract::SetBackdropBlur(frameNode, dimensionRadius, blurOption, sysOptions);
1146 }
1147 
ResetBackdropBlur(ArkUINodeHandle node)1148 void ResetBackdropBlur(ArkUINodeHandle node)
1149 {
1150     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1151     CHECK_NULL_VOID(frameNode);
1152     double blur = 0.0;
1153     BlurOption option;
1154     CalcDimension dimensionRadius(blur, DimensionUnit::PX);
1155     ViewAbstract::SetBackdropBlur(frameNode, dimensionRadius, option);
1156 }
1157 
SetHueRotate(ArkUINodeHandle node,ArkUI_Float32 deg)1158 void SetHueRotate(ArkUINodeHandle node, ArkUI_Float32 deg)
1159 {
1160     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1161     CHECK_NULL_VOID(frameNode);
1162     deg = std::fmod(deg, ROUND_UNIT);
1163     if (deg < 0.0f) {
1164         deg += ROUND_UNIT;
1165     }
1166     ViewAbstract::SetHueRotate(frameNode, deg);
1167 }
1168 
ResetHueRotate(ArkUINodeHandle node)1169 void ResetHueRotate(ArkUINodeHandle node)
1170 {
1171     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1172     CHECK_NULL_VOID(frameNode);
1173     ArkUI_Float32 deg = 0.0f;
1174     ViewAbstract::SetHueRotate(frameNode, deg);
1175 }
1176 
SetInvert(ArkUINodeHandle node,ArkUI_Float32 * invert,ArkUI_Int32 length)1177 void SetInvert(ArkUINodeHandle node, ArkUI_Float32* invert, ArkUI_Int32 length)
1178 {
1179     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1180     CHECK_NULL_VOID(frameNode);
1181     InvertVariant invertVariant;
1182     if (length == NUM_4) {
1183         InvertOption option;
1184         option.low_ = invert[NUM_0];
1185         option.high_ = invert[NUM_1];
1186         option.threshold_ = invert[NUM_2];
1187         option.thresholdRange_ = invert[NUM_3];
1188         invertVariant = option;
1189     } else {
1190         invertVariant = invert[NUM_0];
1191     }
1192     ViewAbstract::SetInvert(frameNode, invertVariant);
1193 }
1194 
ResetInvert(ArkUINodeHandle node)1195 void ResetInvert(ArkUINodeHandle node)
1196 {
1197     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1198     CHECK_NULL_VOID(frameNode);
1199     InvertVariant invert = 0.0f;
1200     ViewAbstract::SetInvert(frameNode, invert);
1201 }
1202 
SetSepia(ArkUINodeHandle node,ArkUI_Float32 sepia)1203 void SetSepia(ArkUINodeHandle node, ArkUI_Float32 sepia)
1204 {
1205     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1206     CHECK_NULL_VOID(frameNode);
1207     CalcDimension value = CalcDimension(sepia, DimensionUnit::VP);
1208     if (LessNotEqual(value.Value(), 0.0)) {
1209         value.SetValue(0.0);
1210     }
1211     ViewAbstract::SetSepia(frameNode, value);
1212 }
1213 
ResetSepia(ArkUINodeHandle node)1214 void ResetSepia(ArkUINodeHandle node)
1215 {
1216     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1217     CHECK_NULL_VOID(frameNode);
1218     CalcDimension value(0.0, DimensionUnit::VP);
1219     ViewAbstract::SetSepia(frameNode, value);
1220 }
1221 
SetSaturate(ArkUINodeHandle node,ArkUI_Float32 saturate)1222 void SetSaturate(ArkUINodeHandle node, ArkUI_Float32 saturate)
1223 {
1224     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1225     CHECK_NULL_VOID(frameNode);
1226     CalcDimension value = CalcDimension(saturate, DimensionUnit::VP);
1227     if (LessNotEqual(value.Value(), 0.0)) {
1228         value.SetValue(0.0);
1229     }
1230     ViewAbstract::SetSaturate(frameNode, value);
1231 }
1232 
ResetSaturate(ArkUINodeHandle node)1233 void ResetSaturate(ArkUINodeHandle node)
1234 {
1235     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1236     CHECK_NULL_VOID(frameNode);
1237     CalcDimension value(1.0, DimensionUnit::VP);
1238     ViewAbstract::SetSaturate(frameNode, value);
1239 }
1240 
SetColorBlend(ArkUINodeHandle node,uint32_t color)1241 void SetColorBlend(ArkUINodeHandle node, uint32_t color)
1242 {
1243     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1244     CHECK_NULL_VOID(frameNode);
1245     ViewAbstract::SetColorBlend(frameNode, Color(color));
1246 }
1247 
ResetColorBlend(ArkUINodeHandle node)1248 void ResetColorBlend(ArkUINodeHandle node)
1249 {
1250     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1251     CHECK_NULL_VOID(frameNode);
1252     Color colorBlend = Color::TRANSPARENT;
1253     ViewAbstract::SetColorBlend(frameNode, colorBlend);
1254 }
1255 
GetColorBlend(ArkUINodeHandle node)1256 ArkUI_Uint32 GetColorBlend(ArkUINodeHandle node)
1257 {
1258     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1259     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
1260     return ViewAbstract::GetColorBlend(frameNode).GetValue();
1261 }
1262 
SetGrayscale(ArkUINodeHandle node,ArkUI_Float64 grayScale)1263 void SetGrayscale(ArkUINodeHandle node, ArkUI_Float64 grayScale)
1264 {
1265     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1266     CHECK_NULL_VOID(frameNode);
1267     CalcDimension value = CalcDimension(grayScale, DimensionUnit::VP);
1268     if (LessNotEqual(value.Value(), 0.0)) {
1269         value.SetValue(0.0);
1270     }
1271     if (GreatNotEqual(value.Value(), 1.0)) {
1272         value.SetValue(1.0);
1273     }
1274     ViewAbstract::SetGrayScale(frameNode, value);
1275 }
1276 
ResetGrayscale(ArkUINodeHandle node)1277 void ResetGrayscale(ArkUINodeHandle node)
1278 {
1279     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1280     CHECK_NULL_VOID(frameNode);
1281     CalcDimension value(0.0, DimensionUnit::VP);
1282     ViewAbstract::SetGrayScale(frameNode, value);
1283 }
1284 
SetContrast(ArkUINodeHandle node,ArkUI_Float64 contrast)1285 void SetContrast(ArkUINodeHandle node, ArkUI_Float64 contrast)
1286 {
1287     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1288     CHECK_NULL_VOID(frameNode);
1289     CalcDimension value = CalcDimension(contrast, DimensionUnit::VP);
1290     if (LessNotEqual(value.Value(), 0.0)) {
1291         value.SetValue(0.0);
1292     }
1293     ViewAbstract::SetContrast(frameNode, value);
1294 }
1295 
ResetContrast(ArkUINodeHandle node)1296 void ResetContrast(ArkUINodeHandle node)
1297 {
1298     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1299     CHECK_NULL_VOID(frameNode);
1300     CalcDimension value(1.0, DimensionUnit::VP);
1301     ViewAbstract::SetContrast(frameNode, value);
1302 }
1303 
SetBrightness(ArkUINodeHandle node,ArkUI_Float64 brightness)1304 void SetBrightness(ArkUINodeHandle node, ArkUI_Float64 brightness)
1305 {
1306     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1307     CHECK_NULL_VOID(frameNode);
1308     CalcDimension value = CalcDimension(brightness, DimensionUnit::VP);
1309     if (LessNotEqual(value.Value(), 0.0)) {
1310         value.SetValue(0.0);
1311     }
1312     ViewAbstract::SetBrightness(frameNode, value);
1313 }
1314 
ResetBrightness(ArkUINodeHandle node)1315 void ResetBrightness(ArkUINodeHandle node)
1316 {
1317     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1318     CHECK_NULL_VOID(frameNode);
1319     CalcDimension value(1.0, DimensionUnit::VP);
1320     ViewAbstract::SetBrightness(frameNode, value);
1321 }
1322 
SetBlur(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Bool disableSystemAdaptation)1323 void SetBlur(ArkUINodeHandle node, ArkUI_Float32 value, const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize,
1324     ArkUI_Bool disableSystemAdaptation)
1325 {
1326     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1327     CHECK_NULL_VOID(frameNode);
1328     ArkUI_Float32 blur = 0.0f;
1329     BlurOption blurOption;
1330     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1331     if (value > 0) {
1332         blur = value;
1333     }
1334     CalcDimension dimensionBlur(blur, DimensionUnit::PX);
1335     SysOptions sysOptions;
1336     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
1337     ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, blurOption, sysOptions);
1338 }
1339 
ResetBlur(ArkUINodeHandle node)1340 void ResetBlur(ArkUINodeHandle node)
1341 {
1342     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1343     CHECK_NULL_VOID(frameNode);
1344     double blur = 0.0;
1345     BlurOption option;
1346     CalcDimension dimensionBlur(blur, DimensionUnit::PX);
1347     ViewAbstract::SetFrontBlur(frameNode, dimensionBlur, option);
1348 }
1349 
1350 /**
1351  * @param values value value
1352  * values[0], values[1] : angle: hasValue, angle value
1353  * values[2] : direction
1354  * values[3] : repeating
1355  * @param valuesLength values length
1356  * @param colors color value
1357  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1358  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1359  * ...
1360  * @param colorsLength colors length
1361  */
SetLinearGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1362 void SetLinearGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1363     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1364 {
1365     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1366     CHECK_NULL_VOID(frameNode);
1367     if ((values == nullptr) || (valuesLength != NUM_4) || ((colorsLength % NUM_3) != 0)) {
1368         return;
1369     }
1370     NG::Gradient gradient;
1371     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1372     SetLinearGradientValues(gradient, values, valuesLength);
1373     SetGradientColors(gradient, colors, colorsLength);
1374     ViewAbstract::SetLinearGradient(frameNode, gradient);
1375 }
1376 
ResetLinearGradient(ArkUINodeHandle node)1377 void ResetLinearGradient(ArkUINodeHandle node)
1378 {
1379     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1380     CHECK_NULL_VOID(frameNode);
1381     NG::Gradient gradient;
1382     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1383     ViewAbstract::SetLinearGradient(frameNode, gradient);
1384 }
1385 
1386 /**
1387  * @param values value value
1388  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
1389  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
1390  * values[6], values[7] : start: hasValue, start degree value
1391  * values[8], values[9] : end: hasValue, end degree value
1392  * values[10], values[11] : rotation: hasValue, rotation degree value
1393  * values[12] : repeating
1394  * @param valuesLength values length
1395  * @param colors color value
1396  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1397  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1398  * ...
1399  * @param colorsLength colors length
1400  */
SetSweepGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1401 void SetSweepGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1402     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1403 {
1404     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1405     CHECK_NULL_VOID(frameNode);
1406     if ((values == nullptr) || (valuesLength != NUM_13) || ((colorsLength % NUM_3) != 0)) {
1407         return;
1408     }
1409     NG::Gradient gradient;
1410     gradient.CreateGradientWithType(NG::GradientType::SWEEP);
1411     SetSweepGradientValues(gradient, values, valuesLength);
1412     SetGradientColors(gradient, colors, colorsLength);
1413     ViewAbstract::SetSweepGradient(frameNode, gradient);
1414 }
1415 
ResetSweepGradient(ArkUINodeHandle node)1416 void ResetSweepGradient(ArkUINodeHandle node)
1417 {
1418     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1419     CHECK_NULL_VOID(frameNode);
1420     NG::Gradient gradient;
1421     gradient.CreateGradientWithType(NG::GradientType::SWEEP);
1422     ViewAbstract::SetSweepGradient(frameNode, gradient);
1423 }
1424 
1425 /**
1426  * @param values value value
1427  * values[0], values[1], values[2] : centerX Dimension: hasValue, value, unit
1428  * values[3], values[4], values[5] : centerY Dimension: hasValue, value, unit
1429  * values[6], values[7], values[8] : radius: Dimension: hasValue, value, unit
1430  * values[9] : repeating
1431  * @param valuesLength values length
1432  * @param colors color value
1433  * colors[0], colors[1], colors[2] : color[0](color, hasDimension, dimension)
1434  * colors[3], colors[4], colors[5] : color[1](color, hasDimension, dimension)
1435  * ...
1436  * @param colorsLength colors length
1437  */
SetRadialGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1438 void SetRadialGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1439     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1440 {
1441     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1442     CHECK_NULL_VOID(frameNode);
1443     if ((values == nullptr) || (valuesLength != NUM_10) || ((colorsLength % NUM_3) != 0)) {
1444         return;
1445     }
1446     NG::Gradient gradient;
1447     gradient.CreateGradientWithType(NG::GradientType::RADIAL);
1448     SetRadialGradientValues(gradient, values, valuesLength);
1449     SetGradientColors(gradient, colors, colorsLength);
1450     ViewAbstract::SetRadialGradient(frameNode, gradient);
1451 }
1452 
ResetRadialGradient(ArkUINodeHandle node)1453 void ResetRadialGradient(ArkUINodeHandle node)
1454 {
1455     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1456     CHECK_NULL_VOID(frameNode);
1457     NG::Gradient gradient;
1458     gradient.CreateGradientWithType(NG::GradientType::RADIAL);
1459     ViewAbstract::SetRadialGradient(frameNode, gradient);
1460 }
1461 
1462 /**
1463  * @param text text value
1464  * @param options option value
1465  * option[0], option[1]: align(hasValue, value)
1466  * option[2], option[3], option[4]: offsetX(hasValue, value, unit)
1467  * option[5], option[6], option[7]: offsetY(hasValue, value, unit)
1468  * option[8]: hasOptions
1469  * option[9]: hasOffset
1470  * @param optionsLength options length
1471  */
SetOverlay(ArkUINodeHandle node,ArkUI_CharPtr text,const ArkUI_Float32 * options,ArkUI_Int32 optionsLength)1472 void SetOverlay(ArkUINodeHandle node, ArkUI_CharPtr text, const ArkUI_Float32* options, ArkUI_Int32 optionsLength)
1473 {
1474     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1475     CHECK_NULL_VOID(frameNode);
1476     if ((options == nullptr) || (optionsLength != NUM_10)) {
1477         return;
1478     }
1479     auto alignHasValue = options[NUM_0];
1480     auto alignValue = options[NUM_1];
1481     auto offsetXHasValue = options[NUM_2];
1482     auto offsetXValue = options[NUM_3];
1483     auto offsetXUnit = options[NUM_4];
1484     auto offsetYHasValue = options[NUM_5];
1485     auto offsetYValue = options[NUM_6];
1486     auto offsetYUnit = options[NUM_7];
1487     auto hasOptions = options[NUM_8];
1488     auto hasOffset = options[NUM_9];
1489     NG::OverlayOptions overlay;
1490     if (text != nullptr) {
1491         overlay.content = text;
1492     }
1493     if (static_cast<bool>(hasOptions)) {
1494         if (static_cast<bool>(alignHasValue)) {
1495             overlay.align = ParseAlignment(static_cast<int32_t>(alignValue));
1496         } else {
1497             overlay.align = Alignment::TOP_LEFT;
1498         }
1499         if (static_cast<bool>(hasOffset)) {
1500             if (static_cast<bool>(offsetXHasValue)) {
1501                 overlay.x = CalcDimension(offsetXValue, static_cast<DimensionUnit>(offsetXUnit));
1502             }
1503             if (static_cast<bool>(offsetYHasValue)) {
1504                 overlay.y = CalcDimension(offsetYValue, static_cast<DimensionUnit>(offsetYUnit));
1505             }
1506         }
1507     } else {
1508         overlay.align = Alignment::TOP_LEFT;
1509         overlay.x = CalcDimension(0);
1510         overlay.y = CalcDimension(0);
1511     }
1512     ViewAbstract::SetOverlay(frameNode, overlay);
1513 }
1514 
ResetOverlay(ArkUINodeHandle node)1515 void ResetOverlay(ArkUINodeHandle node)
1516 {
1517     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1518     CHECK_NULL_VOID(frameNode);
1519     NG::OverlayOptions overlay;
1520     overlay.align = Alignment::TOP_LEFT;
1521     overlay.x = CalcDimension(0);
1522     overlay.y = CalcDimension(0);
1523     ViewAbstract::SetOverlay(frameNode, overlay);
1524 }
1525 
1526 /**
1527  * @param src source value
1528  * @param options option value
1529  * option[offset + 0], option[offset + 1], option[offset + 2]: sliceTop(hasValue, value, unit)
1530  * option[offset + 3], option[offset + 4], option[offset + 5]: sliceRight(hasValue, value, unit)
1531  * option[offset + 6], option[offset + 7], option[offset + 8]: sliceBottom(hasValue, value, unit)
1532  * option[offset + 9], option[offset + 10], option[offset + 11]: sliceLeft(hasValue, value, unit)
1533  * option[offset + 12], option[offset + 13]: repeat(hasValue, value)
1534  * option[offset + 14], option[offset + 15], option[offset + 16]: widthTop(hasValue, value, unit)
1535  * option[offset + 17], option[offset + 18], option[offset + 19]: widthRight(hasValue, value, unit)
1536  * option[offset + 20], option[offset + 21], option[offset + 22]: widthBottom(hasValue, value, unit)
1537  * option[offset + 23], option[offset + 24], option[offset + 25]: widthLeft(hasValue, value, unit)
1538  * option[offset + 26], option[offset + 27], option[offset + 28]: outsetTop(hasValue, value, unit)
1539  * option[offset + 29], option[offset + 30], option[offset + 31]: outsetRight(hasValue, value, unit)
1540  * option[offset + 32], option[offset + 33], option[offset + 34]: outsetBottom(hasValue, value, unit)
1541  * option[offset + 35], option[offset + 36], option[offset + 37]: outsetLeft(hasValue, value, unit)
1542  * option[offset + 38], option[offset + 39]: fill(hasValue, value)
1543  * option[offset + 40]: bitset
1544  * @param optionsLength options length
1545  */
SetBorderImage(ArkUINodeHandle node,ArkUI_CharPtr src,const ArkUIStringAndFloat * options,ArkUI_Int32 optionsLength)1546 void SetBorderImage(
1547     ArkUINodeHandle node, ArkUI_CharPtr src, const ArkUIStringAndFloat* options, ArkUI_Int32 optionsLength)
1548 {
1549     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1550     CHECK_NULL_VOID(frameNode);
1551     // slice:12 double, repeat:2 double, width:12 double, outset:12 double, fill:2 double, bitset:1 double
1552     auto desireLength = NUM_12 + NUM_2 + NUM_12 + NUM_12 + NUM_2 + NUM_1;
1553     if ((options == nullptr) || (optionsLength != desireLength)) {
1554         return;
1555     }
1556     RefPtr<BorderImage> borderImage = AceType::MakeRefPtr<BorderImage>();
1557     if (src != nullptr) {
1558         borderImage->SetSrc(std::string(src));
1559     }
1560     int32_t loc = 0;
1561     std::vector<BorderImageDirection> directions = { BorderImageDirection::TOP, BorderImageDirection::RIGHT,
1562         BorderImageDirection::BOTTOM, BorderImageDirection::LEFT };
1563     SetBorderImageSlice(borderImage, directions, options, optionsLength, loc);  // read 12 double
1564     SetBorderImageRepeat(borderImage, options, optionsLength, loc);             // read 2 double
1565     SetBorderImageWidth(borderImage, directions, options, optionsLength, loc);  // read 12 double
1566     SetBorderImageOutset(borderImage, directions, options, optionsLength, loc); // read 12 double
1567     SetBorderImageFill(borderImage, options, optionsLength, loc);               // read 2 double
1568     auto bitsetValue = options[loc].value;
1569     SetBorderImage(frameNode, borderImage, static_cast<uint8_t>(bitsetValue));
1570 }
1571 
ResetBorderImage(ArkUINodeHandle node)1572 void ResetBorderImage(ArkUINodeHandle node)
1573 {
1574     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1575     CHECK_NULL_VOID(frameNode);
1576     RefPtr<BorderImage> borderImage = AceType::MakeRefPtr<BorderImage>();
1577     uint8_t imageBorderBitsets = 0;
1578     SetBorderImage(frameNode, borderImage, imageBorderBitsets);
1579 }
1580 
SetBorderImageGradient(ArkUINodeHandle node,const ArkUIInt32orFloat32 * values,ArkUI_Int32 valuesLength,const ArkUIInt32orFloat32 * colors,ArkUI_Int32 colorsLength)1581 void SetBorderImageGradient(ArkUINodeHandle node, const ArkUIInt32orFloat32* values, ArkUI_Int32 valuesLength,
1582     const ArkUIInt32orFloat32* colors, ArkUI_Int32 colorsLength)
1583 {
1584     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1585     CHECK_NULL_VOID(frameNode);
1586     if ((values == nullptr) || (valuesLength != NUM_4) || ((colorsLength % NUM_3) != 0)) {
1587         return;
1588     }
1589     NG::Gradient gradient;
1590     gradient.CreateGradientWithType(NG::GradientType::LINEAR);
1591     SetBorderImageGradientValues(gradient, values, valuesLength);
1592     SetGradientColors(gradient, colors, colorsLength);
1593     ViewAbstract::SetBorderImageGradient(frameNode, gradient);
1594 }
1595 
SetForegroundBlurStyle(ArkUINodeHandle node,ArkUI_Int32 (* intArray)[3],ArkUI_Float32 scale,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Bool disableSystemAdaptation)1596 void SetForegroundBlurStyle(ArkUINodeHandle node, ArkUI_Int32 (*intArray)[3], ArkUI_Float32 scale,
1597     const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize, ArkUI_Bool disableSystemAdaptation)
1598 {
1599     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1600     CHECK_NULL_VOID(frameNode);
1601     ArkUI_Int32 blurStyle = (*intArray)[NUM_0];
1602     ArkUI_Int32 colorMode = (*intArray)[NUM_1];
1603     ArkUI_Int32 adaptiveColor = (*intArray)[NUM_2];
1604     BlurStyleOption fgBlurStyle;
1605     if (blurStyle >= 0) {
1606         if (blurStyle >= static_cast<int>(BlurStyle::NO_MATERIAL) &&
1607             blurStyle <= static_cast<int>(BlurStyle::COMPONENT_ULTRA_THICK)) {
1608             fgBlurStyle.blurStyle = static_cast<BlurStyle>(blurStyle);
1609         }
1610     }
1611     bool isHasOptions = !((colorMode < 0) && (adaptiveColor < 0) && (scale < 0) && (blurValuesSize == 0));
1612     if (isHasOptions) {
1613         if (colorMode >= static_cast<int32_t>(ThemeColorMode::SYSTEM) &&
1614             colorMode <= static_cast<int32_t>(ThemeColorMode::DARK)) {
1615             fgBlurStyle.colorMode = static_cast<ThemeColorMode>(colorMode);
1616         }
1617         if (adaptiveColor >= static_cast<int32_t>(AdaptiveColor::DEFAULT) &&
1618             adaptiveColor <= static_cast<int32_t>(AdaptiveColor::AVERAGE)) {
1619             fgBlurStyle.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColor);
1620         }
1621         if (scale >= 0) {
1622             fgBlurStyle.scale = std::clamp(scale, 0.0f, 1.0f);
1623         }
1624         BlurOption blurOption;
1625         blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1626         fgBlurStyle.blurOption = blurOption;
1627     }
1628     SysOptions sysOptions;
1629     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
1630     ViewAbstract::SetForegroundBlurStyle(frameNode, fgBlurStyle, sysOptions);
1631 }
1632 
ResetForegroundBlurStyle(ArkUINodeHandle node)1633 void ResetForegroundBlurStyle(ArkUINodeHandle node)
1634 {
1635     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1636     CHECK_NULL_VOID(frameNode);
1637     BlurStyleOption styleOption;
1638     ViewAbstract::SetForegroundBlurStyle(frameNode, styleOption);
1639 }
1640 
GetForegroundBlurStyle(ArkUINodeHandle node)1641 ArkUIBlurStyleOptionType GetForegroundBlurStyle(ArkUINodeHandle node)
1642 {
1643     ArkUIBlurStyleOptionType styleOptionType = { 0, 0, 0, 1.0f, 0, 0 };
1644     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1645     CHECK_NULL_RETURN(frameNode, styleOptionType);
1646     auto renderContext = frameNode->GetRenderContext();
1647     CHECK_NULL_RETURN(renderContext, styleOptionType);
1648     auto blurStyleOption = renderContext->GetFrontBlurStyle();
1649     if (!blurStyleOption.has_value()) {
1650         return styleOptionType;
1651     }
1652     styleOptionType.blurStyle = static_cast<int32_t>(blurStyleOption->blurStyle);
1653     styleOptionType.colorMode = static_cast<int32_t>(blurStyleOption->colorMode);
1654     styleOptionType.adaptiveColor = static_cast<int32_t>(blurStyleOption->adaptiveColor);
1655     styleOptionType.scale = blurStyleOption->scale;
1656     styleOptionType.grayScaleStart = blurStyleOption->blurOption.grayscale[NUM_0];
1657     styleOptionType.grayScaleEnd = blurStyleOption->blurOption.grayscale[NUM_1];
1658     return styleOptionType;
1659 }
1660 
1661 /**
1662  * @param blurRadius blurRadius value
1663  * @param stops stop value
1664  * stops[0], stops[1] : fractionStops pair[0]
1665  * stops[2], stops[3] : fractionStops pair[1] ...
1666  * @param stopsLength stops length
1667  * @param directionValue direction value
1668  */
SetLinearGradientBlur(ArkUINodeHandle node,ArkUI_Float32 blurRadius,const ArkUI_Float32 * stops,ArkUI_Uint32 stopsLength,ArkUI_Int32 directionValue)1669 void SetLinearGradientBlur(ArkUINodeHandle node, ArkUI_Float32 blurRadius, const ArkUI_Float32* stops,
1670     ArkUI_Uint32 stopsLength, ArkUI_Int32 directionValue)
1671 {
1672     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1673     CHECK_NULL_VOID(frameNode);
1674     blurRadius = std::clamp(blurRadius, 0.0f, 60.0f); // 60.0 represents largest blur radius;
1675     std::vector<std::pair<float, float>> fractionStops;
1676     if ((stopsLength & 0x1) == 0) {
1677         float tmpPos = -1.0f;
1678         for (size_t index = 0; index < stopsLength; index += NUM_2) {
1679             auto first = stops[index];
1680             auto second = stops[index + NUM_1];
1681             std::pair<float, float> fractionStop;
1682             fractionStop.first = static_cast<float>(std::clamp(first, 0.0f, 1.0f));
1683             fractionStop.second = static_cast<float>(std::clamp(second, 0.0f, 1.0f));
1684             if (fractionStop.second <= tmpPos) {
1685                 fractionStops.clear();
1686                 break;
1687             }
1688             tmpPos = fractionStop.second;
1689             fractionStops.push_back(fractionStop);
1690         }
1691     }
1692     if (static_cast<int32_t>(fractionStops.size()) <= 1) {
1693         fractionStops.clear();
1694         fractionStops.push_back(std::pair<float, float>(0.0f, 0.0f));
1695         fractionStops.push_back(std::pair<float, float>(0.0f, 1.0f));
1696     }
1697     if (directionValue < static_cast<int8_t>(GradientDirection::LEFT) ||
1698         directionValue >= static_cast<int8_t>(GradientDirection::NONE)) {
1699         directionValue = static_cast<int8_t>(GradientDirection::BOTTOM);
1700     }
1701     auto direction = static_cast<GradientDirection>(directionValue);
1702     Dimension dimensionRadius(blurRadius, DimensionUnit::PX);
1703     NG::LinearGradientBlurPara blurPara(dimensionRadius, fractionStops, direction);
1704     ViewAbstract::SetLinearGradientBlur(frameNode, blurPara);
1705 }
1706 
ResetLinearGradientBlur(ArkUINodeHandle node)1707 void ResetLinearGradientBlur(ArkUINodeHandle node)
1708 {
1709     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1710     CHECK_NULL_VOID(frameNode);
1711     std::vector<std::pair<float, float>> fractionStops;
1712     fractionStops.push_back(std::pair<float, float>(0.0f, 0.0f));
1713     fractionStops.push_back(std::pair<float, float>(0.0f, 1.0f));
1714     Dimension dimensionRadius(0.0f, DimensionUnit::PX);
1715     NG::LinearGradientBlurPara blurPara(dimensionRadius, fractionStops, GradientDirection::BOTTOM);
1716     ViewAbstract::SetLinearGradientBlur(frameNode, blurPara);
1717 }
1718 
SetBackgroundBlurStyle(ArkUINodeHandle node,ArkUI_Int32 (* intArray)[5],ArkUI_Float32 scale,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Bool isValidColor,ArkUI_Uint32 inactiveColorArg,ArkUI_Bool disableSystemAdaptation)1719 void SetBackgroundBlurStyle(ArkUINodeHandle node, ArkUI_Int32 (*intArray)[5], ArkUI_Float32 scale,
1720     const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize, ArkUI_Bool isValidColor, ArkUI_Uint32 inactiveColorArg,
1721     ArkUI_Bool disableSystemAdaptation)
1722 {
1723     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1724     CHECK_NULL_VOID(frameNode);
1725     ArkUI_Int32 blurStyle = (*intArray)[NUM_0];
1726     ArkUI_Int32 colorMode = (*intArray)[NUM_1];
1727     ArkUI_Int32 adaptiveColor = (*intArray)[NUM_2];
1728     ArkUI_Int32 policy = (*intArray)[NUM_3];
1729     ArkUI_Int32 blurType = (*intArray)[NUM_4];
1730     BlurStyleOption bgBlurStyle;
1731     if (blurStyle >= 0) {
1732         if (blurStyle >= static_cast<int>(BlurStyle::NO_MATERIAL) &&
1733             blurStyle <= static_cast<int>(BlurStyle::COMPONENT_ULTRA_THICK)) {
1734             bgBlurStyle.blurStyle = static_cast<BlurStyle>(blurStyle);
1735         }
1736     }
1737     bool isHasOptions = !((colorMode < 0) && (adaptiveColor < 0) && (scale < 0) && (blurValuesSize == 0));
1738     if (isHasOptions) {
1739         if (colorMode >= static_cast<int32_t>(ThemeColorMode::SYSTEM) &&
1740             colorMode <= static_cast<int32_t>(ThemeColorMode::DARK)) {
1741             bgBlurStyle.colorMode = static_cast<ThemeColorMode>(colorMode);
1742         }
1743         if (adaptiveColor >= static_cast<int32_t>(AdaptiveColor::DEFAULT) &&
1744             adaptiveColor <= static_cast<int32_t>(AdaptiveColor::AVERAGE)) {
1745             bgBlurStyle.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColor);
1746         }
1747         bgBlurStyle.scale = std::clamp(scale, 0.0f, 1.0f);
1748         BlurOption blurOption;
1749         blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
1750         bgBlurStyle.blurOption = blurOption;
1751     }
1752     bgBlurStyle.policy = static_cast<BlurStyleActivePolicy>(policy);
1753     bgBlurStyle.blurType = static_cast<BlurType>(blurType);
1754     bgBlurStyle.isValidColor = isValidColor;
1755     Color inactiveColor(inactiveColorArg);
1756     bgBlurStyle.inactiveColor = inactiveColor;
1757     SysOptions sysOptions;
1758     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
1759     ViewAbstract::SetBackgroundBlurStyle(frameNode, bgBlurStyle, sysOptions);
1760 }
1761 
GetBackgroundBlurStyle(ArkUINodeHandle node)1762 ArkUIBlurStyleOptionType GetBackgroundBlurStyle(ArkUINodeHandle node)
1763 {
1764     ArkUIBlurStyleOptionType styleOptionType = { 0, 0, 0, 1.0f };
1765     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1766     CHECK_NULL_RETURN(frameNode, styleOptionType);
1767     auto renderContext = frameNode->GetRenderContext();
1768     CHECK_NULL_RETURN(renderContext, styleOptionType);
1769     auto backBlurStyleOption = renderContext->GetBackBlurStyle();
1770     if (!backBlurStyleOption.has_value()) {
1771         return styleOptionType;
1772     }
1773     styleOptionType.blurStyle = static_cast<int32_t>(backBlurStyleOption->blurStyle);
1774     styleOptionType.colorMode = static_cast<int32_t>(backBlurStyleOption->colorMode);
1775     styleOptionType.adaptiveColor = static_cast<int32_t>(backBlurStyleOption->adaptiveColor);
1776     styleOptionType.scale = backBlurStyleOption->scale;
1777     auto greyScaleVector = backBlurStyleOption->blurOption.grayscale;
1778     styleOptionType.grayScaleStart = greyScaleVector.size() > NUM_0 ? greyScaleVector[NUM_0] : 0.0f;
1779     styleOptionType.grayScaleEnd = greyScaleVector.size() > NUM_1 ? greyScaleVector[NUM_1] : 0.0f;
1780     return styleOptionType;
1781 }
1782 
ResetBackgroundBlurStyle(ArkUINodeHandle node)1783 void ResetBackgroundBlurStyle(ArkUINodeHandle node)
1784 {
1785     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1786     CHECK_NULL_VOID(frameNode);
1787     BlurStyleOption bgBlurStyle;
1788     ViewAbstract::SetBackgroundBlurStyle(frameNode, bgBlurStyle);
1789 }
1790 
SetBorderWidth(const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,int32_t & offset,NG::BorderWidthProperty & borderWidth,ArkUI_Bool isLocalizedBorderWidth,FrameNode * frameNode)1791 void SetBorderWidth(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset,
1792     NG::BorderWidthProperty& borderWidth, ArkUI_Bool isLocalizedBorderWidth, FrameNode* frameNode)
1793 {
1794     if (isLocalizedBorderWidth) {
1795         SetOptionalBorder(borderWidth.startDimen, values, valuesSize, offset);
1796         SetOptionalBorder(borderWidth.endDimen, values, valuesSize, offset);
1797     } else {
1798         SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
1799         SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
1800     }
1801     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
1802     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
1803     borderWidth.multiValued = true;
1804     if (borderWidth.leftDimen.has_value() || borderWidth.rightDimen.has_value() || borderWidth.topDimen.has_value() ||
1805         borderWidth.bottomDimen.has_value() || borderWidth.startDimen.has_value() || borderWidth.endDimen.has_value()) {
1806         ViewAbstract::SetBorderWidth(frameNode, borderWidth);
1807     }
1808 }
1809 
SetBorderBorderRadius(const ArkUI_Float32 * values,ArkUI_Int32 valuesSize,int32_t & offset,NG::BorderRadiusProperty & borderRadius,ArkUI_Bool isLocalizedBorderRadius,FrameNode * frameNode)1810 void SetBorderBorderRadius(const ArkUI_Float32* values, ArkUI_Int32 valuesSize, int32_t& offset,
1811     NG::BorderRadiusProperty& borderRadius, ArkUI_Bool isLocalizedBorderRadius, FrameNode* frameNode)
1812 {
1813     if (isLocalizedBorderRadius) {
1814         SetOptionalBorder(borderRadius.radiusTopStart, values, valuesSize, offset);
1815         SetOptionalBorder(borderRadius.radiusTopEnd, values, valuesSize, offset);
1816         SetOptionalBorder(borderRadius.radiusBottomStart, values, valuesSize, offset);
1817         SetOptionalBorder(borderRadius.radiusBottomEnd, values, valuesSize, offset);
1818     } else {
1819         SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, offset);
1820         SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, offset);
1821         SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, offset);
1822         SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, offset);
1823     }
1824 
1825     borderRadius.multiValued = true;
1826     if (borderRadius.radiusTopLeft.has_value() || borderRadius.radiusTopRight.has_value() ||
1827         borderRadius.radiusBottomLeft.has_value() || borderRadius.radiusBottomRight.has_value() ||
1828         borderRadius.radiusTopStart.has_value() || borderRadius.radiusTopEnd.has_value() ||
1829         borderRadius.radiusBottomStart.has_value() || borderRadius.radiusBottomEnd.has_value()) {
1830         ViewAbstract::SetBorderRadius(frameNode, borderRadius);
1831     }
1832 }
1833 
1834 /**
1835  * @param src source borderWidth and and BorderRadius value
1836  * @param options option value
1837  * values[offset + 0], option[offset + 1], option[offset + 2]: borderWidth start/left(hasValue, value, unit)
1838  * values[offset + 3], option[offset + 4], option[offset + 5]: borderWidth end/right(hasValue, value, unit)
1839  * values[offset + 6], option[offset + 7], option[offset + 8]: borderWidth top(hasValue, value, unit)
1840  * values[offset + 9], option[offset + 10], option[offset + 11]: borderWidth bottom(hasValue, value, unit)
1841  * values[offset + 12], option[offset + 13], option[offset + 14] : BorderRadius TopStart/Left(hasValue, value, unit)
1842  * values[offset + 15], option[offset + 16], option[offset + 17] : BorderRadius TopEnd/Right(hasValue, value, unit)
1843  * values[offset + 18], option[offset + 19], option[offset + 20] : BorderRadius BottomStart/Left(hasValue, value, unit)
1844  * values[offset + 21], option[offset + 22], option[offset + 23] : BorderRadius BottomEnd/Right(hasValue, value, unit)
1845  * @param optionsLength options valuesSize
1846  * @param src source color and Style value
1847  * colorAndStyle[offset + 0], option[offset + 1]: borderColors startColor/leftColor(hasValue, value)
1848  * colorAndStyle[offset + 2], option[offset + 3]: borderColors endColor/rightColor(hasValue, value)
1849  * colorAndStyle[offset + 4], option[offset + 5]: borderColors topColor(hasValue, value)
1850  * colorAndStyle[offset + 6], option[offset + 7]: borderColors bottomColor(hasValue, value)
1851  * colorAndStyle[offset + 8], option[offset + 9]: borderStyles styleLeft(hasValue, value)
1852  * colorAndStyle[offset + 10], option[offset + 11]: borderStyles styleRight(hasValue, value)
1853  * colorAndStyle[offset + 12], option[offset + 12]: borderStyles styleTop(hasValue, value)
1854  * colorAndStyle[offset + 14], option[offset + 15]: borderStyles styleBottom(hasValue, value)
1855  * @param optionsLength options colorAndStyleSize
1856  * @param isLocalizedBorderWidth options isLocalizedBorderWidth
1857  * @param isLocalizedBorderColor options isLocalizedBorderColor
1858  * @param isLocalizedBorderRadius options isLocalizedBorderRadius
1859  */
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)1860 void SetBorder(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize, const uint32_t* colorAndStyle,
1861     int32_t colorAndStyleSize, ArkUI_Bool isLocalizedBorderWidth, ArkUI_Bool isLocalizedBorderColor,
1862     ArkUI_Bool isLocalizedBorderRadius)
1863 {
1864     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1865     CHECK_NULL_VOID(frameNode);
1866     if ((values == nullptr) || (valuesSize != NUM_24) || (colorAndStyle == nullptr) || colorAndStyleSize != NUM_16) {
1867         return;
1868     }
1869 
1870     int32_t offset = NUM_0;
1871     NG::BorderWidthProperty borderWidth;
1872     SetBorderWidth(values, valuesSize, offset, borderWidth, isLocalizedBorderWidth, frameNode);
1873     NG::BorderRadiusProperty borderRadius;
1874     SetBorderBorderRadius(values, valuesSize, offset, borderRadius, isLocalizedBorderRadius, frameNode);
1875     int32_t colorAndStyleOffset = NUM_0;
1876     NG::BorderColorProperty borderColors;
1877     if (isLocalizedBorderColor) {
1878         SetOptionalBorderColor(borderColors.startColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1879         SetOptionalBorderColor(borderColors.endColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1880     } else {
1881         SetOptionalBorderColor(borderColors.leftColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1882         SetOptionalBorderColor(borderColors.rightColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1883     }
1884     SetOptionalBorderColor(borderColors.topColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1885     SetOptionalBorderColor(borderColors.bottomColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1886     borderColors.multiValued = true;
1887     ViewAbstract::SetBorderColor(frameNode, borderColors);
1888 
1889     NG::BorderStyleProperty borderStyles;
1890     SetOptionalBorderStyle(borderStyles.styleLeft, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1891     SetOptionalBorderStyle(borderStyles.styleRight, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1892     SetOptionalBorderStyle(borderStyles.styleTop, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1893     SetOptionalBorderStyle(borderStyles.styleBottom, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
1894     borderStyles.multiValued = true;
1895     ViewAbstract::SetBorderStyle(frameNode, borderStyles);
1896 }
1897 
ResetBorder(ArkUINodeHandle node)1898 void ResetBorder(ArkUINodeHandle node)
1899 {
1900     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1901     CHECK_NULL_VOID(frameNode);
1902     CalcDimension borderWidth;
1903     ViewAbstract::SetBorderWidth(frameNode, borderWidth);
1904     ViewAbstract::SetBorderColor(frameNode, Color::BLACK);
1905     ViewAbstract::SetBorderRadius(frameNode, borderWidth);
1906     ViewAbstract::SetBorderStyle(frameNode, BorderStyle::SOLID);
1907     ViewAbstract::SetDashGap(frameNode, Dimension(-1));
1908     ViewAbstract::SetDashWidth(frameNode, Dimension(-1));
1909 }
1910 
SetBackgroundImagePosition(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * types,ArkUI_Bool isAlign,ArkUI_Int32 size)1911 void SetBackgroundImagePosition(
1912     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* types, ArkUI_Bool isAlign, ArkUI_Int32 size)
1913 {
1914     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1915     CHECK_NULL_VOID(frameNode);
1916     if (size != NUM_2) {
1917         return;
1918     }
1919     BackgroundImagePosition bgImgPosition;
1920     double valueX = values[NUM_0];
1921     double valueY = values[NUM_1];
1922     DimensionUnit typeX = static_cast<OHOS::Ace::DimensionUnit>(types[NUM_0]);
1923     DimensionUnit typeY = static_cast<OHOS::Ace::DimensionUnit>(types[NUM_1]);
1924     SetBgImgPosition(typeX, typeY, valueX, valueY, bgImgPosition);
1925     bgImgPosition.SetIsAlign(isAlign);
1926     ViewAbstract::SetBackgroundImagePosition(frameNode, bgImgPosition);
1927 }
1928 
ResetBackgroundImagePosition(ArkUINodeHandle node)1929 void ResetBackgroundImagePosition(ArkUINodeHandle node)
1930 {
1931     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1932     CHECK_NULL_VOID(frameNode);
1933     BackgroundImagePosition bgImgPosition;
1934     SetBgImgPosition(DimensionUnit::PX, DimensionUnit::PX, 0.0, 0.0, bgImgPosition);
1935     ViewAbstract::SetBackgroundImagePosition(frameNode, bgImgPosition);
1936 }
1937 
SetResizableFromVec(ImageResizableSlice & resizable,const ArkUIStringAndFloat * options)1938 void SetResizableFromVec(ImageResizableSlice& resizable, const ArkUIStringAndFloat* options)
1939 {
1940     std::vector<ResizableOption> directions = { ResizableOption::LEFT, ResizableOption::TOP, ResizableOption::RIGHT,
1941         ResizableOption::BOTTOM };
1942     for (unsigned int index = 0; index < NUM_12; index += NUM_3) {
1943         std::optional<CalcDimension> optDimension;
1944         SetCalcDimension(optDimension, options, NUM_13, index);
1945         if (optDimension.has_value()) {
1946             auto direction = directions[index / NUM_3];
1947             resizable.SetEdgeSlice(direction, optDimension.value());
1948         }
1949     }
1950 }
1951 
SetBackgroundImageResizable(ArkUINodeHandle node,ArkUIStringAndFloat * options)1952 void SetBackgroundImageResizable(ArkUINodeHandle node, ArkUIStringAndFloat* options)
1953 {
1954     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1955     CHECK_NULL_VOID(frameNode);
1956     ImageResizableSlice resizable;
1957     SetResizableFromVec(resizable, options);
1958     ViewAbstract::SetBackgroundImageResizableSlice(frameNode, resizable);
1959 }
1960 
GetBackgroundImageResizable(ArkUINodeHandle node)1961 ArkUIImageResizableSlice GetBackgroundImageResizable(ArkUINodeHandle node)
1962 {
1963     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1964     ArkUIImageResizableSlice arkUISlice {};
1965     CHECK_NULL_RETURN(frameNode, arkUISlice);
1966     auto slice = ViewAbstract::GetBackgroundImageResizableSlice(frameNode);
1967     arkUISlice.left = static_cast<ArkUI_Float32>(slice.left.ConvertToVp());
1968     arkUISlice.top = static_cast<ArkUI_Float32>(slice.top.ConvertToVp());
1969     arkUISlice.right = static_cast<ArkUI_Float32>(slice.right.ConvertToVp());
1970     arkUISlice.bottom = static_cast<ArkUI_Float32>(slice.bottom.ConvertToVp());
1971     return arkUISlice;
1972 }
1973 
ResetBackgroundImageResizable(ArkUINodeHandle node)1974 void ResetBackgroundImageResizable(ArkUINodeHandle node)
1975 {
1976     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1977     CHECK_NULL_VOID(frameNode);
1978     ImageResizableSlice resizable;
1979     ViewAbstract::SetBackgroundImageResizableSlice(frameNode, resizable);
1980 }
1981 
SetBackgroundImageSize(ArkUINodeHandle node,ArkUI_Float32 valueWidth,ArkUI_Float32 valueHeight,ArkUI_Int32 typeWidth,ArkUI_Int32 typeHeight)1982 void SetBackgroundImageSize(ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight,
1983     ArkUI_Int32 typeWidth, ArkUI_Int32 typeHeight)
1984 {
1985     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1986     CHECK_NULL_VOID(frameNode);
1987     BackgroundImageSize bgImgSize;
1988     bgImgSize.SetSizeTypeX(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeWidth));
1989     bgImgSize.SetSizeValueX(valueWidth);
1990     bgImgSize.SetSizeTypeY(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeHeight));
1991     bgImgSize.SetSizeValueY(valueHeight);
1992     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
1993 }
1994 
GetBackgroundImageSize(ArkUINodeHandle node,ArkUI_Int32 unit)1995 ArkUIImageSizeType GetBackgroundImageSize(ArkUINodeHandle node, ArkUI_Int32 unit)
1996 {
1997     ArkUIImageSizeType imageSizeType = { 0, 0, 0, 0 };
1998     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1999     CHECK_NULL_RETURN(frameNode, imageSizeType);
2000     auto renderContext = frameNode->GetRenderContext();
2001     CHECK_NULL_RETURN(renderContext, imageSizeType);
2002     CHECK_NULL_RETURN(renderContext->GetBackground(), imageSizeType);
2003     auto imageSize = renderContext->GetBackground()->GetBackgroundImageSize();
2004     double density = unit == static_cast<ArkUI_Int32>(DimensionUnit::PX) ? 1 : PipelineBase::GetCurrentDensity();
2005     CHECK_NULL_RETURN(imageSize, imageSizeType);
2006     imageSizeType.xValue = imageSize->GetSizeValueX() / density;
2007     imageSizeType.yValue = imageSize->GetSizeValueY() / density;
2008     imageSizeType.xType = static_cast<int32_t>(imageSize->GetSizeTypeX());
2009     imageSizeType.yType = static_cast<int32_t>(imageSize->GetSizeTypeY());
2010     return imageSizeType;
2011 }
2012 
GetBackgroundImageSizeWidthStyle(ArkUINodeHandle node)2013 int32_t GetBackgroundImageSizeWidthStyle(ArkUINodeHandle node)
2014 {
2015     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2016     CHECK_NULL_RETURN(frameNode, 0);
2017     auto renderContext = frameNode->GetRenderContext();
2018     CHECK_NULL_RETURN(renderContext, 0);
2019     CHECK_NULL_RETURN(renderContext->GetBackground(), 0);
2020     auto imageSize = renderContext->GetBackground()->GetBackgroundImageSize();
2021     CHECK_NULL_RETURN(imageSize, 0);
2022     return static_cast<int32_t>(imageSize->GetSizeTypeX());
2023 }
2024 
ResetBackgroundImageSize(ArkUINodeHandle node)2025 void ResetBackgroundImageSize(ArkUINodeHandle node)
2026 {
2027     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2028     CHECK_NULL_VOID(frameNode);
2029     BackgroundImageSize bgImgSize;
2030     bgImgSize.SetSizeTypeX(BackgroundImageSizeType::AUTO);
2031     bgImgSize.SetSizeTypeY(BackgroundImageSizeType::AUTO);
2032     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
2033 }
2034 
SetBackgroundImage(ArkUINodeHandle node,ArkUI_CharPtr src,ArkUI_CharPtr bundle,ArkUI_CharPtr module,ArkUI_Int32 repeatIndex)2035 void SetBackgroundImage(
2036     ArkUINodeHandle node, ArkUI_CharPtr src, ArkUI_CharPtr bundle, ArkUI_CharPtr module, ArkUI_Int32 repeatIndex)
2037 {
2038     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2039     CHECK_NULL_VOID(frameNode);
2040     std::string srcStr(src);
2041     std::string bundleStr(bundle);
2042     std::string moduleStr(module);
2043     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { srcStr, bundleStr, moduleStr });
2044     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2045     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2046         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2047     } else {
2048         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2049     }
2050 }
2051 
SetBackgroundImageSyncMode(ArkUINodeHandle node,ArkUI_Bool syncMode)2052 void SetBackgroundImageSyncMode(ArkUINodeHandle node, ArkUI_Bool syncMode)
2053 {
2054     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2055     CHECK_NULL_VOID(frameNode);
2056     ViewAbstract::SetBackgroundImageSyncMode(frameNode, syncMode);
2057 }
2058 
ResetBackgroundImageSyncMode(ArkUINodeHandle node)2059 void ResetBackgroundImageSyncMode(ArkUINodeHandle node)
2060 {
2061     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2062     CHECK_NULL_VOID(frameNode);
2063     ViewAbstract::SetBackgroundImageSyncMode(frameNode, false);
2064 }
2065 
SetBackgroundImagePixelMap(ArkUINodeHandle node,void * drawableDescriptor,ArkUI_Int32 repeatIndex)2066 void SetBackgroundImagePixelMap(ArkUINodeHandle node, void* drawableDescriptor, ArkUI_Int32 repeatIndex)
2067 {
2068 #ifndef ACE_UNITTEST
2069     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2070     CHECK_NULL_VOID(frameNode);
2071     RefPtr<OHOS::Ace::PixelMap> pixelmap = PixelMap::GetFromDrawable(drawableDescriptor);
2072     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { pixelmap });
2073     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2074     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2075         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2076     } else {
2077         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2078     }
2079 #endif
2080 }
2081 
SetBackgroundImagePixelMapByPixelMapPtr(ArkUINodeHandle node,void * pixelMapPtr,ArkUI_Int32 repeatIndex)2082 void SetBackgroundImagePixelMapByPixelMapPtr(ArkUINodeHandle node, void* pixelMapPtr, ArkUI_Int32 repeatIndex)
2083 {
2084     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2085     CHECK_NULL_VOID(frameNode);
2086     RefPtr<PixelMap> pixelmap = PixelMap::CreatePixelMap(pixelMapPtr);
2087     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { pixelmap });
2088     auto repeat = static_cast<ImageRepeat>(repeatIndex);
2089     if (repeat >= OHOS::Ace::ImageRepeat::NO_REPEAT && repeat <= OHOS::Ace::ImageRepeat::REPEAT) {
2090         ViewAbstract::SetBackgroundImageRepeat(frameNode, repeat);
2091     } else {
2092         ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2093     }
2094 }
2095 
ResetBackgroundImage(ArkUINodeHandle node)2096 void ResetBackgroundImage(ArkUINodeHandle node)
2097 {
2098     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2099     CHECK_NULL_VOID(frameNode);
2100     std::string srcStr;
2101     std::string bundle;
2102     std::string module;
2103     ViewAbstract::SetBackgroundImage(frameNode, OHOS::Ace::ImageSourceInfo { srcStr, bundle, module });
2104     ViewAbstract::SetBackgroundImageRepeat(frameNode, OHOS::Ace::ImageRepeat::NO_REPEAT);
2105 }
2106 
SetTranslate(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)2107 void SetTranslate(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
2108 {
2109     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2110     CHECK_NULL_VOID(frameNode);
2111     if (length != NUM_3) {
2112         return;
2113     }
2114     auto translateX = CalcDimension(0.0);
2115     auto translateY = CalcDimension(0.0);
2116     auto translateZ = CalcDimension(0.0);
2117     translateX = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2118     translateY = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2119     translateZ = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
2120 
2121     ViewAbstract::SetTranslate(frameNode, TranslateOptions(translateX, translateY, translateZ));
2122 }
2123 
ResetTranslate(ArkUINodeHandle node)2124 void ResetTranslate(ArkUINodeHandle node)
2125 {
2126     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2127     CHECK_NULL_VOID(frameNode);
2128     auto x = CalcDimension(0.0);
2129     auto y = CalcDimension(0.0);
2130     auto z = CalcDimension(0.0);
2131     ViewAbstract::SetTranslate(frameNode, TranslateOptions(x, y, z));
2132 }
2133 /**
2134  * @param values
2135  * values[0] : centerX value; values[1] : centerY value;
2136  * units[0] : centerY unit; units[1] : centerY unit
2137  * values[2]: scaleX;values[3]: scaleY;values[4]: scaleZ
2138  * @param length shadows length
2139  */
SetScale(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength,const ArkUI_Int32 * units,ArkUI_Int32 unitLength)2140 void SetScale(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength, const ArkUI_Int32* units,
2141     ArkUI_Int32 unitLength)
2142 {
2143     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2144     CHECK_NULL_VOID(frameNode);
2145     if (valLength != NUM_5 && valLength != NUM_2) {
2146         return;
2147     }
2148     auto x = values[NUM_0];
2149     auto y = values[NUM_1];
2150     // NOT support Z in source code
2151     VectorF scale(x, y);
2152     ViewAbstract::SetScale(frameNode, scale);
2153     if (valLength != NUM_5) {
2154         return;
2155     }
2156     auto centerX = Dimension(values[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2157     auto centerY = Dimension(values[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2158     auto centerZ = Dimension(0.0, OHOS::Ace::DimensionUnit::VP);
2159 
2160     DimensionOffset center(centerX, centerY);
2161     if (!NearZero(centerZ.Value())) {
2162         center.SetZ(centerZ);
2163     }
2164     ViewAbstract::SetPivot(frameNode, center);
2165 }
2166 
GetScale(ArkUINodeHandle node,ArkUIScaleType * scaleType)2167 void GetScale(ArkUINodeHandle node, ArkUIScaleType* scaleType)
2168 {
2169     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2170     CHECK_NULL_VOID(frameNode);
2171     auto scale = ViewAbstract::GetScale(frameNode);
2172     scaleType->xValue = scale.x;
2173     scaleType->yValue = scale.y;
2174 }
2175 
GetRotate(ArkUINodeHandle node,ArkUIRotateType * rotateType)2176 void GetRotate(ArkUINodeHandle node, ArkUIRotateType* rotateType)
2177 {
2178     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2179     CHECK_NULL_VOID(frameNode);
2180     auto rotate = ViewAbstract::GetRotate(frameNode);
2181     rotateType->xCoordinate = rotate.x;
2182     rotateType->yCoordinate = rotate.y;
2183     rotateType->zCoordinate = rotate.z;
2184     rotateType->angle = rotate.w;
2185     rotateType->sightDistance = rotate.v;
2186 }
2187 
GetBrightness(ArkUINodeHandle node)2188 ArkUI_Float32 GetBrightness(ArkUINodeHandle node)
2189 {
2190     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2191     CHECK_NULL_RETURN(frameNode, DEFAULT_BRIGHTNESS);
2192     return ViewAbstract::GetBrightness(frameNode).Value();
2193 }
2194 
GetSaturate(ArkUINodeHandle node)2195 ArkUI_Float32 GetSaturate(ArkUINodeHandle node)
2196 {
2197     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2198     CHECK_NULL_RETURN(frameNode, DEFAULT_SATURATE);
2199     return ViewAbstract::GetSaturate(frameNode).Value();
2200 }
2201 
GetBackgroundImagePosition(ArkUINodeHandle node,ArkUIPositionOptions * position,ArkUI_Int32 unit)2202 void GetBackgroundImagePosition(ArkUINodeHandle node, ArkUIPositionOptions* position, ArkUI_Int32 unit)
2203 {
2204     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2205     CHECK_NULL_VOID(frameNode);
2206     auto imagePosition = ViewAbstract::GetBackgroundImagePosition(frameNode);
2207     position->x = imagePosition.GetSizeX().GetNativeValue(static_cast<DimensionUnit>(unit));
2208     position->y = imagePosition.GetSizeY().GetNativeValue(static_cast<DimensionUnit>(unit));
2209 }
2210 
2211 /**
2212  * @param values
2213  * values[0]: scaleX;values[1]: scaleY;values[2]: scaleZ
2214  * @param length shadows length
2215  */
SetScaleWithoutTransformCenter(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength)2216 void SetScaleWithoutTransformCenter(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength)
2217 {
2218     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2219     CHECK_NULL_VOID(frameNode);
2220     if (valLength != NUM_3) {
2221         return;
2222     }
2223     auto x = values[NUM_0];
2224     auto y = values[NUM_1];
2225     // NOT support Z in source code
2226     if (x < 0) {
2227         x = 1;
2228     }
2229     if (y < 0) {
2230         y = 1;
2231     }
2232     VectorF scale(x, y);
2233     ViewAbstract::SetScale(frameNode, scale);
2234 }
2235 
ResetScale(ArkUINodeHandle node)2236 void ResetScale(ArkUINodeHandle node)
2237 {
2238     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2239     CHECK_NULL_VOID(frameNode);
2240 
2241     VectorF scale(1.0f, 1.0f);
2242     ViewAbstract::SetScale(frameNode, scale);
2243 
2244     DimensionOffset center(0.5_pct, 0.5_pct);
2245     auto centerZ = Dimension(0.0, OHOS::Ace::DimensionUnit::VP);
2246     if (!NearZero(centerZ.Value())) {
2247         center.SetZ(centerZ);
2248     }
2249     ViewAbstract::SetPivot(frameNode, center);
2250 }
2251 
2252 /**
2253  * @param values
2254  * values[0] : centerX value; values[1] : centerY value; values[3] : centerZ value
2255  * units[0] : centerY unit; units[1] : centerY unit; units[3] : centerZ unit
2256  * values[4]: xDirection;values[5]: yDirection;values[6]: zDirection
2257  * values[7]: angle;values[8]:perspective
2258  * @param length shadows length
2259  */
SetRotate(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength,const ArkUI_Int32 * units,ArkUI_Int32 unitLength)2260 void SetRotate(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength, const ArkUI_Int32* units,
2261     ArkUI_Int32 unitLength)
2262 {
2263     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2264     CHECK_NULL_VOID(frameNode);
2265     if (valLength != NUM_8 || unitLength != NUM_3) {
2266         return;
2267     }
2268     auto centerX = Dimension(values[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_0]));
2269     auto centerY = Dimension(values[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_1]));
2270     auto centerZ = Dimension(values[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(units[NUM_2]));
2271     auto xDirection = values[NUM_3];
2272     auto yDirection = values[NUM_4];
2273     auto zDirection = values[NUM_5];
2274     auto angle = values[NUM_6];
2275     auto perspective = values[NUM_7];
2276     ViewAbstract::SetRotate(frameNode, NG::Vector5F(xDirection, yDirection, zDirection, angle, perspective));
2277 
2278     DimensionOffset center(centerX, centerY);
2279     if (!NearZero(centerZ.Value())) {
2280         center.SetZ(centerZ);
2281     }
2282     ViewAbstract::SetPivot(frameNode, center);
2283 }
2284 
2285 /**
2286  * @param values
2287  * values[0]: xDirection;values[1]: yDirection;values[2]: zDirection
2288  * values[3]: angle;values[4]:perspective
2289  * @param length shadows length
2290  */
SetRotateWithoutTransformCenter(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valLength)2291 void SetRotateWithoutTransformCenter(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valLength)
2292 {
2293     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2294     CHECK_NULL_VOID(frameNode);
2295     if (valLength != NUM_5) {
2296         return;
2297     }
2298 
2299     auto xDirection = values[NUM_0];
2300     auto yDirection = values[NUM_1];
2301     auto zDirection = values[NUM_2];
2302     auto angle = values[NUM_3];
2303     auto perspective = values[NUM_4];
2304     ViewAbstract::SetRotate(frameNode, NG::Vector5F(xDirection, yDirection, zDirection, angle, perspective));
2305 }
2306 
ResetRotate(ArkUINodeHandle node)2307 void ResetRotate(ArkUINodeHandle node)
2308 {
2309     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2310     CHECK_NULL_VOID(frameNode);
2311     NG::RotateOptions rotate(0.0f, 0.0f, 0.0f, 0.0f, 0.5_pct, 0.5_pct, 0.0f, 0.0f);
2312     ViewAbstract::SetRotate(
2313         frameNode, NG::Vector5F(rotate.xDirection, rotate.yDirection, rotate.zDirection, 0.0, rotate.perspective));
2314 
2315     DimensionOffset center(rotate.centerX, rotate.centerY);
2316     if (!NearZero(rotate.centerZ.Value())) {
2317         center.SetZ(rotate.centerZ);
2318     }
2319     ViewAbstract::SetPivot(frameNode, center);
2320 }
2321 
SetGeometryTransition(ArkUINodeHandle node,ArkUI_CharPtr id,const ArkUIGeometryTransitionOptions * options)2322 void SetGeometryTransition(ArkUINodeHandle node, ArkUI_CharPtr id, const ArkUIGeometryTransitionOptions* options)
2323 {
2324     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2325     CHECK_NULL_VOID(frameNode);
2326     std::string idStr(id);
2327     ViewAbstract::SetGeometryTransition(frameNode, idStr,
2328         static_cast<bool>(options->follow), static_cast<bool>(options->hierarchyStrategy));
2329 }
2330 
GetGeometryTransition(ArkUINodeHandle node,ArkUIGeometryTransitionOptions * options)2331 ArkUI_CharPtr GetGeometryTransition(ArkUINodeHandle node, ArkUIGeometryTransitionOptions* options)
2332 {
2333     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2334     CHECK_NULL_RETURN(frameNode, nullptr);
2335     bool followWithoutTransition = false;
2336     bool doRegisterSharedTransition = true;
2337     g_strValue = ViewAbstract::GetGeometryTransition(frameNode, &followWithoutTransition, &doRegisterSharedTransition);
2338     options->follow = followWithoutTransition;
2339     options->hierarchyStrategy = static_cast<int32_t>(doRegisterSharedTransition);
2340     return g_strValue.c_str();
2341 }
2342 
ResetGeometryTransition(ArkUINodeHandle node)2343 void ResetGeometryTransition(ArkUINodeHandle node)
2344 {
2345     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2346     CHECK_NULL_VOID(frameNode);
2347     ViewAbstract::SetGeometryTransition(frameNode, "", false, true);
2348 }
2349 
SetBindTips(ArkUINodeHandle node,ArkUI_CharPtr message,ArkUIBindTipsOptionsTime timeOptions,ArkUIBindTipsOptionsArrow arrowOptions)2350 void SetBindTips(ArkUINodeHandle node, ArkUI_CharPtr message, ArkUIBindTipsOptionsTime timeOptions,
2351     ArkUIBindTipsOptionsArrow arrowOptions)
2352 {
2353     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2354     CHECK_NULL_VOID(frameNode);
2355     auto tipsParam = AceType::MakeRefPtr<PopupParam>();
2356     std::string messageString = message;
2357     tipsParam->SetMessage(messageString);
2358     tipsParam->SetAppearingTime(timeOptions.appearingTime);
2359     tipsParam->SetDisappearingTime(timeOptions.disappearingTime);
2360     tipsParam->SetAppearingTimeWithContinuousOperation(timeOptions.appearingTimeWithContinuousOperation);
2361     tipsParam->SetDisappearingTimeWithContinuousOperation(timeOptions.disappearingTimeWithContinuousOperation);
2362     tipsParam->SetEnableArrow(arrowOptions.enableArrow);
2363     if (arrowOptions.arrowPointPosition) {
2364         CalcDimension offset;
2365         char* pEnd = nullptr;
2366         std::strtod(arrowOptions.arrowPointPosition, &pEnd);
2367         if (pEnd != nullptr) {
2368             if (std::strcmp(pEnd, "Start") == 0) {
2369                 offset = ARROW_ZERO_PERCENT;
2370             }
2371             if (std::strcmp(pEnd, "Center") == 0) {
2372                 offset = ARROW_HALF_PERCENT;
2373             }
2374             if (std::strcmp(pEnd, "End") == 0) {
2375                 offset = ARROW_ONE_HUNDRED_PERCENT;
2376             }
2377             tipsParam->SetArrowOffset(offset);
2378         }
2379     }
2380     CalcDimension arrowWidth(arrowOptions.arrowWidthValue, static_cast<DimensionUnit>(arrowOptions.arrowWidthUnit));
2381     bool setArrowWidthError = true;
2382     if (arrowOptions.arrowWidthValue > 0 &&
2383         static_cast<DimensionUnit>(arrowOptions.arrowWidthUnit) != DimensionUnit::PERCENT) {
2384         tipsParam->SetArrowWidth(arrowWidth);
2385         setArrowWidthError = false;
2386     }
2387     tipsParam->SetErrorArrowWidth(setArrowWidthError);
2388     CalcDimension arrowHeight(arrowOptions.arrowHeightValue, static_cast<DimensionUnit>(arrowOptions.arrowHeightUnit));
2389     bool setArrowHeightError = true;
2390     if (arrowOptions.arrowHeightValue > 0 &&
2391         static_cast<DimensionUnit>(arrowOptions.arrowHeightUnit) != DimensionUnit::PERCENT) {
2392         tipsParam->SetArrowHeight(arrowHeight);
2393         setArrowHeightError = false;
2394     }
2395     tipsParam->SetErrorArrowHeight(setArrowHeightError);
2396     tipsParam->SetBlockEvent(false);
2397     tipsParam->SetTipsFlag(true);
2398     ViewAbstract::BindTips(tipsParam, AceType::Claim(frameNode));
2399 }
2400 
ResetBindTips(ArkUINodeHandle node)2401 void ResetBindTips(ArkUINodeHandle node)
2402 {
2403     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2404     CHECK_NULL_VOID(frameNode);
2405     auto tipsParam = AceType::MakeRefPtr<PopupParam>();
2406     tipsParam->SetBlockEvent(false);
2407     tipsParam->SetTipsFlag(true);
2408     ViewAbstract::BindTips(tipsParam, AceType::Claim(frameNode));
2409 }
2410 
SetOffset(ArkUINodeHandle node,const ArkUI_Float32 * number,const ArkUI_Int32 * unit)2411 void SetOffset(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit)
2412 {
2413     CHECK_NULL_VOID(number);
2414     CHECK_NULL_VOID(unit);
2415     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2416     CHECK_NULL_VOID(frameNode);
2417     Dimension xVal(*(number + 0), static_cast<DimensionUnit>(*(unit + 0)));
2418     Dimension yVal(*(number + 1), static_cast<DimensionUnit>(*(unit + 1)));
2419     ViewAbstract::SetOffset(frameNode, { xVal, yVal });
2420 }
2421 
SetOffsetEdges(ArkUINodeHandle node,ArkUI_Bool useEdges,const ArkUIStringAndFloat * options)2422 void SetOffsetEdges(ArkUINodeHandle node, ArkUI_Bool useEdges, const ArkUIStringAndFloat* options)
2423 {
2424     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2425     CHECK_NULL_VOID(frameNode);
2426 
2427     if (useEdges) {
2428         OHOS::Ace::EdgesParam edges;
2429         ParseEdges(edges, options);
2430         ViewAbstract::SetOffsetEdges(frameNode, edges);
2431     } else {
2432         OffsetT<Dimension> offset;
2433         std::optional<CalcDimension> x;
2434         std::optional<CalcDimension> y;
2435         SetCalcDimension(x, options, NUM_7, NUM_0);
2436         SetCalcDimension(y, options, NUM_7, NUM_3);
2437         if (x.has_value()) {
2438             offset.SetX(x.value());
2439         }
2440         if (y.has_value()) {
2441             offset.SetY(y.value());
2442         }
2443         ViewAbstract::SetOffset(frameNode, offset);
2444     }
2445 }
2446 
GetOffset(ArkUINodeHandle node)2447 ArkUIOffsetType GetOffset(ArkUINodeHandle node)
2448 {
2449     ArkUIOffsetType offsetVp = { 0.0f, 0.0f };
2450     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2451     CHECK_NULL_RETURN(frameNode, offsetVp);
2452     auto renderContext = frameNode->GetRenderContext();
2453     CHECK_NULL_RETURN(renderContext, offsetVp);
2454     CHECK_NULL_RETURN(renderContext->GetPositionProperty(), offsetVp);
2455     if (!renderContext->GetPositionProperty()->HasOffset()) {
2456         return offsetVp;
2457     }
2458     offsetVp.xComponent = renderContext->GetPositionProperty()->GetOffsetValue().GetX().Value();
2459     offsetVp.yComponent = renderContext->GetPositionProperty()->GetOffsetValue().GetY().Value();
2460     return offsetVp;
2461 }
2462 
ResetOffset(ArkUINodeHandle node)2463 void ResetOffset(ArkUINodeHandle node)
2464 {
2465     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2466     CHECK_NULL_VOID(frameNode);
2467     Dimension xVal(0.0, DimensionUnit::VP);
2468     Dimension yVal(0.0, DimensionUnit::VP);
2469     ViewAbstract::SetOffset(frameNode, { xVal, yVal });
2470 }
2471 
SetPadding(ArkUINodeHandle node,const struct ArkUISizeType * top,const struct ArkUISizeType * right,const struct ArkUISizeType * bottom,const struct ArkUISizeType * left)2472 void SetPadding(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right,
2473     const struct ArkUISizeType* bottom, const struct ArkUISizeType* left)
2474 {
2475     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2476     CHECK_NULL_VOID(frameNode);
2477     CalcLength topDimen;
2478     CalcLength rightDimen;
2479     CalcLength bottomDimen;
2480     CalcLength leftDimen;
2481     if (top->string != nullptr) {
2482         topDimen = CalcLength(top->string);
2483     } else {
2484         topDimen = CalcLength(top->value, static_cast<DimensionUnit>(top->unit));
2485     }
2486     if (right->string != nullptr) {
2487         rightDimen = CalcLength(right->string);
2488     } else {
2489         rightDimen = CalcLength(right->value, static_cast<DimensionUnit>(right->unit));
2490     }
2491     if (bottom->string != nullptr) {
2492         bottomDimen = CalcLength(bottom->string);
2493     } else {
2494         bottomDimen = CalcLength(bottom->value, static_cast<DimensionUnit>(bottom->unit));
2495     }
2496     if (left->string != nullptr) {
2497         leftDimen = CalcLength(left->string);
2498     } else {
2499         leftDimen = CalcLength(left->value, static_cast<DimensionUnit>(left->unit));
2500     }
2501     NG::PaddingProperty paddings;
2502     paddings.top = std::optional<CalcLength>(topDimen);
2503     paddings.bottom = std::optional<CalcLength>(bottomDimen);
2504     paddings.left = std::optional<CalcLength>(leftDimen);
2505     paddings.right = std::optional<CalcLength>(rightDimen);
2506     ViewAbstract::SetPadding(frameNode, paddings);
2507 }
2508 
ResetPadding(ArkUINodeHandle node)2509 void ResetPadding(ArkUINodeHandle node)
2510 {
2511     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2512     CHECK_NULL_VOID(frameNode);
2513     NG::PaddingProperty paddings;
2514     paddings.top = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2515     paddings.bottom = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2516     paddings.left = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2517     paddings.right = std::optional<CalcLength>(CalcLength(0.0, DimensionUnit::VP));
2518     ViewAbstract::SetPadding(frameNode, paddings);
2519 }
2520 
SetSafeAreaPadding(ArkUINodeHandle node,const struct ArkUIPaddingType * safeAreaPadding,ArkUI_Bool isLengthMetrics)2521 void SetSafeAreaPadding(
2522     ArkUINodeHandle node, const struct ArkUIPaddingType* safeAreaPadding, ArkUI_Bool isLengthMetrics)
2523 {
2524     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2525     CHECK_NULL_VOID(frameNode);
2526     CalcLength topDimen;
2527     CalcLength endDimen;
2528     CalcLength bottomDimen;
2529     CalcLength startDimen;
2530     if (safeAreaPadding->top.string != nullptr) {
2531         topDimen = CalcLength(safeAreaPadding->top.string);
2532     } else {
2533         topDimen = CalcLength(safeAreaPadding->top.value, static_cast<DimensionUnit>(safeAreaPadding->top.unit));
2534     }
2535     if (safeAreaPadding->end.string != nullptr) {
2536         endDimen = CalcLength(safeAreaPadding->end.string);
2537     } else {
2538         endDimen = CalcLength(safeAreaPadding->end.value, static_cast<DimensionUnit>(safeAreaPadding->end.unit));
2539     }
2540     if (safeAreaPadding->bottom.string != nullptr) {
2541         bottomDimen = CalcLength(safeAreaPadding->bottom.string);
2542     } else {
2543         bottomDimen =
2544             CalcLength(safeAreaPadding->bottom.value, static_cast<DimensionUnit>(safeAreaPadding->bottom.unit));
2545     }
2546     if (safeAreaPadding->start.string != nullptr) {
2547         startDimen = CalcLength(safeAreaPadding->start.string);
2548     } else {
2549         startDimen = CalcLength(safeAreaPadding->start.value, static_cast<DimensionUnit>(safeAreaPadding->start.unit));
2550     }
2551     NG::PaddingProperty paddings;
2552     paddings.top = std::optional<CalcLength>(topDimen);
2553     paddings.bottom = std::optional<CalcLength>(bottomDimen);
2554     if (isLengthMetrics) {
2555         paddings.end = std::optional<CalcLength>(endDimen);
2556         paddings.start = std::optional<CalcLength>(startDimen);
2557     } else {
2558         paddings.right = std::optional<CalcLength>(endDimen);
2559         paddings.left = std::optional<CalcLength>(startDimen);
2560     }
2561     ViewAbstract::SetSafeAreaPadding(frameNode, paddings);
2562 }
2563 
ResetSafeAreaPadding(ArkUINodeHandle node)2564 void ResetSafeAreaPadding(ArkUINodeHandle node)
2565 {
2566     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2567     CHECK_NULL_VOID(frameNode);
2568     ViewAbstract::ResetSafeAreaPadding(frameNode);
2569 }
2570 
2571 /**
2572  * @param values value value
2573  * values[0] : left, values[1] : top, values[2] : right, values[3] : bottom
2574  * @param units unit value
2575  * units[0] : left, units[1] : top, units[2] : right, units[3] : bottom
2576  * @param length values length
2577  */
SetPixelStretchEffect(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)2578 void SetPixelStretchEffect(
2579     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
2580 {
2581     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2582     CHECK_NULL_VOID(frameNode);
2583     if (length != NUM_4) {
2584         return;
2585     }
2586     auto leftValue = values[NUM_0];
2587     auto leftUnit = units[NUM_0];
2588     auto topValue = values[NUM_1];
2589     auto topUnit = units[NUM_1];
2590     auto rightValue = values[NUM_2];
2591     auto rightUnit = units[NUM_2];
2592     auto bottomValue = values[NUM_3];
2593     auto bottomUnit = units[NUM_3];
2594     Dimension left(leftValue, static_cast<DimensionUnit>(leftUnit));
2595     Dimension top(topValue, static_cast<DimensionUnit>(topUnit));
2596     Dimension right(rightValue, static_cast<DimensionUnit>(rightUnit));
2597     Dimension bottom(bottomValue, static_cast<DimensionUnit>(bottomUnit));
2598     bool illegalInput = false;
2599     if (left.Unit() == DimensionUnit::PERCENT || right.Unit() == DimensionUnit::PERCENT ||
2600         top.Unit() == DimensionUnit::PERCENT || bottom.Unit() == DimensionUnit::PERCENT) {
2601         if ((NearEqual(left.Value(), 0.0) || left.Unit() == DimensionUnit::PERCENT) &&
2602             (NearEqual(top.Value(), 0.0) || top.Unit() == DimensionUnit::PERCENT) &&
2603             (NearEqual(right.Value(), 0.0) || right.Unit() == DimensionUnit::PERCENT) &&
2604             (NearEqual(bottom.Value(), 0.0) || bottom.Unit() == DimensionUnit::PERCENT)) {
2605             left.SetUnit(DimensionUnit::PERCENT);
2606             top.SetUnit(DimensionUnit::PERCENT);
2607             right.SetUnit(DimensionUnit::PERCENT);
2608             bottom.SetUnit(DimensionUnit::PERCENT);
2609         } else {
2610             illegalInput = true;
2611         }
2612     }
2613     PixStretchEffectOption option;
2614     if ((left.IsNonNegative() && top.IsNonNegative() && right.IsNonNegative() && bottom.IsNonNegative()) ||
2615         (left.IsNonPositive() && top.IsNonPositive() && right.IsNonPositive() && bottom.IsNonPositive())) {
2616         option.left = left;
2617         option.top = top;
2618         option.right = right;
2619         option.bottom = bottom;
2620     } else {
2621         illegalInput = true;
2622     }
2623     if (illegalInput) {
2624         option.ResetValue();
2625     }
2626     ViewAbstract::SetPixelStretchEffect(frameNode, option);
2627 }
2628 
ResetPixelStretchEffect(ArkUINodeHandle node)2629 void ResetPixelStretchEffect(ArkUINodeHandle node)
2630 {
2631     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2632     CHECK_NULL_VOID(frameNode);
2633     PixStretchEffectOption option;
2634     option.ResetValue();
2635     ViewAbstract::SetPixelStretchEffect(frameNode, option);
2636 }
2637 
SetLightUpEffect(ArkUINodeHandle node,ArkUI_Float32 radio)2638 void SetLightUpEffect(ArkUINodeHandle node, ArkUI_Float32 radio)
2639 {
2640     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2641     CHECK_NULL_VOID(frameNode);
2642     radio = std::clamp(radio, 0.0f, 1.0f);
2643     ViewAbstract::SetLightUpEffect(frameNode, radio);
2644 }
2645 
ResetLightUpEffect(ArkUINodeHandle node)2646 void ResetLightUpEffect(ArkUINodeHandle node)
2647 {
2648     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2649     CHECK_NULL_VOID(frameNode);
2650     ViewAbstract::SetLightUpEffect(frameNode, 1.0);
2651 }
2652 
SetSphericalEffect(ArkUINodeHandle node,ArkUI_Float64 radio)2653 void SetSphericalEffect(ArkUINodeHandle node, ArkUI_Float64 radio)
2654 {
2655     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2656     CHECK_NULL_VOID(frameNode);
2657     radio = std::clamp(radio, 0.0, 1.0);
2658     ViewAbstract::SetSphericalEffect(frameNode, radio);
2659 }
2660 
ResetSphericalEffect(ArkUINodeHandle node)2661 void ResetSphericalEffect(ArkUINodeHandle node)
2662 {
2663     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2664     CHECK_NULL_VOID(frameNode);
2665     ViewAbstract::SetSphericalEffect(frameNode, 0.0);
2666 }
2667 
SetRenderGroup(ArkUINodeHandle node,ArkUI_Bool isRenderGroup)2668 void SetRenderGroup(ArkUINodeHandle node, ArkUI_Bool isRenderGroup)
2669 {
2670     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2671     CHECK_NULL_VOID(frameNode);
2672     ViewAbstract::SetRenderGroup(frameNode, isRenderGroup);
2673 }
2674 
ResetRenderGroup(ArkUINodeHandle node)2675 void ResetRenderGroup(ArkUINodeHandle node)
2676 {
2677     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2678     CHECK_NULL_VOID(frameNode);
2679     ViewAbstract::SetRenderGroup(frameNode, false);
2680 }
2681 
SetRenderFit(ArkUINodeHandle node,ArkUI_Int32 renderFitNumber)2682 void SetRenderFit(ArkUINodeHandle node, ArkUI_Int32 renderFitNumber)
2683 {
2684     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2685     CHECK_NULL_VOID(frameNode);
2686     auto renderFit = RenderFit::TOP_LEFT;
2687     if (renderFitNumber >= static_cast<int32_t>(RenderFit::CENTER) &&
2688         renderFitNumber <= static_cast<int32_t>(RenderFit::RESIZE_COVER_BOTTOM_RIGHT)) {
2689         renderFit = static_cast<RenderFit>(renderFitNumber);
2690     }
2691     ViewAbstract::SetRenderFit(frameNode, renderFit);
2692 }
2693 
ResetRenderFit(ArkUINodeHandle node)2694 void ResetRenderFit(ArkUINodeHandle node)
2695 {
2696     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2697     CHECK_NULL_VOID(frameNode);
2698     ViewAbstract::SetRenderFit(frameNode, RenderFit::TOP_LEFT);
2699 }
2700 
GetRenderFit(ArkUINodeHandle node)2701 ArkUI_Int32 GetRenderFit(ArkUINodeHandle node)
2702 {
2703     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2704     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
2705     return static_cast<ArkUI_Int32>(ViewAbstract::GetRenderFit(frameNode));
2706 }
2707 
SetUseEffect(ArkUINodeHandle node,ArkUI_Bool useEffect,ArkUI_Int32 effectType)2708 void SetUseEffect(ArkUINodeHandle node, ArkUI_Bool useEffect, ArkUI_Int32 effectType)
2709 {
2710     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2711     CHECK_NULL_VOID(frameNode);
2712     ViewAbstract::SetUseEffect(frameNode, useEffect, static_cast<EffectType>(effectType));
2713 }
2714 
ResetUseEffect(ArkUINodeHandle node)2715 void ResetUseEffect(ArkUINodeHandle node)
2716 {
2717     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2718     CHECK_NULL_VOID(frameNode);
2719     ViewAbstract::SetUseEffect(frameNode, false, EffectType::DEFAULT);
2720 }
2721 
SetForegroundColor(ArkUINodeHandle node,ArkUI_Bool isColor,uint32_t color)2722 void SetForegroundColor(ArkUINodeHandle node, ArkUI_Bool isColor, uint32_t color)
2723 {
2724     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2725     CHECK_NULL_VOID(frameNode);
2726     if (isColor) {
2727         ViewAbstract::SetForegroundColor(frameNode, Color(color));
2728     } else {
2729         auto strategy = static_cast<ForegroundColorStrategy>(color);
2730         ViewAbstract::SetForegroundColorStrategy(frameNode, strategy);
2731     }
2732 }
2733 
ResetForegroundColor(ArkUINodeHandle node)2734 void ResetForegroundColor(ArkUINodeHandle node)
2735 {
2736     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2737     CHECK_NULL_VOID(frameNode);
2738 }
2739 
SetMotionPath(ArkUINodeHandle node,ArkUI_CharPtr path,ArkUI_Float32 from,ArkUI_Float32 to,ArkUI_Bool rotatable)2740 void SetMotionPath(ArkUINodeHandle node, ArkUI_CharPtr path, ArkUI_Float32 from, ArkUI_Float32 to, ArkUI_Bool rotatable)
2741 {
2742     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2743     CHECK_NULL_VOID(frameNode);
2744     OHOS::Ace::MotionPathOption motionPathOption;
2745     std::string pathString = path;
2746     motionPathOption.SetPath(pathString);
2747     motionPathOption.SetBegin(from);
2748     motionPathOption.SetEnd(to);
2749     motionPathOption.SetRotate(rotatable);
2750     ViewAbstract::SetMotionPath(frameNode, motionPathOption);
2751 }
2752 
ResetMotionPath(ArkUINodeHandle node)2753 void ResetMotionPath(ArkUINodeHandle node)
2754 {
2755     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2756     CHECK_NULL_VOID(frameNode);
2757     OHOS::Ace::MotionPathOption motionPathOption = MotionPathOption();
2758     ViewAbstract::SetMotionPath(frameNode, motionPathOption);
2759 }
2760 
2761 
SetMotionBlur(ArkUINodeHandle node,ArkUI_Float32 radius,ArkUI_Float32 anchorX,ArkUI_Float32 anchorY)2762 void SetMotionBlur(ArkUINodeHandle node, ArkUI_Float32 radius, ArkUI_Float32 anchorX, ArkUI_Float32 anchorY)
2763 {
2764     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2765     CHECK_NULL_VOID(frameNode);
2766     MotionBlurOption motionBlurOption;
2767     motionBlurOption.radius = radius;
2768     motionBlurOption.anchor.x = anchorX;
2769     motionBlurOption.anchor.y = anchorY;
2770     ViewAbstract::SetMotionBlur(frameNode, motionBlurOption);
2771 }
2772 
ResetMotionBlur(ArkUINodeHandle node)2773 void ResetMotionBlur(ArkUINodeHandle node)
2774 {
2775     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2776     CHECK_NULL_VOID(frameNode);
2777     MotionBlurOption motionBlurOption;
2778     motionBlurOption.radius = 0.0;
2779     motionBlurOption.anchor.x = 0.0;
2780     motionBlurOption.anchor.y = 0.0;
2781     ViewAbstract::SetMotionBlur(frameNode, motionBlurOption);
2782 }
2783 
SetGroupDefaultFocus(ArkUINodeHandle node,ArkUI_Bool groupDefaultFocus)2784 void SetGroupDefaultFocus(ArkUINodeHandle node, ArkUI_Bool groupDefaultFocus)
2785 {
2786     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2787     CHECK_NULL_VOID(frameNode);
2788     ViewAbstract::SetGroupDefaultFocus(frameNode, groupDefaultFocus);
2789 }
2790 
ResetGroupDefaultFocus(ArkUINodeHandle node)2791 void ResetGroupDefaultFocus(ArkUINodeHandle node)
2792 {
2793     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2794     CHECK_NULL_VOID(frameNode);
2795     bool groupDefaultFocus = false;
2796     ViewAbstract::SetGroupDefaultFocus(frameNode, groupDefaultFocus);
2797 }
2798 
SetFocusOnTouch(ArkUINodeHandle node,ArkUI_Bool focusOnTouch)2799 void SetFocusOnTouch(ArkUINodeHandle node, ArkUI_Bool focusOnTouch)
2800 {
2801     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2802     CHECK_NULL_VOID(frameNode);
2803     ViewAbstract::SetFocusOnTouch(frameNode, focusOnTouch);
2804 }
2805 
ResetFocusOnTouch(ArkUINodeHandle node)2806 void ResetFocusOnTouch(ArkUINodeHandle node)
2807 {
2808     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2809     CHECK_NULL_VOID(frameNode);
2810     bool focusOnTouch = false;
2811     ViewAbstract::SetFocusOnTouch(frameNode, focusOnTouch);
2812 }
2813 
GetFocusOnTouch(ArkUINodeHandle node)2814 ArkUI_Bool GetFocusOnTouch(ArkUINodeHandle node)
2815 {
2816     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2817     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
2818     return static_cast<ArkUI_Bool>(ViewAbstract::GetFocusOnTouch(frameNode));
2819 }
2820 
SetFocusable(ArkUINodeHandle node,ArkUI_Bool focusable)2821 void SetFocusable(ArkUINodeHandle node, ArkUI_Bool focusable)
2822 {
2823     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2824     CHECK_NULL_VOID(frameNode);
2825     if (frameNode->GetTag() == "Custom") {
2826         ViewAbstract::SetFocusType(frameNode, focusable ? FocusType::SCOPE : FocusType::DISABLE);
2827     }
2828     ViewAbstract::SetFocusable(frameNode, focusable);
2829 }
2830 
ResetFocusable(ArkUINodeHandle node)2831 void ResetFocusable(ArkUINodeHandle node)
2832 {
2833     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2834     CHECK_NULL_VOID(frameNode);
2835     bool focusable = false;
2836     ViewAbstract::SetFocusable(frameNode, focusable);
2837 }
2838 
SetTouchable(ArkUINodeHandle node,ArkUI_Bool touchable)2839 void SetTouchable(ArkUINodeHandle node, ArkUI_Bool touchable)
2840 {
2841     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2842     CHECK_NULL_VOID(frameNode);
2843     ViewAbstract::SetTouchable(frameNode, touchable);
2844 }
2845 
ResetTouchable(ArkUINodeHandle node)2846 void ResetTouchable(ArkUINodeHandle node)
2847 {
2848     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2849     CHECK_NULL_VOID(frameNode);
2850     bool touchable = true;
2851     ViewAbstract::SetTouchable(frameNode, touchable);
2852 }
2853 
SetDefaultFocus(ArkUINodeHandle node,ArkUI_Bool defaultFocus)2854 void SetDefaultFocus(ArkUINodeHandle node, ArkUI_Bool defaultFocus)
2855 {
2856     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2857     CHECK_NULL_VOID(frameNode);
2858     ViewAbstract::SetDefaultFocus(frameNode, defaultFocus);
2859 }
2860 
ResetDefaultFocus(ArkUINodeHandle node)2861 void ResetDefaultFocus(ArkUINodeHandle node)
2862 {
2863     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2864     CHECK_NULL_VOID(frameNode);
2865     bool defaultFocus = false;
2866     ViewAbstract::SetDefaultFocus(frameNode, defaultFocus);
2867 }
2868 
SetDisplayPriority(ArkUINodeHandle node,ArkUI_Float32 value)2869 void SetDisplayPriority(ArkUINodeHandle node, ArkUI_Float32 value)
2870 {
2871     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2872     CHECK_NULL_VOID(frameNode);
2873     ViewAbstract::SetDisplayIndex(frameNode, static_cast<int32_t>(value));
2874 }
2875 
ResetDisplayPriority(ArkUINodeHandle node)2876 void ResetDisplayPriority(ArkUINodeHandle node)
2877 {
2878     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2879     CHECK_NULL_VOID(frameNode);
2880     ViewAbstract::SetDisplayIndex(frameNode, DEFAULT_DISPLAY_PRIORITY);
2881 }
2882 
GetDisplayPriority(ArkUINodeHandle node)2883 ArkUI_Int32 GetDisplayPriority(ArkUINodeHandle node)
2884 {
2885     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2886     CHECK_NULL_RETURN(frameNode, DEFAULT_DISPLAY_PRIORITY);
2887     return ViewAbstract::GetDisplayIndex(frameNode);
2888 }
2889 
SetMargin(ArkUINodeHandle node,const struct ArkUISizeType * top,const struct ArkUISizeType * right,const struct ArkUISizeType * bottom,const struct ArkUISizeType * left)2890 void SetMargin(ArkUINodeHandle node, const struct ArkUISizeType* top, const struct ArkUISizeType* right,
2891     const struct ArkUISizeType* bottom, const struct ArkUISizeType* left)
2892 {
2893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2894     CHECK_NULL_VOID(frameNode);
2895     CalcLength topDimen;
2896     CalcLength rightDimen;
2897     CalcLength bottomDimen;
2898     CalcLength leftDimen;
2899     if (top->string != nullptr) {
2900         topDimen = CalcLength(top->string);
2901     } else {
2902         topDimen = CalcLength(top->value, static_cast<DimensionUnit>(top->unit));
2903     }
2904     if (right->string != nullptr) {
2905         rightDimen = CalcLength(right->string);
2906     } else {
2907         rightDimen = CalcLength(right->value, static_cast<DimensionUnit>(right->unit));
2908     }
2909     if (bottom->string != nullptr) {
2910         bottomDimen = CalcLength(bottom->string);
2911     } else {
2912         bottomDimen = CalcLength(bottom->value, static_cast<DimensionUnit>(bottom->unit));
2913     }
2914     if (left->string != nullptr) {
2915         leftDimen = CalcLength(left->string);
2916     } else {
2917         leftDimen = CalcLength(left->value, static_cast<DimensionUnit>(left->unit));
2918     }
2919     NG::PaddingProperty paddings;
2920     paddings.top = std::optional<CalcLength>(topDimen);
2921     paddings.bottom = std::optional<CalcLength>(bottomDimen);
2922     paddings.left = std::optional<CalcLength>(leftDimen);
2923     paddings.right = std::optional<CalcLength>(rightDimen);
2924     ViewAbstract::SetMargin(frameNode, paddings);
2925 }
2926 
ResetMargin(ArkUINodeHandle node)2927 void ResetMargin(ArkUINodeHandle node)
2928 {
2929     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2930     CHECK_NULL_VOID(frameNode);
2931     ViewAbstract::SetMargin(frameNode, NG::CalcLength(0.0));
2932 }
2933 
SetMarkAnchor(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit)2934 void SetMarkAnchor(
2935     ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue, ArkUI_Int32 yUnit)
2936 {
2937     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2938     CHECK_NULL_VOID(frameNode);
2939     Dimension xDimension { xValue, static_cast<DimensionUnit>(xUnit) };
2940     Dimension yDimension { yValue, static_cast<DimensionUnit>(yUnit) };
2941     OffsetT<Dimension> value = { xDimension, yDimension };
2942     ViewAbstract::MarkAnchor(frameNode, value);
2943 }
2944 
GetMarkAnchor(ArkUINodeHandle node)2945 ArkUIAnchorType GetMarkAnchor(ArkUINodeHandle node)
2946 {
2947     ArkUIAnchorType anchorType = { 0.0f, 0.0f };
2948     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2949     CHECK_NULL_RETURN(frameNode, anchorType);
2950     auto renderContext = frameNode->GetRenderContext();
2951     CHECK_NULL_RETURN(renderContext, anchorType);
2952     CHECK_NULL_RETURN(renderContext->GetPositionProperty(), anchorType);
2953     if (!renderContext->GetPositionProperty()->HasAnchor()) {
2954         return anchorType;
2955     }
2956     anchorType.xCoordinate = renderContext->GetPositionProperty()->GetAnchor()->GetX().Value();
2957     anchorType.yCoordinate = renderContext->GetPositionProperty()->GetAnchor()->GetY().Value();
2958     return anchorType;
2959 }
2960 
ResetMarkAnchor(ArkUINodeHandle node)2961 void ResetMarkAnchor(ArkUINodeHandle node)
2962 {
2963     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2964     CHECK_NULL_VOID(frameNode);
2965     ViewAbstract::MarkAnchor(frameNode, { Dimension(0.0_vp), Dimension(0.0_vp) });
2966 }
2967 
SetVisibility(ArkUINodeHandle node,ArkUI_Int32 value)2968 void SetVisibility(ArkUINodeHandle node, ArkUI_Int32 value)
2969 {
2970     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2971     CHECK_NULL_VOID(frameNode);
2972     VisibleType value_visibleType = static_cast<VisibleType>(value);
2973     ViewAbstract::SetVisibility(frameNode, value_visibleType);
2974 }
2975 
ResetVisibility(ArkUINodeHandle node)2976 void ResetVisibility(ArkUINodeHandle node)
2977 {
2978     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2979     CHECK_NULL_VOID(frameNode);
2980     ViewAbstract::SetVisibility(frameNode, DEFAULT_VISIBILITY);
2981 }
2982 
SetAccessibilityText(ArkUINodeHandle node,ArkUI_CharPtr value)2983 void SetAccessibilityText(ArkUINodeHandle node, ArkUI_CharPtr value)
2984 {
2985     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2986     CHECK_NULL_VOID(frameNode);
2987     std::string valueStr = value;
2988     ViewAbstractModelNG::SetAccessibilityText(frameNode, valueStr);
2989 }
2990 
ResetAccessibilityText(ArkUINodeHandle node)2991 void ResetAccessibilityText(ArkUINodeHandle node)
2992 {
2993     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2994     CHECK_NULL_VOID(frameNode);
2995     ViewAbstractModelNG::SetAccessibilityText(frameNode, "");
2996 }
2997 
SetAllowDrop(ArkUINodeHandle node,ArkUI_CharPtr * allowDropCharArray,ArkUI_Int32 length)2998 void SetAllowDrop(ArkUINodeHandle node, ArkUI_CharPtr* allowDropCharArray, ArkUI_Int32 length)
2999 {
3000     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3001     CHECK_NULL_VOID(frameNode);
3002     std::set<std::string> allowDropSet;
3003     allowDropSet.clear();
3004     std::string allowDropStr;
3005     for (int32_t i = 0; i < length; i++) {
3006         allowDropStr = allowDropCharArray[i];
3007         allowDropSet.insert(allowDropStr);
3008     }
3009     frameNode->SetDisallowDropForcedly(false);
3010     ViewAbstract::SetAllowDrop(frameNode, allowDropSet);
3011 }
3012 
ResetAllowDrop(ArkUINodeHandle node)3013 void ResetAllowDrop(ArkUINodeHandle node)
3014 {
3015     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3016     CHECK_NULL_VOID(frameNode);
3017     std::set<std::string> allowDrop;
3018     frameNode->SetDisallowDropForcedly(false);
3019     ViewAbstract::SetAllowDrop(frameNode, allowDrop);
3020 }
3021 
SetDisAllowDrop(ArkUINodeHandle node)3022 void SetDisAllowDrop(ArkUINodeHandle node)
3023 {
3024     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3025     CHECK_NULL_VOID(frameNode);
3026     frameNode->SetDisallowDropForcedly(true);
3027 }
3028 
SetAccessibilityLevel(ArkUINodeHandle node,ArkUI_CharPtr value)3029 void SetAccessibilityLevel(ArkUINodeHandle node, ArkUI_CharPtr value)
3030 {
3031     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3032     CHECK_NULL_VOID(frameNode);
3033     CHECK_NULL_VOID(value);
3034     std::string valueStr = value;
3035     ViewAbstractModelNG::SetAccessibilityImportance(frameNode, valueStr);
3036 }
3037 
ResetAccessibilityLevel(ArkUINodeHandle node)3038 void ResetAccessibilityLevel(ArkUINodeHandle node)
3039 {
3040     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3041     CHECK_NULL_VOID(frameNode);
3042     ViewAbstractModelNG::SetAccessibilityImportance(frameNode, "");
3043 }
3044 
SetAccessibilityCustomRole(ArkUINodeHandle node,ArkUI_CharPtr value)3045 void SetAccessibilityCustomRole(ArkUINodeHandle node, ArkUI_CharPtr value)
3046 {
3047     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3048     CHECK_NULL_VOID(frameNode);
3049     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
3050     CHECK_NULL_VOID(accessibilityProperty);
3051     accessibilityProperty->SetAccessibilityCustomRole(std::string(value));
3052 }
3053 
ResetAccessibilityCustomRole(ArkUINodeHandle node)3054 void ResetAccessibilityCustomRole(ArkUINodeHandle node)
3055 {
3056     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3057     CHECK_NULL_VOID(frameNode);
3058     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
3059     CHECK_NULL_VOID(accessibilityProperty);
3060     accessibilityProperty->ResetAccessibilityCustomRole();
3061 }
3062 
SetDirection(ArkUINodeHandle node,ArkUI_Int32 direction)3063 void SetDirection(ArkUINodeHandle node, ArkUI_Int32 direction)
3064 {
3065     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3066     CHECK_NULL_VOID(frameNode);
3067     ViewAbstract::SetLayoutDirection(frameNode, static_cast<TextDirection>(direction));
3068 }
3069 
ResetDirection(ArkUINodeHandle node)3070 void ResetDirection(ArkUINodeHandle node)
3071 {
3072     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3073     CHECK_NULL_VOID(frameNode);
3074     ViewAbstract::SetLayoutDirection(frameNode, DEFAULT_COMMON_DIRECTION);
3075 }
3076 
SetLayoutWeight(ArkUINodeHandle node,ArkUI_Int32 layoutWeight)3077 void SetLayoutWeight(ArkUINodeHandle node, ArkUI_Int32 layoutWeight)
3078 {
3079     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3080     CHECK_NULL_VOID(frameNode);
3081     ViewAbstract::SetLayoutWeight(frameNode, layoutWeight);
3082 }
3083 
ResetLayoutWeight(ArkUINodeHandle node)3084 void ResetLayoutWeight(ArkUINodeHandle node)
3085 {
3086     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3087     CHECK_NULL_VOID(frameNode);
3088     ViewAbstract::SetLayoutWeight(frameNode, DEFAULT_COMMON_LAYOUTWEIGHT);
3089 }
3090 
GetLayoutWeight(ArkUINodeHandle node)3091 ArkUI_Float32 GetLayoutWeight(ArkUINodeHandle node)
3092 {
3093     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3094     CHECK_NULL_RETURN(frameNode, 0.0f);
3095     return ViewAbstract::GetLayoutWeight(frameNode);
3096 }
3097 
SetMinWidth(ArkUINodeHandle node,const struct ArkUISizeType * minWidth)3098 void SetMinWidth(ArkUINodeHandle node, const struct ArkUISizeType* minWidth)
3099 {
3100     CHECK_NULL_VOID(minWidth);
3101     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3102     CHECK_NULL_VOID(frameNode);
3103     CalcLength strResult;
3104     if (minWidth->string != nullptr) {
3105         strResult = CalcLength(minWidth->string);
3106         ViewAbstract::SetMinWidth(frameNode, strResult);
3107     } else {
3108         CalcDimension result(minWidth->value, static_cast<DimensionUnit>(minWidth->unit));
3109         ViewAbstract::SetMinWidth(frameNode, CalcLength(result));
3110     }
3111 }
3112 
ResetMinWidth(ArkUINodeHandle node)3113 void ResetMinWidth(ArkUINodeHandle node)
3114 {
3115     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3116     CHECK_NULL_VOID(frameNode);
3117     ViewAbstract::ResetMinSize(frameNode, true);
3118 }
3119 
SetMaxWidth(ArkUINodeHandle node,const struct ArkUISizeType * maxWidth)3120 void SetMaxWidth(ArkUINodeHandle node, const struct ArkUISizeType* maxWidth)
3121 {
3122     CHECK_NULL_VOID(maxWidth);
3123     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3124     CHECK_NULL_VOID(frameNode);
3125     CalcLength strResult;
3126     if (maxWidth->string != nullptr) {
3127         strResult = CalcLength(maxWidth->string);
3128         ViewAbstract::SetMaxWidth(frameNode, strResult);
3129     } else {
3130         CalcDimension result(maxWidth->value, static_cast<DimensionUnit>(maxWidth->unit));
3131         ViewAbstract::SetMaxWidth(frameNode, CalcLength(result));
3132     }
3133 }
3134 
ResetMaxWidth(ArkUINodeHandle node)3135 void ResetMaxWidth(ArkUINodeHandle node)
3136 {
3137     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3138     CHECK_NULL_VOID(frameNode);
3139     ViewAbstract::ResetMaxSize(frameNode, true);
3140 }
3141 
SetMinHeight(ArkUINodeHandle node,const struct ArkUISizeType * minHeight)3142 void SetMinHeight(ArkUINodeHandle node, const struct ArkUISizeType* minHeight)
3143 {
3144     CHECK_NULL_VOID(minHeight);
3145     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3146     CHECK_NULL_VOID(frameNode);
3147     CalcLength strResult;
3148     if (minHeight->string != nullptr) {
3149         strResult = CalcLength(minHeight->string);
3150         ViewAbstract::SetMinHeight(frameNode, strResult);
3151     } else {
3152         CalcDimension result(minHeight->value, static_cast<DimensionUnit>(minHeight->unit));
3153         ViewAbstract::SetMinHeight(frameNode, CalcLength(result));
3154     }
3155 }
3156 
ResetMinHeight(ArkUINodeHandle node)3157 void ResetMinHeight(ArkUINodeHandle node)
3158 {
3159     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3160     CHECK_NULL_VOID(frameNode);
3161     ViewAbstract::ResetMinSize(frameNode, false);
3162 }
3163 
SetMaxHeight(ArkUINodeHandle node,const struct ArkUISizeType * maxHeight)3164 void SetMaxHeight(ArkUINodeHandle node, const struct ArkUISizeType* maxHeight)
3165 {
3166     CHECK_NULL_VOID(maxHeight);
3167     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3168     CHECK_NULL_VOID(frameNode);
3169     CalcLength strResult;
3170     if (maxHeight->string != nullptr) {
3171         strResult = CalcLength(maxHeight->string);
3172         ViewAbstract::SetMaxHeight(frameNode, strResult);
3173     } else {
3174         CalcDimension result(maxHeight->value, static_cast<DimensionUnit>(maxHeight->unit));
3175         ViewAbstract::SetMaxHeight(frameNode, CalcLength(result));
3176     }
3177 }
3178 
ResetMaxHeight(ArkUINodeHandle node)3179 void ResetMaxHeight(ArkUINodeHandle node)
3180 {
3181     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3182     CHECK_NULL_VOID(frameNode);
3183     ViewAbstract::ResetMaxSize(frameNode, false);
3184 }
3185 
SetSize(ArkUINodeHandle node,const ArkUI_Float32 * number,const ArkUI_Int32 * unit,ArkUI_CharPtr * calc)3186 void SetSize(ArkUINodeHandle node, const ArkUI_Float32* number, const ArkUI_Int32* unit, ArkUI_CharPtr* calc)
3187 {
3188     CHECK_NULL_VOID(number);
3189     CHECK_NULL_VOID(unit);
3190     int widthIndex = 0;
3191     int heightIndex = 1;
3192     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3193     CHECK_NULL_VOID(frameNode);
3194     if (*(unit + widthIndex) == static_cast<int8_t>(DimensionUnit::CALC) && *(calc + widthIndex) != nullptr) {
3195         ViewAbstract::SetWidth(frameNode, CalcLength(std::string(*(calc + widthIndex))));
3196     } else {
3197         ViewAbstract::SetWidth(
3198             frameNode, CalcLength(*(number + widthIndex), static_cast<DimensionUnit>(*(unit + widthIndex))));
3199     }
3200     if (*(unit + heightIndex) == static_cast<int8_t>(DimensionUnit::CALC) && *(calc + heightIndex) != nullptr) {
3201         ViewAbstract::SetHeight(frameNode, CalcLength(std::string(*(calc + heightIndex))));
3202     } else {
3203         ViewAbstract::SetHeight(
3204             frameNode, CalcLength(*(number + heightIndex), static_cast<DimensionUnit>(*(unit + heightIndex))));
3205     }
3206 }
3207 
ResetSize(ArkUINodeHandle node)3208 void ResetSize(ArkUINodeHandle node)
3209 {
3210     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3211     CHECK_NULL_VOID(frameNode);
3212     ViewAbstract::SetWidth(frameNode, CalcLength(0.0, DimensionUnit::VP));
3213     ViewAbstract::SetHeight(frameNode, CalcLength(0.0, DimensionUnit::VP));
3214 }
3215 
ClearWidthOrHeight(ArkUINodeHandle node,ArkUI_Bool isWidth)3216 void ClearWidthOrHeight(ArkUINodeHandle node, ArkUI_Bool isWidth)
3217 {
3218     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3219     CHECK_NULL_VOID(frameNode);
3220     ViewAbstract::ClearWidthOrHeight(frameNode, isWidth);
3221 }
3222 
SetAlignSelf(ArkUINodeHandle node,ArkUI_Int32 value)3223 void SetAlignSelf(ArkUINodeHandle node, ArkUI_Int32 value)
3224 {
3225     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3226     CHECK_NULL_VOID(frameNode);
3227     if (value >= 0 && value <= MAX_ALIGN_VALUE) {
3228         ViewAbstract::SetAlignSelf(frameNode, static_cast<FlexAlign>(value));
3229     } else {
3230         ViewAbstract::SetAlignSelf(frameNode, FlexAlign::AUTO);
3231     }
3232 }
3233 
ResetAlignSelf(ArkUINodeHandle node)3234 void ResetAlignSelf(ArkUINodeHandle node)
3235 {
3236     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3237     CHECK_NULL_VOID(frameNode);
3238     ViewAbstract::SetAlignSelf(frameNode, FlexAlign::AUTO);
3239 }
3240 
SetAspectRatio(ArkUINodeHandle node,ArkUI_Float32 value)3241 void SetAspectRatio(ArkUINodeHandle node, ArkUI_Float32 value)
3242 {
3243     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3244     CHECK_NULL_VOID(frameNode);
3245 
3246     double result = value;
3247     if (LessOrEqual(result, 0.0)) {
3248         if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
3249             ViewAbstract::ResetAspectRatio(frameNode);
3250             return;
3251         } else {
3252             result = 1.0;
3253         }
3254     }
3255 
3256     ViewAbstract::SetAspectRatio(frameNode, static_cast<float>(result));
3257 }
3258 
ResetAspectRatio(ArkUINodeHandle node)3259 void ResetAspectRatio(ArkUINodeHandle node)
3260 {
3261     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3262     CHECK_NULL_VOID(frameNode);
3263 
3264     if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TEN)) {
3265         ViewAbstract::ResetAspectRatio(frameNode);
3266     } else {
3267         ViewAbstract::SetAspectRatio(frameNode, static_cast<float>(1.0));
3268     }
3269 }
3270 
SetFlexGrow(ArkUINodeHandle node,ArkUI_Float32 value)3271 void SetFlexGrow(ArkUINodeHandle node, ArkUI_Float32 value)
3272 {
3273     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3274     CHECK_NULL_VOID(frameNode);
3275 
3276     double result = value;
3277     if (result < 0.0) {
3278         result = 0.0;
3279     }
3280     ViewAbstract::SetFlexGrow(frameNode, static_cast<float>(result));
3281 }
3282 
ResetFlexGrow(ArkUINodeHandle node)3283 void ResetFlexGrow(ArkUINodeHandle node)
3284 {
3285     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3286     CHECK_NULL_VOID(frameNode);
3287     ViewAbstract::SetFlexGrow(frameNode, static_cast<float>(0.0));
3288 }
3289 
SetFlexShrink(ArkUINodeHandle node,ArkUI_Float32 value)3290 void SetFlexShrink(ArkUINodeHandle node, ArkUI_Float32 value)
3291 {
3292     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3293     CHECK_NULL_VOID(frameNode);
3294 
3295     if (value < 0.0) {
3296         ViewAbstract::ResetFlexShrink(frameNode);
3297         return;
3298     }
3299     ViewAbstract::SetFlexShrink(frameNode, static_cast<float>(value));
3300 }
3301 
ResetFlexShrink(ArkUINodeHandle node)3302 void ResetFlexShrink(ArkUINodeHandle node)
3303 {
3304     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3305     CHECK_NULL_VOID(frameNode);
3306     ViewAbstract::ResetFlexShrink(frameNode);
3307 }
3308 
SetGridOffset(ArkUINodeHandle node,ArkUI_Int32 offset)3309 void SetGridOffset(ArkUINodeHandle node, ArkUI_Int32 offset)
3310 {
3311     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3312     CHECK_NULL_VOID(frameNode);
3313     ViewAbstract::SetGrid(frameNode, std::nullopt, offset, GridSizeType::UNDEFINED);
3314 }
3315 
ResetGridOffset(ArkUINodeHandle node)3316 void ResetGridOffset(ArkUINodeHandle node)
3317 {
3318     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3319     CHECK_NULL_VOID(frameNode);
3320     ViewAbstract::SetGrid(frameNode, std::nullopt, DEFAULT_GRID_OFFSET, GridSizeType::UNDEFINED);
3321 }
3322 
SetGridSpan(ArkUINodeHandle node,ArkUI_Int32 value)3323 void SetGridSpan(ArkUINodeHandle node, ArkUI_Int32 value)
3324 {
3325     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3326     CHECK_NULL_VOID(frameNode);
3327     ViewAbstract::SetGrid(frameNode, value, std::nullopt);
3328 }
3329 
ResetGridSpan(ArkUINodeHandle node)3330 void ResetGridSpan(ArkUINodeHandle node)
3331 {
3332     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3333     CHECK_NULL_VOID(frameNode);
3334     ViewAbstract::SetGrid(frameNode, DEFAULT_GRIDSPAN, std::nullopt);
3335 }
3336 
SetExpandSafeArea(ArkUINodeHandle node,ArkUI_Uint32 safeAreaType,ArkUI_Uint32 safeAreaEdge)3337 void SetExpandSafeArea(ArkUINodeHandle node, ArkUI_Uint32 safeAreaType, ArkUI_Uint32 safeAreaEdge)
3338 {
3339     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3340     CHECK_NULL_VOID(frameNode);
3341     NG::SafeAreaExpandOpts opts { .type = NG::SAFE_AREA_TYPE_ALL, .edges = NG::SAFE_AREA_EDGE_ALL };
3342     opts.type = safeAreaType;
3343     opts.edges = safeAreaEdge;
3344     ViewAbstract::UpdateSafeAreaExpandOpts(frameNode, opts);
3345 }
3346 
ResetExpandSafeArea(ArkUINodeHandle node)3347 void ResetExpandSafeArea(ArkUINodeHandle node)
3348 {
3349     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3350     CHECK_NULL_VOID(frameNode);
3351     NG::SafeAreaExpandOpts opts;
3352     opts.type = DEFAULT_SAFE_AREA_TYPE;
3353     opts.edges = DEFAULT_SAFE_AREA_EDGE;
3354     ViewAbstract::UpdateSafeAreaExpandOpts(frameNode, opts);
3355 }
3356 
SetFlexBasis(ArkUINodeHandle node,const struct ArkUIStringAndFloat * flexBasisValue)3357 void SetFlexBasis(ArkUINodeHandle node, const struct ArkUIStringAndFloat* flexBasisValue)
3358 {
3359     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3360     CHECK_NULL_VOID(frameNode);
3361     Dimension result;
3362     if (flexBasisValue->valueStr != nullptr) {
3363         result = StringUtils::StringToDimensionWithUnit(std::string(flexBasisValue->valueStr), DimensionUnit::VP);
3364         // flex basis don't support percent case.
3365         if (result.Unit() == DimensionUnit::PERCENT) {
3366             result.SetUnit(DimensionUnit::AUTO);
3367         }
3368     } else {
3369         result = Dimension(flexBasisValue->value, DimensionUnit::VP);
3370     }
3371     ViewAbstract::SetFlexBasis(frameNode, result);
3372 }
3373 
ResetFlexBasis(ArkUINodeHandle node)3374 void ResetFlexBasis(ArkUINodeHandle node)
3375 {
3376     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3377     CHECK_NULL_VOID(frameNode);
3378     ViewAbstract::SetFlexBasis(frameNode, DEFAULT_FLEX_BASIS);
3379 }
3380 
SetAlignRules(ArkUINodeHandle node,char ** anchors,const ArkUI_Int32 * direction,ArkUI_Int32 length)3381 void SetAlignRules(ArkUINodeHandle node, char** anchors, const ArkUI_Int32* direction, ArkUI_Int32 length)
3382 {
3383     CHECK_NULL_VOID(anchors);
3384     CHECK_NULL_VOID(direction);
3385     if (length != DEFAULT_ALIGN_RULES_SIZE) {
3386         return;
3387     }
3388     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3389     CHECK_NULL_VOID(frameNode);
3390     std::map<AlignDirection, AlignRule> rulesMap;
3391     for (int index = 0; index < length; index++) {
3392         AlignRule alignRule;
3393         alignRule.anchor = std::string(*(anchors + index) == nullptr ? "" : *(anchors + index));
3394         if (index < HORIZONTAL_DIRECTION_RANGE) {
3395             alignRule.horizontal = static_cast<HorizontalAlign>(*(direction + index));
3396         } else {
3397             alignRule.vertical = static_cast<VerticalAlign>(*(direction + index));
3398         }
3399         rulesMap[static_cast<AlignDirection>(index)] = alignRule;
3400     }
3401     ViewAbstract::SetAlignRules(frameNode, rulesMap);
3402     BiasPair biasPair(DEFAULT_BIAS, DEFAULT_BIAS);
3403     ViewAbstract::SetBias(frameNode, biasPair);
3404 }
3405 
SetAlignRulesWidthType(ArkUINodeHandle node,const ArkUIAlignRulesType * alignRulesType)3406 void SetAlignRulesWidthType(ArkUINodeHandle node, const ArkUIAlignRulesType* alignRulesType)
3407 {
3408     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3409     CHECK_NULL_VOID(frameNode);
3410     CHECK_NULL_VOID(alignRulesType);
3411     std::map<AlignDirection, AlignRule> rulesMap;
3412     for (int32_t i = 0; i < alignRulesType->anchorCount && i < NUM_6; i++) {
3413         std::string anchorId(alignRulesType->anchorIds[i]);
3414         if (anchorId.empty()) {
3415             continue;
3416         }
3417         AlignRule alignRule;
3418         alignRule.anchor = anchorId;
3419         if (i < NUM_3) {
3420             alignRule.horizontal = static_cast<HorizontalAlign>(alignRulesType->alignTypes[i]);
3421         } else {
3422             alignRule.vertical = static_cast<VerticalAlign>(alignRulesType->alignTypes[i]);
3423         }
3424         rulesMap[static_cast<AlignDirection>(i)] = alignRule;
3425     }
3426     ViewAbstract::SetAlignRules(frameNode, rulesMap);
3427     BiasPair biasPair(alignRulesType->biasHorizontalValue, alignRulesType->biasVerticalValue);
3428     ViewAbstract::SetBias(frameNode, biasPair);
3429 }
3430 
ResetAlignRules(ArkUINodeHandle node)3431 void ResetAlignRules(ArkUINodeHandle node)
3432 {
3433     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3434     CHECK_NULL_VOID(frameNode);
3435     ViewAbstract::ResetAlignRules(frameNode);
3436 }
3437 
GetAlignRules(ArkUINodeHandle node,ArkUI_CharPtr * anchors,ArkUI_Int32 * direction,ArkUI_Int32 length)3438 void GetAlignRules(ArkUINodeHandle node, ArkUI_CharPtr* anchors, ArkUI_Int32* direction, ArkUI_Int32 length)
3439 {
3440     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3441     CHECK_NULL_VOID(frameNode);
3442     auto alignRules = ViewAbstract::GetAlignRules(frameNode);
3443 
3444     ArkUI_Int32 index = 0;
3445     for (const AlignDirection alignDirection : { AlignDirection::LEFT, AlignDirection::MIDDLE, AlignDirection::RIGHT,
3446          AlignDirection::TOP, AlignDirection::CENTER, AlignDirection::BOTTOM, AlignDirection::START,
3447          AlignDirection::END }) {
3448         if (index >= length) {
3449             return;
3450         }
3451         auto it = alignRules.find(alignDirection);
3452         if (it != alignRules.end()) {
3453             anchors[index] = it->second.anchor.c_str();
3454             switch (alignDirection) {
3455                 case AlignDirection::LEFT:
3456                 case AlignDirection::RIGHT:
3457                 case AlignDirection::CENTER:
3458                 case AlignDirection::START:
3459                 case AlignDirection::END:
3460                     direction[index] = static_cast<ArkUI_Int32>(it->second.horizontal) - 1;
3461                     break;
3462                 case AlignDirection::TOP:
3463                 case AlignDirection::MIDDLE:
3464                 case AlignDirection::BOTTOM:
3465                     direction[index] = static_cast<ArkUI_Int32>(it->second.vertical) - 1;
3466                     break;
3467             }
3468         } else {
3469             anchors[index] = nullptr;
3470             direction[index] = -1;
3471         }
3472         ++index;
3473     }
3474 }
3475 
SetAccessibilityDescription(ArkUINodeHandle node,ArkUI_CharPtr value)3476 void SetAccessibilityDescription(ArkUINodeHandle node, ArkUI_CharPtr value)
3477 {
3478     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3479     CHECK_NULL_VOID(frameNode);
3480     CHECK_NULL_VOID(value);
3481     std::string valueStr = value;
3482     ViewAbstractModelNG::SetAccessibilityDescription(frameNode, valueStr);
3483 }
3484 
ResetAccessibilityDescription(ArkUINodeHandle node)3485 void ResetAccessibilityDescription(ArkUINodeHandle node)
3486 {
3487     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3488     CHECK_NULL_VOID(frameNode);
3489     ViewAbstractModelNG::SetAccessibilityDescription(frameNode, "");
3490 }
3491 
SetId(ArkUINodeHandle node,ArkUI_CharPtr id)3492 void SetId(ArkUINodeHandle node, ArkUI_CharPtr id)
3493 {
3494     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3495     CHECK_NULL_VOID(frameNode);
3496     std::string valueStr = id;
3497     ViewAbstract::SetInspectorId(frameNode, valueStr);
3498 }
3499 
ResetId(ArkUINodeHandle node)3500 void ResetId(ArkUINodeHandle node)
3501 {
3502     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3503     CHECK_NULL_VOID(frameNode);
3504     std::string id = "";
3505     ViewAbstract::SetInspectorId(frameNode, id);
3506 }
3507 
SetKey(ArkUINodeHandle node,ArkUI_CharPtr key)3508 void SetKey(ArkUINodeHandle node, ArkUI_CharPtr key)
3509 {
3510     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3511     CHECK_NULL_VOID(frameNode);
3512     std::string valueStr = key;
3513     ViewAbstract::SetInspectorId(frameNode, valueStr);
3514 }
3515 
ResetKey(ArkUINodeHandle node)3516 void ResetKey(ArkUINodeHandle node)
3517 {
3518     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3519     CHECK_NULL_VOID(frameNode);
3520     std::string defaultStr = "";
3521     ViewAbstract::SetInspectorId(frameNode, defaultStr);
3522 }
3523 
SetRestoreId(ArkUINodeHandle node,uint32_t id)3524 void SetRestoreId(ArkUINodeHandle node, uint32_t id)
3525 {
3526     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3527     CHECK_NULL_VOID(frameNode);
3528     ViewAbstract::SetRestoreId(frameNode, id);
3529 }
3530 
ResetRestoreId(ArkUINodeHandle node)3531 void ResetRestoreId(ArkUINodeHandle node)
3532 {
3533     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3534     CHECK_NULL_VOID(frameNode);
3535     ViewAbstract::SetRestoreId(frameNode, DEFAULT_ID);
3536 }
3537 
SetTabIndex(ArkUINodeHandle node,ArkUI_Int32 index)3538 void SetTabIndex(ArkUINodeHandle node, ArkUI_Int32 index)
3539 {
3540     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3541     CHECK_NULL_VOID(frameNode);
3542     ViewAbstract::SetTabIndex(frameNode, index);
3543 }
3544 
ResetTabIndex(ArkUINodeHandle node)3545 void ResetTabIndex(ArkUINodeHandle node)
3546 {
3547     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3548     CHECK_NULL_VOID(frameNode);
3549     int32_t index = 0;
3550     ViewAbstract::SetTabIndex(frameNode, index);
3551 }
3552 
SetObscured(ArkUINodeHandle node,const ArkUI_Int32 * reason,ArkUI_Int32 length)3553 void SetObscured(ArkUINodeHandle node, const ArkUI_Int32* reason, ArkUI_Int32 length)
3554 {
3555     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3556     CHECK_NULL_VOID(frameNode);
3557     std::vector<ObscuredReasons> reasons(length);
3558     reasons.clear();
3559     for (int32_t i = 0; i < length; i++) {
3560         reasons.emplace_back(static_cast<ObscuredReasons>(reason[i]));
3561     }
3562 
3563     ViewAbstract::SetObscured(frameNode, reasons);
3564 }
3565 
ResetObscured(ArkUINodeHandle node)3566 void ResetObscured(ArkUINodeHandle node)
3567 {
3568     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3569     CHECK_NULL_VOID(frameNode);
3570     std::vector<ObscuredReasons> reasons(0);
3571     ViewAbstract::SetObscured(frameNode, reasons);
3572 }
3573 
SetResponseRegion(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)3574 void SetResponseRegion(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
3575 {
3576     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3577     CHECK_NULL_VOID(frameNode);
3578     std::vector<DimensionRect> region;
3579     for (int32_t i = 0; i < length / NUM_4; i++) {
3580         CalcDimension xDimen =
3581             CalcDimension(values[i * NUM_4 + NUM_0], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_0]));
3582         CalcDimension yDimen =
3583             CalcDimension(values[i * NUM_4 + NUM_1], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_1]));
3584         CalcDimension widthDimen =
3585             CalcDimension(values[i * NUM_4 + NUM_2], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_2]));
3586         CalcDimension heightDimen =
3587             CalcDimension(values[i * NUM_4 + NUM_3], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_3]));
3588         DimensionOffset offsetDimen(xDimen, yDimen);
3589         DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3590         region.emplace_back(dimenRect);
3591     }
3592     ViewAbstract::SetResponseRegion(frameNode, region);
3593 }
3594 
ResetResponseRegion(ArkUINodeHandle node)3595 void ResetResponseRegion(ArkUINodeHandle node)
3596 {
3597     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3598     CHECK_NULL_VOID(frameNode);
3599     std::vector<DimensionRect> region;
3600     CalcDimension xDimen = CalcDimension(0.0, DimensionUnit::VP);
3601     CalcDimension yDimen = CalcDimension(0.0, DimensionUnit::VP);
3602     CalcDimension widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
3603     CalcDimension heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
3604     DimensionOffset offsetDimen(xDimen, yDimen);
3605     DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3606     region.emplace_back(dimenRect);
3607     ViewAbstract::SetResponseRegion(frameNode, region);
3608 }
3609 
SetForegroundEffect(ArkUINodeHandle node,ArkUI_Float32 radius,ArkUI_Bool disableSystemAdaptation)3610 void SetForegroundEffect(ArkUINodeHandle node, ArkUI_Float32 radius, ArkUI_Bool disableSystemAdaptation)
3611 {
3612     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3613     CHECK_NULL_VOID(frameNode);
3614     radius = std::max(radius, 0.0f);
3615     SysOptions sysOptions;
3616     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
3617     ViewAbstract::SetForegroundEffect(frameNode, static_cast<float>(radius), sysOptions);
3618 }
3619 
ResetForegroundEffect(ArkUINodeHandle node)3620 void ResetForegroundEffect(ArkUINodeHandle node)
3621 {
3622     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3623     CHECK_NULL_VOID(frameNode);
3624     ViewAbstract::SetForegroundEffect(frameNode, 0.0f);
3625 }
3626 
SetBackgroundEffect(ArkUINodeHandle node,ArkUI_Float32 radiusArg,ArkUI_Float32 saturationArg,ArkUI_Float32 brightnessArg,ArkUI_Uint32 colorArg,ArkUI_Int32 adaptiveColorArg,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize,ArkUI_Int32 policy,ArkUI_Int32 blurType,ArkUI_Bool isValidColor,ArkUI_Uint32 inactiveColorArg,ArkUI_Bool disableSystemAdaptation)3627 void SetBackgroundEffect(ArkUINodeHandle node, ArkUI_Float32 radiusArg, ArkUI_Float32 saturationArg,
3628     ArkUI_Float32 brightnessArg, ArkUI_Uint32 colorArg, ArkUI_Int32 adaptiveColorArg, const ArkUI_Float32* blurValues,
3629     ArkUI_Int32 blurValuesSize, ArkUI_Int32 policy, ArkUI_Int32 blurType, ArkUI_Bool isValidColor,
3630     ArkUI_Uint32 inactiveColorArg, ArkUI_Bool disableSystemAdaptation)
3631 {
3632     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3633     CHECK_NULL_VOID(frameNode);
3634     CalcDimension radius;
3635     radius.SetValue(radiusArg);
3636     Color color(colorArg);
3637     BlurOption blurOption;
3638     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
3639 
3640     EffectOption option;
3641     option.radius = radius;
3642     option.saturation = saturationArg;
3643     option.brightness = brightnessArg;
3644     option.color = color;
3645     option.adaptiveColor = static_cast<AdaptiveColor>(adaptiveColorArg);
3646     option.blurOption = blurOption;
3647     option.blurType = static_cast<BlurType>(blurType);
3648     option.policy = static_cast<BlurStyleActivePolicy>(policy);
3649     Color inactiveColor(inactiveColorArg);
3650     option.inactiveColor = inactiveColor;
3651     option.isValidColor = isValidColor;
3652     SysOptions sysOptions;
3653     sysOptions.disableSystemAdaptation = disableSystemAdaptation;
3654     ViewAbstract::SetBackgroundEffect(frameNode, option, sysOptions);
3655 }
3656 
ResetBackgroundEffect(ArkUINodeHandle node)3657 void ResetBackgroundEffect(ArkUINodeHandle node)
3658 {
3659     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3660     CHECK_NULL_VOID(frameNode);
3661     CalcDimension radius;
3662     radius.SetValue(0.0f);
3663     double saturation = 1.0f;
3664     double brightness = 1.0f;
3665     Color color = Color::TRANSPARENT;
3666     color.SetValue(Color::TRANSPARENT.GetValue());
3667     auto adaptiveColor = AdaptiveColor::DEFAULT;
3668     BlurOption blurOption;
3669     EffectOption effectOption = { radius, saturation, brightness, color, adaptiveColor, blurOption };
3670     ViewAbstract::SetBackgroundEffect(frameNode, effectOption);
3671 }
3672 
SetBackgroundBrightness(ArkUINodeHandle node,ArkUI_Float32 rate,ArkUI_Float32 lightUpDegree)3673 void SetBackgroundBrightness(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree)
3674 {
3675     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3676     CHECK_NULL_VOID(frameNode);
3677     ViewAbstract::SetDynamicLightUp(frameNode, rate, lightUpDegree);
3678 }
3679 
ResetBackgroundBrightness(ArkUINodeHandle node)3680 void ResetBackgroundBrightness(ArkUINodeHandle node)
3681 {
3682     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3683     CHECK_NULL_VOID(frameNode);
3684     double rate = 0.0;
3685     double lightUpDegree = 0.0;
3686     ViewAbstract::SetDynamicLightUp(frameNode, rate, lightUpDegree);
3687 }
3688 
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)3689 void SetBackgroundBrightnessInternal(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree,
3690     ArkUI_Float32 cubicCoeff, ArkUI_Float32 quadCoeff, ArkUI_Float32 saturation,
3691     const ArkUI_Float32* posRGBValues, ArkUI_Int32 posRGBValuesSize,
3692     const ArkUI_Float32* negRGBValues, ArkUI_Int32 negRGBValuesSize , ArkUI_Float32 fraction)
3693 {
3694     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3695     std::vector<float> posRGB;
3696     posRGB.assign(posRGBValues, posRGBValues + posRGBValuesSize);
3697     std::vector<float> negRGB;
3698     negRGB.assign(negRGBValues, negRGBValues + negRGBValuesSize);
3699     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3700         saturation, posRGB, negRGB, fraction };
3701     CHECK_NULL_VOID(frameNode);
3702     ViewAbstract::SetBgDynamicBrightness(frameNode, brightnessOption);
3703 }
3704 
ResetBackgroundBrightnessInternal(ArkUINodeHandle node)3705 void ResetBackgroundBrightnessInternal(ArkUINodeHandle node)
3706 {
3707     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3708     CHECK_NULL_VOID(frameNode);
3709     float rate = 1.0f;
3710     float lightUpDegree = 0.0f;
3711     float cubicCoeff = 0.0f;
3712     float quadCoeff = 0.0f;
3713     float saturation = 1.0f;
3714     std::vector<float> posRGB(3, 0.0);
3715     std::vector<float> negRGB(3, 0.0);
3716     float fraction = 1.0;
3717     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3718         saturation, posRGB, negRGB, fraction };
3719     ViewAbstract::SetBgDynamicBrightness(frameNode, brightnessOption);
3720 }
3721 
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)3722 void SetForegroundBrightness(ArkUINodeHandle node, ArkUI_Float32 rate, ArkUI_Float32 lightUpDegree,
3723     ArkUI_Float32 cubicCoeff, ArkUI_Float32 quadCoeff, ArkUI_Float32 saturation,
3724     const ArkUI_Float32* posRGBValues, ArkUI_Int32 posRGBValuesSize,
3725     const ArkUI_Float32* negRGBValues, ArkUI_Int32 negRGBValuesSize, ArkUI_Float32 fraction)
3726 {
3727     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3728     std::vector<float> posRGB;
3729     posRGB.assign(posRGBValues, posRGBValues + posRGBValuesSize);
3730     std::vector<float> negRGB;
3731     negRGB.assign(negRGBValues, negRGBValues + negRGBValuesSize);
3732     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3733         saturation, posRGB, negRGB, fraction };
3734     CHECK_NULL_VOID(frameNode);
3735     ViewAbstract::SetFgDynamicBrightness(frameNode, brightnessOption);
3736 }
3737 
ResetForegroundBrightness(ArkUINodeHandle node)3738 void ResetForegroundBrightness(ArkUINodeHandle node)
3739  {
3740     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3741     CHECK_NULL_VOID(frameNode);
3742     float rate = 1.0f;
3743     float lightUpDegree = 0.0f;
3744     float cubicCoeff = 0.0f;
3745     float quadCoeff = 0.0f;
3746     float saturation = 1.0f;
3747     std::vector<float> posRGB(3, 0.0);
3748     std::vector<float> negRGB(3, 0.0);
3749     float fraction = 1.0;
3750     BrightnessOption brightnessOption = { rate, lightUpDegree, cubicCoeff, quadCoeff,
3751         saturation, posRGB, negRGB, fraction };
3752     ViewAbstract::SetFgDynamicBrightness(frameNode, brightnessOption);
3753 }
3754 
ParseDragPreviewMode(NG::DragPreviewOption & previewOption,int32_t modeValue,bool & isAuto)3755 void ParseDragPreviewMode(NG::DragPreviewOption& previewOption, int32_t modeValue, bool& isAuto)
3756 {
3757     isAuto = false;
3758     switch (modeValue) {
3759         case static_cast<int32_t>(NG::DragPreviewMode::AUTO):
3760             previewOption.ResetDragPreviewMode();
3761             isAuto = true;
3762             break;
3763         case static_cast<int32_t>(NG::DragPreviewMode::DISABLE_SCALE):
3764             previewOption.isScaleEnabled = false;
3765             break;
3766         case static_cast<int32_t>(NG::DragPreviewMode::ENABLE_DEFAULT_SHADOW):
3767             previewOption.isDefaultShadowEnabled = true;
3768             break;
3769         case static_cast<int32_t>(NG::DragPreviewMode::ENABLE_DEFAULT_RADIUS):
3770             previewOption.isDefaultRadiusEnabled = true;
3771             break;
3772         case static_cast<int32_t>(NG::DragPreviewMode::ENABLE_DRAG_ITEM_GRAY_EFFECT):
3773             previewOption.isDefaultDragItemGrayEffectEnabled = true;
3774             break;
3775         case static_cast<int32_t>(NG::DragPreviewMode::ENABLE_MULTI_TILE_EFFECT):
3776             previewOption.isMultiTiled = true;
3777             break;
3778         case static_cast<int32_t>(NG::DragPreviewMode::ENABLE_TOUCH_POINT_CALCULATION_BASED_ON_FINAL_PREVIEW):
3779             previewOption.isTouchPointCalculationBasedOnFinalPreviewEnable = true;
3780             break;
3781         default:
3782             break;
3783     }
3784 }
3785 
SetDragPreviewOptions(ArkUINodeHandle node,ArkUIDragPreViewOptions dragPreviewOptions,ArkUIDragInteractionOptions dragInteractionOptions)3786 void SetDragPreviewOptions(ArkUINodeHandle node, ArkUIDragPreViewOptions dragPreviewOptions,
3787     ArkUIDragInteractionOptions dragInteractionOptions)
3788 {
3789     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3790     CHECK_NULL_VOID(frameNode);
3791     NG::DragPreviewOption option;
3792     bool isAuto = true;
3793     if (!dragPreviewOptions.isModeArray) {
3794         ParseDragPreviewMode(option, dragPreviewOptions.mode, isAuto);
3795     } else {
3796         for (int32_t i = 0; i < dragPreviewOptions.modeArrayLength; i++) {
3797             ParseDragPreviewMode(option, dragPreviewOptions.modeArray[i], isAuto);
3798             if (isAuto) {
3799                 break;
3800             }
3801         }
3802     }
3803 
3804     if (dragPreviewOptions.isBadgeNumber) {
3805         option.badgeNumber = dragPreviewOptions.badgeNumber;
3806     } else {
3807         option.isShowBadge = dragPreviewOptions.isShowBadge;
3808     }
3809     option.sizeChangeEffect = static_cast<NG::DraggingSizeChangeEffect>(dragPreviewOptions.sizeChangeEffect);
3810     option.isNumber = dragPreviewOptions.isBadgeNumber;
3811     option.isMultiSelectionEnabled = dragInteractionOptions.isMultiSelectionEnabled;
3812     option.defaultAnimationBeforeLifting = dragInteractionOptions.defaultAnimationBeforeLifting;
3813     option.enableEdgeAutoScroll = dragInteractionOptions.enableEdgeAutoScroll;
3814     option.enableHapticFeedback = dragInteractionOptions.enableHapticFeedback;
3815     option.isLiftingDisabled = dragInteractionOptions.isLiftingDisabled;
3816     ViewAbstract::SetDragPreviewOptions(frameNode, option);
3817 }
3818 
ResetDragPreviewOptions(ArkUINodeHandle node)3819 void ResetDragPreviewOptions(ArkUINodeHandle node)
3820 {
3821     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3822     CHECK_NULL_VOID(frameNode);
3823     ViewAbstract::SetDragPreviewOptions(frameNode, NG::DragPreviewOption());
3824 }
3825 
SetDisableDataPrefetch(ArkUINodeHandle node,ArkUI_Bool value)3826 void SetDisableDataPrefetch(ArkUINodeHandle node, ArkUI_Bool value)
3827 {
3828     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3829     CHECK_NULL_VOID(frameNode);
3830     ViewAbstract::SetDisableDataPrefetch(frameNode, value);
3831 }
3832 
SetMouseResponseRegion(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units,ArkUI_Int32 length)3833 void SetMouseResponseRegion(
3834     ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units, ArkUI_Int32 length)
3835 {
3836     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3837     CHECK_NULL_VOID(frameNode);
3838     std::vector<DimensionRect> region;
3839     for (int32_t i = 0; i < length / NUM_4; i++) {
3840         CalcDimension xDimen =
3841             CalcDimension(values[i * NUM_4 + NUM_0], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_0]));
3842         CalcDimension yDimen =
3843             CalcDimension(values[i * NUM_4 + NUM_1], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_1]));
3844         CalcDimension widthDimen =
3845             CalcDimension(values[i * NUM_4 + NUM_2], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_2]));
3846         CalcDimension heightDimen =
3847             CalcDimension(values[i * NUM_4 + NUM_3], static_cast<DimensionUnit>(units[i * NUM_4 + NUM_3]));
3848         DimensionOffset offsetDimen(xDimen, yDimen);
3849         DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3850         region.emplace_back(dimenRect);
3851     }
3852     ViewAbstract::SetMouseResponseRegion(frameNode, region);
3853 }
3854 
ResetMouseResponseRegion(ArkUINodeHandle node)3855 void ResetMouseResponseRegion(ArkUINodeHandle node)
3856 {
3857     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3858     CHECK_NULL_VOID(frameNode);
3859     std::vector<DimensionRect> region;
3860     CalcDimension xDimen = CalcDimension(0.0, DimensionUnit::VP);
3861     CalcDimension yDimen = CalcDimension(0.0, DimensionUnit::VP);
3862     CalcDimension widthDimen = CalcDimension(1, DimensionUnit::PERCENT);
3863     CalcDimension heightDimen = CalcDimension(1, DimensionUnit::PERCENT);
3864     DimensionOffset offsetDimen(xDimen, yDimen);
3865     DimensionRect dimenRect(widthDimen, heightDimen, offsetDimen);
3866     region.emplace_back(dimenRect);
3867     ViewAbstract::SetMouseResponseRegion(frameNode, region);
3868 }
3869 
SetEnabled(ArkUINodeHandle node,ArkUI_Bool value)3870 void SetEnabled(ArkUINodeHandle node, ArkUI_Bool value)
3871 {
3872     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3873     CHECK_NULL_VOID(frameNode);
3874     ViewAbstract::SetEnabled(frameNode, value);
3875 }
3876 
ResetEnabled(ArkUINodeHandle node)3877 void ResetEnabled(ArkUINodeHandle node)
3878 {
3879     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3880     CHECK_NULL_VOID(frameNode);
3881     ViewAbstract::SetEnabled(frameNode, true);
3882 }
3883 
SetUseShadowBatching(ArkUINodeHandle node,ArkUI_Bool value)3884 void SetUseShadowBatching(ArkUINodeHandle node, ArkUI_Bool value)
3885 {
3886     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3887     CHECK_NULL_VOID(frameNode);
3888     ViewAbstractModelNG::SetUseShadowBatching(frameNode, value);
3889 }
3890 
ResetUseShadowBatching(ArkUINodeHandle node)3891 void ResetUseShadowBatching(ArkUINodeHandle node)
3892 {
3893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3894     CHECK_NULL_VOID(frameNode);
3895     ViewAbstractModelNG::SetUseShadowBatching(frameNode, false);
3896 }
3897 
SetDraggable(ArkUINodeHandle node,ArkUI_Bool value)3898 void SetDraggable(ArkUINodeHandle node, ArkUI_Bool value)
3899 {
3900     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3901     CHECK_NULL_VOID(frameNode);
3902     ViewAbstract::SetDraggable(frameNode, value);
3903 }
3904 
ResetDraggable(ArkUINodeHandle node)3905 void ResetDraggable(ArkUINodeHandle node)
3906 {
3907     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3908     CHECK_NULL_VOID(frameNode);
3909     ViewAbstract::SetDraggable(frameNode, false);
3910 }
3911 
SetAccessibilityGroup(ArkUINodeHandle node,ArkUI_Bool value)3912 void SetAccessibilityGroup(ArkUINodeHandle node, ArkUI_Bool value)
3913 {
3914     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3915     CHECK_NULL_VOID(frameNode);
3916     ViewAbstractModelNG::SetAccessibilityGroup(frameNode, value);
3917 }
3918 
ResetAccessibilityGroup(ArkUINodeHandle node)3919 void ResetAccessibilityGroup(ArkUINodeHandle node)
3920 {
3921     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3922     CHECK_NULL_VOID(frameNode);
3923     ViewAbstractModelNG::SetAccessibilityGroup(frameNode, false);
3924 }
3925 
SetAccessibilityNextFocusId(ArkUINodeHandle node,ArkUI_CharPtr value)3926 void SetAccessibilityNextFocusId(ArkUINodeHandle node, ArkUI_CharPtr value)
3927 {
3928     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3929     CHECK_NULL_VOID(frameNode);
3930     std::string valueStr = value;
3931     ViewAbstractModelNG::SetAccessibilityNextFocusId(frameNode, valueStr);
3932 }
3933 
ResetAccessibilityNextFocusId(ArkUINodeHandle node)3934 void ResetAccessibilityNextFocusId(ArkUINodeHandle node)
3935 {
3936     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3937     CHECK_NULL_VOID(frameNode);
3938     ViewAbstractModelNG::SetAccessibilityNextFocusId(frameNode, "");
3939 }
3940 
SetAccessibilityDefaultFocus(ArkUINodeHandle node,ArkUI_Bool value)3941 void SetAccessibilityDefaultFocus(ArkUINodeHandle node, ArkUI_Bool value)
3942 {
3943     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3944     CHECK_NULL_VOID(frameNode);
3945     ViewAbstractModelNG::SetAccessibilityDefaultFocus(frameNode, value);
3946 }
3947 
ResetAccessibilityDefaultFocus(ArkUINodeHandle node)3948 void ResetAccessibilityDefaultFocus(ArkUINodeHandle node)
3949 {
3950     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3951     CHECK_NULL_VOID(frameNode);
3952     ViewAbstractModelNG::SetAccessibilityDefaultFocus(frameNode, false);
3953 }
3954 
SetAccessibilityUseSamePage(ArkUINodeHandle node,ArkUI_Bool isFullSilent)3955 void SetAccessibilityUseSamePage(ArkUINodeHandle node, ArkUI_Bool isFullSilent)
3956 {
3957     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3958     CHECK_NULL_VOID(frameNode);
3959     std::string pageMode = isFullSilent ? "FULL_SILENT" : "SEMI_SILENT";
3960     ViewAbstractModelNG::SetAccessibilityUseSamePage(frameNode, pageMode);
3961 }
3962 
ResetAccessibilityUseSamePage(ArkUINodeHandle node)3963 void ResetAccessibilityUseSamePage(ArkUINodeHandle node)
3964 {
3965     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3966     CHECK_NULL_VOID(frameNode);
3967     ViewAbstractModelNG::SetAccessibilityUseSamePage(frameNode, "");
3968 }
3969 
SetAccessibilityScrollTriggerable(ArkUINodeHandle node,ArkUI_Bool value)3970 void SetAccessibilityScrollTriggerable(ArkUINodeHandle node, ArkUI_Bool value)
3971 {
3972     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3973     CHECK_NULL_VOID(frameNode);
3974     ViewAbstractModelNG::SetAccessibilityScrollTriggerable(frameNode, value, false);
3975 }
3976 
ResetAccessibilityScrollTriggerable(ArkUINodeHandle node)3977 void ResetAccessibilityScrollTriggerable(ArkUINodeHandle node)
3978 {
3979     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3980     CHECK_NULL_VOID(frameNode);
3981     ViewAbstractModelNG::SetAccessibilityScrollTriggerable(frameNode, true, true);
3982 }
3983 
SetAccessibilityFocusDrawLevel(ArkUINodeHandle node,ArkUI_Int32 drawLevel)3984 void SetAccessibilityFocusDrawLevel(ArkUINodeHandle node, ArkUI_Int32 drawLevel)
3985 {
3986     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3987     CHECK_NULL_VOID(frameNode);
3988     ViewAbstractModelNG::SetAccessibilityFocusDrawLevel(frameNode, drawLevel);
3989 }
3990 
ResetAccessibilityFocusDrawLevel(ArkUINodeHandle node)3991 void ResetAccessibilityFocusDrawLevel(ArkUINodeHandle node)
3992 {
3993     auto* frameNode = reinterpret_cast<FrameNode*>(node);
3994     CHECK_NULL_VOID(frameNode);
3995     ViewAbstractModelNG::SetAccessibilityFocusDrawLevel(frameNode, 0);
3996 }
3997 
SetHoverEffect(ArkUINodeHandle node,ArkUI_Int32 hoverEffectValue)3998 void SetHoverEffect(ArkUINodeHandle node, ArkUI_Int32 hoverEffectValue)
3999 {
4000     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4001     CHECK_NULL_VOID(frameNode);
4002     OHOS::Ace::HoverEffectType hoverEffect = OHOS::Ace::HoverEffectType::AUTO;
4003     hoverEffect = static_cast<OHOS::Ace::HoverEffectType>(hoverEffectValue);
4004     ViewAbstract::SetHoverEffect(frameNode, hoverEffect);
4005 }
4006 
ResetHoverEffect(ArkUINodeHandle node)4007 void ResetHoverEffect(ArkUINodeHandle node)
4008 {
4009     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4010     CHECK_NULL_VOID(frameNode);
4011     ViewAbstract::SetHoverEffect(frameNode, OHOS::Ace::HoverEffectType::AUTO);
4012 }
4013 
SetClickEffect(ArkUINodeHandle node,const int32_t levelValue,ArkUI_Float32 scaleValue)4014 void SetClickEffect(ArkUINodeHandle node, const int32_t levelValue, ArkUI_Float32 scaleValue)
4015 {
4016     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4017     CHECK_NULL_VOID(frameNode);
4018     OHOS::Ace::ClickEffectLevel level = OHOS::Ace::ClickEffectLevel::UNDEFINED;
4019     level = static_cast<OHOS::Ace::ClickEffectLevel>(levelValue);
4020     ViewAbstract::SetClickEffectLevel(frameNode, level, scaleValue);
4021 }
4022 
ResetClickEffect(ArkUINodeHandle node)4023 void ResetClickEffect(ArkUINodeHandle node)
4024 {
4025     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4026     CHECK_NULL_VOID(frameNode);
4027     ViewAbstract::SetClickEffectLevel(frameNode, OHOS::Ace::ClickEffectLevel::UNDEFINED, 0.9f);
4028 }
4029 
SetKeyBoardShortCut(ArkUINodeHandle node,ArkUI_CharPtr value,const ArkUI_Int32 * keysIntArray,ArkUI_Int32 length)4030 void SetKeyBoardShortCut(ArkUINodeHandle node, ArkUI_CharPtr value, const ArkUI_Int32* keysIntArray, ArkUI_Int32 length)
4031 {
4032     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4033     CHECK_NULL_VOID(frameNode);
4034     std::string valueStr = value;
4035     std::vector<OHOS::Ace::ModifierKey> keysVector(length);
4036     keysVector.clear();
4037     for (int32_t i = 0; i < length; i++) {
4038         keysVector.emplace_back(static_cast<OHOS::Ace::ModifierKey>(keysIntArray[i]));
4039     }
4040     ViewAbstractModelNG::SetKeyboardShortcut(frameNode, valueStr, keysVector, nullptr);
4041 }
4042 
ResetKeyBoardShortCut(ArkUINodeHandle node)4043 void ResetKeyBoardShortCut(ArkUINodeHandle node)
4044 {
4045     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4046     CHECK_NULL_VOID(frameNode);
4047     ViewAbstractModelNG::SetKeyboardShortcut(frameNode, "", std::vector<OHOS::Ace::ModifierKey>(), nullptr);
4048 }
4049 
SetPointLightPosition(ArkUINodeHandle node,const struct ArkUISizeType * positionX,const struct ArkUISizeType * positionY,const struct ArkUISizeType * positionZ)4050 void SetPointLightPosition(ArkUINodeHandle node, const struct ArkUISizeType* positionX,
4051     const struct ArkUISizeType* positionY, const struct ArkUISizeType* positionZ)
4052 {
4053 #ifdef POINT_LIGHT_ENABLE
4054     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4055     CHECK_NULL_VOID(frameNode);
4056     CHECK_NULL_VOID(positionX);
4057     CHECK_NULL_VOID(positionY);
4058     CHECK_NULL_VOID(positionZ);
4059     CalcDimension lightPositionX(positionX->value, static_cast<DimensionUnit>(positionX->unit));
4060     CalcDimension lightPositionY(positionY->value, static_cast<DimensionUnit>(positionY->unit));
4061     CalcDimension lightPositionZ(positionZ->value, static_cast<DimensionUnit>(positionZ->unit));
4062     ViewAbstract::SetLightPosition(frameNode, lightPositionX, lightPositionY, lightPositionZ);
4063 #endif
4064 }
4065 
ResetPointLightPosition(ArkUINodeHandle node)4066 void ResetPointLightPosition(ArkUINodeHandle node)
4067 {
4068 #ifdef POINT_LIGHT_ENABLE
4069     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4070     CHECK_NULL_VOID(frameNode);
4071     CalcDimension lightPositionX(0.0f, DimensionUnit::VP);
4072     CalcDimension lightPositionY(0.0f, DimensionUnit::VP);
4073     CalcDimension lightPositionZ(0.0f, DimensionUnit::VP);
4074     ViewAbstract::SetLightPosition(frameNode, lightPositionX, lightPositionY, lightPositionZ);
4075 #endif
4076 }
4077 
SetPointLightIntensity(ArkUINodeHandle node,ArkUI_Float32 intensity)4078 void SetPointLightIntensity(ArkUINodeHandle node, ArkUI_Float32 intensity)
4079 {
4080 #ifdef POINT_LIGHT_ENABLE
4081     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4082     CHECK_NULL_VOID(frameNode);
4083     ViewAbstract::SetLightIntensity(frameNode, static_cast<float>(intensity));
4084 #endif
4085 }
4086 
ResetPointLightIntensity(ArkUINodeHandle node)4087 void ResetPointLightIntensity(ArkUINodeHandle node)
4088 {
4089 #ifdef POINT_LIGHT_ENABLE
4090     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4091     CHECK_NULL_VOID(frameNode);
4092     ViewAbstract::SetLightIntensity(frameNode, 0.0f);
4093 #endif
4094 }
4095 
SetPointLightColor(ArkUINodeHandle node,ArkUI_Uint32 color)4096 void SetPointLightColor(ArkUINodeHandle node, ArkUI_Uint32 color)
4097 {
4098 #ifdef POINT_LIGHT_ENABLE
4099     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4100     CHECK_NULL_VOID(frameNode);
4101     Color colorValue(color);
4102     ViewAbstract::SetLightColor(frameNode, colorValue);
4103 #endif
4104 }
4105 
ResetPointLightColor(ArkUINodeHandle node)4106 void ResetPointLightColor(ArkUINodeHandle node)
4107 {
4108 #ifdef POINT_LIGHT_ENABLE
4109     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4110     CHECK_NULL_VOID(frameNode);
4111     ViewAbstract::SetLightColor(frameNode, Color::WHITE);
4112 #endif
4113 }
4114 
SetPointLightIlluminated(ArkUINodeHandle node,ArkUI_Uint32 illuminated,const struct ArkUISizeType * illuminatedBorderWidth)4115 void SetPointLightIlluminated(
4116     ArkUINodeHandle node, ArkUI_Uint32 illuminated, const struct ArkUISizeType* illuminatedBorderWidth)
4117 {
4118 #ifdef POINT_LIGHT_ENABLE
4119     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4120     CHECK_NULL_VOID(frameNode);
4121     ViewAbstract::SetLightIlluminated(frameNode, static_cast<uint32_t>(illuminated));
4122     Dimension borderWidthValue(illuminatedBorderWidth->value, static_cast<DimensionUnit>(illuminatedBorderWidth->unit));
4123     ViewAbstract::SetIlluminatedBorderWidth(frameNode, borderWidthValue);
4124 #endif
4125 }
4126 
ResetPointLightIlluminated(ArkUINodeHandle node)4127 void ResetPointLightIlluminated(ArkUINodeHandle node)
4128 {
4129 #ifdef POINT_LIGHT_ENABLE
4130     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4131     CHECK_NULL_VOID(frameNode);
4132     ViewAbstract::SetLightIlluminated(frameNode, 0);
4133     Dimension borderWidthValue(0.0f, DimensionUnit::VP);
4134     ViewAbstract::SetIlluminatedBorderWidth(frameNode, borderWidthValue);
4135 #endif
4136 }
4137 
SetPointLightBloom(ArkUINodeHandle node,ArkUI_Float32 bloom,ArkUI_Float32 bloomRadius,ArkUI_Uint32 bloomColor)4138 void SetPointLightBloom(ArkUINodeHandle node, ArkUI_Float32 bloom, ArkUI_Float32 bloomRadius, ArkUI_Uint32 bloomColor)
4139 {
4140 #ifdef POINT_LIGHT_ENABLE
4141     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4142     CHECK_NULL_VOID(frameNode);
4143     ViewAbstract::SetBloom(frameNode, static_cast<float>(bloom));
4144     Shadow shadow;
4145     shadow.SetBlurRadius(bloom * static_cast<float>(bloomRadius));
4146     Color bloomColorValue(bloomColor);
4147     shadow.SetColor(bloomColorValue);
4148     ViewAbstract::SetBackShadow(frameNode, shadow);
4149 #endif
4150 }
4151 
ResetPointLightBloom(ArkUINodeHandle node)4152 void ResetPointLightBloom(ArkUINodeHandle node)
4153 {
4154 #ifdef POINT_LIGHT_ENABLE
4155     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4156     CHECK_NULL_VOID(frameNode);
4157     ViewAbstract::SetBloom(frameNode, 0.0f);
4158     Shadow shadow;
4159     shadow.SetBlurRadius(0);
4160     ViewAbstract::SetBackShadow(frameNode, shadow);
4161 #endif
4162 }
4163 
SetClip(ArkUINodeHandle node,ArkUI_Int32 isClip)4164 void SetClip(ArkUINodeHandle node, ArkUI_Int32 isClip)
4165 {
4166     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4167     CHECK_NULL_VOID(frameNode);
4168     ViewAbstract::SetClipEdge(frameNode, static_cast<bool>(isClip));
4169 }
4170 
SetClipShape(ArkUINodeHandle node,ArkUI_CharPtr type,const ArkUI_Float32 * attribute,ArkUI_Int32 length,ArkUI_Int32 unit)4171 void SetClipShape(
4172     ArkUINodeHandle node, ArkUI_CharPtr type, const ArkUI_Float32* attribute, ArkUI_Int32 length, ArkUI_Int32 unit)
4173 {
4174     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4175     CHECK_NULL_VOID(frameNode);
4176     if (std::strcmp(type, "rect") == 0) {
4177         auto shape = AceType::MakeRefPtr<ShapeRect>();
4178         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4179         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4180         auto radiusWidth = Dimension(attribute[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(unit));
4181         auto radiusHeight = Dimension(attribute[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(unit));
4182         shape->SetWidth(width);
4183         shape->SetHeight(height);
4184         shape->SetRadiusWidth(radiusWidth);
4185         shape->SetRadiusHeight(radiusHeight);
4186         if (length > NUM_4) {
4187             auto topLeftRadius = length > NUM_4
4188                                      ? Dimension(attribute[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(unit))
4189                                      : Dimension(0);
4190             auto bottomLeftRadius = length > NUM_5
4191                                         ? Dimension(attribute[NUM_5], static_cast<OHOS::Ace::DimensionUnit>(unit))
4192                                         : Dimension(0);
4193             auto topRightRadius = length > NUM_6
4194                                       ? Dimension(attribute[NUM_6], static_cast<OHOS::Ace::DimensionUnit>(unit))
4195                                       : Dimension(0);
4196             auto bottomRightRadius = length > NUM_7
4197                                          ? Dimension(attribute[NUM_7], static_cast<OHOS::Ace::DimensionUnit>(unit))
4198                                          : Dimension(0);
4199             shape->SetTopLeftRadius(Radius(topLeftRadius));
4200             shape->SetBottomLeftRadius(Radius(bottomLeftRadius));
4201             shape->SetTopRightRadius(Radius(topRightRadius));
4202             shape->SetBottomRightRadius(Radius(bottomRightRadius));
4203         }
4204         ViewAbstract::SetClipShape(frameNode, shape);
4205     }
4206     if (std::strcmp(type, "circle") == 0) {
4207         auto shape = AceType::MakeRefPtr<Circle>();
4208         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4209         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4210         shape->SetWidth(width);
4211         shape->SetHeight(height);
4212         ViewAbstract::SetClipShape(frameNode, shape);
4213     }
4214     if (std::strcmp(type, "ellipse") == 0) {
4215         auto shape = AceType::MakeRefPtr<Ellipse>();
4216         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4217         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4218         shape->SetWidth(width);
4219         shape->SetHeight(height);
4220         ViewAbstract::SetClipShape(frameNode, shape);
4221     }
4222 }
4223 
SetClipPath(ArkUINodeHandle node,ArkUI_CharPtr type,const ArkUI_Float32 (* attribute)[2],ArkUI_CharPtr commands,ArkUI_Int32 unit)4224 void SetClipPath(ArkUINodeHandle node, ArkUI_CharPtr type, const ArkUI_Float32 (*attribute)[2], ArkUI_CharPtr commands,
4225     ArkUI_Int32 unit)
4226 {
4227     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4228     CHECK_NULL_VOID(frameNode);
4229     auto path = AceType::MakeRefPtr<Path>();
4230     auto width = Dimension((*attribute)[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4231     auto height = Dimension((*attribute)[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4232     std::string pathCommands(commands);
4233     path->SetWidth(width);
4234     path->SetHeight(height);
4235     path->SetValue(StringUtils::TrimStr(pathCommands));
4236     ViewAbstract::SetClipShape(frameNode, path);
4237 }
4238 
ResetClip(ArkUINodeHandle node)4239 void ResetClip(ArkUINodeHandle node)
4240 {
4241     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4242     CHECK_NULL_VOID(frameNode);
4243     ViewAbstract::SetClipEdge(frameNode, false);
4244 }
4245 
SetAnimationOption(std::shared_ptr<AnimationOption> & option,const ArkUIAnimationOptionType * animationOption)4246 void SetAnimationOption(std::shared_ptr<AnimationOption>& option, const ArkUIAnimationOptionType* animationOption)
4247 {
4248     option->SetDuration(animationOption->duration);
4249     option->SetCurve(CURVES[std::clamp(animationOption->curve, 0, static_cast<int32_t>(CURVES.size() - 1))]);
4250     option->SetDelay(animationOption->delay);
4251     option->SetIteration(animationOption->iteration);
4252     option->SetAnimationDirection(static_cast<AnimationDirection>(animationOption->playMode));
4253     option->SetTempo(animationOption->tempo);
4254 }
4255 
SetTransitionCenter(ArkUINodeHandle node,ArkUI_Float32 centerXValue,ArkUI_Int32 centerXUnit,ArkUI_Float32 centerYValue,int32_t centerYUnit,ArkUI_Float32 centerZValue,ArkUI_Int32 centerZUnit)4256 void SetTransitionCenter(ArkUINodeHandle node, ArkUI_Float32 centerXValue, ArkUI_Int32 centerXUnit,
4257     ArkUI_Float32 centerYValue, int32_t centerYUnit, ArkUI_Float32 centerZValue, ArkUI_Int32 centerZUnit)
4258 {
4259     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4260     CHECK_NULL_VOID(frameNode);
4261     Dimension centerXDimension(centerXValue, static_cast<DimensionUnit>(centerXUnit));
4262     Dimension centerYDimension(centerYValue, static_cast<DimensionUnit>(centerYUnit));
4263     Dimension centerZDimension(centerZValue, static_cast<DimensionUnit>(centerZUnit));
4264     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4265     auto renderContext = frameNode->GetRenderContext();
4266     if (renderContext) {
4267         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4268     }
4269     if (!oneCenterTransition) {
4270         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4271     }
4272     oneCenterTransition->SetCenterX(centerXDimension);
4273     oneCenterTransition->SetCenterY(centerYDimension);
4274     oneCenterTransition->SetCenterZ(centerZDimension);
4275     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4276     while (chainEffect) {
4277         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4278             auto rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4279             NG::RotateOptions rotate(rotateEffect->GetEffect().xDirection, rotateEffect->GetEffect().yDirection,
4280                 rotateEffect->GetEffect().zDirection, rotateEffect->GetEffect().angle,
4281                 oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY(), oneCenterTransition->GetCenterZ(),
4282                 rotateEffect->GetEffect().perspective);
4283             rotateEffect->SetRotateEffect(rotate);
4284         } else if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4285             auto scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4286             NG::ScaleOptions scale(scaleEffect->GetEffect().xScale, scaleEffect->GetEffect().yScale,
4287                 scaleEffect->GetEffect().zScale, oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY());
4288             scaleEffect->SetScaleEffect(scale);
4289         }
4290         chainEffect = chainEffect->GetNext();
4291     }
4292     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4293     chainEffect = oneCenterTransition->GetTransitionEffect();
4294     if (chainEffect) {
4295         ViewAbstract::SetChainedTransition(frameNode, chainEffect);
4296     }
4297     DimensionOffset offset(centerXDimension, centerYDimension);
4298     offset.SetZ(centerZDimension);
4299     ViewAbstract::SetPivot(frameNode, offset);
4300 }
4301 
GetTransformCenter(ArkUINodeHandle node)4302 ArkUITransformCenterType GetTransformCenter(ArkUINodeHandle node)
4303 {
4304     ArkUITransformCenterType transformCenter = { 0.0f, 0.0f, 0.0f };
4305     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4306     CHECK_NULL_RETURN(frameNode, transformCenter);
4307     CHECK_NULL_RETURN(frameNode->GetGeometryNode(), transformCenter);
4308     auto renderContext = frameNode->GetRenderContext();
4309     CHECK_NULL_RETURN(renderContext, transformCenter);
4310     auto oneCenterTransform = renderContext->GetOneCenterTransitionOption();
4311     auto width = frameNode->GetGeometryNode() ? frameNode->GetGeometryNode()->GetFrameSize().Width() : 0.0f;
4312     auto height = frameNode->GetGeometryNode() ? frameNode->GetGeometryNode()->GetFrameSize().Height() : 0.0f;
4313     Dimension centerXDimension(HALF, DimensionUnit::PERCENT);
4314     Dimension centerYDimension(HALF, DimensionUnit::PERCENT);
4315     Dimension centerZDimension(0, DimensionUnit::VP);
4316     if (renderContext && oneCenterTransform) {
4317         centerXDimension.SetValue(oneCenterTransform->GetCenterX().Value());
4318         centerXDimension.SetUnit(oneCenterTransform->GetCenterX().Unit());
4319         centerYDimension.SetValue(oneCenterTransform->GetCenterY().Value());
4320         centerYDimension.SetUnit(oneCenterTransform->GetCenterY().Unit());
4321         centerZDimension.SetValue(oneCenterTransform->GetCenterZ().Value());
4322         centerZDimension.SetUnit(oneCenterTransform->GetCenterZ().Unit());
4323     }
4324     if (centerXDimension.Unit() == DimensionUnit::PERCENT) {
4325         Dimension centerXPx(width * centerXDimension.Value(), DimensionUnit::PX);
4326         centerXDimension.SetValue(centerXPx.ConvertToVp());
4327         centerXDimension.SetUnit(DimensionUnit::VP);
4328     }
4329     if (centerYDimension.Unit() == DimensionUnit::PERCENT) {
4330         Dimension centerYPx(height * centerYDimension.Value(), DimensionUnit::PX);
4331         centerYDimension.SetValue(centerYPx.ConvertToVp());
4332         centerYDimension.SetUnit(DimensionUnit::VP);
4333     }
4334     if (centerZDimension.Unit() == DimensionUnit::PERCENT) {
4335         centerZDimension.SetValue(0.0f);
4336         centerZDimension.SetUnit(DimensionUnit::VP);
4337     }
4338     transformCenter.centerX = centerXDimension.Value();
4339     transformCenter.centerY = centerYDimension.Value();
4340     transformCenter.centerZ = centerZDimension.Value();
4341     return transformCenter;
4342 }
4343 
ResetTransformCenter(RefPtr<OneCenterTransitionOptionType> & oneCenterTransition)4344 void ResetTransformCenter(RefPtr<OneCenterTransitionOptionType>& oneCenterTransition)
4345 {
4346     Dimension centerXDimension(HALF, DimensionUnit::PERCENT);
4347     Dimension centerYDimension(HALF, DimensionUnit::PERCENT);
4348     Dimension centerZDimension(0, DimensionUnit::VP);
4349     oneCenterTransition->SetCenterX(centerXDimension);
4350     oneCenterTransition->SetCenterY(centerYDimension);
4351     oneCenterTransition->SetCenterZ(centerZDimension);
4352 }
4353 
SetOpacityTransition(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUIAnimationOptionType * animationOption)4354 void SetOpacityTransition(ArkUINodeHandle node, ArkUI_Float32 value, const ArkUIAnimationOptionType* animationOption)
4355 {
4356     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4357     CHECK_NULL_VOID(frameNode);
4358     double opacity = value;
4359     if (opacity > 1.0 || LessNotEqual(opacity, 0.0)) {
4360         opacity = 1.0;
4361     }
4362     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4363     auto renderContext = frameNode->GetRenderContext();
4364     if (renderContext) {
4365         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4366     }
4367     if (!oneCenterTransition) {
4368         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4369         ResetTransformCenter(oneCenterTransition);
4370     }
4371     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4372     RefPtr<NG::ChainedOpacityEffect> opacityEffect;
4373     while (chainEffect) {
4374         if (chainEffect->GetType() == ChainedTransitionEffectType::OPACITY) {
4375             opacityEffect = AceType::DynamicCast<NG::ChainedOpacityEffect>(chainEffect);
4376             break;
4377         }
4378         chainEffect = chainEffect->GetNext();
4379     }
4380     auto option = std::make_shared<AnimationOption>();
4381     SetAnimationOption(option, animationOption);
4382     if (!opacityEffect) {
4383         opacityEffect = AceType::MakeRefPtr<NG::ChainedOpacityEffect>(opacity);
4384         opacityEffect->SetAnimationOption(option);
4385         opacityEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4386         oneCenterTransition->SetTransitionEffect(opacityEffect);
4387     } else {
4388         opacityEffect->SetOpacity(opacity);
4389         opacityEffect->SetAnimationOption(option);
4390     }
4391     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4392     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4393 }
4394 
findCurveIndex(const RefPtr<Curve> curve)4395 int32_t findCurveIndex(const RefPtr<Curve> curve)
4396 {
4397     CHECK_NULL_RETURN(curve, 0);
4398     auto iterator = std::find(CURVES.begin(), CURVES.end(), curve);
4399     if (iterator == CURVES.end()) {
4400         return 0;
4401     }
4402     return iterator - CURVES.begin();
4403 }
4404 
ParseAnimationOptionToStruct(const std::shared_ptr<AnimationOption> animationOption,ArkUIAnimationOptionType & animationType)4405 void ParseAnimationOptionToStruct(
4406     const std::shared_ptr<AnimationOption> animationOption, ArkUIAnimationOptionType& animationType)
4407 {
4408     CHECK_NULL_VOID(animationOption);
4409     animationType.duration = animationOption->GetDuration();
4410     animationType.curve = findCurveIndex(animationOption->GetCurve());
4411     animationType.delay = animationOption->GetDelay();
4412     animationType.iteration = animationOption->GetIteration();
4413     animationType.playMode = static_cast<int32_t>(animationOption->GetAnimationDirection());
4414     animationType.tempo = animationOption->GetTempo();
4415 }
4416 
GetOpacityTransition(ArkUINodeHandle node)4417 ArkUIOpacityTransitionType GetOpacityTransition(ArkUINodeHandle node)
4418 {
4419     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4420     ArkUIOpacityTransitionType opacityAnimationStruct = { 1.0f, animationType };
4421     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4422     CHECK_NULL_RETURN(frameNode, opacityAnimationStruct);
4423     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4424     auto renderContext = frameNode->GetRenderContext();
4425     if (renderContext) {
4426         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4427     }
4428     CHECK_NULL_RETURN(oneCenterTransition, opacityAnimationStruct);
4429     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4430     RefPtr<NG::ChainedOpacityEffect> opacityEffect;
4431     while (chainEffect) {
4432         if (chainEffect->GetType() == ChainedTransitionEffectType::OPACITY) {
4433             opacityEffect = AceType::DynamicCast<NG::ChainedOpacityEffect>(chainEffect);
4434             break;
4435         }
4436         chainEffect = chainEffect->GetNext();
4437     }
4438     CHECK_NULL_RETURN(opacityEffect, opacityAnimationStruct);
4439     opacityAnimationStruct.opacity = opacityEffect->GetEffect();
4440     ParseAnimationOptionToStruct(opacityEffect->GetAnimationOption(), opacityAnimationStruct.animation);
4441     return opacityAnimationStruct;
4442 }
4443 
SetRotateTransition(ArkUINodeHandle node,ArkUI_Float32 * arrayValue,ArkUI_Int32 length,ArkUI_Float32 perspective,ArkUI_Float32 angle,const ArkUIAnimationOptionType * animationOption)4444 void SetRotateTransition(ArkUINodeHandle node, ArkUI_Float32* arrayValue, ArkUI_Int32 length, ArkUI_Float32 perspective,
4445     ArkUI_Float32 angle, const ArkUIAnimationOptionType* animationOption)
4446 {
4447     CHECK_NULL_VOID(arrayValue);
4448     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4449     CHECK_NULL_VOID(frameNode);
4450     if (length < ARRAY_SIZE) {
4451         return;
4452     }
4453     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4454     auto renderContext = frameNode->GetRenderContext();
4455     if (renderContext) {
4456         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4457     }
4458     if (!oneCenterTransition) {
4459         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4460         ResetTransformCenter(oneCenterTransition);
4461     }
4462     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4463     RefPtr<NG::ChainedRotateEffect> rotateEffect;
4464     while (chainEffect) {
4465         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4466             rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4467             break;
4468         }
4469         chainEffect = chainEffect->GetNext();
4470     }
4471     auto option = std::make_shared<AnimationOption>();
4472     SetAnimationOption(option, animationOption);
4473     NG::RotateOptions rotate(arrayValue[X_INDEX], arrayValue[Y_INDEX], arrayValue[Z_INDEX], angle,
4474         oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY(), oneCenterTransition->GetCenterZ(),
4475         perspective);
4476     if (!rotateEffect) {
4477         rotateEffect = AceType::MakeRefPtr<NG::ChainedRotateEffect>(rotate);
4478         rotateEffect->SetAnimationOption(option);
4479         rotateEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4480         oneCenterTransition->SetTransitionEffect(rotateEffect);
4481     } else {
4482         rotateEffect->SetRotateEffect(rotate);
4483         rotateEffect->SetAnimationOption(option);
4484     }
4485     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4486     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4487 }
4488 
GetRotateTransition(ArkUINodeHandle node)4489 ArkUIRotateTransitionType GetRotateTransition(ArkUINodeHandle node)
4490 {
4491     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4492     ArkUIRotateTransitionType rotateAnimationStruct = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, animationType };
4493     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4494     CHECK_NULL_RETURN(frameNode, rotateAnimationStruct);
4495     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4496     auto renderContext = frameNode->GetRenderContext();
4497     if (renderContext) {
4498         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4499     }
4500     CHECK_NULL_RETURN(oneCenterTransition, rotateAnimationStruct);
4501     RefPtr<NG::ChainedRotateEffect> rotateEffect;
4502     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4503     while (chainEffect) {
4504         if (chainEffect->GetType() == ChainedTransitionEffectType::ROTATE) {
4505             rotateEffect = AceType::DynamicCast<NG::ChainedRotateEffect>(chainEffect);
4506             break;
4507         }
4508         chainEffect = chainEffect->GetNext();
4509     }
4510     CHECK_NULL_RETURN(rotateEffect, rotateAnimationStruct);
4511     auto xRotation = rotateEffect->GetEffect().xDirection;
4512     auto yRotation = rotateEffect->GetEffect().yDirection;
4513     auto zRotation = rotateEffect->GetEffect().zDirection;
4514     auto angle = rotateEffect->GetEffect().angle;
4515     auto perspective = rotateEffect->GetEffect().perspective;
4516     rotateAnimationStruct.xRotation = xRotation;
4517     rotateAnimationStruct.yRotation = yRotation;
4518     rotateAnimationStruct.zRotation = zRotation;
4519     rotateAnimationStruct.angle = angle;
4520     rotateAnimationStruct.perspective = perspective;
4521     ParseAnimationOptionToStruct(rotateEffect->GetAnimationOption(), rotateAnimationStruct.animation);
4522     return rotateAnimationStruct;
4523 }
4524 
SetScaleTransition(ArkUINodeHandle node,ArkUI_Float32 * arrayValue,ArkUI_Int32 length,const ArkUIAnimationOptionType * animationOption)4525 void SetScaleTransition(ArkUINodeHandle node, ArkUI_Float32* arrayValue, ArkUI_Int32 length,
4526     const ArkUIAnimationOptionType* animationOption)
4527 {
4528     CHECK_NULL_VOID(arrayValue);
4529     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4530     CHECK_NULL_VOID(frameNode);
4531     if (length < ARRAY_SIZE) {
4532         return;
4533     }
4534     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4535     auto renderContext = frameNode->GetRenderContext();
4536     if (renderContext) {
4537         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4538     }
4539     if (!oneCenterTransition) {
4540         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4541         ResetTransformCenter(oneCenterTransition);
4542     }
4543     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4544     RefPtr<NG::ChainedScaleEffect> scaleEffect;
4545     while (chainEffect) {
4546         if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4547             scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4548             break;
4549         }
4550         chainEffect = chainEffect->GetNext();
4551     }
4552     auto option = std::make_shared<AnimationOption>();
4553     SetAnimationOption(option, animationOption);
4554     NG::ScaleOptions scale(arrayValue[X_INDEX], arrayValue[Y_INDEX], arrayValue[Z_INDEX],
4555         oneCenterTransition->GetCenterX(), oneCenterTransition->GetCenterY());
4556     if (!scaleEffect) {
4557         scaleEffect = AceType::MakeRefPtr<NG::ChainedScaleEffect>(scale);
4558         scaleEffect->SetAnimationOption(option);
4559         scaleEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4560         oneCenterTransition->SetTransitionEffect(scaleEffect);
4561     } else {
4562         scaleEffect->SetScaleEffect(scale);
4563         scaleEffect->SetAnimationOption(option);
4564     }
4565     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4566     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4567 }
4568 
GetScaleTransition(ArkUINodeHandle node)4569 ArkUIScaleTransitionType GetScaleTransition(ArkUINodeHandle node)
4570 {
4571     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4572     ArkUIScaleTransitionType scaleAnimationStruct = { 1.0f, 1.0f, 1.0f, animationType };
4573     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4574     CHECK_NULL_RETURN(frameNode, scaleAnimationStruct);
4575     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4576     auto renderContext = frameNode->GetRenderContext();
4577     if (renderContext) {
4578         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4579     }
4580     CHECK_NULL_RETURN(oneCenterTransition, scaleAnimationStruct);
4581     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4582     RefPtr<NG::ChainedScaleEffect> scaleEffect;
4583     while (chainEffect) {
4584         if (chainEffect->GetType() == ChainedTransitionEffectType::SCALE) {
4585             scaleEffect = AceType::DynamicCast<NG::ChainedScaleEffect>(chainEffect);
4586             break;
4587         }
4588         chainEffect = chainEffect->GetNext();
4589     }
4590     CHECK_NULL_RETURN(scaleEffect, scaleAnimationStruct);
4591     auto xScale = scaleEffect->GetEffect().xScale;
4592     auto yScale = scaleEffect->GetEffect().yScale;
4593     auto zScale = scaleEffect->GetEffect().zScale;
4594     scaleAnimationStruct.xScale = xScale;
4595     scaleAnimationStruct.yScale = yScale;
4596     scaleAnimationStruct.zScale = zScale;
4597     ParseAnimationOptionToStruct(scaleEffect->GetAnimationOption(), scaleAnimationStruct.animation);
4598     return scaleAnimationStruct;
4599 }
4600 
SetTranslateTransition(ArkUINodeHandle node,ArkUI_Float32 xValue,ArkUI_Int32 xUnit,ArkUI_Float32 yValue,ArkUI_Int32 yUnit,ArkUI_Float32 zValue,ArkUI_Int32 zUnit,const ArkUIAnimationOptionType * animationOption)4601 void SetTranslateTransition(ArkUINodeHandle node, ArkUI_Float32 xValue, ArkUI_Int32 xUnit, ArkUI_Float32 yValue,
4602     ArkUI_Int32 yUnit, ArkUI_Float32 zValue, ArkUI_Int32 zUnit, const ArkUIAnimationOptionType* animationOption)
4603 {
4604     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4605     CHECK_NULL_VOID(frameNode);
4606     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4607     auto renderContext = frameNode->GetRenderContext();
4608     if (renderContext) {
4609         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4610     }
4611     if (!oneCenterTransition) {
4612         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4613         ResetTransformCenter(oneCenterTransition);
4614     }
4615     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4616     RefPtr<NG::ChainedTranslateEffect> translateEffect;
4617     while (chainEffect) {
4618         if (chainEffect->GetType() == ChainedTransitionEffectType::TRANSLATE) {
4619             translateEffect = AceType::DynamicCast<NG::ChainedTranslateEffect>(chainEffect);
4620             break;
4621         }
4622         chainEffect = chainEffect->GetNext();
4623     }
4624 
4625     auto option = std::make_shared<AnimationOption>();
4626     SetAnimationOption(option, animationOption);
4627     Dimension xDimension(xValue, static_cast<DimensionUnit>(xUnit));
4628     Dimension yDimension(yValue, static_cast<DimensionUnit>(yUnit));
4629     Dimension zDimension(zValue, static_cast<DimensionUnit>(zUnit));
4630     NG::TranslateOptions translate(xDimension, yDimension, zDimension);
4631     if (!translateEffect) {
4632         translateEffect = AceType::MakeRefPtr<NG::ChainedTranslateEffect>(translate);
4633         translateEffect->SetAnimationOption(option);
4634         translateEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4635         oneCenterTransition->SetTransitionEffect(translateEffect);
4636     } else {
4637         translateEffect->SetTranslateEffect(translate);
4638         translateEffect->SetAnimationOption(option);
4639     }
4640     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4641     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4642 }
4643 
GetTranslateTransition(ArkUINodeHandle node)4644 ArkUITranslateTransitionType GetTranslateTransition(ArkUINodeHandle node)
4645 {
4646     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4647     ArkUITranslateTransitionType translateAnimationStruct = { 0.0f, 0.0f, 0.0f, animationType };
4648     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4649     CHECK_NULL_RETURN(frameNode, translateAnimationStruct);
4650     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4651     auto renderContext = frameNode->GetRenderContext();
4652     if (renderContext) {
4653         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4654     }
4655     CHECK_NULL_RETURN(oneCenterTransition, translateAnimationStruct);
4656     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4657     RefPtr<NG::ChainedTranslateEffect> translateEffect;
4658     while (chainEffect) {
4659         if (chainEffect->GetType() == ChainedTransitionEffectType::TRANSLATE) {
4660             translateEffect = AceType::DynamicCast<NG::ChainedTranslateEffect>(chainEffect);
4661             break;
4662         }
4663         chainEffect = chainEffect->GetNext();
4664     }
4665     CHECK_NULL_RETURN(translateEffect, translateAnimationStruct);
4666     auto xTransition = translateEffect->GetEffect().x.Value();
4667     auto yTransition = translateEffect->GetEffect().y.Value();
4668     auto zTransition = translateEffect->GetEffect().z.Value();
4669     translateAnimationStruct.xTransition = xTransition;
4670     translateAnimationStruct.yTransition = yTransition;
4671     translateAnimationStruct.zTransition = zTransition;
4672     ParseAnimationOptionToStruct(translateEffect->GetAnimationOption(), translateAnimationStruct.animation);
4673     return translateAnimationStruct;
4674 }
4675 
SetMoveTransition(ArkUINodeHandle node,ArkUI_Int32 value,const ArkUIAnimationOptionType * animationOption)4676 void SetMoveTransition(ArkUINodeHandle node, ArkUI_Int32 value, const ArkUIAnimationOptionType* animationOption)
4677 {
4678     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4679     CHECK_NULL_VOID(frameNode);
4680     auto edgeType = static_cast<TransitionEdge>(value);
4681     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4682     auto renderContext = frameNode->GetRenderContext();
4683     if (renderContext) {
4684         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4685     }
4686     if (!oneCenterTransition) {
4687         oneCenterTransition = AceType::MakeRefPtr<OneCenterTransitionOptionType>();
4688         ResetTransformCenter(oneCenterTransition);
4689     }
4690     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4691     RefPtr<NG::ChainedMoveEffect> moveEffect;
4692     while (chainEffect) {
4693         if (chainEffect->GetType() == ChainedTransitionEffectType::MOVE) {
4694             moveEffect = AceType::DynamicCast<NG::ChainedMoveEffect>(chainEffect);
4695             break;
4696         }
4697         chainEffect = chainEffect->GetNext();
4698     }
4699     auto option = std::make_shared<AnimationOption>();
4700     SetAnimationOption(option, animationOption);
4701     if (!moveEffect) {
4702         moveEffect = AceType::MakeRefPtr<NG::ChainedMoveEffect>(edgeType);
4703         moveEffect->SetAnimationOption(option);
4704         moveEffect->SetNext(oneCenterTransition->GetTransitionEffect());
4705         oneCenterTransition->SetTransitionEffect(moveEffect);
4706     } else {
4707         moveEffect->SetAnimationOption(option);
4708     }
4709     ACE_UPDATE_NODE_RENDER_CONTEXT(OneCenterTransitionOption, oneCenterTransition, frameNode);
4710     ViewAbstract::SetChainedTransition(frameNode, oneCenterTransition->GetTransitionEffect());
4711 }
4712 
GetMoveTransition(ArkUINodeHandle node)4713 ArkUIMoveTransitionType GetMoveTransition(ArkUINodeHandle node)
4714 {
4715     ArkUIAnimationOptionType animationType = { DEFAULT_DURATION, 0, 0, 1, 0, 1.0f };
4716     ArkUIMoveTransitionType moveAnimationStruct = { 0, animationType };
4717     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4718     CHECK_NULL_RETURN(frameNode, moveAnimationStruct);
4719     RefPtr<OneCenterTransitionOptionType> oneCenterTransition;
4720     auto renderContext = frameNode->GetRenderContext();
4721     if (renderContext) {
4722         oneCenterTransition = renderContext->GetOneCenterTransitionOption();
4723     }
4724     CHECK_NULL_RETURN(oneCenterTransition, moveAnimationStruct);
4725     RefPtr<NG::ChainedTransitionEffect> chainEffect = oneCenterTransition->GetTransitionEffect();
4726     RefPtr<NG::ChainedMoveEffect> moveEffect;
4727     while (chainEffect) {
4728         if (chainEffect->GetType() == ChainedTransitionEffectType::MOVE) {
4729             moveEffect = AceType::DynamicCast<NG::ChainedMoveEffect>(chainEffect);
4730             break;
4731         }
4732         chainEffect = chainEffect->GetNext();
4733     }
4734     CHECK_NULL_RETURN(moveEffect, moveAnimationStruct);
4735     moveAnimationStruct.edgeType = static_cast<ArkUI_Int32>(moveEffect->GetEffect());
4736     ParseAnimationOptionToStruct(moveEffect->GetAnimationOption(), moveAnimationStruct.animation);
4737     return moveAnimationStruct;
4738 }
4739 
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)4740 void SetMaskShape(ArkUINodeHandle node, ArkUI_CharPtr type, ArkUI_Uint32 fill, ArkUI_Uint32 stroke,
4741     ArkUI_Float32 strokeWidth, const ArkUI_Float32* attribute, ArkUI_Int32 length, ArkUI_Int32 unit)
4742 {
4743     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4744     CHECK_NULL_VOID(frameNode);
4745     std::string shapeType(type);
4746     auto strokeWidth_ = Dimension(strokeWidth, static_cast<OHOS::Ace::DimensionUnit>(unit));
4747     if (shapeType == "rect") {
4748         auto shape = AceType::MakeRefPtr<ShapeRect>();
4749         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4750         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4751         auto radiusWidth = Dimension(attribute[NUM_2], static_cast<OHOS::Ace::DimensionUnit>(unit));
4752         auto radiusHeight = Dimension(attribute[NUM_3], static_cast<OHOS::Ace::DimensionUnit>(unit));
4753         shape->SetWidth(width);
4754         shape->SetHeight(height);
4755         shape->SetRadiusWidth(radiusWidth);
4756         shape->SetRadiusHeight(radiusHeight);
4757         shape->SetColor(Color(fill));
4758         shape->SetStrokeColor(stroke);
4759         shape->SetStrokeWidth(strokeWidth);
4760         if (length > NUM_4) {
4761             auto topLeftRadius = length > NUM_4
4762                                      ? Dimension(attribute[NUM_4], static_cast<OHOS::Ace::DimensionUnit>(unit))
4763                                      : Dimension(0);
4764             auto bottomLeftRadius = length > NUM_5
4765                                         ? Dimension(attribute[NUM_5], static_cast<OHOS::Ace::DimensionUnit>(unit))
4766                                         : Dimension(0);
4767             auto topRightRadius = length > NUM_6
4768                                       ? Dimension(attribute[NUM_6], static_cast<OHOS::Ace::DimensionUnit>(unit))
4769                                       : Dimension(0);
4770             auto bottomRightRadius = length > NUM_7
4771                                          ? Dimension(attribute[NUM_7], static_cast<OHOS::Ace::DimensionUnit>(unit))
4772                                          : Dimension(0);
4773             shape->SetTopLeftRadius(Radius(topLeftRadius));
4774             shape->SetBottomLeftRadius(Radius(bottomLeftRadius));
4775             shape->SetTopRightRadius(Radius(topRightRadius));
4776             shape->SetBottomRightRadius(Radius(bottomRightRadius));
4777         }
4778         ViewAbstract::SetMask(frameNode, shape);
4779     } else if (shapeType == "circle") {
4780         auto shape = AceType::MakeRefPtr<Circle>();
4781         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(1));
4782         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(1));
4783         shape->SetWidth(width);
4784         shape->SetHeight(height);
4785         shape->SetColor(Color(fill));
4786         shape->SetStrokeColor(stroke);
4787         shape->SetStrokeWidth(strokeWidth);
4788         ViewAbstract::SetMask(frameNode, shape);
4789     } else if (shapeType == "ellipse") {
4790         auto shape = AceType::MakeRefPtr<Ellipse>();
4791         auto width = Dimension(attribute[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(1));
4792         auto height = Dimension(attribute[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(1));
4793         shape->SetWidth(width);
4794         shape->SetHeight(height);
4795         shape->SetColor(Color(fill));
4796         shape->SetStrokeColor(stroke);
4797         shape->SetStrokeWidth(strokeWidth);
4798         ViewAbstract::SetMask(frameNode, shape);
4799     } else {
4800         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "type are invalid");
4801         return;
4802     }
4803 }
4804 
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)4805 void SetMaskPath(ArkUINodeHandle node, ArkUI_CharPtr type, ArkUI_Uint32 fill, ArkUI_Uint32 stroke,
4806     ArkUI_Float32 strokeWidth, const ArkUI_Float32 (*attribute)[2], ArkUI_CharPtr commands, ArkUI_Int32 unit)
4807 {
4808     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4809     auto strokeWidth_ = Dimension(strokeWidth, static_cast<OHOS::Ace::DimensionUnit>(unit));
4810     CHECK_NULL_VOID(frameNode);
4811     auto path = AceType::MakeRefPtr<Path>();
4812     auto width = Dimension((*attribute)[NUM_0], static_cast<OHOS::Ace::DimensionUnit>(unit));
4813     auto height = Dimension((*attribute)[NUM_1], static_cast<OHOS::Ace::DimensionUnit>(unit));
4814     std::string pathCommands(commands);
4815     path->SetWidth(width);
4816     path->SetHeight(height);
4817     path->SetValue(StringUtils::TrimStr(pathCommands));
4818     path->SetColor(Color(fill));
4819     path->SetStrokeColor(stroke);
4820     path->SetStrokeWidth(strokeWidth);
4821     ViewAbstract::SetMask(frameNode, path);
4822 }
4823 
SetProgressMask(ArkUINodeHandle node,const ArkUI_Float32 * attribute,ArkUI_Uint32 color)4824 void SetProgressMask(ArkUINodeHandle node, const ArkUI_Float32* attribute, ArkUI_Uint32 color)
4825 {
4826     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4827     CHECK_NULL_VOID(frameNode);
4828     auto progressMask = AceType::MakeRefPtr<NG::ProgressMaskProperty>();
4829     int value = attribute[NUM_0];
4830     int total = attribute[NUM_1];
4831     progressMask->SetValue(value);
4832     progressMask->SetMaxValue(total);
4833     progressMask->SetColor(Color(color));
4834     ViewAbstract::SetProgressMask(frameNode, progressMask);
4835 }
4836 
ResetMask(ArkUINodeHandle node)4837 void ResetMask(ArkUINodeHandle node)
4838 {
4839     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4840     CHECK_NULL_VOID(frameNode);
4841     ViewAbstract::SetMask(frameNode, nullptr);
4842 }
4843 
SetOutlineColor(ArkUINodeHandle node,const uint32_t * values,int32_t valuesSize)4844 void SetOutlineColor(ArkUINodeHandle node, const uint32_t* values, int32_t valuesSize)
4845 {
4846     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4847     CHECK_NULL_VOID(frameNode);
4848     int32_t colorOffset = NUM_0;
4849     NG::BorderColorProperty borderColors;
4850     SetOptionalBorderColor(borderColors.topColor, values, valuesSize, colorOffset);
4851     SetOptionalBorderColor(borderColors.rightColor, values, valuesSize, colorOffset);
4852     SetOptionalBorderColor(borderColors.bottomColor, values, valuesSize, colorOffset);
4853     SetOptionalBorderColor(borderColors.leftColor, values, valuesSize, colorOffset);
4854     borderColors.multiValued = true;
4855     ViewAbstract::SetOuterBorderColor(frameNode, borderColors);
4856 }
4857 
ResetOutlineColor(ArkUINodeHandle node)4858 void ResetOutlineColor(ArkUINodeHandle node)
4859 {
4860     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4861     CHECK_NULL_VOID(frameNode);
4862     ViewAbstract::SetOuterBorderColor(frameNode, Color::BLACK);
4863 }
4864 
GetOutlineColor(ArkUINodeHandle node,ArkUI_Uint32 (* values)[4])4865 void GetOutlineColor(ArkUINodeHandle node, ArkUI_Uint32 (*values)[4])
4866 {
4867     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4868     CHECK_NULL_VOID(frameNode);
4869     auto colors = ViewAbstract::GetOuterBorderColor(frameNode);
4870     (*values)[NUM_0] = colors.topColor->GetValue();
4871     (*values)[NUM_1] = colors.rightColor->GetValue();
4872     (*values)[NUM_2] = colors.bottomColor->GetValue();
4873     (*values)[NUM_3] = colors.leftColor->GetValue();
4874 }
4875 
GetSize(ArkUINodeHandle node,ArkUI_Float32 (* values)[2],ArkUI_Int32 unit)4876 void GetSize(ArkUINodeHandle node, ArkUI_Float32 (*values)[2], ArkUI_Int32 unit)
4877 {
4878     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4879     CHECK_NULL_VOID(frameNode);
4880     (*values)[NUM_0] = ViewAbstract::GetWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
4881     (*values)[NUM_1] = ViewAbstract::GetHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
4882 }
4883 
GetRenderGroup(ArkUINodeHandle node)4884 ArkUI_Bool GetRenderGroup(ArkUINodeHandle node)
4885 {
4886     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4887     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
4888     return static_cast<ArkUI_Bool>(ViewAbstract::GetRenderGroup(frameNode));
4889 }
4890 
SetOutlineRadius(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize)4891 void SetOutlineRadius(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize)
4892 {
4893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4894     CHECK_NULL_VOID(frameNode);
4895     int32_t radiusOffset = NUM_0;
4896 
4897     NG::BorderRadiusProperty borderRadius;
4898     SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, radiusOffset);
4899     SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, radiusOffset);
4900     SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, radiusOffset);
4901     SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, radiusOffset);
4902     borderRadius.multiValued = true;
4903     ViewAbstract::SetOuterBorderRadius(frameNode, borderRadius);
4904 }
4905 
ResetOutlineRadius(ArkUINodeHandle node)4906 void ResetOutlineRadius(ArkUINodeHandle node)
4907 {
4908     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4909     CHECK_NULL_VOID(frameNode);
4910     Dimension value;
4911     ViewAbstract::SetOuterBorderRadius(frameNode, value);
4912 }
4913 
SetOutlineWidth(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize)4914 void SetOutlineWidth(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize)
4915 {
4916     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4917     CHECK_NULL_VOID(frameNode);
4918     int32_t offset = NUM_0;
4919     NG::BorderWidthProperty borderWidth;
4920 
4921     SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
4922     SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
4923     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
4924     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
4925     borderWidth.multiValued = true;
4926     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4927 }
4928 
SetOutlineWidthFloat(ArkUINodeHandle node,ArkUI_Float32 left,ArkUI_Float32 top,ArkUI_Float32 right,ArkUI_Float32 bottom)4929 void SetOutlineWidthFloat(ArkUINodeHandle node, ArkUI_Float32 left, ArkUI_Float32 top,
4930     ArkUI_Float32 right, ArkUI_Float32 bottom)
4931 {
4932     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4933     CHECK_NULL_VOID(frameNode);
4934     NG::BorderWidthProperty borderWidth;
4935     borderWidth.leftDimen = Dimension(left, DimensionUnit::VP);
4936     borderWidth.topDimen = Dimension(top, DimensionUnit::VP);
4937     borderWidth.rightDimen = Dimension(right, DimensionUnit::VP);
4938     borderWidth.bottomDimen = Dimension(bottom, DimensionUnit::VP);
4939     borderWidth.multiValued = true;
4940     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
4941 }
4942 
GetOutlineWidthFloat(ArkUINodeHandle node,ArkUI_Float32 * borderWidthVector,ArkUI_Int32 borderWidthSize)4943 void GetOutlineWidthFloat(ArkUINodeHandle node, ArkUI_Float32* borderWidthVector, ArkUI_Int32 borderWidthSize)
4944 {
4945     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4946     CHECK_NULL_VOID(frameNode);
4947     if (borderWidthSize < OUTLINE_WIDTH_VECTOR_SIZE) {
4948         return;
4949     }
4950     NG::BorderWidthProperty borderWidth = ViewAbstract::GetOuterBorderWidth(frameNode);
4951     borderWidthVector[OUTLINE_LEFT_WIDTH_INDEX] = borderWidth.leftDimen.has_value() ?
4952         borderWidth.leftDimen->Value() : 0.0f;
4953     borderWidthVector[OUTLINE_TOP_WIDTH_INDEX] = borderWidth.topDimen.has_value() ?
4954         borderWidth.topDimen->Value() : 0.0f;
4955     borderWidthVector[OUTLINE_RIGHT_WIDTH_INDEX] = borderWidth.rightDimen.has_value() ?
4956         borderWidth.rightDimen->Value() : 0.0f;
4957     borderWidthVector[OUTLINE_BOTTOM_WIDTH_INDEX] = borderWidth.bottomDimen.has_value() ?
4958         borderWidth.bottomDimen->Value() : 0.0f;
4959 }
4960 
ResetOutlineWidth(ArkUINodeHandle node)4961 void ResetOutlineWidth(ArkUINodeHandle node)
4962 {
4963     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4964     CHECK_NULL_VOID(frameNode);
4965     Dimension value;
4966     ViewAbstract::SetOuterBorderWidth(frameNode, value);
4967 }
4968 
SetOutlineStyle(ArkUINodeHandle node,const uint32_t * values,int32_t valuesSize)4969 void SetOutlineStyle(ArkUINodeHandle node, const uint32_t* values, int32_t valuesSize)
4970 {
4971     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4972     CHECK_NULL_VOID(frameNode);
4973     int32_t styleOffset = NUM_0;
4974     NG::BorderStyleProperty borderStyles;
4975     SetOptionalBorderStyle(borderStyles.styleLeft, values, valuesSize, styleOffset);
4976     SetOptionalBorderStyle(borderStyles.styleRight, values, valuesSize, styleOffset);
4977     SetOptionalBorderStyle(borderStyles.styleTop, values, valuesSize, styleOffset);
4978     SetOptionalBorderStyle(borderStyles.styleBottom, values, valuesSize, styleOffset);
4979     borderStyles.multiValued = true;
4980     ViewAbstract::SetOuterBorderStyle(frameNode, borderStyles);
4981 }
4982 
ResetOutlineStyle(ArkUINodeHandle node)4983 void ResetOutlineStyle(ArkUINodeHandle node)
4984 {
4985     auto* frameNode = reinterpret_cast<FrameNode*>(node);
4986     CHECK_NULL_VOID(frameNode);
4987     ViewAbstract::SetOuterBorderStyle(frameNode, BorderStyle::SOLID);
4988 }
4989 /**
4990  * @param src source OutlineWidth and and OutlineRadius value
4991  * @param options option value
4992  * values[offset + 0], option[offset + 1], option[offset + 2]: OutlineWidth left(hasValue, value, unit)
4993  * values[offset + 3], option[offset + 4], option[offset + 5]: OutlineWidth right(hasValue, value, unit)
4994  * values[offset + 6], option[offset + 7], option[offset + 8]: OutlineWidth top(hasValue, value, unit)
4995  * values[offset + 9], option[offset + 10], option[offset + 11]: OutlineWidth bottom(hasValue, value, unit)
4996  * values[offset + 12], option[offset + 13], option[offset + 14] : OutlineRadius TopLeft(hasValue, value, unit)
4997  * values[offset + 15], option[offset + 16], option[offset + 17] : OutlineRadius TopRight(hasValue, value, unit)
4998  * values[offset + 18], option[offset + 19], option[offset + 20] : OutlineRadius BottomLeft(hasValue, value, unit)
4999  * values[offset + 21], option[offset + 22], option[offset + 23] : OutlineRadius BottomRight(hasValue, value, unit)
5000  * @param optionsLength options valuesSize
5001  * @param src source color and Style value
5002  * colorAndStyle[offset + 0], option[offset + 1]: OutlineColors leftColor(hasValue, value)
5003  * colorAndStyle[offset + 2], option[offset + 3]: OutlineColors rightColor(hasValue, value)
5004  * colorAndStyle[offset + 4], option[offset + 5]: OutlineColors topColor(hasValue, value)
5005  * colorAndStyle[offset + 6], option[offset + 7]: OutlineColors bottomColor(hasValue, value)
5006  * colorAndStyle[offset + 8], option[offset + 9]: OutlineStyles styleLeft(hasValue, value)
5007  * colorAndStyle[offset + 10], option[offset + 11]: OutlineStyles styleRight(hasValue, value)
5008  * colorAndStyle[offset + 12], option[offset + 12]: OutlineStyles styleTop(hasValue, value)
5009  * colorAndStyle[offset + 14], option[offset + 15]: OutlineStyles styleBottom(hasValue, value)
5010  * @param optionsLength options colorAndStyleSize
5011  */
SetOutline(ArkUINodeHandle node,const ArkUI_Float32 * values,int32_t valuesSize,const uint32_t * colorAndStyle,int32_t colorAndStyleSize)5012 void SetOutline(ArkUINodeHandle node, const ArkUI_Float32* values, int32_t valuesSize, const uint32_t* colorAndStyle,
5013     int32_t colorAndStyleSize)
5014 {
5015     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5016     CHECK_NULL_VOID(frameNode);
5017     if ((values == nullptr) || (valuesSize != NUM_24) || (colorAndStyle == nullptr) || colorAndStyleSize != NUM_16) {
5018         return;
5019     }
5020 
5021     int32_t offset = NUM_0; // offset for outline width and outline radius
5022     NG::BorderWidthProperty borderWidth;
5023     SetOptionalBorder(borderWidth.leftDimen, values, valuesSize, offset);
5024     SetOptionalBorder(borderWidth.rightDimen, values, valuesSize, offset);
5025     SetOptionalBorder(borderWidth.topDimen, values, valuesSize, offset);
5026     SetOptionalBorder(borderWidth.bottomDimen, values, valuesSize, offset);
5027     borderWidth.multiValued = true;
5028     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
5029 
5030     NG::BorderRadiusProperty borderRadius;
5031     SetOptionalBorder(borderRadius.radiusTopLeft, values, valuesSize, offset);
5032     SetOptionalBorder(borderRadius.radiusTopRight, values, valuesSize, offset);
5033     SetOptionalBorder(borderRadius.radiusBottomLeft, values, valuesSize, offset);
5034     SetOptionalBorder(borderRadius.radiusBottomRight, values, valuesSize, offset);
5035     borderRadius.multiValued = true;
5036     ViewAbstract::SetOuterBorderRadius(frameNode, borderRadius);
5037 
5038     int32_t colorAndStyleOffset = NUM_0; // offset for outline color and outline style
5039     NG::BorderColorProperty borderColors;
5040     SetOptionalBorderColor(borderColors.leftColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5041     SetOptionalBorderColor(borderColors.rightColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5042     SetOptionalBorderColor(borderColors.topColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5043     SetOptionalBorderColor(borderColors.bottomColor, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5044     borderColors.multiValued = true;
5045     ViewAbstract::SetOuterBorderColor(frameNode, borderColors);
5046 
5047     NG::BorderStyleProperty borderStyles;
5048     SetOptionalBorderStyle(borderStyles.styleLeft, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5049     SetOptionalBorderStyle(borderStyles.styleRight, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5050     SetOptionalBorderStyle(borderStyles.styleTop, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5051     SetOptionalBorderStyle(borderStyles.styleBottom, colorAndStyle, colorAndStyleSize, colorAndStyleOffset);
5052     borderStyles.multiValued = true;
5053     ViewAbstract::SetOuterBorderStyle(frameNode, borderStyles);
5054 }
5055 
ResetOutline(ArkUINodeHandle node)5056 void ResetOutline(ArkUINodeHandle node)
5057 {
5058     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5059     CHECK_NULL_VOID(frameNode);
5060     CalcDimension borderWidth;
5061     ViewAbstract::SetOuterBorderWidth(frameNode, borderWidth);
5062     ViewAbstract::SetOuterBorderColor(frameNode, Color::BLACK);
5063     ViewAbstract::SetOuterBorderRadius(frameNode, borderWidth);
5064     ViewAbstract::SetOuterBorderStyle(frameNode, BorderStyle::SOLID);
5065 }
GetFocusable(ArkUINodeHandle node)5066 ArkUI_Bool GetFocusable(ArkUINodeHandle node)
5067 {
5068     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5069     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5070     return static_cast<ArkUI_Bool>(ViewAbstract::GetFocusable(frameNode));
5071 }
5072 
GetDefaultFocus(ArkUINodeHandle node)5073 ArkUI_Bool GetDefaultFocus(ArkUINodeHandle node)
5074 {
5075     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5076     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5077     return static_cast<ArkUI_Bool>(ViewAbstract::GetDefaultFocus(frameNode));
5078 }
5079 
GetResponseRegion(ArkUINodeHandle node,ArkUI_Float32 (* values)[32])5080 ArkUI_Int32 GetResponseRegion(ArkUINodeHandle node, ArkUI_Float32 (*values)[32])
5081 {
5082     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5083     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5084     std::vector<DimensionRect> responseRegions = ViewAbstract::GetResponseRegion(frameNode);
5085     //set int default
5086     int index = 0;
5087     for (auto& element : responseRegions) {
5088         (*values)[index++] = element.GetOffset().GetX().Value();
5089         (*values)[index++] = element.GetOffset().GetY().Value();
5090         (*values)[index++] = element.GetWidth().Value() * PERCENT_100;
5091         (*values)[index++] = element.GetHeight().Value() * PERCENT_100;
5092     }
5093     //values size
5094     return index;
5095 }
5096 
GetOverlay(ArkUINodeHandle node,ArkUIOverlayOptions * options,ArkUI_Int32 unit)5097 ArkUI_CharPtr GetOverlay(ArkUINodeHandle node, ArkUIOverlayOptions* options, ArkUI_Int32 unit)
5098 {
5099     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5100     CHECK_NULL_RETURN(frameNode, nullptr);
5101     NG::OverlayOptions overlayOptions = ViewAbstract::GetOverlay(frameNode);
5102     options->align = ParseAlignmentToIndex(overlayOptions.align);
5103     options->x = overlayOptions.x.GetNativeValue(static_cast<DimensionUnit>(unit));
5104     options->y = overlayOptions.y.GetNativeValue(static_cast<DimensionUnit>(unit));
5105     options->content = overlayOptions.content.c_str();
5106     g_strValue = overlayOptions.content;
5107     return g_strValue.c_str();
5108 }
5109 
GetAccessibilityGroup(ArkUINodeHandle node)5110 ArkUI_Bool GetAccessibilityGroup(ArkUINodeHandle node)
5111 {
5112     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5113     CHECK_NULL_RETURN(frameNode, false);
5114     return static_cast<ArkUI_Bool>(ViewAbstractModelNG::GetAccessibilityGroup(frameNode));
5115 }
5116 
GetAccessibilityText(ArkUINodeHandle node)5117 ArkUI_CharPtr GetAccessibilityText(ArkUINodeHandle node)
5118 {
5119     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5120     CHECK_NULL_RETURN(frameNode, nullptr);
5121     g_strValue = ViewAbstractModelNG::GetAccessibilityText(frameNode);
5122     return g_strValue.c_str();
5123 }
5124 
GetAccessibilityDescription(ArkUINodeHandle node)5125 ArkUI_CharPtr GetAccessibilityDescription(ArkUINodeHandle node)
5126 {
5127     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5128     CHECK_NULL_RETURN(frameNode, nullptr);
5129     g_strValue = ViewAbstractModelNG::GetAccessibilityDescription(frameNode);
5130     return g_strValue.c_str();
5131 }
5132 
GetAccessibilityLevel(ArkUINodeHandle node)5133 ArkUI_CharPtr GetAccessibilityLevel(ArkUINodeHandle node)
5134 {
5135     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5136     CHECK_NULL_RETURN(frameNode, nullptr);
5137     g_strValue = ViewAbstractModelNG::GetAccessibilityImportance(frameNode);
5138     return g_strValue.c_str();
5139 }
5140 
SetNeedFocus(ArkUINodeHandle node,ArkUI_Bool value)5141 void SetNeedFocus(ArkUINodeHandle node, ArkUI_Bool value)
5142 {
5143     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5144     CHECK_NULL_VOID(frameNode);
5145     ViewAbstract::SetNeedFocus(frameNode, value);
5146 }
5147 
GetNeedFocus(ArkUINodeHandle node)5148 ArkUI_Bool GetNeedFocus(ArkUINodeHandle node)
5149 {
5150     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5151     CHECK_NULL_RETURN(frameNode, false);
5152     return static_cast<ArkUI_Bool>(ViewAbstract::GetNeedFocus(frameNode));
5153 }
5154 
SetBlendMode(ArkUINodeHandle node,int32_t blendMode,ArkUI_Int32 blendApplyTypeValue)5155 void SetBlendMode(ArkUINodeHandle node, int32_t blendMode, ArkUI_Int32 blendApplyTypeValue)
5156 {
5157     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5158     CHECK_NULL_VOID(frameNode);
5159     ViewAbstractModelNG::SetBlendMode(frameNode, static_cast<OHOS::Ace::BlendMode>(blendMode));
5160     ViewAbstractModelNG::SetBlendApplyType(frameNode, static_cast<OHOS::Ace::BlendApplyType>(blendApplyTypeValue));
5161 }
5162 
ResetBlendMode(ArkUINodeHandle node)5163 void ResetBlendMode(ArkUINodeHandle node)
5164 {
5165     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5166     CHECK_NULL_VOID(frameNode);
5167     ViewAbstractModelNG::SetBlendMode(frameNode, OHOS::Ace::BlendMode::NONE);
5168     ViewAbstractModelNG::SetBlendApplyType(frameNode, OHOS::Ace::BlendApplyType::FAST);
5169 }
5170 
SetMonopolizeEvents(ArkUINodeHandle node,ArkUI_Bool value)5171 void SetMonopolizeEvents(ArkUINodeHandle node, ArkUI_Bool value)
5172 {
5173     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5174     CHECK_NULL_VOID(frameNode);
5175     ViewAbstractModelNG::SetMonopolizeEvents(frameNode, value);
5176 }
5177 
ResetMonopolizeEvents(ArkUINodeHandle node)5178 void ResetMonopolizeEvents(ArkUINodeHandle node)
5179 {
5180     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5181     CHECK_NULL_VOID(frameNode);
5182     ViewAbstractModelNG::SetMonopolizeEvents(frameNode, false);
5183 }
5184 
SetConstraintSize(ArkUINodeHandle node,const ArkUI_Float32 * values,const ArkUI_Int32 * units)5185 void SetConstraintSize(ArkUINodeHandle node, const ArkUI_Float32* values, const ArkUI_Int32* units)
5186 {
5187     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5188     CHECK_NULL_VOID(frameNode);
5189     ViewAbstract::SetMinWidth(frameNode, CalcLength(values[NUM_0], static_cast<DimensionUnit>(units[NUM_0])));
5190     ViewAbstract::SetMaxWidth(frameNode, CalcLength(values[NUM_1], static_cast<DimensionUnit>(units[NUM_1])));
5191     ViewAbstract::SetMinHeight(frameNode, CalcLength(values[NUM_2], static_cast<DimensionUnit>(units[NUM_2])));
5192     ViewAbstract::SetMaxHeight(frameNode, CalcLength(values[NUM_3], static_cast<DimensionUnit>(units[NUM_3])));
5193 }
5194 
ResetConstraintSize(ArkUINodeHandle node)5195 void ResetConstraintSize(ArkUINodeHandle node)
5196 {
5197     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5198     CHECK_NULL_VOID(frameNode);
5199     ViewAbstract::ResetMaxSize(frameNode, true);
5200     ViewAbstract::ResetMinSize(frameNode, true);
5201     ViewAbstract::ResetMaxSize(frameNode, false);
5202     ViewAbstract::ResetMinSize(frameNode, false);
5203 }
5204 
BindCustomPopup(FrameNode * frameNode,ArkUIPopupParam * value,UINode * customNode)5205 void BindCustomPopup(FrameNode* frameNode, ArkUIPopupParam* value, UINode* customNode)
5206 {
5207     auto popupParam = AceType::MakeRefPtr<PopupParam>();
5208     std::function<void(bool)> onStateChangeFunc =
5209         (value->onStateChange == nullptr) ? std::function<void(bool)>([](bool) -> void {})
5210         : ([stateChangeCallBack = value->onStateChange, id = value->onStateChangeId](bool input) -> void {
5211             stateChangeCallBack(id, input);
5212         });
5213     auto onStateChangeCallback = [onStateChangeFunc](const std::string& param) {
5214         auto paramData = JsonUtil::ParseJsonString(param);
5215         onStateChangeFunc(paramData->GetBool("isVisible"));
5216     };
5217 
5218     popupParam->SetIsShow(value->isShow);
5219     popupParam->SetUseCustomComponent(value->useCustomComponent);
5220     popupParam->SetPlacement(static_cast<Placement>(value->placement));
5221     popupParam->SetMaskColor(Color(value->maskColor));
5222     popupParam->SetBackgroundColor(Color(value->backgroundColor));
5223     popupParam->SetEnableArrow(value->enableArrow);
5224     popupParam->SetHasAction(!value->autoCancel);
5225     popupParam->SetOnStateChange(onStateChangeCallback);
5226     if (popupParam->IsShow()) {
5227         ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode),
5228             AceType::Claim(customNode));
5229     } else {
5230         ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
5231     }
5232 }
5233 
BindBasePopup(FrameNode * frameNode,ArkUIPopupParam * value)5234 void BindBasePopup(FrameNode* frameNode, ArkUIPopupParam* value)
5235 {
5236     auto popupParam = AceType::MakeRefPtr<PopupParam>();
5237 
5238     std::function<void(bool)> onStateChangeFunc =
5239         (value->onStateChange == nullptr) ? std::function<void(bool)>([](bool) -> void {})
5240         : ([stateChangeCallBack = value->onStateChange, id = value->onStateChangeId](bool input) -> void {
5241             stateChangeCallBack(id, input);
5242         });
5243     std::function<void()> primaryActionFunc =
5244         (value->primaryAction == nullptr) ? std::function<void()>([]() -> void {})
5245         : ([primaryActionCallBack = value->primaryAction, id = value->primaryActionId]() -> void {
5246             primaryActionCallBack(id);
5247         });
5248     std::function<void()> secondaryActionFunc =
5249         (value->secondaryAction == nullptr) ? std::function<void()>([]() -> void {})
5250         : ([secondaryActionCallBack = value->secondaryAction, id = value->secondaryActionId]() -> void {
5251             secondaryActionCallBack(id);
5252         });
5253     auto onStateChangeCallback = [onStateChangeFunc](const std::string& param) {
5254         auto paramData = JsonUtil::ParseJsonString(param);
5255         onStateChangeFunc(paramData->GetBool("isVisible"));
5256     };
5257     popupParam->SetIsShow(value->isShow);
5258     popupParam->SetMessage(value->message);
5259     popupParam->SetPlacement(static_cast<Placement>(value->placement));
5260     popupParam->SetOnStateChange(onStateChangeCallback);
5261     std::string primaryString = value->primaryString;
5262     if (!primaryString.empty()) {
5263         ButtonProperties propertiesPrimary;
5264         propertiesPrimary.value = primaryString;
5265         auto touchPrimaryCallback = [primaryActionFunc](TouchEventInfo&) {primaryActionFunc();};
5266         auto onNewClick = [primaryActionFunc](const GestureEvent& info) {primaryActionFunc();};
5267         propertiesPrimary.touchFunc = touchPrimaryCallback;
5268         propertiesPrimary.action = AceType::MakeRefPtr<NG::ClickEvent>(onNewClick);
5269         propertiesPrimary.showButton = true;
5270         popupParam->SetPrimaryButtonProperties(propertiesPrimary);
5271     }
5272 
5273     std::string secondaryString = value->secondaryString;
5274     if (!secondaryString.empty()) {
5275         ButtonProperties propertiesSecondary;
5276         propertiesSecondary.value = secondaryString;
5277         auto touchSecondaryCallback = [secondaryActionFunc](TouchEventInfo&) {secondaryActionFunc();};
5278         auto onNewClick = [secondaryActionFunc](const GestureEvent& info) {secondaryActionFunc();};
5279         propertiesSecondary.touchFunc = touchSecondaryCallback;
5280         propertiesSecondary.action = AceType::MakeRefPtr<NG::ClickEvent>(onNewClick);
5281         propertiesSecondary.showButton = true;
5282         popupParam->SetSecondaryButtonProperties(propertiesSecondary);
5283     }
5284     ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
5285 }
5286 
SetBindPopup(ArkUINodeHandle node,ArkUIPopupParam * value,ArkUINodeHandle customNode)5287 void SetBindPopup(ArkUINodeHandle node, ArkUIPopupParam* value, ArkUINodeHandle customNode)
5288 {
5289     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5290     CHECK_NULL_VOID(frameNode);
5291 
5292     if (customNode != nullptr) {
5293         BindCustomPopup(frameNode, value, reinterpret_cast<UINode*>(customNode));
5294     } else {
5295         BindBasePopup(frameNode, value);
5296     }
5297 }
5298 
ResetBindPopup(ArkUINodeHandle node)5299 void ResetBindPopup(ArkUINodeHandle node)
5300 {
5301     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5302     CHECK_NULL_VOID(frameNode);
5303     auto popupParam = AceType::MakeRefPtr<PopupParam>();
5304     popupParam->SetIsShow(false);
5305     ViewAbstract::BindPopup(popupParam, AceType::Claim(frameNode), nullptr);
5306 }
5307 
GetOpacity(ArkUINodeHandle node)5308 ArkUI_Float32 GetOpacity(ArkUINodeHandle node)
5309 {
5310     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5311     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5312     return ViewAbstract::GetOpacity(frameNode);
5313 }
5314 
GetBorderWidth(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 unit)5315 void GetBorderWidth(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 unit)
5316 {
5317     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5318     CHECK_NULL_VOID(frameNode);
5319     auto width = ViewAbstract::GetBorderWidth(frameNode);
5320     (*values)[NUM_0] = width.topDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5321     (*values)[NUM_1] = width.rightDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5322     (*values)[NUM_2] = width.bottomDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5323     (*values)[NUM_3] = width.leftDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
5324 }
5325 
GetBorderWidthDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5326 void GetBorderWidthDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5327 {
5328     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5329     CHECK_NULL_VOID(frameNode);
5330     auto borderWidth = ViewAbstract::GetLayoutBorderWidth(frameNode);
5331     (*values)[NUM_0] = borderWidth.topDimen->Value();
5332     (*units)[NUM_0] = static_cast<ArkUI_Int32>(borderWidth.topDimen->Unit());
5333     (*values)[NUM_1] = borderWidth.rightDimen->Value();
5334     (*units)[NUM_1] = static_cast<ArkUI_Int32>(borderWidth.rightDimen->Unit());
5335     (*values)[NUM_2] = borderWidth.bottomDimen->Value();
5336     (*units)[NUM_2] = static_cast<ArkUI_Int32>(borderWidth.bottomDimen->Unit());
5337     (*values)[NUM_3] = borderWidth.leftDimen->Value();
5338     (*units)[NUM_3] = static_cast<ArkUI_Int32>(borderWidth.leftDimen->Unit());
5339 }
5340 
GetBorderRadius(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 unit)5341 void GetBorderRadius(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 unit)
5342 {
5343     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5344     CHECK_NULL_VOID(frameNode);
5345     auto radius = ViewAbstract::GetBorderRadius(frameNode);
5346     (*values)[NUM_0] = radius.radiusTopLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
5347     (*values)[NUM_1] = radius.radiusTopRight->GetNativeValue(static_cast<DimensionUnit>(unit));
5348     (*values)[NUM_2] = radius.radiusBottomLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
5349     (*values)[NUM_3] = radius.radiusBottomRight->GetNativeValue(static_cast<DimensionUnit>(unit));
5350 }
5351 
GetBorderColor(ArkUINodeHandle node,ArkUI_Uint32 (* values)[4])5352 void GetBorderColor(ArkUINodeHandle node, ArkUI_Uint32 (*values)[4])
5353 {
5354     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5355     CHECK_NULL_VOID(frameNode);
5356     auto colors = ViewAbstract::GetBorderColor(frameNode);
5357     (*values)[NUM_0] = colors.topColor->GetValue();
5358     (*values)[NUM_1] = colors.rightColor->GetValue();
5359     (*values)[NUM_2] = colors.bottomColor->GetValue();
5360     (*values)[NUM_3] = colors.leftColor->GetValue();
5361 }
5362 
GetBorderStyle(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5363 void GetBorderStyle(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5364 {
5365     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5366     CHECK_NULL_VOID(frameNode);
5367     auto styles = ViewAbstract::GetBorderStyle(frameNode);
5368     (*values)[NUM_0] = static_cast<ArkUI_Int32>(styles.styleTop.value());
5369     (*values)[NUM_1] = static_cast<ArkUI_Int32>(styles.styleRight.value());
5370     (*values)[NUM_2] = static_cast<ArkUI_Int32>(styles.styleBottom.value());
5371     (*values)[NUM_3] = static_cast<ArkUI_Int32>(styles.styleLeft.value());
5372 }
5373 
GetZIndex(ArkUINodeHandle node)5374 ArkUI_Int32 GetZIndex(ArkUINodeHandle node)
5375 {
5376     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5377     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5378     return ViewAbstract::GetZIndex(frameNode);
5379 }
5380 
GetVisibility(ArkUINodeHandle node)5381 ArkUI_Int32 GetVisibility(ArkUINodeHandle node)
5382 {
5383     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5384     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5385     return static_cast<ArkUI_Int32>(ViewAbstract::GetVisibility(frameNode));
5386 }
5387 
GetClip(ArkUINodeHandle node)5388 ArkUI_Int32 GetClip(ArkUINodeHandle node)
5389 {
5390     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5391     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5392     return static_cast<ArkUI_Int32>(ViewAbstract::GetClip(frameNode));
5393 }
5394 
GetClipShape(ArkUINodeHandle node,ArkUIClipShapeOptions * options,ArkUI_Int32 unit)5395 void GetClipShape(ArkUINodeHandle node, ArkUIClipShapeOptions* options, ArkUI_Int32 unit)
5396 {
5397     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5398     CHECK_NULL_VOID(frameNode);
5399     auto basicShape = ViewAbstract::GetClipShape(frameNode);
5400     options->width = basicShape->GetWidth().GetNativeValue(static_cast<DimensionUnit>(unit));
5401     options->height = basicShape->GetHeight().GetNativeValue(static_cast<DimensionUnit>(unit));
5402     options->type = static_cast<ArkUI_Int32>(basicShape->GetBasicShapeType());
5403     switch (basicShape->GetBasicShapeType()) {
5404         case BasicShapeType::PATH: {
5405             auto path = AceType::DynamicCast<Path>(basicShape);
5406             options->commands = path->GetValue().c_str();
5407             break;
5408         }
5409         case BasicShapeType::RECT: {
5410             auto shapeRect = AceType::DynamicCast<ShapeRect>(basicShape);
5411             //radiusWidth
5412             options->radiusWidth =
5413                 shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5414             //radiusHeight
5415             options->radiusHeight =
5416                 shapeRect->GetTopLeftRadius().GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5417             //topLeftRadius
5418             options->topLeftRadius =
5419                 shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5420             //bottomLeftRadius
5421             options->bottomLeftRadius =
5422                 shapeRect->GetBottomLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5423             //topRightRadius
5424             options->topRightRadius =
5425                 shapeRect->GetTopRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5426             //bottomRightRadius
5427             options->bottomRightRadius =
5428                 shapeRect->GetBottomRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5429             break;
5430         }
5431         default:
5432             break;
5433     }
5434 }
5435 
GetTransform(ArkUINodeHandle node,ArkUI_Float32 (* values)[16])5436 void GetTransform(ArkUINodeHandle node, ArkUI_Float32 (*values)[16])
5437 {
5438     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5439     CHECK_NULL_VOID(frameNode);
5440     auto transforms = ViewAbstract::GetTransform(frameNode);
5441     for (int i = 0; i < NUM_16; i++) {
5442         (*values)[i] = transforms[i];
5443     }
5444 }
5445 
GetHitTestBehavior(ArkUINodeHandle node)5446 ArkUI_Int32 GetHitTestBehavior(ArkUINodeHandle node)
5447 {
5448     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5449     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5450     return static_cast<ArkUI_Int32>(ViewAbstract::GetHitTestBehavior(frameNode));
5451 }
5452 
GetPosition(ArkUINodeHandle node,ArkUIPositionOptions * values,ArkUI_Int32 unit)5453 void GetPosition(ArkUINodeHandle node, ArkUIPositionOptions* values, ArkUI_Int32 unit)
5454 {
5455     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5456     CHECK_NULL_VOID(frameNode);
5457     auto positions = ViewAbstract::GetPosition(frameNode);
5458     values->x = positions.GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5459     values->y = positions.GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5460 }
5461 
GetShadow(ArkUINodeHandle node)5462 ArkUI_Int32 GetShadow(ArkUINodeHandle node)
5463 {
5464     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5465     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5466     int style = static_cast<ArkUI_Int32>(ViewAbstract::GetShadow(frameNode)->GetStyle());
5467     return style;
5468 }
5469 
GetCustomShadow(ArkUINodeHandle node,ArkUICustomShadowOptions * options)5470 void GetCustomShadow(ArkUINodeHandle node, ArkUICustomShadowOptions* options)
5471 {
5472     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5473     CHECK_NULL_VOID(frameNode);
5474     auto shadow = ViewAbstract::GetShadow(frameNode);
5475     options->color = shadow->GetColor().GetValue();
5476     options->shadowType = static_cast<ArkUI_Int32>(shadow->GetShadowType());
5477     options->colorStrategy = static_cast<ArkUI_Int32>(shadow->GetShadowColorStrategy());
5478     options->offsetX = shadow->GetOffset().GetX();
5479     options->offsetY = shadow->GetOffset().GetY();
5480     options->radius = shadow->GetBlurRadius();
5481     options->fill = static_cast<ArkUI_Int32>(shadow->GetIsFilled());
5482 }
5483 
GetSweepGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[6],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stops)[10],ArkUI_Int32 unit)5484 ArkUI_Int32 GetSweepGradient(ArkUINodeHandle node, ArkUI_Float32 (*values)[6], ArkUI_Uint32 (*colors)[10],
5485     ArkUI_Float32 (*stops)[10], ArkUI_Int32 unit)
5486 {
5487     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5488     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5489     auto gradient = ViewAbstract::GetSweepGradient(frameNode);
5490     auto sweepGradient = gradient.GetSweepGradient();
5491 
5492     (*values)[NUM_0] = sweepGradient->centerX->GetNativeValue(static_cast<DimensionUnit>(unit));
5493     (*values)[NUM_1] = sweepGradient->centerY->GetNativeValue(static_cast<DimensionUnit>(unit));
5494     (*values)[NUM_2] = sweepGradient->startAngle->Value();
5495     (*values)[NUM_3] = sweepGradient->endAngle->Value();
5496     (*values)[NUM_4] = sweepGradient->rotation->Value();
5497     (*values)[NUM_5] = gradient.GetRepeat();
5498 
5499     std::vector<GradientColor> gradientColors = gradient.GetColors();
5500     //0 start index
5501     int index = 0;
5502     for (auto& gradientColor : gradientColors) {
5503         (*colors)[index] = gradientColor.GetColor().GetValue();
5504         (*stops)[index] = gradientColor.GetDimension().Value();
5505         index++;
5506     }
5507     return index;
5508 }
5509 
GetRadialGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stops)[10],ArkUI_Int32 unit)5510 ArkUI_Int32 GetRadialGradient(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Uint32 (*colors)[10],
5511     ArkUI_Float32 (*stops)[10], ArkUI_Int32 unit)
5512 {
5513     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5514     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5515     auto gradient = ViewAbstract::GetRadialGradient(frameNode);
5516     auto radialGradient = gradient.GetRadialGradient();
5517 
5518     CHECK_NULL_RETURN(radialGradient, ERROR_INT_CODE);
5519     (*values)[NUM_0] = radialGradient->radialCenterX->GetNativeValue(static_cast<DimensionUnit>(unit));
5520     (*values)[NUM_1] = radialGradient->radialCenterY->GetNativeValue(static_cast<DimensionUnit>(unit));
5521     (*values)[NUM_2] =
5522         gradient.GetRadialGradient()->radialHorizontalSize->GetNativeValue(static_cast<DimensionUnit>(unit));
5523     (*values)[NUM_3] = gradient.GetRepeat();
5524 
5525     std::vector<GradientColor> gradientColors = gradient.GetColors();
5526     //0 start index
5527     int index = 0;
5528     for (auto& gradientColor : gradientColors) {
5529         (*colors)[index] = gradientColor.GetColor().GetValue();
5530         (*stops)[index] = gradientColor.GetDimension().Value();
5531         index++;
5532     }
5533     return index;
5534 }
5535 
GetMask(ArkUINodeHandle node,ArkUIMaskOptions * options,ArkUI_Int32 unit)5536 void GetMask(ArkUINodeHandle node, ArkUIMaskOptions* options, ArkUI_Int32 unit)
5537 {
5538     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5539     CHECK_NULL_VOID(frameNode);
5540     auto basicShape = ViewAbstract::GetMask(frameNode);
5541     if (basicShape == nullptr) {
5542         auto process = ViewAbstract::GetMaskProgress(frameNode);
5543         CHECK_NULL_VOID(process);
5544         options->type = static_cast<ArkUI_Int32>(ArkUI_MaskType::ARKUI_MASK_TYPE_PROGRESS);
5545         options->value = process->GetValue();
5546         options->color = process->GetColor().GetValue();
5547         options->maxValue = process->GetMaxValue();
5548         return;
5549     }
5550     options->type = static_cast<ArkUI_Int32>(basicShape->GetBasicShapeType());
5551     options->fill = basicShape->GetColor().GetValue();
5552     options->strokeColor = basicShape->GetStrokeColor();
5553     options->strokeWidth = basicShape->GetStrokeWidth();
5554     options->width = basicShape->GetWidth().GetNativeValue(static_cast<DimensionUnit>(unit));
5555     options->height = basicShape->GetHeight().GetNativeValue(static_cast<DimensionUnit>(unit));
5556     if (basicShape->GetBasicShapeType() == BasicShapeType::PATH) {
5557         auto path = AceType::DynamicCast<Path>(basicShape);
5558         options->commands = path->GetValue().c_str();
5559     } else if (basicShape->GetBasicShapeType() == BasicShapeType::RECT) {
5560         auto shapeRect = AceType::DynamicCast<ShapeRect>(basicShape);
5561         options->radiusWidth =
5562             shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5563         options->radiusHeight =
5564             shapeRect->GetTopLeftRadius().GetY().GetNativeValue(static_cast<DimensionUnit>(unit));
5565         options->topLeftRadius =
5566             shapeRect->GetTopLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5567         options->bottomLeftRadius =
5568             shapeRect->GetBottomLeftRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5569         options->topRightRadius =
5570             shapeRect->GetTopRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5571         options->bottomRightRadius =
5572             shapeRect->GetBottomRightRadius().GetX().GetNativeValue(static_cast<DimensionUnit>(unit));
5573     }
5574 }
5575 
GetBlendMode(ArkUINodeHandle node,ArkUIBlendModeOptions * options)5576 void GetBlendMode(ArkUINodeHandle node, ArkUIBlendModeOptions* options)
5577 {
5578     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5579     CHECK_NULL_VOID(frameNode);
5580     options->blendMode = static_cast<ArkUI_Int32>(ViewAbstract::GetBlendMode(frameNode));
5581     options->blendApplyType = static_cast<ArkUI_Int32>(ViewAbstract::GetBlendApplyType(frameNode));
5582 }
5583 
GetDirection(ArkUINodeHandle node)5584 ArkUI_Int32 GetDirection(ArkUINodeHandle node)
5585 {
5586     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5587     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5588     int direction = static_cast<ArkUI_Int32>(ViewAbstract::GetDirection(frameNode));
5589     return direction;
5590 }
5591 
GetAlignSelf(ArkUINodeHandle node)5592 ArkUI_Int32 GetAlignSelf(ArkUINodeHandle node)
5593 {
5594     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5595     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5596     int alignSelf = static_cast<ArkUI_Int32>(ViewAbstract::GetAlignSelf(frameNode));
5597     return alignSelf;
5598 }
5599 
GetFlexGrow(ArkUINodeHandle node)5600 ArkUI_Float32 GetFlexGrow(ArkUINodeHandle node)
5601 {
5602     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5603     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5604     return ViewAbstract::GetFlexGrow(frameNode);
5605 }
5606 
GetFlexShrink(ArkUINodeHandle node)5607 ArkUI_Float32 GetFlexShrink(ArkUINodeHandle node)
5608 {
5609     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5610     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5611     return ViewAbstract::GetFlexShrink(frameNode);
5612 }
5613 
GetFlexBasis(ArkUINodeHandle node)5614 ArkUI_Float32 GetFlexBasis(ArkUINodeHandle node)
5615 {
5616     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5617     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5618     return ViewAbstract::GetFlexBasis(frameNode).Value();
5619 }
5620 
GetConstraintSize(ArkUINodeHandle node,ArkUIConstraintSizeOptions * options,ArkUI_Int32 unit)5621 void GetConstraintSize(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options, ArkUI_Int32 unit)
5622 {
5623     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5624     CHECK_NULL_VOID(frameNode);
5625     options->minWidth = ViewAbstract::GetMinWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5626     options->maxWidth = ViewAbstract::GetMaxWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5627     options->minHeight = ViewAbstract::GetMinHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5628     options->maxHeight = ViewAbstract::GetMaxHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5629 }
5630 
GetGrayScale(ArkUINodeHandle node)5631 ArkUI_Float32 GetGrayScale(ArkUINodeHandle node)
5632 {
5633     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5634     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5635     return ViewAbstract::GetGrayScale(frameNode).Value();
5636 }
5637 
GetInvert(ArkUINodeHandle node)5638 ArkUI_Float32 GetInvert(ArkUINodeHandle node)
5639 {
5640     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5641     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5642     return std::get<float>(ViewAbstract::GetInvert(frameNode));
5643 }
5644 
GetSepia(ArkUINodeHandle node)5645 ArkUI_Float32 GetSepia(ArkUINodeHandle node)
5646 {
5647     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5648     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5649     return ViewAbstract::GetSepia(frameNode).Value();
5650 }
5651 
GetContrast(ArkUINodeHandle node)5652 ArkUI_Float32 GetContrast(ArkUINodeHandle node)
5653 {
5654     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5655     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5656     return ViewAbstract::GetContrast(frameNode).Value();
5657 }
5658 
GetForegroundColor(ArkUINodeHandle node)5659 ArkUI_Uint32 GetForegroundColor(ArkUINodeHandle node)
5660 {
5661     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5662     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5663     return ViewAbstract::GetForegroundColor(frameNode).GetValue();
5664 }
5665 
GetBlur(ArkUINodeHandle node)5666 ArkUI_Float32 GetBlur(ArkUINodeHandle node)
5667 {
5668     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5669     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5670     return ViewAbstract::GetFrontBlur(frameNode).Value();
5671 }
5672 
GetLinearGradient(ArkUINodeHandle node,ArkUI_Float32 (* values)[3],ArkUI_Uint32 (* colors)[10],ArkUI_Float32 (* stop)[10])5673 ArkUI_Int32 GetLinearGradient(
5674     ArkUINodeHandle node, ArkUI_Float32 (*values)[3], ArkUI_Uint32 (*colors)[10], ArkUI_Float32 (*stop)[10])
5675 {
5676     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5677     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5678     auto gradient = ViewAbstract::GetLinearGradient(frameNode);
5679     auto angle = gradient.GetLinearGradient()->angle;
5680     //0 angle
5681     (*values)[0] = angle.has_value() ? angle.value().Value() : DEFAULT_ANGLE;
5682     //1 Direction
5683     (*values)[1] = static_cast<int32_t>(convertToLinearGradientDirection(gradient.GetLinearGradient()));
5684     //2 Repeat
5685     (*values)[2] = gradient.GetRepeat();
5686 
5687     std::vector<GradientColor> gradientColors = gradient.GetColors();
5688     //0 start index
5689     int index = 0;
5690     for (auto& gradientColor : gradientColors) {
5691         (*colors)[index] = gradientColor.GetColor().GetValue();
5692         (*stop)[index] = gradientColor.GetDimension().Value();
5693         index++;
5694     }
5695     return index;
5696 }
5697 
GetAlign(ArkUINodeHandle node)5698 ArkUI_Int32 GetAlign(ArkUINodeHandle node)
5699 {
5700     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5701     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5702     return ConvertAlignmentToInt(ViewAbstract::GetAlign(frameNode));
5703 }
5704 
GetWidth(ArkUINodeHandle node,ArkUI_Int32 unit)5705 ArkUI_Float32 GetWidth(ArkUINodeHandle node, ArkUI_Int32 unit)
5706 {
5707     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5708     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5709     return ViewAbstract::GetWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5710 }
5711 
GetHeight(ArkUINodeHandle node,ArkUI_Int32 unit)5712 ArkUI_Float32 GetHeight(ArkUINodeHandle node, ArkUI_Int32 unit)
5713 {
5714     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5715     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5716     return ViewAbstract::GetHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
5717 }
5718 
GetBackgroundColor(ArkUINodeHandle node)5719 ArkUI_Uint32 GetBackgroundColor(ArkUINodeHandle node)
5720 {
5721     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5722     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5723     return ViewAbstract::GetBackgroundColor(frameNode).GetValue();
5724 }
5725 
GetBackgroundImage(ArkUINodeHandle node,ArkUIBackgroundImage * options)5726 void GetBackgroundImage(ArkUINodeHandle node, ArkUIBackgroundImage* options)
5727 {
5728     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5729     CHECK_NULL_VOID(frameNode);
5730     g_strValue = ViewAbstract::GetBackgroundImageSrc(frameNode);
5731     options->src = g_strValue.c_str();
5732     options->repeat = static_cast<int>(ViewAbstract::GetBackgroundImageRepeat(frameNode));
5733 }
5734 
GetPadding(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 length,ArkUI_Int32 unit)5735 void GetPadding(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 length, ArkUI_Int32 unit)
5736 {
5737     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5738     CHECK_NULL_VOID(frameNode);
5739     auto padding = ViewAbstract::GetPadding(frameNode);
5740     (*values)[NUM_0] = padding.top->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5741     (*values)[NUM_1] = padding.right->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5742     (*values)[NUM_2] = padding.bottom->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5743     (*values)[NUM_3] = padding.left->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5744     length = NUM_4;
5745 }
5746 
GetPaddingDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5747 void GetPaddingDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5748 {
5749     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5750     CHECK_NULL_VOID(frameNode);
5751     auto padding = ViewAbstract::GetPadding(frameNode);
5752     (*values)[NUM_0] = padding.top->GetDimension().Value();
5753     (*units)[NUM_0] = static_cast<ArkUI_Int32>(padding.top->GetDimension().Unit());
5754     (*values)[NUM_1] = padding.right->GetDimension().Value();
5755     (*units)[NUM_1] = static_cast<ArkUI_Int32>(padding.right->GetDimension().Unit());
5756     (*values)[NUM_2] = padding.bottom->GetDimension().Value();
5757     (*units)[NUM_2] = static_cast<ArkUI_Int32>(padding.bottom->GetDimension().Unit());
5758     (*values)[NUM_3] = padding.left->GetDimension().Value();
5759     (*units)[NUM_3] = static_cast<ArkUI_Int32>(padding.left->GetDimension().Unit());
5760 }
5761 
GetConfigSize(ArkUINodeHandle node,ArkUI_Float32 (* values)[2],ArkUI_Int32 (* units)[2])5762 void GetConfigSize(ArkUINodeHandle node, ArkUI_Float32 (*values)[2], ArkUI_Int32 (*units)[2])
5763 {
5764     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5765     CHECK_NULL_VOID(frameNode);
5766     auto size = ViewAbstract::GetConfigSize(frameNode);
5767     (*values)[NUM_0] = size->Width()->GetDimension().Value();
5768     (*units)[NUM_0] = static_cast<ArkUI_Int32>(size->Width()->GetDimension().Unit());
5769     (*values)[NUM_1] = size->Height()->GetDimension().Value();
5770     (*units)[NUM_1] = static_cast<ArkUI_Int32>(size->Height()->GetDimension().Unit());
5771 }
5772 
GetKey(ArkUINodeHandle node)5773 ArkUI_CharPtr GetKey(ArkUINodeHandle node)
5774 {
5775     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5776     CHECK_NULL_RETURN(frameNode, nullptr);
5777     g_strValue = ViewAbstract::GetKey(frameNode);
5778     return g_strValue.c_str();
5779 }
5780 
GetEnabled(ArkUINodeHandle node)5781 int GetEnabled(ArkUINodeHandle node)
5782 {
5783     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5784     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5785     return static_cast<ArkUI_Int32>(ViewAbstract::GetEnabled(frameNode));
5786 }
5787 
GetMargin(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 length,ArkUI_Int32 unit)5788 void GetMargin(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 length, ArkUI_Int32 unit)
5789 {
5790     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5791     CHECK_NULL_VOID(frameNode);
5792     auto margin = ViewAbstract::GetMargin(frameNode);
5793     (*values)[NUM_0] = margin.top->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5794     (*values)[NUM_1] = margin.right->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5795     (*values)[NUM_2] = margin.bottom->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5796     (*values)[NUM_3] = margin.left->GetDimensionContainsNegative().GetNativeValue(static_cast<DimensionUnit>(unit));
5797     length = NUM_4;
5798 }
5799 
GetMarginDimension(ArkUINodeHandle node,ArkUI_Float32 (* values)[4],ArkUI_Int32 (* units)[4])5800 void GetMarginDimension(ArkUINodeHandle node, ArkUI_Float32 (*values)[4], ArkUI_Int32 (*units)[4])
5801 {
5802     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5803     CHECK_NULL_VOID(frameNode);
5804     auto margin = ViewAbstract::GetMargin(frameNode);
5805     (*values)[NUM_0] = margin.top->GetDimension().Value();
5806     (*units)[NUM_0] = static_cast<ArkUI_Int32>(margin.top->GetDimension().Unit());
5807     (*values)[NUM_1] = margin.right->GetDimension().Value();
5808     (*units)[NUM_1] = static_cast<ArkUI_Int32>(margin.right->GetDimension().Unit());
5809     (*values)[NUM_2] = margin.bottom->GetDimension().Value();
5810     (*units)[NUM_2] = static_cast<ArkUI_Int32>(margin.bottom->GetDimension().Unit());
5811     (*values)[NUM_3] = margin.left->GetDimension().Value();
5812     (*units)[NUM_3] = static_cast<ArkUI_Int32>(margin.left->GetDimension().Unit());
5813 }
5814 
GetTranslate(ArkUINodeHandle node,ArkUI_Float32 (* values)[3],ArkUI_Int32 unit)5815 void GetTranslate(ArkUINodeHandle node, ArkUI_Float32 (*values)[3], ArkUI_Int32 unit)
5816 {
5817     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5818     CHECK_NULL_VOID(frameNode);
5819     auto translate = ViewAbstract::GetTranslate(frameNode);
5820     (*values)[NUM_0] = translate.x.GetNativeValue(static_cast<DimensionUnit>(unit));
5821     (*values)[NUM_1] = translate.y.GetNativeValue(static_cast<DimensionUnit>(unit));
5822     (*values)[NUM_2] = translate.z.GetNativeValue(static_cast<DimensionUnit>(unit));
5823 }
5824 
GetAspectRatio(ArkUINodeHandle node)5825 ArkUI_Float32 GetAspectRatio(ArkUINodeHandle node)
5826 {
5827     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5828     CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
5829     return ViewAbstract::GetAspectRatio(frameNode);
5830 }
5831 
SetBackgroundImageSizeWithUnit(ArkUINodeHandle node,ArkUI_Float32 valueWidth,ArkUI_Float32 valueHeight,ArkUI_Int32 unit)5832 void SetBackgroundImageSizeWithUnit(
5833     ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight, ArkUI_Int32 unit)
5834 {
5835     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5836     CHECK_NULL_VOID(frameNode);
5837     BackgroundImageSize bgImgSize;
5838     CalcDimension width(valueWidth, static_cast<DimensionUnit>(unit));
5839     CalcDimension height(valueHeight, static_cast<DimensionUnit>(unit));
5840     bgImgSize.SetSizeTypeX(OHOS::Ace::BackgroundImageSizeType::LENGTH);
5841     bgImgSize.SetSizeValueX(width.GetNativeValue(DimensionUnit::PX));
5842     bgImgSize.SetSizeTypeY(OHOS::Ace::BackgroundImageSizeType::LENGTH);
5843     bgImgSize.SetSizeValueY(height.GetNativeValue(DimensionUnit::PX));
5844     ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
5845 }
5846 
SetChainStyle(ArkUINodeHandle node,ArkUI_Int32 direction,ArkUI_Int32 style)5847 void SetChainStyle(ArkUINodeHandle node, ArkUI_Int32 direction, ArkUI_Int32 style)
5848 {
5849     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5850     CHECK_NULL_VOID(frameNode);
5851     ChainInfo chainInfo;
5852     chainInfo.direction = static_cast<LineDirection>(direction);
5853     chainInfo.style = static_cast<ChainStyle>(style);
5854     ViewAbstract::SetChainStyle(frameNode, chainInfo);
5855 }
5856 
GetChainStyle(ArkUINodeHandle node,ArkUI_Int32 (* values)[2])5857 void GetChainStyle(ArkUINodeHandle node, ArkUI_Int32 (*values)[2])
5858 {
5859     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5860     CHECK_NULL_VOID(frameNode);
5861     auto chainInfo = ViewAbstract::GetChainStyle(frameNode);
5862     // 0 index is direction
5863     if (chainInfo.direction.has_value()) {
5864         (*values)[0] = static_cast<ArkUI_Int32>(chainInfo.direction.value());
5865     } else {
5866         (*values)[0] = -1;
5867     }
5868     // 1 index is style
5869     if (chainInfo.style.has_value()) {
5870         (*values)[1] = static_cast<ArkUI_Int32>(chainInfo.style.value());
5871     } else {
5872         (*values)[1] = -1;
5873     }
5874 }
5875 
ResetChainStyle(ArkUINodeHandle node)5876 void ResetChainStyle(ArkUINodeHandle node)
5877 {
5878     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5879     CHECK_NULL_VOID(frameNode);
5880     ViewAbstract::ResetChainStyle(frameNode);
5881 }
5882 
SetBias(ArkUINodeHandle node,ArkUI_Float32 horizontal,ArkUI_Float32 vertical)5883 void SetBias(ArkUINodeHandle node, ArkUI_Float32 horizontal, ArkUI_Float32 vertical)
5884 {
5885     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5886     CHECK_NULL_VOID(frameNode);
5887     BiasPair pair1(horizontal, vertical);
5888     ViewAbstract::SetBias(frameNode, pair1);
5889 }
5890 
GetBias(ArkUINodeHandle node,ArkUI_Float32 * values)5891 void GetBias(ArkUINodeHandle node, ArkUI_Float32* values)
5892 {
5893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5894     CHECK_NULL_VOID(frameNode);
5895     auto bias = ViewAbstract::GetBias(frameNode);
5896     //horizontal
5897     values[0] = bias.first;
5898     //vertical
5899     values[1] = bias.second;
5900 }
5901 
ResetBias(ArkUINodeHandle node)5902 void ResetBias(ArkUINodeHandle node)
5903 {
5904     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5905     CHECK_NULL_VOID(frameNode);
5906     ViewAbstract::ResetBias(frameNode);
5907 }
SetOnVisibleAreaChange(ArkUINodeHandle node,ArkUI_Int64 extraParam,ArkUI_Float32 * values,ArkUI_Int32 size)5908 void SetOnVisibleAreaChange(ArkUINodeHandle node, ArkUI_Int64 extraParam, ArkUI_Float32* values, ArkUI_Int32 size)
5909 {
5910     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5911     CHECK_NULL_VOID(frameNode);
5912     int32_t nodeId = frameNode->GetId();
5913     std::vector<double> ratioList(values, values + size);
5914     auto onEvent = [nodeId, extraParam](bool visible, double ratio) {
5915         ArkUINodeEvent event;
5916         event.kind = COMPONENT_ASYNC_EVENT;
5917         event.nodeId = nodeId;
5918         event.extraParam = static_cast<intptr_t>(extraParam);
5919         event.componentAsyncEvent.subKind = ON_VISIBLE_AREA_CHANGE;
5920         event.componentAsyncEvent.data[0].i32 = visible;
5921         event.componentAsyncEvent.data[1].f32 = static_cast<ArkUI_Float32>(ratio);
5922         SendArkUISyncEvent(&event);
5923     };
5924     ViewAbstract::SetOnVisibleChange(frameNode, onEvent, ratioList);
5925 }
5926 
SetLayoutRect(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5927 void SetLayoutRect(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5928 {
5929     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5930     auto rect =
5931         NG::RectF((*values)[0], (*values)[1], (*values)[2], (*values)[3]); // 2:index of width, 3:index of height
5932     ViewAbstract::SetLayoutRect(frameNode, rect);
5933 }
5934 
GetLayoutRect(ArkUINodeHandle node,ArkUI_Int32 (* values)[4])5935 void GetLayoutRect(ArkUINodeHandle node, ArkUI_Int32 (*values)[4])
5936 {
5937     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5938     auto rect = ViewAbstract::GetLayoutRect(frameNode);
5939     (*values)[0] = rect.GetX();
5940     (*values)[1] = rect.GetY();
5941     (*values)[2] = rect.Width(); // 2:index of width
5942     (*values)[3] = rect.Height(); // 3:index of height
5943 }
5944 
ResetLayoutRect(ArkUINodeHandle node)5945 void ResetLayoutRect(ArkUINodeHandle node)
5946 {
5947     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5948     ViewAbstract::ResetLayoutRect(frameNode);
5949 }
5950 
SetSystemBarEffect(ArkUINodeHandle node,ArkUI_Bool enable)5951 void SetSystemBarEffect(ArkUINodeHandle node, ArkUI_Bool enable)
5952 {
5953     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5954     CHECK_NULL_VOID(frameNode);
5955     ViewAbstract::SetSystemBarEffect(frameNode, enable);
5956 }
5957 
GetAccessibilityID(ArkUINodeHandle node)5958 ArkUI_Int32 GetAccessibilityID(ArkUINodeHandle node)
5959 {
5960     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5961     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
5962     ArkUI_Int32 value = frameNode->GetAccessibilityId();
5963     return value;
5964 }
5965 
SetAccessibilityState(ArkUINodeHandle node,const ArkUIAccessibilityState & state)5966 void SetAccessibilityState(ArkUINodeHandle node, const ArkUIAccessibilityState& state)
5967 {
5968     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5969     CHECK_NULL_VOID(frameNode);
5970     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5971     CHECK_NULL_VOID(accessibilityProperty);
5972     if (state.isDisabled.isSet) {
5973         accessibilityProperty->SetUserDisabled(state.isDisabled.value);
5974     }
5975     if (state.isSelected.isSet) {
5976         accessibilityProperty->SetUserSelected(state.isSelected.value);
5977     }
5978     if (state.checkedType.isSet) {
5979         accessibilityProperty->SetUserCheckedType(state.checkedType.value);
5980     }
5981 }
5982 
GetAccessibilityState(ArkUINodeHandle node,ArkUIAccessibilityState & state)5983 void GetAccessibilityState(ArkUINodeHandle node, ArkUIAccessibilityState& state)
5984 {
5985     auto* frameNode = reinterpret_cast<FrameNode*>(node);
5986     CHECK_NULL_VOID(frameNode);
5987     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
5988     CHECK_NULL_VOID(accessibilityProperty);
5989     state.isDisabled.isSet = accessibilityProperty->HasUserDisabled();
5990     state.isDisabled.value = accessibilityProperty->IsUserDisabled();
5991     state.isSelected.isSet = accessibilityProperty->HasUserSelected();
5992     state.isSelected.value = accessibilityProperty->IsUserSelected();
5993     state.checkedType.isSet = accessibilityProperty->HasUserCheckedType();
5994     state.checkedType.value = accessibilityProperty->GetUserCheckedType();
5995 }
5996 
ResetAccessibilityState(ArkUINodeHandle node)5997 void ResetAccessibilityState(ArkUINodeHandle node)
5998 {
5999     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6000     CHECK_NULL_VOID(frameNode);
6001     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6002     CHECK_NULL_VOID(accessibilityProperty);
6003     if (accessibilityProperty->HasUserDisabled()) {
6004         accessibilityProperty->SetUserDisabled(false);
6005     }
6006     if (accessibilityProperty->HasUserSelected()) {
6007         accessibilityProperty->SetUserSelected(false);
6008     }
6009     if (accessibilityProperty->HasUserCheckedType()) {
6010         accessibilityProperty->SetUserCheckedType(0);
6011     }
6012 }
6013 
SetAccessibilityValue(ArkUINodeHandle node,const ArkUIAccessibilityValue & value)6014 void SetAccessibilityValue(ArkUINodeHandle node, const ArkUIAccessibilityValue& value)
6015 {
6016     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6017     CHECK_NULL_VOID(frameNode);
6018     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6019     CHECK_NULL_VOID(accessibilityProperty);
6020     if (value.min.isSet) {
6021         accessibilityProperty->SetUserMinValue(value.min.value);
6022     }
6023     if (value.max.isSet) {
6024         accessibilityProperty->SetUserMaxValue(value.max.value);
6025     }
6026     if (value.current.isSet) {
6027         accessibilityProperty->SetUserCurrentValue(value.current.value);
6028     }
6029     if (value.rangeMin.isSet) {
6030         accessibilityProperty->SetUserRangeMinValue(value.rangeMin.value);
6031     }
6032     if (value.rangeMax.isSet) {
6033         accessibilityProperty->SetUserRangeMaxValue(value.rangeMax.value);
6034     }
6035     if (value.rangeCurrent.isSet) {
6036         accessibilityProperty->SetUserRangeCurrentValue(value.rangeCurrent.value);
6037     }
6038     if (value.text.isSet) {
6039         accessibilityProperty->SetUserTextValue(value.text.value);
6040     }
6041 }
6042 
GetAccessibilityValue(ArkUINodeHandle node,ArkUIAccessibilityValue & value)6043 void GetAccessibilityValue(ArkUINodeHandle node, ArkUIAccessibilityValue& value)
6044 {
6045     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6046     CHECK_NULL_VOID(frameNode);
6047     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6048     CHECK_NULL_VOID(accessibilityProperty);
6049     value.min.isSet = accessibilityProperty->HasUserMinValue();
6050     value.min.value = accessibilityProperty->GetUserMinValue();
6051     value.max.isSet = accessibilityProperty->HasUserMaxValue();
6052     value.max.value = accessibilityProperty->GetUserMaxValue();
6053     value.current.isSet = accessibilityProperty->HasUserCurrentValue();
6054     value.current.value = accessibilityProperty->GetUserCurrentValue();
6055     value.rangeMin.isSet = accessibilityProperty->HasUserRangeMinValue();
6056     value.rangeMin.value = accessibilityProperty->GetUserRangeMinValue();
6057     value.rangeMax.isSet = accessibilityProperty->HasUserRangeMaxValue();
6058     value.rangeMax.value = accessibilityProperty->GetUserRangeMaxValue();
6059     value.rangeCurrent.isSet = accessibilityProperty->HasUserRangeCurrentValue();
6060     value.rangeCurrent.value = accessibilityProperty->GetUserRangeCurrentValue();
6061     value.text.isSet = accessibilityProperty->HasUserTextValue();
6062     g_strValue = accessibilityProperty->GetUserTextValue();
6063     value.text.value = g_strValue.c_str();
6064 }
6065 
ResetAccessibilityValue(ArkUINodeHandle node)6066 void ResetAccessibilityValue(ArkUINodeHandle node)
6067 {
6068     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6069     CHECK_NULL_VOID(frameNode);
6070     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6071     CHECK_NULL_VOID(accessibilityProperty);
6072     if (accessibilityProperty->HasUserMinValue()) {
6073         accessibilityProperty->SetUserMinValue(-1);
6074     }
6075     if (accessibilityProperty->HasUserMaxValue()) {
6076         accessibilityProperty->SetUserMaxValue(-1);
6077     }
6078     if (accessibilityProperty->HasUserCurrentValue()) {
6079         accessibilityProperty->SetUserCurrentValue(-1);
6080     }
6081     if (accessibilityProperty->HasUserRangeMinValue()) {
6082         accessibilityProperty->SetUserRangeMinValue(-1);
6083     }
6084     if (accessibilityProperty->HasUserRangeMaxValue()) {
6085         accessibilityProperty->SetUserRangeMaxValue(-1);
6086     }
6087     if (accessibilityProperty->HasUserRangeCurrentValue()) {
6088         accessibilityProperty->SetUserRangeCurrentValue(-1);
6089     }
6090     if (accessibilityProperty->HasUserTextValue()) {
6091         accessibilityProperty->SetUserTextValue("");
6092     }
6093 }
6094 
SetAccessibilityActions(ArkUINodeHandle node,ArkUI_Uint32 actions)6095 void SetAccessibilityActions(ArkUINodeHandle node, ArkUI_Uint32 actions)
6096 {
6097     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6098     CHECK_NULL_VOID(frameNode);
6099     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6100     accessibilityProperty->SetAccessibilityActions(actions);
6101 }
6102 
ResetAccessibilityActions(ArkUINodeHandle node)6103 void ResetAccessibilityActions(ArkUINodeHandle node)
6104 {
6105     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6106     CHECK_NULL_VOID(frameNode);
6107     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6108     accessibilityProperty->ResetAccessibilityActions();
6109 }
6110 
GetAccessibilityActions(ArkUINodeHandle node)6111 ArkUI_Uint32 GetAccessibilityActions(ArkUINodeHandle node)
6112 {
6113     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6114     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
6115     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6116     return accessibilityProperty->GetAccessibilityActions();
6117 }
6118 
SetAccessibilityRole(ArkUINodeHandle node,ArkUI_CharPtr role)6119 void SetAccessibilityRole(ArkUINodeHandle node, ArkUI_CharPtr role)
6120 {
6121     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6122     CHECK_NULL_VOID(frameNode);
6123     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6124     accessibilityProperty->SetAccessibilityRole(std::string(role));
6125 }
6126 
ResetAccessibilityRole(ArkUINodeHandle node)6127 void ResetAccessibilityRole(ArkUINodeHandle node)
6128 {
6129     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6130     CHECK_NULL_VOID(frameNode);
6131     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6132     accessibilityProperty->ResetAccessibilityRole();
6133 }
6134 
GetAccessibilityRole(ArkUINodeHandle node)6135 ArkUI_CharPtr GetAccessibilityRole(ArkUINodeHandle node)
6136 {
6137     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6138     CHECK_NULL_RETURN(frameNode, nullptr);
6139     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
6140     g_strValue = accessibilityProperty->GetAccessibilityRole();
6141     return g_strValue.c_str();
6142 }
6143 
SetFocusScopeId(ArkUINodeHandle node,ArkUI_CharPtr id,ArkUI_Bool isGroup,ArkUI_Bool arrowKeyStepOut)6144 void SetFocusScopeId(ArkUINodeHandle node, ArkUI_CharPtr id, ArkUI_Bool isGroup, ArkUI_Bool arrowKeyStepOut)
6145 {
6146     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6147     CHECK_NULL_VOID(frameNode);
6148     std::string idStr = id;
6149     ViewAbstract::SetFocusScopeId(frameNode, idStr, isGroup, arrowKeyStepOut);
6150 }
6151 
ResetFocusScopeId(ArkUINodeHandle node)6152 void ResetFocusScopeId(ArkUINodeHandle node)
6153 {
6154     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6155     CHECK_NULL_VOID(frameNode);
6156     std::string id = "";
6157     bool isGroup = false;
6158     bool arrowKeyStepOut = true;
6159     ViewAbstract::SetFocusScopeId(frameNode, id, isGroup, arrowKeyStepOut);
6160 }
6161 
SetFocusScopePriority(ArkUINodeHandle node,ArkUI_CharPtr scopeId,ArkUI_Int32 priority)6162 void SetFocusScopePriority(ArkUINodeHandle node, ArkUI_CharPtr scopeId, ArkUI_Int32 priority)
6163 {
6164     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6165     CHECK_NULL_VOID(frameNode);
6166     std::string scopeIdStr = scopeId;
6167     ViewAbstract::SetFocusScopePriority(frameNode, scopeIdStr, priority);
6168 }
6169 
ResetFocusScopePriority(ArkUINodeHandle node)6170 void ResetFocusScopePriority(ArkUINodeHandle node)
6171 {
6172     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6173     CHECK_NULL_VOID(frameNode);
6174     std::string scopeId = "";
6175     int32_t priority = 0;
6176     ViewAbstract::SetFocusScopePriority(frameNode, scopeId, priority);
6177 }
6178 
ConvertCeilPixelRoundPolicy(ArkUI_Int32 index)6179 PixelRoundPolicy ConvertCeilPixelRoundPolicy(ArkUI_Int32 index)
6180 {
6181     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
6182     switch (index) {
6183         case 0:
6184             ret = PixelRoundPolicy::FORCE_CEIL_START;
6185             break;
6186         case 1:
6187             ret = PixelRoundPolicy::FORCE_CEIL_TOP;
6188             break;
6189         case 2: // 2:index of end
6190             ret = PixelRoundPolicy::FORCE_CEIL_END;
6191             break;
6192         case 3: // 3:index of bottom
6193             ret = PixelRoundPolicy::FORCE_CEIL_BOTTOM;
6194             break;
6195         default:
6196             break;
6197     }
6198     return ret;
6199 }
6200 
ConvertFloorPixelRoundPolicy(ArkUI_Int32 index)6201 PixelRoundPolicy ConvertFloorPixelRoundPolicy(ArkUI_Int32 index)
6202 {
6203     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
6204     switch (index) {
6205         case 0:
6206             ret = PixelRoundPolicy::FORCE_FLOOR_START;
6207             break;
6208         case 1:
6209             ret = PixelRoundPolicy::FORCE_FLOOR_TOP;
6210             break;
6211         case 2: // 2:index of end
6212             ret = PixelRoundPolicy::FORCE_FLOOR_END;
6213             break;
6214         case 3: // 3:index of bottom
6215             ret = PixelRoundPolicy::FORCE_FLOOR_BOTTOM;
6216             break;
6217         default:
6218             break;
6219     }
6220     return ret;
6221 }
6222 
ConvertNoPixelRoundPolicy(ArkUI_Int32 index)6223 PixelRoundPolicy ConvertNoPixelRoundPolicy(ArkUI_Int32 index)
6224 {
6225     switch (index) {
6226         case 0:
6227             return PixelRoundPolicy::NO_FORCE_ROUND_START;
6228         case 1:
6229             return PixelRoundPolicy::NO_FORCE_ROUND_TOP;
6230         case 2: // 2:index of end
6231             return PixelRoundPolicy::NO_FORCE_ROUND_END;
6232         case 3: // 3:index of bottom
6233             return PixelRoundPolicy::NO_FORCE_ROUND_BOTTOM;
6234         default:
6235             return PixelRoundPolicy::ALL_FORCE_ROUND;
6236     }
6237 }
6238 
ConvertPixelRoundPolicy(ArkUI_Int32 value,ArkUI_Int32 index)6239 uint16_t ConvertPixelRoundPolicy(ArkUI_Int32 value, ArkUI_Int32 index)
6240 {
6241     auto tmp = static_cast<PixelRoundCalcPolicy>(value);
6242     PixelRoundPolicy ret = static_cast<PixelRoundPolicy>(0);
6243     if (tmp == PixelRoundCalcPolicy::FORCE_CEIL) {
6244         ret = ConvertCeilPixelRoundPolicy(index);
6245     } else if (tmp == PixelRoundCalcPolicy::FORCE_FLOOR) {
6246         ret = ConvertFloorPixelRoundPolicy(index);
6247     } else if (tmp == PixelRoundCalcPolicy::NO_FORCE_ROUND) {
6248         ret = ConvertNoPixelRoundPolicy(index);
6249     }
6250     return static_cast<uint16_t>(ret);
6251 }
6252 
SetPixelRound(ArkUINodeHandle node,const ArkUI_Int32 * values,ArkUI_Int32 length)6253 void SetPixelRound(ArkUINodeHandle node, const ArkUI_Int32* values, ArkUI_Int32 length)
6254 {
6255     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6256     CHECK_NULL_VOID(frameNode);
6257 
6258     uint16_t value = 0;
6259     for (ArkUI_Int32 index = 0; index < length; index++) {
6260         value |= ConvertPixelRoundPolicy(values[index], index);
6261     }
6262     ViewAbstract::SetPixelRound(frameNode, value);
6263 }
6264 
ResetPixelRound(ArkUINodeHandle node)6265 void ResetPixelRound(ArkUINodeHandle node)
6266 {
6267     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6268     CHECK_NULL_VOID(frameNode);
6269     ViewAbstract::SetPixelRound(frameNode, static_cast<uint16_t>(PixelRoundCalcPolicy::NO_FORCE_ROUND));
6270 }
6271 
ParseTransition(ArkUITransitionEffectOption * option)6272 RefPtr<NG::ChainedTransitionEffect> ParseTransition(ArkUITransitionEffectOption* option)
6273 {
6274     CHECK_NULL_RETURN(option, nullptr);
6275     auto type = static_cast<TransitionEffectType>(option->type);
6276     RefPtr<NG::ChainedTransitionEffect> transitionEffect;
6277     switch (type) {
6278         case TransitionEffectType::TRANSITION_EFFECT_OPACITY: {
6279             transitionEffect = AceType::MakeRefPtr<NG::ChainedOpacityEffect>(option->opacity);
6280             break;
6281         }
6282 
6283         case TransitionEffectType::TRANSITION_EFFECT_TRANSLATE: {
6284             CalcDimension x(option->translate.x, DimensionUnit::VP);
6285             CalcDimension y(option->translate.y, DimensionUnit::VP);
6286             CalcDimension z(option->translate.z, DimensionUnit::VP);
6287             NG::TranslateOptions translate(x, y, z);
6288             transitionEffect = AceType::MakeRefPtr<NG::ChainedTranslateEffect>(translate);
6289             break;
6290         }
6291 
6292         case TransitionEffectType::TRANSITION_EFFECT_SCALE: {
6293             CalcDimension centerX(option->scale.centerX, DimensionUnit::PERCENT);
6294             CalcDimension centerY(option->scale.centerY, DimensionUnit::PERCENT);
6295             NG::ScaleOptions scale(option->scale.x, option->scale.y, option->scale.z, centerX, centerY);
6296             transitionEffect = AceType::MakeRefPtr<NG::ChainedScaleEffect>(scale);
6297             break;
6298         }
6299 
6300         case TransitionEffectType::TRANSITION_EFFECT_ROTATE: {
6301             CalcDimension centerX(option->rotate.centerX, DimensionUnit::PERCENT);
6302             CalcDimension centerY(option->rotate.centerY, DimensionUnit::PERCENT);
6303             CalcDimension centerZ(option->rotate.centerZ, DimensionUnit::PERCENT);
6304             NG::RotateOptions rotate(option->rotate.x, option->rotate.y, option->rotate.z, option->rotate.angle,
6305                 centerX, centerY, centerZ, option->rotate.perspective);
6306             transitionEffect = AceType::MakeRefPtr<NG::ChainedRotateEffect>(rotate);
6307             break;
6308         }
6309 
6310         case TransitionEffectType::TRANSITION_EFFECT_MOVE: {
6311             transitionEffect =
6312                 AceType::MakeRefPtr<NG::ChainedMoveEffect>(static_cast<NG::TransitionEdge>(option->move));
6313             break;
6314         }
6315 
6316         case TransitionEffectType::TRANSITION_EFFECT_ASYMMETRIC: {
6317             RefPtr<NG::ChainedTransitionEffect> appearEffect;
6318             RefPtr<NG::ChainedTransitionEffect> disappearEffect;
6319             if (option->appear) {
6320                 appearEffect = ParseTransition(option->appear);
6321             }
6322             if (option->disappear) {
6323                 disappearEffect = ParseTransition(option->disappear);
6324             }
6325             transitionEffect = AceType::MakeRefPtr<NG::ChainedAsymmetricEffect>(appearEffect, disappearEffect);
6326             break;
6327         }
6328     }
6329 
6330     CHECK_NULL_RETURN(transitionEffect, nullptr);
6331 
6332     if (option->hasAnimation) {
6333         auto animation = option->animation;
6334         AnimationOption animationOption;
6335         animationOption.SetDuration(animation.duration);
6336         animationOption.SetDelay(animation.delay);
6337         animationOption.SetIteration(animation.iterations);
6338         animationOption.SetTempo(animation.tempo);
6339         animationOption.SetAnimationDirection(DIRECTION_LIST[
6340             static_cast<ArkUI_Uint32>(animation.playMode) > DIRECTION_LIST.size() ? 0 : animation.playMode]);
6341 
6342         // curve
6343         if (animation.iCurve) {
6344             auto curve = reinterpret_cast<Curve*>(animation.iCurve);
6345             animationOption.SetCurve(AceType::Claim(curve));
6346         } else {
6347             if (animation.curve < 0 || static_cast<ArkUI_Uint32>(animation.curve) >= CURVES.size()) {
6348                 animationOption.SetCurve(OHOS::Ace::Curves::EASE_IN_OUT);
6349             } else {
6350                 animationOption.SetCurve(CURVES[animation.curve]);
6351             }
6352         }
6353 
6354         if (animation.expectedFrameRateRange) {
6355             RefPtr<FrameRateRange> frameRateRange =
6356                 AceType::MakeRefPtr<FrameRateRange>(animation.expectedFrameRateRange->min,
6357                     animation.expectedFrameRateRange->max, animation.expectedFrameRateRange->expected);
6358             animationOption.SetFrameRateRange(frameRateRange);
6359         }
6360         auto animationOptionResult = std::make_shared<AnimationOption>(animationOption);
6361         transitionEffect->SetAnimationOption(animationOptionResult);
6362     }
6363 
6364     if (option->combine) {
6365         transitionEffect->SetNext(ParseTransition(option->combine));
6366     }
6367     return transitionEffect;
6368 }
6369 
SetTransition(ArkUINodeHandle node,ArkUITransitionEffectOption * option)6370 void SetTransition(ArkUINodeHandle node, ArkUITransitionEffectOption* option)
6371 {
6372     CHECK_NULL_VOID(option);
6373     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6374     CHECK_NULL_VOID(frameNode);
6375 
6376     auto transitionEffectOption = ParseTransition(option);
6377     CHECK_NULL_VOID(transitionEffectOption);
6378     ViewAbstract::SetChainedTransition(frameNode, transitionEffectOption);
6379 }
6380 
SetDragPreview(ArkUINodeHandle node,ArkUIDragPreview dragPreview)6381 void SetDragPreview(ArkUINodeHandle node, ArkUIDragPreview dragPreview)
6382 {
6383     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6384     CHECK_NULL_VOID(frameNode);
6385     NG::DragDropInfo dragPreviewInfo;
6386     dragPreviewInfo.inspectorId = dragPreview.inspectorId;
6387     dragPreviewInfo.onlyForLifting = dragPreview.onlyForLifting;
6388     if (dragPreview.extraInfo) {
6389         dragPreviewInfo.extraInfo = dragPreview.extraInfo;
6390     }
6391     if (dragPreview.pixelMap) {
6392         dragPreviewInfo.pixelMap = PixelMap::CreatePixelMap(dragPreview.pixelMap);
6393     }
6394     ViewAbstract::SetDragPreview(frameNode, dragPreviewInfo);
6395 }
6396 
ResetDragPreview(ArkUINodeHandle node)6397 void ResetDragPreview(ArkUINodeHandle node)
6398 {
6399     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6400     CHECK_NULL_VOID(frameNode);
6401     NG::DragDropInfo dragPreviewInfo;
6402     ViewAbstract::SetDragPreview(frameNode, dragPreviewInfo);
6403 }
6404 
GetExpandSafeArea(ArkUINodeHandle node,ArkUI_Uint32 (* values)[2])6405 void GetExpandSafeArea(ArkUINodeHandle node, ArkUI_Uint32 (*values)[2])
6406 {
6407     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6408     CHECK_NULL_VOID(frameNode);
6409     (*values)[NUM_0] = ViewAbstract::GetSafeAreaExpandType(frameNode);
6410     (*values)[NUM_1] = ViewAbstract::GetSafeAreaExpandEdges(frameNode);
6411 }
6412 
SetBorderDashParams(ArkUINodeHandle node,const ArkUI_Float32 * values,ArkUI_Int32 valuesSize)6413 void SetBorderDashParams(ArkUINodeHandle node, const ArkUI_Float32* values, ArkUI_Int32 valuesSize)
6414 {
6415     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6416     CHECK_NULL_VOID(frameNode);
6417     if ((values == nullptr) || (valuesSize != NUM_36)) {
6418         return;
6419     }
6420     auto isRightToLeft = AceApplicationInfo::GetInstance().IsRightToLeft();
6421     int32_t offset = NUM_0;
6422     NG::BorderWidthProperty borderDashGap;
6423     SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6424     SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6425     SetOptionalBorder(borderDashGap.topDimen, values, valuesSize, offset);
6426     SetOptionalBorder(borderDashGap.bottomDimen, values, valuesSize, offset);
6427     if (isRightToLeft) {
6428         SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6429         SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6430     } else {
6431         SetOptionalBorder(borderDashGap.leftDimen, values, valuesSize, offset);
6432         SetOptionalBorder(borderDashGap.rightDimen, values, valuesSize, offset);
6433     }
6434     borderDashGap.multiValued = true;
6435     if (borderDashGap.leftDimen.has_value() || borderDashGap.rightDimen.has_value() ||
6436         borderDashGap.topDimen.has_value() || borderDashGap.bottomDimen.has_value()) {
6437         ViewAbstract::SetDashGap(frameNode, borderDashGap);
6438     } else {
6439         ViewAbstract::SetDashGap(frameNode, Dimension(DEFAULT_DASH_DIMENSION));
6440     }
6441 
6442     NG::BorderWidthProperty borderDashWidth;
6443     SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6444     SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6445     SetOptionalBorder(borderDashWidth.topDimen, values, valuesSize, offset);
6446     SetOptionalBorder(borderDashWidth.bottomDimen, values, valuesSize, offset);
6447     if (isRightToLeft) {
6448         SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6449         SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6450     } else {
6451         SetOptionalBorder(borderDashWidth.leftDimen, values, valuesSize, offset);
6452         SetOptionalBorder(borderDashWidth.rightDimen, values, valuesSize, offset);
6453     }
6454     borderDashWidth.multiValued = true;
6455     if (borderDashWidth.leftDimen.has_value() || borderDashWidth.rightDimen.has_value() ||
6456         borderDashWidth.topDimen.has_value() || borderDashWidth.bottomDimen.has_value()) {
6457         ViewAbstract::SetDashWidth(frameNode, borderDashWidth);
6458     } else {
6459         ViewAbstract::SetDashWidth(frameNode, Dimension(DEFAULT_DASH_DIMENSION));
6460     }
6461 }
6462 
GetNodeUniqueId(ArkUINodeHandle node)6463 ArkUI_Int32 GetNodeUniqueId(ArkUINodeHandle node)
6464 {
6465     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6466     CHECK_NULL_RETURN(frameNode, -1);
6467     return frameNode->GetId();
6468 }
6469 
SetNextFocus(ArkUINodeHandle node,ArkUI_CharPtr forward,ArkUI_CharPtr backward,ArkUI_CharPtr up,ArkUI_CharPtr down,ArkUI_CharPtr left,ArkUI_CharPtr right,ArkUI_Uint32 hasValue)6470 void SetNextFocus(ArkUINodeHandle node, ArkUI_CharPtr forward, ArkUI_CharPtr backward,
6471     ArkUI_CharPtr up, ArkUI_CharPtr down, ArkUI_CharPtr left, ArkUI_CharPtr right, ArkUI_Uint32 hasValue)
6472 {
6473     CHECK_NULL_VOID(node);
6474     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6475     if ((hasValue >> 5) & 1) { // 5: forward
6476         ViewAbstract::SetNextFocus(frameNode, FocusIntension::TAB, forward);
6477     }
6478     if ((hasValue >> 4) & 1) { // 4: backward
6479         ViewAbstract::SetNextFocus(frameNode, FocusIntension::SHIFT_TAB, backward);
6480     }
6481     if ((hasValue >> 3) & 1) { // 3: up
6482         ViewAbstract::SetNextFocus(frameNode, FocusIntension::UP, up);
6483     }
6484     if ((hasValue >> 2) & 1) { // 2: down
6485         ViewAbstract::SetNextFocus(frameNode, FocusIntension::DOWN, down);
6486     }
6487     if ((hasValue >> 1) & 1) { // 1: left
6488         ViewAbstract::SetNextFocus(frameNode, FocusIntension::LEFT, std::string(left));
6489     }
6490     if ((hasValue >> 0) & 1) { // 0: right
6491         ViewAbstract::SetNextFocus(frameNode, FocusIntension::RIGHT, std::string(right));
6492     }
6493 }
6494 
SetNextFocusOneByOne(ArkUINodeHandle node,::FocusMove idx,ArkUINodeHandle focusNode)6495 void SetNextFocusOneByOne(ArkUINodeHandle node, ::FocusMove idx, ArkUINodeHandle focusNode)
6496 {
6497     CHECK_NULL_VOID(node);
6498     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6499     auto* focusFrameNode = reinterpret_cast<FrameNode*>(focusNode);
6500     auto nodePtr = AceType::WeakClaim<AceType>(focusFrameNode);
6501     FocusIntension key;
6502     switch (idx) {
6503         case ::FocusMove::FOCUS_MOVE_FORWARD:
6504             key = FocusIntension::TAB;
6505             break;
6506         case ::FocusMove::FOCUS_MOVE_BACKWARD:
6507             key = FocusIntension::SHIFT_TAB;
6508             break;
6509         case ::FocusMove::FOCUS_MOVE_UP:
6510             key = FocusIntension::UP;
6511             break;
6512         case ::FocusMove::FOCUS_MOVE_DOWN:
6513             key = FocusIntension::DOWN;
6514             break;
6515         case ::FocusMove::FOCUS_MOVE_LEFT:
6516             key = FocusIntension::LEFT;
6517             break;
6518         case ::FocusMove::FOCUS_MOVE_RIGHT:
6519             key = FocusIntension::RIGHT;
6520             break;
6521         default:
6522             return;
6523     }
6524     ViewAbstract::SetNextFocus(frameNode, key, nodePtr);
6525 }
6526 
ResetNextFocus(ArkUINodeHandle node)6527 void ResetNextFocus(ArkUINodeHandle node)
6528 {
6529     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6530     CHECK_NULL_VOID(frameNode);
6531     ViewAbstract::ResetNextFocus(frameNode);
6532 }
6533 
SetFocusBoxStyle(ArkUINodeHandle node,ArkUI_Float32 valueMargin,ArkUI_Int32 marginUnit,ArkUI_Float32 valueStrokeWidth,ArkUI_Int32 widthUnit,ArkUI_Uint32 valueColor,ArkUI_Uint32 hasValue)6534 void SetFocusBoxStyle(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Int32 marginUnit,
6535     ArkUI_Float32 valueStrokeWidth, ArkUI_Int32 widthUnit, ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue)
6536 {
6537     CHECK_NULL_VOID(node);
6538     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6539     auto marginUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(marginUnit);
6540     auto widthUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(widthUnit);
6541     NG::FocusBoxStyle style;
6542     if ((hasValue >> 2) & 1) { // 2: margin
6543         CalcDimension margin = CalcDimension(valueMargin, DimensionUnit::FP);
6544         if (marginUnitEnum >= OHOS::Ace::DimensionUnit::PX && marginUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
6545             marginUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
6546             margin.SetUnit(marginUnitEnum);
6547         }
6548         style.margin = margin;
6549     }
6550     if ((hasValue >> 1) & 1) { // 1: strokeWidth
6551         CalcDimension strokeWidth = CalcDimension(valueStrokeWidth, DimensionUnit::FP);
6552         if (widthUnitEnum >= OHOS::Ace::DimensionUnit::PX && widthUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
6553             widthUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
6554             strokeWidth.SetUnit(widthUnitEnum);
6555         }
6556         style.strokeWidth = strokeWidth;
6557     }
6558     if ((hasValue >> 0) & 1) { // 0: strokeColor
6559         Color strokeColor(valueColor);
6560         style.strokeColor = strokeColor;
6561     }
6562     ViewAbstract::SetFocusBoxStyle(frameNode, style);
6563 }
6564 
ResetFocusBoxStyle(ArkUINodeHandle node)6565 void ResetFocusBoxStyle(ArkUINodeHandle node)
6566 {
6567     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6568     CHECK_NULL_VOID(frameNode);
6569     NG::FocusBoxStyle style;
6570     ViewAbstract::SetFocusBoxStyle(frameNode, style);
6571 }
6572 
SetClickDistance(ArkUINodeHandle node,ArkUI_Float32 valueMargin)6573 void SetClickDistance(ArkUINodeHandle node, ArkUI_Float32 valueMargin)
6574 {
6575     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6576     CHECK_NULL_VOID(frameNode);
6577     double clickDistance = static_cast<double>(valueMargin);
6578     ViewAbstract::SetClickDistance(frameNode, clickDistance);
6579 }
6580 
ResetClickDistance(ArkUINodeHandle node)6581 void ResetClickDistance(ArkUINodeHandle node)
6582 {
6583     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6584     CHECK_NULL_VOID(frameNode);
6585     ViewAbstract::SetClickDistance(frameNode, std::numeric_limits<double>::infinity());
6586 }
6587 
SetBlendModeByBlender(ArkUINodeHandle node,ArkUINodeHandle blender,ArkUI_Int32 blendApplyTypeValue)6588 void SetBlendModeByBlender(ArkUINodeHandle node, ArkUINodeHandle blender, ArkUI_Int32 blendApplyTypeValue)
6589 {
6590     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6591     CHECK_NULL_VOID(frameNode);
6592     OHOS::Rosen::BrightnessBlender* brightnessBlender = reinterpret_cast<OHOS::Rosen::BrightnessBlender*>(blender);
6593     ViewAbstractModelNG::SetBrightnessBlender(frameNode, brightnessBlender);
6594     ViewAbstractModelNG::SetBlendApplyType(frameNode, static_cast<OHOS::Ace::BlendApplyType>(blendApplyTypeValue));
6595 }
6596 
SetTabStop(ArkUINodeHandle node,ArkUI_Bool tabstop)6597 void SetTabStop(ArkUINodeHandle node, ArkUI_Bool tabstop)
6598 {
6599     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6600     CHECK_NULL_VOID(frameNode);
6601     ViewAbstract::SetTabStop(frameNode, tabstop);
6602 }
6603 
ResetTabStop(ArkUINodeHandle node)6604 void ResetTabStop(ArkUINodeHandle node)
6605 {
6606     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6607     CHECK_NULL_VOID(frameNode);
6608     bool tabstop = false;
6609     ViewAbstract::SetTabStop(frameNode, tabstop);
6610 }
6611 
GetTabStop(ArkUINodeHandle node)6612 ArkUI_Bool GetTabStop(ArkUINodeHandle node)
6613 {
6614     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6615     CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
6616     return static_cast<ArkUI_Bool>(ViewAbstract::GetTabStop(frameNode));
6617 }
6618 
DispatchKeyEvent(ArkUINodeHandle node,ArkUIKeyEvent * arkUIkeyEvent)6619 void DispatchKeyEvent(ArkUINodeHandle node, ArkUIKeyEvent* arkUIkeyEvent)
6620 {
6621     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6622     CHECK_NULL_VOID(frameNode);
6623     CHECK_NULL_VOID(arkUIkeyEvent);
6624     KeyEvent keyEvent;
6625     keyEvent.action = static_cast<KeyAction>(arkUIkeyEvent->type);
6626     keyEvent.code = static_cast<KeyCode>(arkUIkeyEvent->keyCode);
6627     keyEvent.key.assign(arkUIkeyEvent->keyText);
6628     keyEvent.sourceType = static_cast<SourceType>(arkUIkeyEvent->keySource);
6629     keyEvent.deviceId = arkUIkeyEvent->deviceId;
6630     keyEvent.unicode = arkUIkeyEvent->unicode;
6631     std::chrono::nanoseconds nanoseconds(static_cast<int64_t>(arkUIkeyEvent->timestamp));
6632     TimeStamp timeStamp(nanoseconds);
6633     keyEvent.timeStamp = timeStamp;
6634     for (int32_t i = 0; i < arkUIkeyEvent->keyCodesLength; i ++) {
6635         keyEvent.pressedCodes.push_back(static_cast<KeyCode>(arkUIkeyEvent->pressedKeyCodes[i]));
6636     }
6637     keyEvent.keyIntention = static_cast<KeyIntention>(arkUIkeyEvent->intentionCode);
6638     ViewAbstract::DispatchKeyEvent(frameNode, keyEvent);
6639 }
6640 
PostTouchEventToFrameNode(ArkUINodeHandle node,TouchEvent & touchEvent)6641 ArkUI_Int32 PostTouchEventToFrameNode(ArkUINodeHandle node, TouchEvent& touchEvent)
6642 {
6643     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6644     if (!frameNode) {
6645         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent framenode is null!");
6646         return ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL;
6647     }
6648     auto frameNodePtr = AceType::Claim<FrameNode>(frameNode);
6649     if (!frameNodePtr) {
6650         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent framenodeptr is null!");
6651         return ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL;
6652     }
6653     auto pipelineContext = frameNodePtr->GetContext();
6654     if (!pipelineContext) {
6655         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent pipeline context is null!");
6656         return ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL;
6657     }
6658     auto postEventManager = pipelineContext->GetPostEventManager();
6659     if (!postEventManager) {
6660         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent post event manager is null!");
6661         return ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL;
6662     }
6663     bool res = postEventManager->PostEvent(frameNodePtr, touchEvent);
6664     if (!res) {
6665         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent post event fail!");
6666         return ARKUI_ERROR_CODE_POST_CLONED_NO_COMPONENT_HIT_TO_RESPOND_TO_THE_EVENT;
6667     }
6668     return ERROR_CODE_NO_ERROR;
6669 }
6670 
PostTouchEvent(ArkUINodeHandle node,const ArkUITouchEvent * arkUITouchEvent)6671 ArkUI_Int32 PostTouchEvent(ArkUINodeHandle node, const ArkUITouchEvent* arkUITouchEvent)
6672 {
6673     if (!arkUITouchEvent) {
6674         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "PostTouchEvent touchevent is null!");
6675         return ARKUI_ERROR_CODE_PARAM_INVALID;
6676     }
6677     TouchEvent touchEvent;
6678     touchEvent.type = static_cast<TouchType>(arkUITouchEvent->action);
6679     touchEvent.sourceType = static_cast<SourceType>(arkUITouchEvent->sourceType);
6680     touchEvent.sourceTool = static_cast<SourceTool>(arkUITouchEvent->actionTouchPoint.toolType);
6681     touchEvent.force = arkUITouchEvent->actionTouchPoint.pressure;
6682     touchEvent.deviceId = arkUITouchEvent->deviceId;
6683     std::chrono::nanoseconds nanoseconds(static_cast<int64_t>(arkUITouchEvent->timeStamp));
6684     TimeStamp time(nanoseconds);
6685     touchEvent.time = time;
6686     touchEvent.targetDisplayId = arkUITouchEvent->targetDisplayId;
6687     ArkUITouchPoint* touchPointes = arkUITouchEvent->touchPointes;
6688     auto density = PipelineBase::GetCurrentDensity();
6689     for (size_t index = 0; index < arkUITouchEvent->touchPointSize; index++) {
6690         TouchPoint point;
6691         point.id = touchPointes[index].id;
6692         point.x = touchPointes[index].nodeX;
6693         point.y = touchPointes[index].nodeY;
6694         point.screenX = touchPointes[index].screenX * density;
6695         point.screenY = touchPointes[index].screenY * density;
6696         point.originalId = touchPointes[index].id;
6697         std::chrono::nanoseconds downNanoseconds(static_cast<int64_t>(touchPointes[index].pressedTime));
6698         TimeStamp downTime(downNanoseconds);
6699         point.downTime = downTime;
6700         point.force = touchPointes[index].pressure;
6701         touchEvent.pointers.emplace_back(point);
6702     }
6703     touchEvent.id = arkUITouchEvent->actionTouchPoint.id;
6704     touchEvent.x = arkUITouchEvent->actionTouchPoint.nodeX;
6705     touchEvent.y = arkUITouchEvent->actionTouchPoint.nodeY;
6706     touchEvent.screenX = arkUITouchEvent->actionTouchPoint.screenX * density;
6707     touchEvent.screenY = arkUITouchEvent->actionTouchPoint.screenY * density;
6708     touchEvent.originalId = arkUITouchEvent->actionTouchPoint.id;
6709     ArkUITouchEvent* arkUITouchEventCloned = const_cast<ArkUITouchEvent*>(arkUITouchEvent);
6710     NG::SetPostPointerEvent(touchEvent, arkUITouchEventCloned);
6711     return PostTouchEventToFrameNode(node, touchEvent);
6712 }
6713 
SetHistoryTouchEvent(ArkUITouchEvent * arkUITouchEventCloned,const ArkUITouchEvent * arkUITouchEvent)6714 void SetHistoryTouchEvent(ArkUITouchEvent* arkUITouchEventCloned, const ArkUITouchEvent* arkUITouchEvent)
6715 {
6716     std::array<ArkUIHistoryTouchEvent, MAX_HISTORY_EVENT_COUNT> allHistoryEvents;
6717     std::array<std::array<ArkUITouchPoint, MAX_POINTS>, MAX_HISTORY_EVENT_COUNT> allHistoryPoints;
6718     if (arkUITouchEvent->historySize > 0) {
6719         for (size_t i = 0; i < arkUITouchEvent->historySize; i++) {
6720             allHistoryEvents[i].action = arkUITouchEvent->historyEvents[i].action;
6721             allHistoryEvents[i].sourceType = arkUITouchEvent->historyEvents[i].sourceType;
6722             allHistoryEvents[i].timeStamp = arkUITouchEvent->historyEvents[i].timeStamp;
6723             allHistoryEvents[i].actionTouchPoint.nodeX = arkUITouchEvent->historyEvents[i].actionTouchPoint.nodeX;
6724             allHistoryEvents[i].actionTouchPoint.nodeY = arkUITouchEvent->historyEvents[i].actionTouchPoint.nodeY;
6725             allHistoryEvents[i].actionTouchPoint.windowX = arkUITouchEvent->historyEvents[i].actionTouchPoint.windowX;
6726             allHistoryEvents[i].actionTouchPoint.windowY = arkUITouchEvent->historyEvents[i].actionTouchPoint.windowY;
6727             allHistoryEvents[i].actionTouchPoint.screenX = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenX;
6728             allHistoryEvents[i].actionTouchPoint.screenY = arkUITouchEvent->historyEvents[i].actionTouchPoint.screenY;
6729             allHistoryEvents[i].actionTouchPoint.pressure =
6730                 arkUITouchEvent->historyEvents[i].actionTouchPoint.pressure;
6731             for (size_t j = 0; j < arkUITouchEvent->historyEvents[i].touchPointSize; j++) {
6732                 allHistoryPoints[i][j].id = arkUITouchEvent->historyEvents[i].touchPointes[j].id;
6733                 allHistoryPoints[i][j].nodeX = arkUITouchEvent->historyEvents[i].touchPointes[j].nodeX;
6734                 allHistoryPoints[i][j].nodeY = arkUITouchEvent->historyEvents[i].touchPointes[j].nodeY;
6735                 allHistoryPoints[i][j].windowX = arkUITouchEvent->historyEvents[i].touchPointes[j].windowX;
6736                 allHistoryPoints[i][j].windowY = arkUITouchEvent->historyEvents[i].touchPointes[j].windowY;
6737                 allHistoryPoints[i][j].screenX = arkUITouchEvent->historyEvents[i].touchPointes[j].screenX;
6738                 allHistoryPoints[i][j].screenY = arkUITouchEvent->historyEvents[i].touchPointes[j].screenY;
6739                 allHistoryPoints[i][j].contactAreaWidth =
6740                     arkUITouchEvent->historyEvents[i].touchPointes[j].contactAreaWidth;
6741                 allHistoryPoints[i][j].contactAreaHeight =
6742                     arkUITouchEvent->historyEvents[i].touchPointes[j].contactAreaHeight;
6743                 allHistoryPoints[i][j].pressure = arkUITouchEvent->historyEvents[i].touchPointes[j].pressure;
6744                 allHistoryPoints[i][j].tiltX = arkUITouchEvent->historyEvents[i].touchPointes[j].tiltX;
6745                 allHistoryPoints[i][j].tiltY = arkUITouchEvent->historyEvents[i].touchPointes[j].tiltY;
6746                 allHistoryPoints[i][j].pressedTime =
6747                     arkUITouchEvent->historyEvents[i].touchPointes[j].pressedTime;
6748                 allHistoryPoints[i][j].toolType = arkUITouchEvent->historyEvents[i].touchPointes[j].toolType;
6749                 allHistoryPoints[i][j].operatingHand =
6750                     arkUITouchEvent->historyEvents[i].touchPointes[j].operatingHand;
6751             }
6752             if (arkUITouchEvent->historyEvents[i].touchPointSize > 0) {
6753                 allHistoryEvents[i].touchPointes = &(allHistoryPoints[i][0]);
6754             }
6755             allHistoryEvents[i].touchPointSize = arkUITouchEvent->historyEvents[i].touchPointSize;
6756         }
6757         arkUITouchEventCloned->historyEvents = &allHistoryEvents[0];
6758         arkUITouchEventCloned->historySize = arkUITouchEvent->historySize;
6759     } else {
6760         arkUITouchEventCloned->historyEvents = nullptr;
6761         arkUITouchEventCloned->historySize = 0;
6762     }
6763 }
6764 
CreateClonedTouchEvent(ArkUITouchEvent * arkUITouchEventCloned,const ArkUITouchEvent * arkUITouchEvent)6765 void CreateClonedTouchEvent(ArkUITouchEvent* arkUITouchEventCloned, const ArkUITouchEvent* arkUITouchEvent)
6766 {
6767     if (!arkUITouchEventCloned || !arkUITouchEvent) {
6768         TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "CreateClonedTouchEvent touchevent is null!");
6769         return;
6770     }
6771     arkUITouchEventCloned->target.id = arkUITouchEvent->target.id;
6772     arkUITouchEventCloned->target.type = arkUITouchEvent->target.type;
6773     arkUITouchEventCloned->target.area = arkUITouchEvent->target.area;
6774     arkUITouchEventCloned->target.origin = arkUITouchEvent->target.origin;
6775     arkUITouchEventCloned->action = arkUITouchEvent->action;
6776     arkUITouchEventCloned->changedPointerId = arkUITouchEvent->changedPointerId;
6777     arkUITouchEventCloned->actionTouchPoint = arkUITouchEvent->actionTouchPoint;
6778     arkUITouchEventCloned->timeStamp = arkUITouchEvent->timeStamp;
6779     arkUITouchEventCloned->sourceType = arkUITouchEvent->sourceType;
6780     arkUITouchEventCloned->targetDisplayId = arkUITouchEvent->targetDisplayId;
6781     arkUITouchEventCloned->deviceId = arkUITouchEvent->deviceId;
6782     MMI::PointerEvent* pointerEvent = reinterpret_cast<MMI::PointerEvent*>(arkUITouchEvent->rawPointerEvent);
6783     NG::SetClonedPointerEvent(pointerEvent, arkUITouchEventCloned);
6784     std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
6785     if (arkUITouchEvent->touchPointSize > 0) {
6786         for (size_t i = 0; i < arkUITouchEvent->touchPointSize; i++) {
6787             touchPoints[i] = arkUITouchEvent->touchPointes[i];
6788         }
6789         arkUITouchEventCloned->touchPointes = &touchPoints[0];
6790         arkUITouchEventCloned->touchPointSize = arkUITouchEvent->touchPointSize;
6791     } else {
6792         arkUITouchEventCloned->touchPointes = nullptr;
6793         arkUITouchEventCloned->touchPointSize = 0;
6794     }
6795     arkUITouchEventCloned->subKind = arkUITouchEvent->subKind;
6796     SetHistoryTouchEvent(arkUITouchEventCloned, arkUITouchEvent);
6797     arkUITouchEventCloned->stopPropagation = arkUITouchEvent->stopPropagation;
6798 }
6799 
DestroyTouchEvent(ArkUITouchEvent * arkUITouchEvent)6800 void DestroyTouchEvent(ArkUITouchEvent* arkUITouchEvent)
6801 {
6802     CHECK_NULL_VOID(arkUITouchEvent);
6803     NG::DestroyRawPointerEvent(arkUITouchEvent);
6804     delete arkUITouchEvent;
6805     arkUITouchEvent = nullptr;
6806 }
6807 
SetOnFocusExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node))6808 void SetOnFocusExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node))
6809 {
6810     auto* uiNode = reinterpret_cast<UINode*>(node);
6811     CHECK_NULL_VOID(uiNode);
6812     auto onFocus = [node, eventReceiver]() {
6813         eventReceiver(node);
6814     };
6815     ViewAbstract::SetOnFocus(reinterpret_cast<FrameNode*>(node), std::move(onFocus));
6816 }
6817 
SetOnBlurExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node))6818 void SetOnBlurExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node))
6819 {
6820     auto* uiNode = reinterpret_cast<UINode*>(node);
6821     CHECK_NULL_VOID(uiNode);
6822     auto onBlur = [node, eventReceiver]() {
6823         eventReceiver(node);
6824     };
6825     ViewAbstract::SetOnBlur(reinterpret_cast<FrameNode*>(node), std::move(onBlur));
6826 }
6827 
SetOnTouchExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node,ArkUINodeEvent event))6828 void SetOnTouchExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node, ArkUINodeEvent event))
6829 {
6830     auto* uiNode = reinterpret_cast<UINode*>(node);
6831     CHECK_NULL_VOID(uiNode);
6832     auto onTouch = [node, eventReceiver](TouchEventInfo& eventInfo) {
6833         ArkUINodeEvent event;
6834         auto target = eventInfo.GetTarget();
6835         event.touchEvent.target.id = target.id.c_str();
6836         event.touchEvent.target.type = target.type.c_str();
6837         const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
6838         if (changeTouch.size() > 0) {
6839             TouchLocationInfo front = changeTouch.front();
6840             event.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
6841         }
6842         eventReceiver(node, event);
6843     };
6844     ViewAbstract::SetOnTouch(reinterpret_cast<FrameNode*>(node), std::move(onTouch));
6845 }
6846 
SetOnHoverExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node,bool isHover))6847 void SetOnHoverExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node, bool isHover))
6848 {
6849     auto* uiNode = reinterpret_cast<UINode*>(node);
6850     CHECK_NULL_VOID(uiNode);
6851     auto onHover = [node, eventReceiver](bool isHover, HoverInfo& info) {
6852         eventReceiver(node, isHover);
6853     };
6854     ViewAbstract::SetOnHover(reinterpret_cast<FrameNode*>(node), std::move(onHover));
6855 }
6856 
SetOnHoverMoveExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node))6857 void SetOnHoverMoveExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node))
6858 {
6859     auto* uiNode = reinterpret_cast<UINode*>(node);
6860     CHECK_NULL_VOID(uiNode);
6861     auto onHoverMove = [node, eventReceiver](HoverInfo& info) {
6862         eventReceiver(node);
6863     };
6864     ViewAbstract::SetOnHoverMove(reinterpret_cast<FrameNode*>(node), std::move(onHoverMove));
6865 }
6866 
SetOnChangeExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node,bool isOn))6867 void SetOnChangeExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node, bool isOn))
6868 {
6869     auto* uiNode = reinterpret_cast<UINode*>(node);
6870     CHECK_NULL_VOID(uiNode);
6871     auto onChange = [node, eventReceiver](const bool isOn) {
6872         eventReceiver(node, isOn);
6873     };
6874     if (uiNode->GetTag() == V2::SWITCH_ETS_TAG) {
6875         ToggleModelNG::OnChange(reinterpret_cast<FrameNode*>(node), std::move(onChange));
6876     } else if (uiNode->GetTag() == V2::CHECK_BOX_ETS_TAG) {
6877         CheckBoxModelNG::SetOnChange(reinterpret_cast<FrameNode*>(node), std::move(onChange));
6878     } else {
6879         RadioModelNG::SetOnChange(reinterpret_cast<FrameNode*>(node), std::move(onChange));
6880     }
6881 }
6882 
SetOnClickExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node,ArkUINodeEvent event))6883 void SetOnClickExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node, ArkUINodeEvent event))
6884 {
6885     auto* uiNode = reinterpret_cast<UINode*>(node);
6886     CHECK_NULL_VOID(uiNode);
6887     auto onClick = [node, eventReceiver](GestureEvent& info) {
6888         ArkUINodeEvent event;
6889         event.kind = COMPONENT_ASYNC_EVENT;
6890         event.componentAsyncEvent.subKind = ON_CLICK;
6891         auto target = info.GetTarget();
6892         event.touchEvent.target = { target.id.c_str(), target.type.c_str(),
6893             { static_cast<ArkUI_Int32>(target.area.GetOffset().GetX().Value()),
6894                 static_cast<ArkUI_Int32>(target.area.GetOffset().GetY().Value()),
6895                 static_cast<ArkUI_Int32>(target.area.GetWidth().Value()),
6896                 static_cast<ArkUI_Int32>(target.area.GetHeight().Value()) },
6897             { static_cast<ArkUI_Int32>(target.origin.GetX().Value()),
6898                 static_cast<ArkUI_Int32>(target.origin.GetY().Value()) } };
6899         Offset globalOffset = info.GetGlobalLocation();
6900         Offset localOffset = info.GetLocalLocation();
6901         Offset screenOffset = info.GetScreenLocation();
6902         // x
6903         event.componentAsyncEvent.data[0].f32 = localOffset.GetX();
6904         // y
6905         event.componentAsyncEvent.data[1].f32 = localOffset.GetY();
6906         // timestamp
6907         event.componentAsyncEvent.data[2].f32 = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
6908         // source
6909         event.componentAsyncEvent.data[3].i32 = static_cast<int32_t>(info.GetSourceDevice());
6910         // windowX
6911         event.componentAsyncEvent.data[4].f32 = globalOffset.GetX();
6912         // windowY
6913         event.componentAsyncEvent.data[5].f32 = globalOffset.GetY();
6914         // displayX
6915         event.componentAsyncEvent.data[6].f32 = screenOffset.GetX();
6916         // displayY
6917         event.componentAsyncEvent.data[7].f32 = screenOffset.GetY();
6918         eventReceiver(node, event);
6919     };
6920     if (uiNode->GetTag() == V2::SPAN_ETS_TAG) {
6921         SpanModelNG::SetOnClick(uiNode, std::move(onClick));
6922     } else if (uiNode->GetTag() == V2::TEXT_ETS_TAG) {
6923         TextModelNG::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onClick));
6924     }  else {
6925         ViewAbstract::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onClick));
6926     }
6927 }
6928 
SetOnAppearExt(ArkUINodeHandle node,void (* eventReceiver)(ArkUINodeHandle node))6929 void SetOnAppearExt(ArkUINodeHandle node, void (*eventReceiver)(ArkUINodeHandle node))
6930 {
6931     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6932     CHECK_NULL_VOID(frameNode);
6933     auto onAppear = [node, weak = AceType::WeakClaim(frameNode), eventReceiver]() {
6934         eventReceiver(node);
6935     };
6936     ViewAbstract::SetOnAppear(frameNode, std::move(onAppear));
6937 }
6938 
SetNodeBackdropBlur(ArkUINodeHandle node,ArkUI_Float32 value,const ArkUI_Float32 * blurValues,ArkUI_Int32 blurValuesSize)6939 void SetNodeBackdropBlur(
6940     ArkUINodeHandle node, ArkUI_Float32 value, const ArkUI_Float32* blurValues, ArkUI_Int32 blurValuesSize)
6941 {
6942     ArkUI_Float32 blur = 0.0f;
6943     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6944     CHECK_NULL_VOID(frameNode);
6945     blur = value > 0 ? value : blur;
6946     BlurOption blurOption;
6947     blurOption.grayscale.assign(blurValues, blurValues + blurValuesSize);
6948     CalcDimension dimensionRadius(blur, DimensionUnit::PX);
6949     ViewAbstract::SetNodeBackdropBlur(frameNode, dimensionRadius, blurOption);
6950 }
6951 
SetPrivacySensitve(ArkUINodeHandle node,ArkUI_Int32 sensitive)6952 void SetPrivacySensitve(ArkUINodeHandle node, ArkUI_Int32 sensitive)
6953 {
6954     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6955     CHECK_NULL_VOID(frameNode);
6956     ViewAbstract::SetPrivacySensitive(frameNode, static_cast<bool>(sensitive));
6957 }
6958 
ResetPrivacySensitve(ArkUINodeHandle node)6959 void ResetPrivacySensitve(ArkUINodeHandle node)
6960 {
6961     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6962     CHECK_NULL_VOID(frameNode);
6963     ViewAbstract::SetPrivacySensitive(frameNode, false);
6964 }
6965 
GetNodeBackdropBlur(ArkUINodeHandle node)6966 ArkUIBackdropBlur GetNodeBackdropBlur(ArkUINodeHandle node)
6967 {
6968     ArkUIBackdropBlur backdropBlur;
6969     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6970     CHECK_NULL_RETURN(frameNode, backdropBlur);
6971     auto renderContext = frameNode->GetRenderContext();
6972     CHECK_NULL_RETURN(renderContext, backdropBlur);
6973     auto blur = renderContext->GetBackBlurRadius();
6974     backdropBlur.dimensionRadius = blur.has_value() ? blur.value().Value() : 0.0f;
6975     auto propBackdropBlurOption = renderContext->GetBackdropBlurOption();
6976     if (propBackdropBlurOption.has_value() && propBackdropBlurOption->grayscale.size() >= NUM_2) {
6977         backdropBlur.brighteningBlur = propBackdropBlurOption->grayscale[NUM_0];
6978         backdropBlur.darkeningBlur = propBackdropBlurOption->grayscale[NUM_1];
6979     }
6980     return backdropBlur;
6981 }
6982 
SetOnVisibleAreaApproximateChange(ArkUINodeHandle node,ArkUI_Int64 extraParam,ArkUI_Float32 * values,ArkUI_Int32 size,ArkUI_Int32 interval)6983 void SetOnVisibleAreaApproximateChange(
6984     ArkUINodeHandle node, ArkUI_Int64 extraParam, ArkUI_Float32* values, ArkUI_Int32 size, ArkUI_Int32 interval)
6985 {
6986     auto* frameNode = reinterpret_cast<FrameNode*>(node);
6987     CHECK_NULL_VOID(frameNode);
6988     int32_t nodeId = frameNode->GetId();
6989     std::vector<double> ratioList(values, values + size);
6990     auto onEvent = [nodeId, extraParam](bool visible, double ratio) {
6991         ArkUINodeEvent event;
6992         event.kind = COMPONENT_ASYNC_EVENT;
6993         event.nodeId = nodeId;
6994         event.extraParam = static_cast<intptr_t>(extraParam);
6995         event.componentAsyncEvent.subKind = ON_VISIBLE_AREA_APPROXIMATE_CHANGE;
6996         event.componentAsyncEvent.data[0].i32 = visible;
6997         event.componentAsyncEvent.data[1].f32 = static_cast<ArkUI_Float32>(ratio);
6998         SendArkUISyncEvent(&event);
6999     };
7000     ViewAbstract::SetOnVisibleAreaApproximateChange(frameNode, onEvent, ratioList, interval);
7001 }
7002 
FreezeUINodeById(ArkUI_CharPtr id,ArkUI_Bool isFreeze)7003 void FreezeUINodeById(ArkUI_CharPtr id, ArkUI_Bool isFreeze)
7004 {
7005     std::string idStr(id);
7006     ViewAbstract::FreezeUINodeById(idStr, isFreeze);
7007 }
7008 
FreezeUINodeByUniqueId(ArkUI_Int32 uniqueId,ArkUI_Bool isFreeze)7009 void FreezeUINodeByUniqueId(ArkUI_Int32 uniqueId, ArkUI_Bool isFreeze)
7010 {
7011     ViewAbstract::FreezeUINodeByUniqueId(uniqueId, isFreeze);
7012 }
7013 
7014 } // namespace
7015 
7016 namespace NodeModifier {
7017 namespace {
7018 OHOS::Ace::TouchEventInfo globalEventInfo("global");
7019 }
7020 
GetCommonModifier()7021 const ArkUICommonModifier* GetCommonModifier()
7022 {
7023     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
7024     static const ArkUICommonModifier modifier = {
7025         .setBackgroundColor = SetBackgroundColor,
7026         .resetBackgroundColor = ResetBackgroundColor,
7027         .setWidth = SetWidth,
7028         .resetWidth = ResetWidth,
7029         .setHeight = SetHeight,
7030         .resetHeight = ResetHeight,
7031         .setBorderRadius = SetBorderRadius,
7032         .resetBorderRadius = ResetBorderRadius,
7033         .setBorderWidth = SetBorderWidth,
7034         .resetBorderWidth = ResetBorderWidth,
7035         .setTransform = SetTransform,
7036         .resetTransform = ResetTransform,
7037         .setBorderColor = SetBorderColor,
7038         .resetBorderColor = ResetBorderColor,
7039         .setPosition = SetPosition,
7040         .resetPosition = ResetPosition,
7041         .setPositionEdges = SetPositionEdges,
7042         .resetPositionEdges = ResetPositionEdges,
7043         .setBorderStyle = SetBorderStyle,
7044         .resetBorderStyle = ResetBorderStyle,
7045         .setBackShadow = SetBackShadow,
7046         .resetBackShadow = ResetBackShadow,
7047         .setHitTestBehavior = SetHitTestBehavior,
7048         .resetHitTestBehavior = ResetHitTestBehavior,
7049         .setZIndex = SetZIndex,
7050         .resetZIndex = ResetZIndex,
7051         .setOpacity = SetOpacity,
7052         .resetOpacity = ResetOpacity,
7053         .setAlign = SetAlign,
7054         .resetAlign = ResetAlign,
7055         .setBackdropBlur = SetBackdropBlur,
7056         .resetBackdropBlur = ResetBackdropBlur,
7057         .setHueRotate = SetHueRotate,
7058         .resetHueRotate = ResetHueRotate,
7059         .setInvert = SetInvert,
7060         .resetInvert = ResetInvert,
7061         .setSepia = SetSepia,
7062         .resetSepia = ResetSepia,
7063         .setSaturate = SetSaturate,
7064         .resetSaturate = ResetSaturate,
7065         .setColorBlend = SetColorBlend,
7066         .resetColorBlend = ResetColorBlend,
7067         .setGrayscale = SetGrayscale,
7068         .resetGrayscale = ResetGrayscale,
7069         .setContrast = SetContrast,
7070         .resetContrast = ResetContrast,
7071         .setBrightness = SetBrightness,
7072         .resetBrightness = ResetBrightness,
7073         .setBlur = SetBlur,
7074         .resetBlur = ResetBlur,
7075         .setLinearGradient = SetLinearGradient,
7076         .resetLinearGradient = ResetLinearGradient,
7077         .setSweepGradient = SetSweepGradient,
7078         .resetSweepGradient = ResetSweepGradient,
7079         .setRadialGradient = SetRadialGradient,
7080         .resetRadialGradient = ResetRadialGradient,
7081         .setOverlay = SetOverlay,
7082         .resetOverlay = ResetOverlay,
7083         .setBorderImage = SetBorderImage,
7084         .resetBorderImage = ResetBorderImage,
7085         .setBorderImageGradient = SetBorderImageGradient,
7086         .setForegroundBlurStyle = SetForegroundBlurStyle,
7087         .resetForegroundBlurStyle = ResetForegroundBlurStyle,
7088         .setLinearGradientBlur = SetLinearGradientBlur,
7089         .resetLinearGradientBlur = ResetLinearGradientBlur,
7090         .setBackgroundBlurStyle = SetBackgroundBlurStyle,
7091         .resetBackgroundBlurStyle = ResetBackgroundBlurStyle,
7092         .setBorder = SetBorder,
7093         .resetBorder = ResetBorder,
7094         .setBackgroundImagePosition = SetBackgroundImagePosition,
7095         .resetBackgroundImagePosition = ResetBackgroundImagePosition,
7096         .setBackgroundImageSize = SetBackgroundImageSize,
7097         .resetBackgroundImageSize = ResetBackgroundImageSize,
7098         .setBackgroundImage = SetBackgroundImage,
7099         .resetBackgroundImage = ResetBackgroundImage,
7100         .setBackgroundImageSyncMode = SetBackgroundImageSyncMode,
7101         .resetBackgroundImageSyncMode = ResetBackgroundImageSyncMode,
7102         .setTranslate = SetTranslate,
7103         .resetTranslate = ResetTranslate,
7104         .setScale = SetScale,
7105         .setScaleWithoutTransformCenter = SetScaleWithoutTransformCenter,
7106         .resetScale = ResetScale,
7107         .setRotate = SetRotate,
7108         .setRotateWithoutTransformCenter = SetRotateWithoutTransformCenter,
7109         .resetRotate = ResetRotate,
7110         .setGeometryTransition = SetGeometryTransition,
7111         .resetGeometryTransition = ResetGeometryTransition,
7112         .setBindTips = SetBindTips,
7113         .resetBindTips = ResetBindTips,
7114         .setPixelStretchEffect = SetPixelStretchEffect,
7115         .resetPixelStretchEffect = ResetPixelStretchEffect,
7116         .setLightUpEffect = SetLightUpEffect,
7117         .resetLightUpEffect = ResetLightUpEffect,
7118         .setSphericalEffect = SetSphericalEffect,
7119         .resetSphericalEffect = ResetSphericalEffect,
7120         .setRenderGroup = SetRenderGroup,
7121         .resetRenderGroup = ResetRenderGroup,
7122         .setRenderFit = SetRenderFit,
7123         .resetRenderFit = ResetRenderFit,
7124         .setUseEffect = SetUseEffect,
7125         .resetUseEffect = ResetUseEffect,
7126         .setForegroundColor = SetForegroundColor,
7127         .resetForegroundColor = ResetForegroundColor,
7128         .setMotionPath = SetMotionPath,
7129         .resetMotionPath = ResetMotionPath,
7130         .setMotionBlur = SetMotionBlur,
7131         .resetMotionBlur = ResetMotionBlur,
7132         .setGroupDefaultFocus = SetGroupDefaultFocus,
7133         .resetGroupDefaultFocus = ResetGroupDefaultFocus,
7134         .setFocusOnTouch = SetFocusOnTouch,
7135         .resetFocusOnTouch = ResetFocusOnTouch,
7136         .setFocusable = SetFocusable,
7137         .resetFocusable = ResetFocusable,
7138         .setTouchable = SetTouchable,
7139         .resetTouchable = ResetTouchable,
7140         .setDefaultFocus = SetDefaultFocus,
7141         .resetDefaultFocus = ResetDefaultFocus,
7142         .setDisplayPriority = SetDisplayPriority,
7143         .resetDisplayPriority = ResetDisplayPriority,
7144         .setOffset = SetOffset,
7145         .setOffsetEdges = SetOffsetEdges,
7146         .resetOffset = ResetOffset,
7147         .setPadding = SetPadding,
7148         .resetPadding = ResetPadding,
7149         .setMargin = SetMargin,
7150         .resetMargin = ResetMargin,
7151         .setSafeAreaPadding = SetSafeAreaPadding,
7152         .resetSafeAreaPadding = ResetSafeAreaPadding,
7153         .setMarkAnchor = SetMarkAnchor,
7154         .resetMarkAnchor = ResetMarkAnchor,
7155         .setVisibility = SetVisibility,
7156         .resetVisibility = ResetVisibility,
7157         .setAccessibilityText = SetAccessibilityText,
7158         .resetAccessibilityText = ResetAccessibilityText,
7159         .setAllowDrop = SetAllowDrop,
7160         .resetAllowDrop = ResetAllowDrop,
7161         .setAccessibilityLevel = SetAccessibilityLevel,
7162         .resetAccessibilityLevel = ResetAccessibilityLevel,
7163         .setAccessibilityCustomRole = SetAccessibilityCustomRole,
7164         .resetAccessibilityCustomRole = ResetAccessibilityCustomRole,
7165         .setDirection = SetDirection,
7166         .resetDirection = ResetDirection,
7167         .setLayoutWeight = SetLayoutWeight,
7168         .resetLayoutWeight = ResetLayoutWeight,
7169         .setMinWidth = SetMinWidth,
7170         .resetMinWidth = ResetMinWidth,
7171         .setMaxWidth = SetMaxWidth,
7172         .resetMaxWidth = ResetMaxWidth,
7173         .setMinHeight = SetMinHeight,
7174         .resetMinHeight = ResetMinHeight,
7175         .setMaxHeight = SetMaxHeight,
7176         .resetMaxHeight = ResetMaxHeight,
7177         .setSize = SetSize,
7178         .resetSize = ResetSize,
7179         .clearWidthOrHeight = ClearWidthOrHeight,
7180         .setAlignSelf = SetAlignSelf,
7181         .resetAlignSelf = ResetAlignSelf,
7182         .setAspectRatio = SetAspectRatio,
7183         .resetAspectRatio = ResetAspectRatio,
7184         .setFlexGrow = SetFlexGrow,
7185         .resetFlexGrow = ResetFlexGrow,
7186         .setFlexShrink = SetFlexShrink,
7187         .resetFlexShrink = ResetFlexShrink,
7188         .setGridOffset = SetGridOffset,
7189         .resetGridOffset = ResetGridOffset,
7190         .setGridSpan = SetGridSpan,
7191         .resetGridSpan = ResetGridSpan,
7192         .setExpandSafeArea = SetExpandSafeArea,
7193         .resetExpandSafeArea = ResetExpandSafeArea,
7194         .setFlexBasis = SetFlexBasis,
7195         .resetFlexBasis = ResetFlexBasis,
7196         .setAlignRules = SetAlignRules,
7197         .resetAlignRules = ResetAlignRules,
7198         .setAccessibilityDescription = SetAccessibilityDescription,
7199         .resetAccessibilityDescription = ResetAccessibilityDescription,
7200         .setId = SetId,
7201         .resetId = ResetId,
7202         .setKey = SetKey,
7203         .resetKey = ResetKey,
7204         .setRestoreId = SetRestoreId,
7205         .resetRestoreId = ResetRestoreId,
7206         .setTabIndex = SetTabIndex,
7207         .resetTabIndex = ResetTabIndex,
7208         .setObscured = SetObscured,
7209         .resetObscured = ResetObscured,
7210         .setResponseRegion = SetResponseRegion,
7211         .resetResponseRegion = ResetResponseRegion,
7212         .setForegroundEffect = SetForegroundEffect,
7213         .resetForegroundEffect = ResetForegroundEffect,
7214         .setBackgroundEffect = SetBackgroundEffect,
7215         .resetBackgroundEffect = ResetBackgroundEffect,
7216         .setBackgroundBrightness = SetBackgroundBrightness,
7217         .resetBackgroundBrightness = ResetBackgroundBrightness,
7218         .setBackgroundBrightnessInternal = SetBackgroundBrightnessInternal,
7219         .resetBackgroundBrightnessInternal = ResetBackgroundBrightnessInternal,
7220         .setForegroundBrightness = SetForegroundBrightness,
7221         .resetForegroundBrightness = ResetForegroundBrightness,
7222         .setDragPreviewOptions = SetDragPreviewOptions,
7223         .resetDragPreviewOptions = ResetDragPreviewOptions,
7224         .setMouseResponseRegion = SetMouseResponseRegion,
7225         .resetMouseResponseRegion = ResetMouseResponseRegion,
7226         .setEnabled = SetEnabled,
7227         .resetEnabled = ResetEnabled,
7228         .setUseShadowBatching = SetUseShadowBatching,
7229         .resetUseShadowBatching = ResetUseShadowBatching,
7230         .setDraggable = SetDraggable,
7231         .resetDraggable = ResetDraggable,
7232         .setAccessibilityGroup = SetAccessibilityGroup,
7233         .resetAccessibilityGroup = ResetAccessibilityGroup,
7234         .setAccessibilityNextFocusId = SetAccessibilityNextFocusId,
7235         .resetAccessibilityNextFocusId = ResetAccessibilityNextFocusId,
7236         .setAccessibilityDefaultFocus = SetAccessibilityDefaultFocus,
7237         .resetAccessibilityDefaultFocus = ResetAccessibilityDefaultFocus,
7238         .setAccessibilityUseSamePage = SetAccessibilityUseSamePage,
7239         .resetAccessibilityUseSamePage = ResetAccessibilityUseSamePage,
7240         .setAccessibilityScrollTriggerable = SetAccessibilityScrollTriggerable,
7241         .resetAccessibilityScrollTriggerable = ResetAccessibilityScrollTriggerable,
7242         .setAccessibilityFocusDrawLevel = SetAccessibilityFocusDrawLevel,
7243         .resetAccessibilityFocusDrawLevel = ResetAccessibilityFocusDrawLevel,
7244         .setHoverEffect = SetHoverEffect,
7245         .resetHoverEffect = ResetHoverEffect,
7246         .setClickEffect = SetClickEffect,
7247         .resetClickEffect = ResetClickEffect,
7248         .setKeyBoardShortCut = SetKeyBoardShortCut,
7249         .resetKeyBoardShortCut = ResetKeyBoardShortCut,
7250         .setPointLightPosition = SetPointLightPosition,
7251         .resetPointLightPosition = ResetPointLightPosition,
7252         .setPointLightIntensity = SetPointLightIntensity,
7253         .resetPointLightIntensity = ResetPointLightIntensity,
7254         .setPointLightColor = SetPointLightColor,
7255         .resetPointLightColor = ResetPointLightColor,
7256         .setPointLightIlluminated = SetPointLightIlluminated,
7257         .resetPointLightIlluminated = ResetPointLightIlluminated,
7258         .setPointLightBloom = SetPointLightBloom,
7259         .resetPointLightBloom = ResetPointLightBloom,
7260         .setClip = SetClip,
7261         .setClipShape = SetClipShape,
7262         .setClipPath = SetClipPath,
7263         .resetClip = ResetClip,
7264         .setTransitionCenter = SetTransitionCenter,
7265         .setOpacityTransition = SetOpacityTransition,
7266         .setRotateTransition = SetRotateTransition,
7267         .setScaleTransition = SetScaleTransition,
7268         .setTranslateTransition = SetTranslateTransition,
7269         .setMaskShape = SetMaskShape,
7270         .setMaskPath = SetMaskPath,
7271         .setProgressMask = SetProgressMask,
7272         .setBlendMode = SetBlendMode,
7273         .resetBlendMode = ResetBlendMode,
7274         .setMonopolizeEvents = SetMonopolizeEvents,
7275         .resetMonopolizeEvents = ResetMonopolizeEvents,
7276         .setConstraintSize = SetConstraintSize,
7277         .resetConstraintSize = ResetConstraintSize,
7278         .setOutlineColor = SetOutlineColor,
7279         .resetOutlineColor = ResetOutlineColor,
7280         .setOutlineRadius = SetOutlineRadius,
7281         .resetOutlineRadius = ResetOutlineRadius,
7282         .setOutlineWidth = SetOutlineWidth,
7283         .resetOutlineWidth = ResetOutlineWidth,
7284         .setOutlineStyle = SetOutlineStyle,
7285         .resetOutlineStyle = ResetOutlineStyle,
7286         .setOutline = SetOutline,
7287         .resetOutline = ResetOutline,
7288         .setBindPopup = SetBindPopup,
7289         .resetBindPopup = ResetBindPopup,
7290         .getFocusable = GetFocusable,
7291         .getDefaultFocus = GetDefaultFocus,
7292         .getResponseRegion = GetResponseRegion,
7293         .getOverlay = GetOverlay,
7294         .getAccessibilityGroup = GetAccessibilityGroup,
7295         .getAccessibilityText = GetAccessibilityText,
7296         .getAccessibilityDescription = GetAccessibilityDescription,
7297         .getAccessibilityLevel = GetAccessibilityLevel,
7298         .setNeedFocus = SetNeedFocus,
7299         .getNeedFocus = GetNeedFocus,
7300         .getOpacity = GetOpacity,
7301         .getBorderWidth = GetBorderWidth,
7302         .getBorderWidthDimension = GetBorderWidthDimension,
7303         .getBorderRadius = GetBorderRadius,
7304         .getBorderColor = GetBorderColor,
7305         .getBorderStyle = GetBorderStyle,
7306         .getZIndex = GetZIndex,
7307         .getVisibility = GetVisibility,
7308         .getClip = GetClip,
7309         .getClipShape = GetClipShape,
7310         .getTransform = GetTransform,
7311         .getHitTestBehavior = GetHitTestBehavior,
7312         .getPosition = GetPosition,
7313         .getShadow = GetShadow,
7314         .getCustomShadow = GetCustomShadow,
7315         .getSweepGradient = GetSweepGradient,
7316         .getRadialGradient = GetRadialGradient,
7317         .getMask = GetMask,
7318         .getBlendMode = GetBlendMode,
7319         .getDirection = GetDirection,
7320         .getAlignSelf = GetAlignSelf,
7321         .getTransformCenter = GetTransformCenter,
7322         .getOpacityTransition = GetOpacityTransition,
7323         .getRotateTransition = GetRotateTransition,
7324         .getScaleTransition = GetScaleTransition,
7325         .getTranslateTransition = GetTranslateTransition,
7326         .getOffset = GetOffset,
7327         .getMarkAnchor = GetMarkAnchor,
7328         .getAlignRules = GetAlignRules,
7329         .getBackgroundBlurStyle = GetBackgroundBlurStyle,
7330         .getBackgroundImageSize = GetBackgroundImageSize,
7331         .getBackgroundImageSizeWithStyle = GetBackgroundImageSizeWidthStyle,
7332         .setOutlineWidthFloat = SetOutlineWidthFloat,
7333         .getOutlineWidthFloat = GetOutlineWidthFloat,
7334         .getDisplayPriority = GetDisplayPriority,
7335         .setAlignRulesWidthType = SetAlignRulesWidthType,
7336         .getLayoutWeight = GetLayoutWeight,
7337         .getScale = GetScale,
7338         .getRotate = GetRotate,
7339         .getBrightness = GetBrightness,
7340         .getSaturate = GetSaturate,
7341         .getBackgroundImagePosition = GetBackgroundImagePosition,
7342         .getFlexGrow = GetFlexGrow,
7343         .getFlexShrink = GetFlexShrink,
7344         .getFlexBasis = GetFlexBasis,
7345         .getConstraintSize = GetConstraintSize,
7346         .getGrayScale = GetGrayScale,
7347         .getInvert = GetInvert,
7348         .getSepia = GetSepia,
7349         .getContrast = GetContrast,
7350         .getForegroundColor = GetForegroundColor,
7351         .getBlur = GetBlur,
7352         .getLinearGradient = GetLinearGradient,
7353         .getAlign = GetAlign,
7354         .getWidth = GetWidth,
7355         .getHeight = GetHeight,
7356         .getBackgroundColor = GetBackgroundColor,
7357         .getBackgroundImage = GetBackgroundImage,
7358         .getPadding = GetPadding,
7359         .getPaddingDimension = GetPaddingDimension,
7360         .getConfigSize = GetConfigSize,
7361         .getKey = GetKey,
7362         .getEnabled = GetEnabled,
7363         .getMargin = GetMargin,
7364         .getMarginDimension = GetMarginDimension,
7365         .getTranslate = GetTranslate,
7366         .setMoveTransition = SetMoveTransition,
7367         .getMoveTransition = GetMoveTransition,
7368         .resetMask = ResetMask,
7369         .getAspectRatio = GetAspectRatio,
7370         .setBackgroundImageResizable = SetBackgroundImageResizable,
7371         .getBackgroundImageResizable = GetBackgroundImageResizable,
7372         .resetBackgroundImageResizable = ResetBackgroundImageResizable,
7373         .setBackgroundImageSizeWithUnit = SetBackgroundImageSizeWithUnit,
7374         .getRenderFit = GetRenderFit,
7375         .getOutlineColor = GetOutlineColor,
7376         .getSize = GetSize,
7377         .getRenderGroup = GetRenderGroup,
7378         .setOnVisibleAreaChange = SetOnVisibleAreaChange,
7379         .getGeometryTransition = GetGeometryTransition,
7380         .setChainStyle = SetChainStyle,
7381         .getChainStyle = GetChainStyle,
7382         .resetChainStyle = ResetChainStyle,
7383         .setBias = SetBias,
7384         .getBias = GetBias,
7385         .resetBias = ResetBias,
7386         .getColorBlend = GetColorBlend,
7387         .getForegroundBlurStyle = GetForegroundBlurStyle,
7388         .setBackgroundImagePixelMap = SetBackgroundImagePixelMap,
7389         .setBackgroundImagePixelMapByPixelMapPtr = SetBackgroundImagePixelMapByPixelMapPtr,
7390         .setLayoutRect = SetLayoutRect,
7391         .getLayoutRect = GetLayoutRect,
7392         .resetLayoutRect = ResetLayoutRect,
7393         .getFocusOnTouch = GetFocusOnTouch,
7394         .setSystemBarEffect = SetSystemBarEffect,
7395         .getAccessibilityID = GetAccessibilityID,
7396         .setAccessibilityState = SetAccessibilityState,
7397         .getAccessibilityState = GetAccessibilityState,
7398         .resetAccessibilityState = ResetAccessibilityState,
7399         .setAccessibilityValue = SetAccessibilityValue,
7400         .getAccessibilityValue = GetAccessibilityValue,
7401         .resetAccessibilityValue = ResetAccessibilityValue,
7402         .setAccessibilityActions = SetAccessibilityActions,
7403         .resetAccessibilityActions = ResetAccessibilityActions,
7404         .getAccessibilityActions = GetAccessibilityActions,
7405         .setAccessibilityRole = SetAccessibilityRole,
7406         .resetAccessibilityRole = ResetAccessibilityRole,
7407         .getAccessibilityRole = GetAccessibilityRole,
7408         .setFocusScopeId = SetFocusScopeId,
7409         .resetFocusScopeId = ResetFocusScopeId,
7410         .setFocusScopePriority = SetFocusScopePriority,
7411         .resetFocusScopePriority = ResetFocusScopePriority,
7412         .setPixelRound = SetPixelRound,
7413         .resetPixelRound = ResetPixelRound,
7414         .setBorderDashParams = SetBorderDashParams,
7415         .getExpandSafeArea = GetExpandSafeArea,
7416         .setTransition = SetTransition,
7417         .setDragPreview = SetDragPreview,
7418         .resetDragPreview = ResetDragPreview,
7419         .getNodeUniqueId = GetNodeUniqueId,
7420         .setNextFocus = SetNextFocus,
7421         .setNextFocusOneByOne = SetNextFocusOneByOne,
7422         .resetNextFocus = ResetNextFocus,
7423         .setFocusBoxStyle = SetFocusBoxStyle,
7424         .resetFocusBoxStyle = ResetFocusBoxStyle,
7425         .setClickDistance = SetClickDistance,
7426         .resetClickDistance = ResetClickDistance,
7427         .setDisAllowDrop = SetDisAllowDrop,
7428         .setBlendModeByBlender = SetBlendModeByBlender,
7429         .setTabStop = SetTabStop,
7430         .resetTabStop = ResetTabStop,
7431         .getTabStop = GetTabStop,
7432         .setOnFocus = SetOnFocusExt,
7433         .setOnBlur = SetOnBlurExt,
7434         .setOnTouch = SetOnTouchExt,
7435         .setOnHover = SetOnHoverExt,
7436         .setOnHoverMove = SetOnHoverMoveExt,
7437         .setOnChange = SetOnChangeExt,
7438         .setOnClick = SetOnClickExt,
7439         .setOnAppear = SetOnAppearExt,
7440         .dispatchKeyEvent = DispatchKeyEvent,
7441         .postTouchEvent = PostTouchEvent,
7442         .createClonedTouchEvent = CreateClonedTouchEvent,
7443         .destroyTouchEvent = DestroyTouchEvent,
7444         .resetEnableAnalyzer = nullptr,
7445         .setEnableAnalyzer = nullptr,
7446         .setNodeBackdropBlur = SetNodeBackdropBlur,
7447         .getNodeBackdropBlur = GetNodeBackdropBlur,
7448         .setDisableDataPrefetch = SetDisableDataPrefetch,
7449         .setOnVisibleAreaApproximateChange = SetOnVisibleAreaApproximateChange,
7450         .setPrivacySensitive = SetPrivacySensitve,
7451         .resetPrivacySensitive = ResetPrivacySensitve,
7452         .freezeUINodeById = FreezeUINodeById,
7453         .freezeUINodeByUniqueId = FreezeUINodeByUniqueId,
7454     };
7455     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
7456 
7457     return &modifier;
7458 }
7459 
GetCJUICommonModifier()7460 const CJUICommonModifier* GetCJUICommonModifier()
7461 {
7462     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
7463     static const CJUICommonModifier modifier = {
7464         .setBackgroundColor = SetBackgroundColor,
7465         .resetBackgroundColor = ResetBackgroundColor,
7466         .setWidth = SetWidth,
7467         .resetWidth = ResetWidth,
7468         .setHeight = SetHeight,
7469         .resetHeight = ResetHeight,
7470         .setBorderRadius = SetBorderRadius,
7471         .resetBorderRadius = ResetBorderRadius,
7472         .setBorderWidth = SetBorderWidth,
7473         .resetBorderWidth = ResetBorderWidth,
7474         .setTransform = SetTransform,
7475         .resetTransform = ResetTransform,
7476         .setBorderColor = SetBorderColor,
7477         .resetBorderColor = ResetBorderColor,
7478         .setPosition = SetPosition,
7479         .resetPosition = ResetPosition,
7480         .setPositionEdges = SetPositionEdges,
7481         .resetPositionEdges = ResetPositionEdges,
7482         .setBorderStyle = SetBorderStyle,
7483         .resetBorderStyle = ResetBorderStyle,
7484         .setBackShadow = SetBackShadow,
7485         .resetBackShadow = ResetBackShadow,
7486         .setHitTestBehavior = SetHitTestBehavior,
7487         .resetHitTestBehavior = ResetHitTestBehavior,
7488         .setZIndex = SetZIndex,
7489         .resetZIndex = ResetZIndex,
7490         .setOpacity = SetOpacity,
7491         .resetOpacity = ResetOpacity,
7492         .setAlign = SetAlign,
7493         .resetAlign = ResetAlign,
7494         .setBackdropBlur = SetBackdropBlur,
7495         .resetBackdropBlur = ResetBackdropBlur,
7496         .setHueRotate = SetHueRotate,
7497         .resetHueRotate = ResetHueRotate,
7498         .setInvert = SetInvert,
7499         .resetInvert = ResetInvert,
7500         .setSepia = SetSepia,
7501         .resetSepia = ResetSepia,
7502         .setSaturate = SetSaturate,
7503         .resetSaturate = ResetSaturate,
7504         .setColorBlend = SetColorBlend,
7505         .resetColorBlend = ResetColorBlend,
7506         .setGrayscale = SetGrayscale,
7507         .resetGrayscale = ResetGrayscale,
7508         .setContrast = SetContrast,
7509         .resetContrast = ResetContrast,
7510         .setBrightness = SetBrightness,
7511         .resetBrightness = ResetBrightness,
7512         .setBlur = SetBlur,
7513         .resetBlur = ResetBlur,
7514         .setLinearGradient = SetLinearGradient,
7515         .resetLinearGradient = ResetLinearGradient,
7516         .setSweepGradient = SetSweepGradient,
7517         .resetSweepGradient = ResetSweepGradient,
7518         .setRadialGradient = SetRadialGradient,
7519         .resetRadialGradient = ResetRadialGradient,
7520         .setOverlay = SetOverlay,
7521         .resetOverlay = ResetOverlay,
7522         .setBorderImage = SetBorderImage,
7523         .resetBorderImage = ResetBorderImage,
7524         .setBorderImageGradient = SetBorderImageGradient,
7525         .setForegroundBlurStyle = SetForegroundBlurStyle,
7526         .resetForegroundBlurStyle = ResetForegroundBlurStyle,
7527         .setLinearGradientBlur = SetLinearGradientBlur,
7528         .resetLinearGradientBlur = ResetLinearGradientBlur,
7529         .setBackgroundBlurStyle = SetBackgroundBlurStyle,
7530         .resetBackgroundBlurStyle = ResetBackgroundBlurStyle,
7531         .setBorder = SetBorder,
7532         .resetBorder = ResetBorder,
7533         .setBackgroundImagePosition = SetBackgroundImagePosition,
7534         .resetBackgroundImagePosition = ResetBackgroundImagePosition,
7535         .setBackgroundImageSize = SetBackgroundImageSize,
7536         .resetBackgroundImageSize = ResetBackgroundImageSize,
7537         .setBackgroundImage = SetBackgroundImage,
7538         .resetBackgroundImage = ResetBackgroundImage,
7539         .setTranslate = SetTranslate,
7540         .resetTranslate = ResetTranslate,
7541         .setScale = SetScale,
7542         .setScaleWithoutTransformCenter = SetScaleWithoutTransformCenter,
7543         .resetScale = ResetScale,
7544         .setRotate = SetRotate,
7545         .setRotateWithoutTransformCenter = SetRotateWithoutTransformCenter,
7546         .resetRotate = ResetRotate,
7547         .setGeometryTransition = SetGeometryTransition,
7548         .resetGeometryTransition = ResetGeometryTransition,
7549         .setPixelStretchEffect = SetPixelStretchEffect,
7550         .resetPixelStretchEffect = ResetPixelStretchEffect,
7551         .setLightUpEffect = SetLightUpEffect,
7552         .resetLightUpEffect = ResetLightUpEffect,
7553         .setSphericalEffect = SetSphericalEffect,
7554         .resetSphericalEffect = ResetSphericalEffect,
7555         .setRenderGroup = SetRenderGroup,
7556         .resetRenderGroup = ResetRenderGroup,
7557         .setRenderFit = SetRenderFit,
7558         .resetRenderFit = ResetRenderFit,
7559         .setUseEffect = SetUseEffect,
7560         .resetUseEffect = ResetUseEffect,
7561         .setForegroundColor = SetForegroundColor,
7562         .resetForegroundColor = ResetForegroundColor,
7563         .setMotionPath = SetMotionPath,
7564         .resetMotionPath = ResetMotionPath,
7565         .setMotionBlur = SetMotionBlur,
7566         .resetMotionBlur = ResetMotionBlur,
7567         .setGroupDefaultFocus = SetGroupDefaultFocus,
7568         .resetGroupDefaultFocus = ResetGroupDefaultFocus,
7569         .setFocusOnTouch = SetFocusOnTouch,
7570         .resetFocusOnTouch = ResetFocusOnTouch,
7571         .setFocusable = SetFocusable,
7572         .resetFocusable = ResetFocusable,
7573         .setTouchable = SetTouchable,
7574         .resetTouchable = ResetTouchable,
7575         .setDefaultFocus = SetDefaultFocus,
7576         .resetDefaultFocus = ResetDefaultFocus,
7577         .setDisplayPriority = SetDisplayPriority,
7578         .resetDisplayPriority = ResetDisplayPriority,
7579         .setOffset = SetOffset,
7580         .setOffsetEdges = SetOffsetEdges,
7581         .resetOffset = ResetOffset,
7582         .setPadding = SetPadding,
7583         .resetPadding = ResetPadding,
7584         .setMargin = SetMargin,
7585         .resetMargin = ResetMargin,
7586         .setMarkAnchor = SetMarkAnchor,
7587         .resetMarkAnchor = ResetMarkAnchor,
7588         .setVisibility = SetVisibility,
7589         .resetVisibility = ResetVisibility,
7590         .setAccessibilityText = SetAccessibilityText,
7591         .resetAccessibilityText = ResetAccessibilityText,
7592         .setAllowDrop = SetAllowDrop,
7593         .resetAllowDrop = ResetAllowDrop,
7594         .setAccessibilityLevel = SetAccessibilityLevel,
7595         .resetAccessibilityLevel = ResetAccessibilityLevel,
7596         .setAccessibilityCustomRole = SetAccessibilityCustomRole,
7597         .resetAccessibilityCustomRole = ResetAccessibilityCustomRole,
7598         .setDirection = SetDirection,
7599         .resetDirection = ResetDirection,
7600         .setLayoutWeight = SetLayoutWeight,
7601         .resetLayoutWeight = ResetLayoutWeight,
7602         .setMinWidth = SetMinWidth,
7603         .resetMinWidth = ResetMinWidth,
7604         .setMaxWidth = SetMaxWidth,
7605         .resetMaxWidth = ResetMaxWidth,
7606         .setMinHeight = SetMinHeight,
7607         .resetMinHeight = ResetMinHeight,
7608         .setMaxHeight = SetMaxHeight,
7609         .resetMaxHeight = ResetMaxHeight,
7610         .setSize = SetSize,
7611         .resetSize = ResetSize,
7612         .clearWidthOrHeight = ClearWidthOrHeight,
7613         .setAlignSelf = SetAlignSelf,
7614         .resetAlignSelf = ResetAlignSelf,
7615         .setAspectRatio = SetAspectRatio,
7616         .resetAspectRatio = ResetAspectRatio,
7617         .setFlexGrow = SetFlexGrow,
7618         .resetFlexGrow = ResetFlexGrow,
7619         .setFlexShrink = SetFlexShrink,
7620         .resetFlexShrink = ResetFlexShrink,
7621         .setGridOffset = SetGridOffset,
7622         .resetGridOffset = ResetGridOffset,
7623         .setGridSpan = SetGridSpan,
7624         .resetGridSpan = ResetGridSpan,
7625         .setExpandSafeArea = SetExpandSafeArea,
7626         .resetExpandSafeArea = ResetExpandSafeArea,
7627         .setFlexBasis = SetFlexBasis,
7628         .resetFlexBasis = ResetFlexBasis,
7629         .setAlignRules = SetAlignRules,
7630         .resetAlignRules = ResetAlignRules,
7631         .setAccessibilityDescription = SetAccessibilityDescription,
7632         .resetAccessibilityDescription = ResetAccessibilityDescription,
7633         .setId = SetId,
7634         .resetId = ResetId,
7635         .setKey = SetKey,
7636         .resetKey = ResetKey,
7637         .setRestoreId = SetRestoreId,
7638         .resetRestoreId = ResetRestoreId,
7639         .setTabIndex = SetTabIndex,
7640         .resetTabIndex = ResetTabIndex,
7641         .setObscured = SetObscured,
7642         .resetObscured = ResetObscured,
7643         .setResponseRegion = SetResponseRegion,
7644         .resetResponseRegion = ResetResponseRegion,
7645         .setForegroundEffect = SetForegroundEffect,
7646         .resetForegroundEffect = ResetForegroundEffect,
7647         .setBackgroundEffect = SetBackgroundEffect,
7648         .resetBackgroundEffect = ResetBackgroundEffect,
7649         .setBackgroundBrightness = SetBackgroundBrightness,
7650         .resetBackgroundBrightness = ResetBackgroundBrightness,
7651         .setBackgroundBrightnessInternal = SetBackgroundBrightnessInternal,
7652         .resetBackgroundBrightnessInternal = ResetBackgroundBrightnessInternal,
7653         .setForegroundBrightness = SetForegroundBrightness,
7654         .resetForegroundBrightness = ResetForegroundBrightness,
7655         .setDragPreviewOptions = SetDragPreviewOptions,
7656         .resetDragPreviewOptions = ResetDragPreviewOptions,
7657         .setMouseResponseRegion = SetMouseResponseRegion,
7658         .resetMouseResponseRegion = ResetMouseResponseRegion,
7659         .setEnabled = SetEnabled,
7660         .resetEnabled = ResetEnabled,
7661         .setUseShadowBatching = SetUseShadowBatching,
7662         .resetUseShadowBatching = ResetUseShadowBatching,
7663         .setDraggable = SetDraggable,
7664         .resetDraggable = ResetDraggable,
7665         .setAccessibilityGroup = SetAccessibilityGroup,
7666         .resetAccessibilityGroup = ResetAccessibilityGroup,
7667         .setHoverEffect = SetHoverEffect,
7668         .resetHoverEffect = ResetHoverEffect,
7669         .setClickEffect = SetClickEffect,
7670         .resetClickEffect = ResetClickEffect,
7671         .setKeyBoardShortCut = SetKeyBoardShortCut,
7672         .resetKeyBoardShortCut = ResetKeyBoardShortCut,
7673         .setPointLightPosition = SetPointLightPosition,
7674         .resetPointLightPosition = ResetPointLightPosition,
7675         .setPointLightIntensity = SetPointLightIntensity,
7676         .resetPointLightIntensity = ResetPointLightIntensity,
7677         .setPointLightColor = SetPointLightColor,
7678         .resetPointLightColor = ResetPointLightColor,
7679         .setPointLightIlluminated = SetPointLightIlluminated,
7680         .resetPointLightIlluminated = ResetPointLightIlluminated,
7681         .setPointLightBloom = SetPointLightBloom,
7682         .resetPointLightBloom = ResetPointLightBloom,
7683         .setClip = SetClip,
7684         .setClipShape = SetClipShape,
7685         .setClipPath = SetClipPath,
7686         .resetClip = ResetClip,
7687         .setTransitionCenter = SetTransitionCenter,
7688         .setOpacityTransition = SetOpacityTransition,
7689         .setRotateTransition = SetRotateTransition,
7690         .setScaleTransition = SetScaleTransition,
7691         .setTranslateTransition = SetTranslateTransition,
7692         .setMaskShape = SetMaskShape,
7693         .setMaskPath = SetMaskPath,
7694         .setProgressMask = SetProgressMask,
7695         .setBlendMode = SetBlendMode,
7696         .resetBlendMode = ResetBlendMode,
7697         .setMonopolizeEvents = SetMonopolizeEvents,
7698         .resetMonopolizeEvents = ResetMonopolizeEvents,
7699         .setConstraintSize = SetConstraintSize,
7700         .resetConstraintSize = ResetConstraintSize,
7701         .setOutlineColor = SetOutlineColor,
7702         .resetOutlineColor = ResetOutlineColor,
7703         .setOutlineRadius = SetOutlineRadius,
7704         .resetOutlineRadius = ResetOutlineRadius,
7705         .setOutlineWidth = SetOutlineWidth,
7706         .resetOutlineWidth = ResetOutlineWidth,
7707         .setOutlineStyle = SetOutlineStyle,
7708         .resetOutlineStyle = ResetOutlineStyle,
7709         .setOutline = SetOutline,
7710         .resetOutline = ResetOutline,
7711         .setBindPopup = SetBindPopup,
7712         .resetBindPopup = ResetBindPopup,
7713         .getFocusable = GetFocusable,
7714         .getDefaultFocus = GetDefaultFocus,
7715         .getResponseRegion = GetResponseRegion,
7716         .getOverlay = GetOverlay,
7717         .getAccessibilityGroup = GetAccessibilityGroup,
7718         .getAccessibilityText = GetAccessibilityText,
7719         .getAccessibilityDescription = GetAccessibilityDescription,
7720         .getAccessibilityLevel = GetAccessibilityLevel,
7721         .setNeedFocus = SetNeedFocus,
7722         .getNeedFocus = GetNeedFocus,
7723         .getOpacity = GetOpacity,
7724         .getBorderWidth = GetBorderWidth,
7725         .getBorderWidthDimension = GetBorderWidthDimension,
7726         .getBorderRadius = GetBorderRadius,
7727         .getBorderColor = GetBorderColor,
7728         .getBorderStyle = GetBorderStyle,
7729         .getZIndex = GetZIndex,
7730         .getVisibility = GetVisibility,
7731         .getClip = GetClip,
7732         .getClipShape = GetClipShape,
7733         .getTransform = GetTransform,
7734         .getHitTestBehavior = GetHitTestBehavior,
7735         .getPosition = GetPosition,
7736         .getShadow = GetShadow,
7737         .getCustomShadow = GetCustomShadow,
7738         .getSweepGradient = GetSweepGradient,
7739         .getRadialGradient = GetRadialGradient,
7740         .getMask = GetMask,
7741         .getBlendMode = GetBlendMode,
7742         .getDirection = GetDirection,
7743         .getAlignSelf = GetAlignSelf,
7744         .getTransformCenter = GetTransformCenter,
7745         .getOpacityTransition = GetOpacityTransition,
7746         .getRotateTransition = GetRotateTransition,
7747         .getScaleTransition = GetScaleTransition,
7748         .getTranslateTransition = GetTranslateTransition,
7749         .getOffset = GetOffset,
7750         .getMarkAnchor = GetMarkAnchor,
7751         .getAlignRules = GetAlignRules,
7752         .getBackgroundBlurStyle = GetBackgroundBlurStyle,
7753         .getBackgroundImageSize = GetBackgroundImageSize,
7754         .getBackgroundImageSizeWithStyle = GetBackgroundImageSizeWidthStyle,
7755         .setOutlineWidthFloat = SetOutlineWidthFloat,
7756         .getOutlineWidthFloat = GetOutlineWidthFloat,
7757         .getDisplayPriority = GetDisplayPriority,
7758         .setAlignRulesWidthType = SetAlignRulesWidthType,
7759         .getLayoutWeight = GetLayoutWeight,
7760         .getScale = GetScale,
7761         .getRotate = GetRotate,
7762         .getBrightness = GetBrightness,
7763         .getSaturate = GetSaturate,
7764         .getBackgroundImagePosition = GetBackgroundImagePosition,
7765         .getFlexGrow = GetFlexGrow,
7766         .getFlexShrink = GetFlexShrink,
7767         .getFlexBasis = GetFlexBasis,
7768         .getConstraintSize = GetConstraintSize,
7769         .getGrayScale = GetGrayScale,
7770         .getInvert = GetInvert,
7771         .getSepia = GetSepia,
7772         .getContrast = GetContrast,
7773         .getForegroundColor = GetForegroundColor,
7774         .getBlur = GetBlur,
7775         .getLinearGradient = GetLinearGradient,
7776         .getAlign = GetAlign,
7777         .getWidth = GetWidth,
7778         .getHeight = GetHeight,
7779         .getBackgroundColor = GetBackgroundColor,
7780         .getBackgroundImage = GetBackgroundImage,
7781         .getPadding = GetPadding,
7782         .getPaddingDimension = GetPaddingDimension,
7783         .getConfigSize = GetConfigSize,
7784         .getKey = GetKey,
7785         .getEnabled = GetEnabled,
7786         .getMargin = GetMargin,
7787         .getMarginDimension = GetMarginDimension,
7788         .getTranslate = GetTranslate,
7789         .setMoveTransition = SetMoveTransition,
7790         .getMoveTransition = GetMoveTransition,
7791         .resetMask = ResetMask,
7792         .getAspectRatio = GetAspectRatio,
7793         .setBackgroundImageResizable = SetBackgroundImageResizable,
7794         .resetBackgroundImageResizable = ResetBackgroundImageResizable,
7795         .setBackgroundImageSizeWithUnit = SetBackgroundImageSizeWithUnit,
7796         .getRenderFit = GetRenderFit,
7797         .getOutlineColor = GetOutlineColor,
7798         .getSize = GetSize,
7799         .getRenderGroup = GetRenderGroup,
7800         .setOnVisibleAreaChange = SetOnVisibleAreaChange,
7801         .getGeometryTransition = GetGeometryTransition,
7802         .setChainStyle = SetChainStyle,
7803         .getChainStyle = GetChainStyle,
7804         .resetChainStyle = ResetChainStyle,
7805         .setBias = SetBias,
7806         .getBias = GetBias,
7807         .resetBias = ResetBias,
7808         .getColorBlend = GetColorBlend,
7809         .getForegroundBlurStyle = GetForegroundBlurStyle,
7810         .setBackgroundImagePixelMap = SetBackgroundImagePixelMap,
7811         .setBackgroundImagePixelMapByPixelMapPtr = SetBackgroundImagePixelMapByPixelMapPtr,
7812         .setLayoutRect = SetLayoutRect,
7813         .getLayoutRect = GetLayoutRect,
7814         .resetLayoutRect = ResetLayoutRect,
7815         .getFocusOnTouch = GetFocusOnTouch,
7816         .setSystemBarEffect = SetSystemBarEffect,
7817         .getAccessibilityID = GetAccessibilityID,
7818         .setAccessibilityState = SetAccessibilityState,
7819         .getAccessibilityState = GetAccessibilityState,
7820         .resetAccessibilityState = ResetAccessibilityState,
7821         .setAccessibilityValue = SetAccessibilityValue,
7822         .getAccessibilityValue = GetAccessibilityValue,
7823         .resetAccessibilityValue = ResetAccessibilityValue,
7824         .setAccessibilityActions = SetAccessibilityActions,
7825         .resetAccessibilityActions = ResetAccessibilityActions,
7826         .getAccessibilityActions = GetAccessibilityActions,
7827         .setAccessibilityRole = SetAccessibilityRole,
7828         .resetAccessibilityRole = ResetAccessibilityRole,
7829         .getAccessibilityRole = GetAccessibilityRole,
7830         .setFocusScopeId = SetFocusScopeId,
7831         .resetFocusScopeId = ResetFocusScopeId,
7832         .setFocusScopePriority = SetFocusScopePriority,
7833         .resetFocusScopePriority = ResetFocusScopePriority,
7834         .setPixelRound = SetPixelRound,
7835         .resetPixelRound = ResetPixelRound,
7836         .setBorderDashParams = SetBorderDashParams,
7837         .getExpandSafeArea = GetExpandSafeArea,
7838         .setTransition = SetTransition,
7839         .setDragPreview = SetDragPreview,
7840         .resetDragPreview = ResetDragPreview,
7841         .freezeUINodeById = FreezeUINodeById,
7842         .freezeUINodeByUniqueId = FreezeUINodeByUniqueId,
7843     };
7844     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
7845 
7846     return &modifier;
7847 }
7848 
SetOnAppear(ArkUINodeHandle node,void * extraParam)7849 void SetOnAppear(ArkUINodeHandle node, void* extraParam)
7850 {
7851     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7852     CHECK_NULL_VOID(frameNode);
7853     int32_t nodeId = frameNode->GetId();
7854     auto onAppear = [node = AceType::WeakClaim(frameNode), nodeId, extraParam]() {
7855         ArkUINodeEvent event;
7856         event.kind = COMPONENT_ASYNC_EVENT;
7857         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7858         event.nodeId = nodeId;
7859         event.componentAsyncEvent.subKind = ON_APPEAR;
7860         PipelineContext::SetCallBackNode(node);
7861         SendArkUISyncEvent(&event);
7862     };
7863     ViewAbstract::SetOnAppear(frameNode, std::move(onAppear));
7864 }
7865 
SetOnDisappear(ArkUINodeHandle node,void * extraParam)7866 void SetOnDisappear(ArkUINodeHandle node, void* extraParam)
7867 {
7868     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7869     CHECK_NULL_VOID(frameNode);
7870     int32_t nodeId = frameNode->GetId();
7871     auto onDisappear = [node = AceType::WeakClaim(frameNode), nodeId, extraParam]() {
7872         ArkUINodeEvent event;
7873         event.kind = COMPONENT_ASYNC_EVENT;
7874         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7875         event.nodeId = nodeId;
7876         event.componentAsyncEvent.subKind = ON_DISAPPEAR;
7877         PipelineContext::SetCallBackNode(node);
7878         SendArkUISyncEvent(&event);
7879     };
7880     ViewAbstract::SetOnDisappear(frameNode, std::move(onDisappear));
7881 }
7882 
SetOnAttach(ArkUINodeHandle node,void * extraParam)7883 void SetOnAttach(ArkUINodeHandle node, void* extraParam)
7884 {
7885     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7886     CHECK_NULL_VOID(frameNode);
7887     int32_t nodeId = frameNode->GetId();
7888     auto onAttach = [node = AceType::WeakClaim(frameNode), nodeId, extraParam]() {
7889         ArkUINodeEvent event;
7890         event.kind = COMPONENT_ASYNC_EVENT;
7891         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7892         event.nodeId = nodeId;
7893         event.componentAsyncEvent.subKind = ON_ATTACH;
7894         PipelineContext::SetCallBackNode(node);
7895         SendArkUISyncEvent(&event);
7896     };
7897     ViewAbstract::SetOnAttach(frameNode, std::move(onAttach));
7898 }
7899 
SetOnDetach(ArkUINodeHandle node,void * extraParam)7900 void SetOnDetach(ArkUINodeHandle node, void* extraParam)
7901 {
7902     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7903     CHECK_NULL_VOID(frameNode);
7904     int32_t nodeId = frameNode->GetId();
7905     auto onDetach = [node = AceType::WeakClaim(frameNode), nodeId, extraParam]() {
7906         ArkUINodeEvent event;
7907         event.kind = COMPONENT_ASYNC_EVENT;
7908         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7909         event.nodeId = nodeId;
7910         event.componentAsyncEvent.subKind = ON_DETACH;
7911         PipelineContext::SetCallBackNode(node);
7912         SendArkUISyncEvent(&event);
7913     };
7914     ViewAbstract::SetOnDetach(frameNode, std::move(onDetach));
7915 }
7916 
SetOnFocus(ArkUINodeHandle node,void * extraParam)7917 void SetOnFocus(ArkUINodeHandle node, void* extraParam)
7918 {
7919     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7920     CHECK_NULL_VOID(frameNode);
7921     int32_t nodeId = frameNode->GetId();
7922     auto onEvent = [nodeId, extraParam]() {
7923         ArkUINodeEvent event;
7924         event.kind = COMPONENT_ASYNC_EVENT;
7925         event.nodeId = nodeId;
7926         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7927         event.componentAsyncEvent.subKind = ON_FOCUS;
7928         SendArkUISyncEvent(&event);
7929     };
7930     ViewAbstract::SetOnFocus(frameNode, std::move(onEvent));
7931 }
7932 
SetOnBlur(ArkUINodeHandle node,void * extraParam)7933 void SetOnBlur(ArkUINodeHandle node, void* extraParam)
7934 {
7935     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7936     CHECK_NULL_VOID(frameNode);
7937     int32_t nodeId = frameNode->GetId();
7938     auto onEvent = [nodeId, extraParam]() {
7939         ArkUINodeEvent event;
7940         event.kind = COMPONENT_ASYNC_EVENT;
7941         event.nodeId = nodeId;
7942         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7943         event.componentAsyncEvent.subKind = ON_BLUR;
7944         SendArkUISyncEvent(&event);
7945     };
7946     ViewAbstract::SetOnBlur(frameNode, std::move(onEvent));
7947 }
7948 
SetOnAreaChange(ArkUINodeHandle node,void * extraParam)7949 void SetOnAreaChange(ArkUINodeHandle node, void* extraParam)
7950 {
7951     auto* frameNode = reinterpret_cast<FrameNode*>(node);
7952     CHECK_NULL_VOID(frameNode);
7953     int32_t nodeId = frameNode->GetId();
7954     auto onAreaChanged = [nodeId, node = AceType::WeakClaim(frameNode), extraParam](
7955                              const Rect& oldRect, const Offset& oldOrigin, const Rect& rect, const Offset& origin) {
7956         ArkUINodeEvent event;
7957         event.kind = COMPONENT_ASYNC_EVENT;
7958         event.nodeId = nodeId;
7959         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
7960         event.componentAsyncEvent.subKind = ON_AREA_CHANGE;
7961         PipelineContext::SetCallBackNode(node);
7962         auto oldLocalOffset = oldRect.GetOffset();
7963         event.componentAsyncEvent.data[0].f32 = PipelineBase::Px2VpWithCurrentDensity(oldRect.Width());
7964         event.componentAsyncEvent.data[1].f32 = PipelineBase::Px2VpWithCurrentDensity(oldRect.Height());
7965         event.componentAsyncEvent.data[2].f32 = PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetX());
7966         event.componentAsyncEvent.data[3].f32 = PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetY());
7967         event.componentAsyncEvent.data[4].f32 =
7968             PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetX() + oldOrigin.GetX());
7969         event.componentAsyncEvent.data[5].f32 =
7970             PipelineBase::Px2VpWithCurrentDensity(oldLocalOffset.GetY() + oldOrigin.GetY());
7971 
7972         auto localOffset = rect.GetOffset();
7973         event.componentAsyncEvent.data[6].f32 = PipelineBase::Px2VpWithCurrentDensity(rect.Width());
7974         event.componentAsyncEvent.data[7].f32 = PipelineBase::Px2VpWithCurrentDensity(rect.Height());
7975         event.componentAsyncEvent.data[8].f32 = PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX());
7976         event.componentAsyncEvent.data[9].f32 = PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY());
7977         event.componentAsyncEvent.data[10].f32 =
7978             PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX() + origin.GetX());
7979         event.componentAsyncEvent.data[11].f32 =
7980             PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY() + origin.GetY());
7981         SendArkUISyncEvent(&event);
7982     };
7983     auto areaChangeCallback = [areaChangeFunc = std::move(onAreaChanged)](const RectF& oldRect,
7984                                   const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) {
7985         areaChangeFunc(Rect(oldRect.GetX(), oldRect.GetY(), oldRect.Width(), oldRect.Height()),
7986             Offset(oldOrigin.GetX(), oldOrigin.GetY()), Rect(rect.GetX(), rect.GetY(), rect.Width(), rect.Height()),
7987             Offset(origin.GetX(), origin.GetY()));
7988     };
7989     ViewAbstract::SetOnAreaChanged(frameNode, std::move(areaChangeCallback));
7990 }
7991 
SetOnClickInfo(ArkUINodeEvent & event,GestureEvent & info,bool usePx)7992 void SetOnClickInfo(ArkUINodeEvent& event, GestureEvent& info, bool usePx)
7993 {
7994     const auto& targetLocalOffset = info.GetTarget().area.GetOffset();
7995     const auto& targetOrigin = info.GetTarget().origin;
7996     // width height x y globalx globaly
7997     event.clickEvent.targetPositionX =
7998         usePx ? targetLocalOffset.GetX().ConvertToPx() : targetLocalOffset.GetX().ConvertToVp();
7999     event.clickEvent.targetPositionY =
8000         usePx ? targetLocalOffset.GetY().ConvertToPx() : targetLocalOffset.GetY().ConvertToVp();
8001     event.clickEvent.targetGlobalPositionX =
8002         usePx ? targetOrigin.GetX().ConvertToPx() + targetLocalOffset.GetX().ConvertToPx()
8003               : targetOrigin.GetX().ConvertToVp() + targetLocalOffset.GetX().ConvertToVp();
8004     event.clickEvent.targetGlobalPositionY =
8005         usePx ? targetOrigin.GetY().ConvertToPx() + targetLocalOffset.GetY().ConvertToPx()
8006               : targetOrigin.GetY().ConvertToVp() + targetLocalOffset.GetY().ConvertToVp();
8007     event.clickEvent.width =
8008         usePx ? info.GetTarget().area.GetWidth().ConvertToPx() : info.GetTarget().area.GetWidth().ConvertToVp();
8009     event.clickEvent.height =
8010         usePx ? info.GetTarget().area.GetHeight().ConvertToPx() : info.GetTarget().area.GetHeight().ConvertToVp();
8011     // tiltX tiltY
8012     event.clickEvent.tiltX =
8013         usePx ? info.GetTiltX().value_or(0.0f) : PipelineBase::Px2VpWithCurrentDensity(info.GetTiltX().value_or(0.0f));
8014     event.clickEvent.tiltY =
8015         usePx ? info.GetTiltY().value_or(0.0f) : PipelineBase::Px2VpWithCurrentDensity(info.GetTiltY().value_or(0.0f));
8016     // rollAngle
8017     event.clickEvent.rollAngle = info.GetRollAngle().value_or(0.0f);
8018     //pressure
8019     event.clickEvent.pressure = info.GetForce();
8020     // sourcetool
8021     event.clickEvent.toolType = static_cast<int32_t>(info.GetSourceTool());
8022     // deviceid
8023     event.clickEvent.deviceId = info.GetDeviceId();
8024     // modifierkeystates
8025     event.clickEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info.GetPressedKeyCodes());
8026     if (!info.GetFingerList().empty()) {
8027         event.clickEvent.clickPointSize =
8028             info.GetFingerList().size() < MAX_POINTS ? info.GetFingerList().size() : MAX_POINTS;
8029     } else {
8030         event.clickEvent.clickPointSize = 0;
8031     }
8032 }
8033 
TriggerOnClickEvent(void * extraParam,int32_t nodeId,bool usePx,GestureEvent & info)8034 void TriggerOnClickEvent(void* extraParam, int32_t nodeId, bool usePx, GestureEvent& info)
8035 {
8036     Offset globalOffset = info.GetGlobalLocation();
8037     Offset localOffset = info.GetLocalLocation();
8038     Offset screenOffset = info.GetScreenLocation();
8039     ArkUINodeEvent event;
8040     event.kind = ArkUIEventCategory::CLICK_EVENT;
8041     event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8042     event.nodeId = nodeId;
8043     event.clickEvent.subKind = ArkUIEventSubKind::ON_CLICK_EVENT;
8044     event.clickEvent.localX = usePx ? localOffset.GetX() : PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX());
8045     event.clickEvent.localY = usePx ? localOffset.GetY() : PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY());
8046     event.clickEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8047     event.clickEvent.sourceType = static_cast<int32_t>(info.GetSourceDevice());
8048     event.clickEvent.windowX = usePx ? globalOffset.GetX() : PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX());
8049     event.clickEvent.windowY = usePx ? globalOffset.GetY() : PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY());
8050     event.clickEvent.displayX =
8051         usePx ? screenOffset.GetX() : PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX());
8052     event.clickEvent.displayY =
8053         usePx ? screenOffset.GetY() : PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY());
8054     SetOnClickInfo(event, info, usePx);
8055     SendArkUISyncEvent(&event);
8056 }
8057 
SetOnClick(ArkUINodeHandle node,void * extraParam)8058 void SetOnClick(ArkUINodeHandle node, void* extraParam)
8059 {
8060     auto* uiNode = reinterpret_cast<UINode*>(node);
8061     CHECK_NULL_VOID(uiNode);
8062     int32_t nodeId = uiNode->GetId();
8063     auto onEvent = [nodeId, extraParam](GestureEvent& info) {
8064         ArkUINodeEvent event;
8065         event.kind = COMPONENT_ASYNC_EVENT;
8066         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8067         event.nodeId = nodeId;
8068         event.componentAsyncEvent.subKind = ON_CLICK;
8069         auto target = info.GetTarget();
8070         event.touchEvent.target = { target.id.c_str(), target.type.c_str(),
8071             { static_cast<ArkUI_Int32>(target.area.GetOffset().GetX().Value()),
8072                 static_cast<ArkUI_Int32>(target.area.GetOffset().GetY().Value()),
8073                 static_cast<ArkUI_Int32>(target.area.GetWidth().Value()),
8074                 static_cast<ArkUI_Int32>(target.area.GetHeight().Value()) },
8075             { static_cast<ArkUI_Int32>(target.origin.GetX().Value()),
8076                 static_cast<ArkUI_Int32>(target.origin.GetY().Value()) } };
8077         Offset globalOffset = info.GetGlobalLocation();
8078         Offset localOffset = info.GetLocalLocation();
8079         Offset screenOffset = info.GetScreenLocation();
8080         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8081         //x
8082         event.componentAsyncEvent.data[0].f32 =
8083             usePx ? PipelineBase::Px2VpWithCurrentDensity(localOffset.GetX()) : localOffset.GetX();
8084         //y
8085         event.componentAsyncEvent.data[1].f32 =
8086             usePx ? PipelineBase::Px2VpWithCurrentDensity(localOffset.GetY()) : localOffset.GetY();
8087         //timestamp
8088         event.componentAsyncEvent.data[2].f32 = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8089         //source
8090         event.componentAsyncEvent.data[3].i32 = static_cast<int32_t>(info.GetSourceDevice());
8091         //windowX
8092         event.componentAsyncEvent.data[4].f32 =
8093             usePx ? PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetX()) : globalOffset.GetX();
8094         //windowY
8095         event.componentAsyncEvent.data[5].f32 =
8096             usePx ? PipelineBase::Px2VpWithCurrentDensity(globalOffset.GetY()) : globalOffset.GetY();
8097         //displayX
8098         event.componentAsyncEvent.data[6].f32 =
8099             usePx ? PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetX()) : screenOffset.GetX();
8100         //displayY
8101         event.componentAsyncEvent.data[7].f32 =
8102             usePx ? PipelineBase::Px2VpWithCurrentDensity(screenOffset.GetY()) : screenOffset.GetY();
8103         SendArkUISyncEvent(&event);
8104         TriggerOnClickEvent(extraParam, nodeId, usePx, info);
8105     };
8106     if (uiNode->GetTag() == V2::SPAN_ETS_TAG) {
8107         SpanModelNG::SetOnClick(uiNode, std::move(onEvent));
8108     } else if (uiNode->GetTag() == V2::TEXT_ETS_TAG) {
8109         TextModelNG::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onEvent));
8110     }  else {
8111         ViewAbstract::SetOnClick(reinterpret_cast<FrameNode*>(node), std::move(onEvent));
8112     }
8113 }
8114 
SetOnKeyEvent(ArkUINodeHandle node,void * extraParam)8115 void SetOnKeyEvent(ArkUINodeHandle node, void* extraParam)
8116 {
8117     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8118     CHECK_NULL_VOID(frameNode);
8119     int32_t nodeId = frameNode->GetId();
8120     auto onKeyEvent = [frameNode, nodeId, extraParam](KeyEventInfo& info) -> bool {
8121         ArkUINodeEvent event;
8122         event.kind = ArkUIEventCategory::KEY_INPUT_EVENT;
8123         event.nodeId = nodeId;
8124         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8125         event.keyEvent.subKind = ArkUIEventSubKind::ON_KEY_EVENT;
8126         event.keyEvent.type = static_cast<int32_t>(info.GetKeyType());
8127         event.keyEvent.keyCode = static_cast<int32_t>(info.GetKeyCode());
8128         event.keyEvent.keyText = info.GetKeyText();
8129         event.keyEvent.keySource = static_cast<int32_t>(info.GetKeySource());
8130         event.keyEvent.deviceId = info.GetDeviceId();
8131         event.keyEvent.unicode = info.GetUnicode();
8132         event.keyEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8133         // modifierkeystates
8134         event.keyEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info.GetPressedKeyCodes());
8135 
8136         std::vector<int32_t> pressKeyCodeList;
8137         auto pressedKeyCodes = info.GetPressedKeyCodes();
8138         event.keyEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
8139         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
8140             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
8141         }
8142         event.keyEvent.pressedKeyCodes = pressKeyCodeList.data();
8143         event.keyEvent.intentionCode = static_cast<int32_t>(info.GetKeyIntention());
8144 
8145         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
8146         SendArkUISyncEvent(&event);
8147         info.SetStopPropagation(event.keyEvent.stopPropagation);
8148         return event.keyEvent.isConsumed;
8149     };
8150     ViewAbstract::SetOnKeyEvent(frameNode, onKeyEvent);
8151 }
8152 
SetOnKeyPreIme(ArkUINodeHandle node,void * extraParam)8153 void SetOnKeyPreIme(ArkUINodeHandle node, void* extraParam)
8154 {
8155     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8156     CHECK_NULL_VOID(frameNode);
8157     int32_t nodeId = frameNode->GetId();
8158     auto onPreImeEvent = [frameNode, nodeId, extraParam](KeyEventInfo& info) -> bool {
8159         ArkUINodeEvent event;
8160         event.kind = ArkUIEventCategory::KEY_INPUT_EVENT;
8161         event.nodeId = nodeId;
8162         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8163         event.keyEvent.subKind = ON_KEY_PREIME;
8164         event.keyEvent.type = static_cast<int32_t>(info.GetKeyType());
8165         event.keyEvent.keyCode = static_cast<int32_t>(info.GetKeyCode());
8166         event.keyEvent.keyText = info.GetKeyText();
8167         event.keyEvent.keySource = static_cast<int32_t>(info.GetKeySource());
8168         event.keyEvent.deviceId = info.GetDeviceId();
8169         event.keyEvent.unicode = info.GetUnicode();
8170         event.keyEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8171 
8172         std::vector<int32_t> pressKeyCodeList;
8173         auto pressedKeyCodes = info.GetPressedKeyCodes();
8174         event.keyEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
8175         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
8176             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
8177         }
8178         event.keyEvent.pressedKeyCodes = pressKeyCodeList.data();
8179         event.keyEvent.intentionCode = static_cast<int32_t>(info.GetKeyIntention());
8180 
8181         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
8182         SendArkUISyncEvent(&event);
8183         info.SetStopPropagation(event.keyEvent.stopPropagation);
8184         return event.keyEvent.isConsumed;
8185     };
8186     NG::ViewAbstractModelNG::SetOnKeyPreIme(frameNode, std::move(onPreImeEvent));
8187 }
8188 
SetOnKeyEventDispatch(ArkUINodeHandle node,void * extraParam)8189 void SetOnKeyEventDispatch(ArkUINodeHandle node, void* extraParam)
8190 {
8191     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8192     CHECK_NULL_VOID(frameNode);
8193     int32_t nodeId = frameNode->GetId();
8194     auto onKeyEvent = [frameNode, nodeId, extraParam](KeyEventInfo& info) -> bool {
8195         ArkUINodeEvent event;
8196         event.kind = ArkUIEventCategory::KEY_INPUT_EVENT;
8197         event.nodeId = nodeId;
8198         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8199         event.keyEvent.subKind = ArkUIEventSubKind::ON_KEY_DISPATCH;
8200         event.keyEvent.type = static_cast<int32_t>(info.GetKeyType());
8201         event.keyEvent.keyCode = static_cast<int32_t>(info.GetKeyCode());
8202         event.keyEvent.keyText = info.GetKeyText();
8203         event.keyEvent.keySource = static_cast<int32_t>(info.GetKeySource());
8204         event.keyEvent.deviceId = info.GetDeviceId();
8205         event.keyEvent.unicode = info.GetUnicode();
8206         event.keyEvent.timestamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8207 
8208         std::vector<int32_t> pressKeyCodeList;
8209         auto pressedKeyCodes = info.GetPressedKeyCodes();
8210         event.keyEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
8211         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
8212             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
8213         }
8214         event.keyEvent.pressedKeyCodes = pressKeyCodeList.data();
8215         event.keyEvent.intentionCode = static_cast<int32_t>(info.GetKeyIntention());
8216 
8217         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
8218         SendArkUISyncEvent(&event);
8219         info.SetStopPropagation(event.keyEvent.stopPropagation);
8220         return event.keyEvent.isConsumed;
8221     };
8222     ViewAbstract::SetOnKeyEventDispatch(frameNode, onKeyEvent);
8223 }
SetOnFocusAxisEvent(ArkUINodeHandle node,void * extraParam)8224 void SetOnFocusAxisEvent(ArkUINodeHandle node, void* extraParam)
8225 {
8226     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8227     CHECK_NULL_VOID(frameNode);
8228     int32_t nodeId = frameNode->GetId();
8229     auto onFocusAxisEvent = [frameNode, nodeId, extraParam](FocusAxisEventInfo& info) {
8230         ArkUINodeEvent event;
8231         event.kind = ArkUIEventCategory::FOCUS_AXIS_EVENT;
8232         event.nodeId = nodeId;
8233         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8234         event.focusAxisEvent.subKind = ArkUIEventSubKind::ON_FOCUS_AXIS;
8235         event.focusAxisEvent.absXValue = info.GetAbsXValue();
8236         event.focusAxisEvent.absYValue = info.GetAbsYValue();
8237         event.focusAxisEvent.absZValue = info.GetAbsZValue();
8238         event.focusAxisEvent.absRzValue = info.GetAbsRzValue();
8239         event.focusAxisEvent.absGasValue = info.GetAbsGasValue();
8240         event.focusAxisEvent.absBrakeValue = info.GetAbsBrakeValue();
8241         event.focusAxisEvent.absHat0XValue = info.GetAbsHat0XValue();
8242         event.focusAxisEvent.absHat0YValue = info.GetAbsHat0YValue();
8243         event.focusAxisEvent.timeStamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8244         event.focusAxisEvent.toolType = static_cast<int32_t>(info.GetSourceTool());
8245         event.focusAxisEvent.sourceType = static_cast<int32_t>(info.GetSourceDevice());
8246         event.focusAxisEvent.deviceId = info.GetDeviceId();
8247         const auto& targetLocalOffset = info.GetTarget().area.GetOffset();
8248         const auto& targetOrigin = info.GetTarget().origin;
8249         // width height x y globalx globaly
8250         event.focusAxisEvent.targetPositionX = targetLocalOffset.GetX().ConvertToPx();
8251         event.focusAxisEvent.targetPositionY = targetLocalOffset.GetY().ConvertToPx();
8252         event.focusAxisEvent.targetGlobalPositionX =
8253             targetOrigin.GetX().ConvertToPx() + targetLocalOffset.GetX().ConvertToPx();
8254         event.focusAxisEvent.targetGlobalPositionY =
8255             targetOrigin.GetY().ConvertToPx() + targetLocalOffset.GetY().ConvertToPx();
8256         event.focusAxisEvent.width = info.GetTarget().area.GetWidth().ConvertToPx();
8257         event.focusAxisEvent.height = info.GetTarget().area.GetHeight().ConvertToPx();
8258         // modifierkeystates
8259         event.focusAxisEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info.GetPressedKeyCodes());
8260         std::vector<int32_t> pressKeyCodeList;
8261         auto pressedKeyCodes = info.GetPressedKeyCodes();
8262         event.focusAxisEvent.keyCodesLength = static_cast<int32_t>(pressedKeyCodes.size());
8263         for (auto it = pressedKeyCodes.begin(); it != pressedKeyCodes.end(); it++) {
8264             pressKeyCodeList.push_back(static_cast<int32_t>(*it));
8265         }
8266         event.focusAxisEvent.pressedKeyCodes = pressKeyCodeList.data();
8267         event.focusAxisEvent.targetDisplayId = info.GetTargetDisplayId();
8268 
8269         PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
8270         SendArkUISyncEvent(&event);
8271         info.SetStopPropagation(event.focusAxisEvent.stopPropagation);
8272     };
8273     ViewAbstract::SetOnFocusAxisEvent(frameNode, onFocusAxisEvent);
8274 }
8275 
ResetOnKeyEvent(ArkUINodeHandle node)8276 void ResetOnKeyEvent(ArkUINodeHandle node)
8277 {
8278     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8279     CHECK_NULL_VOID(frameNode);
8280     ViewAbstract::DisableOnKeyEvent(frameNode);
8281 }
8282 
ResetOnKeyPreIme(ArkUINodeHandle node)8283 void ResetOnKeyPreIme(ArkUINodeHandle node)
8284 {
8285     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8286     CHECK_NULL_VOID(frameNode);
8287     NG::ViewAbstractModelNG::DisableOnKeyPreIme(frameNode);
8288 }
8289 
ResetOnFocusAxisEvent(ArkUINodeHandle node)8290 void ResetOnFocusAxisEvent(ArkUINodeHandle node)
8291 {
8292     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8293     CHECK_NULL_VOID(frameNode);
8294     NG::ViewAbstractModelNG::DisableOnFocusAxisEvent(frameNode);
8295 }
8296 
ConvertTouchLocationInfoToPoint(const TouchLocationInfo & locationInfo,ArkUITouchPoint & touchPoint,bool usePx)8297 void ConvertTouchLocationInfoToPoint(const TouchLocationInfo& locationInfo, ArkUITouchPoint& touchPoint, bool usePx)
8298 {
8299     const OHOS::Ace::Offset& globalLocation = locationInfo.GetGlobalLocation();
8300     const OHOS::Ace::Offset& localLocation = locationInfo.GetLocalLocation();
8301     const OHOS::Ace::Offset& screenLocation = locationInfo.GetScreenLocation();
8302     touchPoint.id = locationInfo.GetFingerId();
8303     double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
8304     touchPoint.nodeX = localLocation.GetX() / density;
8305     touchPoint.nodeY = localLocation.GetY() / density;
8306     touchPoint.windowX = globalLocation.GetX() / density;
8307     touchPoint.windowY = globalLocation.GetY() / density;
8308     touchPoint.screenX = screenLocation.GetX() / density;
8309     touchPoint.screenY = screenLocation.GetY() / density;
8310     touchPoint.pressure = locationInfo.GetForce();
8311     touchPoint.contactAreaWidth = locationInfo.GetSize();
8312     touchPoint.contactAreaHeight = locationInfo.GetSize();
8313     touchPoint.tiltX = locationInfo.GetTiltX().value_or(0.0f);
8314     touchPoint.tiltY = locationInfo.GetTiltY().value_or(0.0f);
8315     touchPoint.rollAngle = locationInfo.GetRollAngle().value_or(0.0f);
8316     touchPoint.toolType = static_cast<int32_t>(locationInfo.GetSourceTool());
8317     touchPoint.pressedTime = locationInfo.GetPressedTime().time_since_epoch().count();
8318     touchPoint.operatingHand = locationInfo.GetOperatingHand();
8319 }
8320 
ConvertTouchPointsToPoints(std::vector<TouchPoint> & touchPointes,std::array<ArkUITouchPoint,MAX_POINTS> & points,const TouchLocationInfo & historyLoaction,bool usePx)8321 void ConvertTouchPointsToPoints(std::vector<TouchPoint>& touchPointes,
8322     std::array<ArkUITouchPoint, MAX_POINTS>& points, const TouchLocationInfo& historyLoaction, bool usePx)
8323 {
8324     if (touchPointes.empty()) {
8325         return;
8326     }
8327     size_t i = 0;
8328     for (auto& touchPoint : touchPointes) {
8329         if (i >= MAX_POINTS) {
8330             break;
8331         }
8332         double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
8333         points[i].id = touchPoint.id;
8334         points[i].nodeX = NearEqual(density, 0.0) ? 0.0f :
8335             historyLoaction.GetLocalLocation().GetX() / density;
8336         points[i].nodeY = NearEqual(density, 0.0) ? 0.0f :
8337             historyLoaction.GetLocalLocation().GetY() / density;
8338         points[i].windowX = NearEqual(density, 0.0) ? 0.0f :
8339             historyLoaction.GetGlobalLocation().GetX() / density;
8340         points[i].windowY = NearEqual(density, 0.0) ? 0.0f :
8341             historyLoaction.GetGlobalLocation().GetY() / density;
8342         points[i].screenX = NearEqual(density, 0.0) ? 0.0f :
8343             historyLoaction.GetScreenLocation().GetX() / density;
8344         points[i].screenY = NearEqual(density, 0.0) ? 0.0f :
8345             historyLoaction.GetScreenLocation().GetY() / density;
8346         points[i].contactAreaWidth = touchPoint.size;
8347         points[i].contactAreaHeight = touchPoint.size;
8348         points[i].pressure = touchPoint.force;
8349         points[i].tiltX = touchPoint.tiltX.value_or(0.0f);
8350         points[i].tiltY = touchPoint.tiltY.value_or(0.0f);
8351         points[i].rollAngle = touchPoint.rollAngle.value_or(0.0f);
8352         points[i].pressedTime = touchPoint.downTime.time_since_epoch().count();
8353         points[i].toolType = static_cast<int32_t>(historyLoaction.GetSourceTool());
8354         points[i].operatingHand = touchPoint.operatingHand;
8355         i++;
8356     }
8357 }
8358 
SetOnTouch(ArkUINodeHandle node,void * extraParam)8359 void SetOnTouch(ArkUINodeHandle node, void* extraParam)
8360 {
8361     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8362     CHECK_NULL_VOID(frameNode);
8363     int32_t nodeId = frameNode->GetId();
8364     auto onEvent = [nodeId, extraParam](TouchEventInfo& eventInfo) {
8365         globalEventInfo = eventInfo;
8366         ArkUINodeEvent event;
8367         event.kind = TOUCH_EVENT;
8368         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8369         event.nodeId = nodeId;
8370         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8371         auto target = eventInfo.GetTarget();
8372         event.touchEvent.target.id = target.id.c_str();
8373         event.touchEvent.target.type = target.type.c_str();
8374         const auto& targetLocalOffset = eventInfo.GetTarget().area.GetOffset();
8375         const auto& targetOrigin = eventInfo.GetTarget().origin;
8376         // width height x y globalx globaly
8377         event.touchEvent.targetPositionX =
8378             usePx ? targetLocalOffset.GetX().ConvertToPx() : targetLocalOffset.GetX().ConvertToVp();
8379         event.touchEvent.targetPositionY =
8380             usePx ? targetLocalOffset.GetY().ConvertToPx() : targetLocalOffset.GetY().ConvertToVp();
8381         event.touchEvent.targetGlobalPositionX =
8382             usePx ? targetOrigin.GetX().ConvertToPx() + targetLocalOffset.GetX().ConvertToPx()
8383                   : targetOrigin.GetX().ConvertToVp() + targetLocalOffset.GetX().ConvertToVp();
8384         event.touchEvent.targetGlobalPositionY =
8385             usePx ? targetOrigin.GetY().ConvertToPx() + targetLocalOffset.GetY().ConvertToPx()
8386                   : targetOrigin.GetY().ConvertToVp() + targetLocalOffset.GetY().ConvertToVp();
8387         event.touchEvent.width = usePx ? eventInfo.GetTarget().area.GetWidth().ConvertToPx()
8388                                        : eventInfo.GetTarget().area.GetWidth().ConvertToVp();
8389         event.touchEvent.height = usePx ? eventInfo.GetTarget().area.GetHeight().ConvertToPx()
8390                                         : eventInfo.GetTarget().area.GetHeight().ConvertToVp();
8391         // rollAngle
8392         event.touchEvent.rollAngle = eventInfo.GetRollAngle().value_or(0.0f);
8393         // deviceid
8394         event.touchEvent.deviceId = eventInfo.GetDeviceId();
8395         //modifierkeystates
8396         event.touchEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(eventInfo.GetPressedKeyCodes());
8397         event.touchEvent.target.area = {
8398             static_cast<ArkUI_Int32>(target.area.GetOffset().GetX().Value()),
8399             static_cast<ArkUI_Int32>(target.area.GetOffset().GetY().Value()),
8400             static_cast<ArkUI_Int32>(target.area.GetWidth().Value()),
8401             static_cast<ArkUI_Int32>(target.area.GetHeight().Value())
8402         };
8403         event.touchEvent.target.origin = {
8404             static_cast<ArkUI_Int32>(target.origin.GetX().Value()),
8405             static_cast<ArkUI_Int32>(target.origin.GetY().Value())
8406         };
8407         const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
8408         if (changeTouch.size() > 0) {
8409             TouchLocationInfo front = changeTouch.front();
8410             event.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
8411             event.touchEvent.changedPointerId = front.GetFingerId();
8412             ConvertTouchLocationInfoToPoint(front, event.touchEvent.actionTouchPoint, usePx);
8413         }
8414         event.touchEvent.timeStamp = eventInfo.GetTimeStamp().time_since_epoch().count();
8415         event.touchEvent.sourceType = static_cast<int32_t>(eventInfo.GetSourceDevice());
8416         event.touchEvent.targetDisplayId = eventInfo.GetTargetDisplayId();
8417         event.touchEvent.rawPointerEvent = eventInfo.GetPointerEvent().get();
8418 
8419         std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
8420         if (!eventInfo.GetTouches().empty()) {
8421             size_t index = 0;
8422             for (auto& touchLocationInfo : eventInfo.GetTouches()) {
8423                 if (index >= MAX_POINTS) {
8424                     break;
8425                 }
8426                 ConvertTouchLocationInfoToPoint(touchLocationInfo, touchPoints[index++], usePx);
8427             }
8428             event.touchEvent.touchPointes = &touchPoints[0];
8429             event.touchEvent.touchPointSize =
8430                 eventInfo.GetTouches().size() < MAX_POINTS ? eventInfo.GetTouches().size() : MAX_POINTS;
8431         } else {
8432             event.touchEvent.touchPointes = nullptr;
8433             event.touchEvent.touchPointSize = 0;
8434         }
8435         event.touchEvent.subKind = ON_TOUCH;
8436         std::array<ArkUIHistoryTouchEvent, MAX_HISTORY_EVENT_COUNT> allHistoryEvents;
8437         std::array<std::array<ArkUITouchPoint, MAX_POINTS>, MAX_HISTORY_EVENT_COUNT> allHistoryPoints;
8438         if (!eventInfo.GetHistoryPointerEvent().empty() &&
8439             eventInfo.GetHistoryPointerEvent().size() == eventInfo.GetHistory().size()) {
8440             auto historyLoacationIterator = std::begin(eventInfo.GetHistory());
8441             auto historyMMIPointerEventIterator = std::begin(eventInfo.GetHistoryPointerEvent());
8442             for (size_t i = 0; i < eventInfo.GetHistory().size() && i < MAX_HISTORY_EVENT_COUNT; i++) {
8443                 if (!(*historyMMIPointerEventIterator)) {
8444                     historyLoacationIterator++;
8445                     historyMMIPointerEventIterator++;
8446                     continue;
8447                 }
8448                 auto tempTouchEvent = NG::ConvertToTouchEvent((*historyMMIPointerEventIterator));
8449                 allHistoryEvents[i].action = static_cast<int32_t>(tempTouchEvent.type);
8450                 allHistoryEvents[i].sourceType = static_cast<int32_t>(tempTouchEvent.sourceType);
8451                 allHistoryEvents[i].timeStamp = tempTouchEvent.time.time_since_epoch().count();
8452                 double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
8453                 allHistoryEvents[i].actionTouchPoint.nodeX =
8454                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetLocalLocation().GetX() / density;
8455                 allHistoryEvents[i].actionTouchPoint.nodeY =
8456                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetLocalLocation().GetY() / density;
8457                 allHistoryEvents[i].actionTouchPoint.windowX =
8458                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetGlobalLocation().GetX() / density;
8459                 allHistoryEvents[i].actionTouchPoint.windowY =
8460                     NearEqual(density, 0.0) ? 0.0f : (*historyLoacationIterator).GetGlobalLocation().GetY() / density;
8461                 allHistoryEvents[i].actionTouchPoint.screenX = tempTouchEvent.screenX;
8462                 allHistoryEvents[i].actionTouchPoint.screenY = tempTouchEvent.screenY;
8463                 allHistoryEvents[i].actionTouchPoint.pressure = tempTouchEvent.force;
8464                 ConvertTouchPointsToPoints(
8465                     tempTouchEvent.pointers, allHistoryPoints[i], *historyLoacationIterator, usePx);
8466                 if (tempTouchEvent.pointers.size() > 0) {
8467                     allHistoryEvents[i].touchPointes = &(allHistoryPoints[i][0]);
8468                 }
8469                 allHistoryEvents[i].touchPointSize =
8470                     tempTouchEvent.pointers.size() < MAX_POINTS ? tempTouchEvent.pointers.size() : MAX_POINTS;
8471                 historyLoacationIterator++;
8472                 historyMMIPointerEventIterator++;
8473             }
8474             event.touchEvent.historyEvents = &allHistoryEvents[0];
8475             event.touchEvent.historySize = eventInfo.GetHistoryPointerEvent().size() < MAX_HISTORY_EVENT_COUNT
8476                                                ? eventInfo.GetHistoryPointerEvent().size()
8477                                                : MAX_HISTORY_EVENT_COUNT;
8478         } else {
8479             event.touchEvent.historyEvents = nullptr;
8480             event.touchEvent.historySize = 0;
8481         }
8482         event.touchEvent.stopPropagation = false;
8483         SendArkUISyncEvent(&event);
8484         eventInfo.SetStopPropagation(event.touchEvent.stopPropagation);
8485     };
8486     ViewAbstract::SetOnTouch(frameNode, std::move(onEvent));
8487 }
8488 
SetOnTouchIntercept(ArkUINodeHandle node,void * extraParam)8489 void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam)
8490 {
8491     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8492     CHECK_NULL_VOID(frameNode);
8493     int32_t nodeId = frameNode->GetId();
8494     auto onTouchIntercept = [nodeId, extraParam](TouchEventInfo& eventInfo) -> NG::HitTestMode {
8495         globalEventInfo = eventInfo;
8496         ArkUINodeEvent touchEvent;
8497         touchEvent.kind = TOUCH_EVENT;
8498         touchEvent.extraParam = reinterpret_cast<intptr_t>(extraParam);
8499         touchEvent.nodeId = nodeId;
8500         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8501         const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
8502         if (changeTouch.size() > 0) {
8503             TouchLocationInfo front = changeTouch.front();
8504             touchEvent.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
8505             ConvertTouchLocationInfoToPoint(front, touchEvent.touchEvent.actionTouchPoint, usePx);
8506         }
8507         touchEvent.touchEvent.timeStamp = eventInfo.GetTimeStamp().time_since_epoch().count();
8508         touchEvent.touchEvent.sourceType = static_cast<int32_t>(eventInfo.GetSourceDevice());
8509         touchEvent.touchEvent.targetDisplayId = eventInfo.GetTargetDisplayId();
8510 
8511         std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
8512         if (!eventInfo.GetTouches().empty()) {
8513             size_t index = 0;
8514             for (auto& touchLocationInfo: eventInfo.GetTouches()) {
8515                 if (index >= MAX_POINTS) {
8516                     break;
8517                 }
8518                 ConvertTouchLocationInfoToPoint(touchLocationInfo, touchPoints[index++], usePx);
8519             }
8520             touchEvent.touchEvent.touchPointes = &touchPoints[0];
8521             touchEvent.touchEvent.touchPointSize = eventInfo.GetTouches().size() < MAX_POINTS ?
8522             eventInfo.GetTouches().size() : MAX_POINTS;
8523         } else {
8524             touchEvent.touchEvent.touchPointes = nullptr;
8525             touchEvent.touchEvent.touchPointSize = 0;
8526         }
8527         touchEvent.touchEvent.historyEvents = nullptr;
8528         touchEvent.touchEvent.historySize = 0;
8529         touchEvent.touchEvent.subKind = ON_TOUCH_INTERCEPT;
8530         touchEvent.touchEvent.interceptResult = 0;
8531         SendArkUISyncEvent(&touchEvent);
8532         return static_cast<NG::HitTestMode>(touchEvent.touchEvent.interceptResult);
8533     };
8534     ViewAbstract::SetOnTouchIntercept(frameNode, std::move(onTouchIntercept));
8535 }
8536 
TriggerOnHoverEvent(void * extraParam,int32_t nodeId,bool isHover,HoverInfo & info)8537 void TriggerOnHoverEvent(void* extraParam, int32_t nodeId, bool isHover, HoverInfo& info)
8538 {
8539     ArkUINodeEvent event;
8540     event.kind = ArkUIEventCategory::HOVER_EVENT;
8541     event.nodeId = nodeId;
8542     event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8543     event.hoverEvent.subKind = ON_HOVER_EVENT;
8544     event.hoverEvent.isHover = isHover;
8545     const auto& targetLocalOffset = info.GetTarget().area.GetOffset();
8546     const auto& targetOrigin = info.GetTarget().origin;
8547     bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8548     // width height x y globalx globaly
8549     event.hoverEvent.targetPositionX =
8550         usePx ? targetLocalOffset.GetX().ConvertToPx() : targetLocalOffset.GetX().ConvertToVp();
8551     event.hoverEvent.targetPositionY =
8552         usePx ? targetLocalOffset.GetY().ConvertToPx() : targetLocalOffset.GetY().ConvertToVp();
8553     event.hoverEvent.targetGlobalPositionX =
8554         usePx ? targetOrigin.GetX().ConvertToPx() + targetLocalOffset.GetX().ConvertToPx()
8555               : targetOrigin.GetX().ConvertToVp() + targetLocalOffset.GetX().ConvertToVp();
8556     event.hoverEvent.targetGlobalPositionY =
8557         usePx ? targetOrigin.GetY().ConvertToPx() + targetLocalOffset.GetY().ConvertToPx()
8558               : targetOrigin.GetY().ConvertToVp() + targetLocalOffset.GetY().ConvertToVp();
8559     event.hoverEvent.width =
8560         usePx ? info.GetTarget().area.GetWidth().ConvertToPx() : info.GetTarget().area.GetWidth().ConvertToVp();
8561     event.hoverEvent.height =
8562         usePx ? info.GetTarget().area.GetHeight().ConvertToPx() : info.GetTarget().area.GetHeight().ConvertToVp();
8563     // deviceid
8564     event.hoverEvent.deviceId = info.GetDeviceId();
8565     // modifierkeystates
8566     event.hoverEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info.GetPressedKeyCodes());
8567     // timestamp
8568     event.hoverEvent.timeStamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8569     // sourcetool
8570     event.hoverEvent.toolType = static_cast<int32_t>(info.GetSourceTool());
8571     // source
8572     event.hoverEvent.sourceType = static_cast<int32_t>(info.GetSourceDevice());
8573     // tiltX tiltY
8574     event.hoverEvent.tiltX = info.GetTiltX().value_or(0.0f);
8575     event.hoverEvent.tiltY = info.GetTiltX().value_or(0.0f);
8576     // rollAngle
8577     event.hoverEvent.rollAngle = info.GetRollAngle().value_or(0.0f);
8578     // stoppropagation
8579     event.hoverEvent.stopPropagation = false;
8580     SendArkUISyncEvent(&event);
8581     info.SetStopPropagation(event.hoverEvent.stopPropagation);
8582 }
8583 
SetOnHover(ArkUINodeHandle node,void * extraParam)8584 void SetOnHover(ArkUINodeHandle node, void* extraParam)
8585 {
8586     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8587     CHECK_NULL_VOID(frameNode);
8588     int32_t nodeId = frameNode->GetId();
8589     auto onEvent = [nodeId, extraParam](bool isHover, HoverInfo& info) {
8590         ArkUINodeEvent event;
8591         event.kind = COMPONENT_ASYNC_EVENT;
8592         event.nodeId = nodeId;
8593         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8594         event.componentAsyncEvent.subKind = ON_HOVER;
8595         event.componentAsyncEvent.data[0].i32 = isHover;
8596         SendArkUISyncEvent(&event);
8597         TriggerOnHoverEvent(extraParam, nodeId, isHover, info);
8598     };
8599     ViewAbstract::SetOnHover(frameNode, onEvent);
8600 }
8601 
SetOnHoverMove(ArkUINodeHandle node,void * extraParam)8602 void SetOnHoverMove(ArkUINodeHandle node, void* extraParam)
8603 {
8604     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8605     CHECK_NULL_VOID(frameNode);
8606     int32_t nodeId = frameNode->GetId();
8607     auto onEvent = [nodeId, extraParam](HoverInfo& info) {
8608         ArkUINodeEvent event;
8609         event.kind = TOUCH_EVENT;
8610         event.nodeId = nodeId;
8611         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8612         event.touchEvent.subKind = ON_HOVER_MOVE;
8613         event.touchEvent.actionTouchPoint.nodeX = info.GetLocalLocation().GetX();
8614         event.touchEvent.actionTouchPoint.nodeY = info.GetLocalLocation().GetY();
8615         event.touchEvent.actionTouchPoint.windowX = info.GetGlobalLocation().GetX();
8616         event.touchEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY();
8617         event.touchEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX();
8618         event.touchEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY();
8619         event.touchEvent.actionTouchPoint.rollAngle = info.GetRollAngle().value_or(0.0f);
8620         SendArkUISyncEvent(&event);
8621     };
8622     ViewAbstract::SetOnHoverMove(frameNode, onEvent);
8623 }
8624 
SetOnMouseInfo(ArkUINodeEvent & event,MouseInfo & info,bool usePx)8625 void SetOnMouseInfo(ArkUINodeEvent& event, MouseInfo& info, bool usePx)
8626 {
8627     const auto& targetLocalOffset = info.GetTarget().area.GetOffset();
8628     const auto& targetOrigin = info.GetTarget().origin;
8629     // width height x y globalx globaly
8630     event.mouseEvent.targetPositionX =
8631         usePx ? targetLocalOffset.GetX().ConvertToPx() : targetLocalOffset.GetX().ConvertToVp();
8632     event.mouseEvent.targetPositionY =
8633         usePx ? targetLocalOffset.GetY().ConvertToPx() : targetLocalOffset.GetY().ConvertToVp();
8634     event.mouseEvent.targetGlobalPositionX =
8635         usePx ? targetOrigin.GetX().ConvertToPx() + targetLocalOffset.GetX().ConvertToPx()
8636               : targetOrigin.GetX().ConvertToVp() + targetLocalOffset.GetX().ConvertToVp();
8637     event.mouseEvent.targetGlobalPositionY =
8638         usePx ? targetOrigin.GetY().ConvertToPx() + targetLocalOffset.GetY().ConvertToPx()
8639               : targetOrigin.GetY().ConvertToVp() + targetLocalOffset.GetY().ConvertToVp();
8640     event.mouseEvent.width =
8641         usePx ? info.GetTarget().area.GetWidth().ConvertToPx() : info.GetTarget().area.GetWidth().ConvertToVp();
8642     event.mouseEvent.height =
8643         usePx ? info.GetTarget().area.GetHeight().ConvertToPx() : info.GetTarget().area.GetHeight().ConvertToVp();
8644     // deviceid
8645     event.mouseEvent.deviceId = info.GetDeviceId();
8646     // modifierkeystates
8647     event.mouseEvent.modifierKeyState = NodeModifier::CalculateModifierKeyState(info.GetPressedKeyCodes());
8648     // pressure
8649     event.mouseEvent.actionTouchPoint.pressure = info.GetForce();
8650     // toolType
8651     event.mouseEvent.actionTouchPoint.toolType = static_cast<int32_t>(info.GetSourceTool());
8652     // source
8653     event.mouseEvent.sourceType = static_cast<int32_t>(info.GetSourceDevice());
8654     // stoppropagation
8655     event.mouseEvent.stopPropagation = false;
8656 }
8657 
SetOnMouse(ArkUINodeHandle node,void * extraParam)8658 void SetOnMouse(ArkUINodeHandle node, void* extraParam)
8659 {
8660     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8661     CHECK_NULL_VOID(frameNode);
8662     int32_t nodeId = frameNode->GetId();
8663     auto onEvent = [nodeId, extraParam](MouseInfo& info) {
8664         ArkUINodeEvent event;
8665         event.kind = MOUSE_INPUT_EVENT;
8666         event.nodeId = nodeId;
8667         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8668         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8669         double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
8670         event.mouseEvent.subKind = ON_MOUSE;
8671         event.mouseEvent.actionTouchPoint.nodeX = info.GetLocalLocation().GetX() / density;
8672         event.mouseEvent.actionTouchPoint.nodeY = info.GetLocalLocation().GetY() / density;
8673         event.mouseEvent.button = static_cast<int32_t>(info.GetButton());
8674         event.mouseEvent.action = static_cast<int32_t>(info.GetAction());
8675         event.mouseEvent.timeStamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8676         event.mouseEvent.actionTouchPoint.windowX = info.GetGlobalLocation().GetX() / density;
8677         event.mouseEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY() / density;
8678         event.mouseEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX() / density;
8679         event.mouseEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY() / density;
8680         event.mouseEvent.rawDeltaX = info.GetRawDeltaX() / density;
8681         event.mouseEvent.rawDeltaY = info.GetRawDeltaY() / density;
8682         event.mouseEvent.targetDisplayId = info.GetTargetDisplayId();
8683 
8684         std::vector<int32_t> pressedButtonList;
8685         auto pressedButtons = info.GetPressedButtons();
8686         event.mouseEvent.pressedButtonsLength = static_cast<int32_t>(pressedButtons.size());
8687         for (auto it = pressedButtons.begin(); it != pressedButtons.end(); it++) {
8688             pressedButtonList.push_back(static_cast<int32_t>(*it));
8689         }
8690         event.mouseEvent.pressedButtons = pressedButtonList.data();
8691         SetOnMouseInfo(event, info, usePx);
8692         SendArkUISyncEvent(&event);
8693         info.SetStopPropagation(event.mouseEvent.stopPropagation);
8694     };
8695     ViewAbstract::SetOnMouse(frameNode, onEvent);
8696 }
8697 
SetOnAxisEvent(ArkUINodeHandle node,void * extraParam)8698 void SetOnAxisEvent(ArkUINodeHandle node, void* extraParam)
8699 {
8700     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8701     CHECK_NULL_VOID(frameNode);
8702     int32_t nodeId = frameNode->GetId();
8703     auto onEvent = [nodeId, extraParam](AxisInfo& info) {
8704         ArkUINodeEvent event;
8705         event.kind = AXIS_EVENT;
8706         event.nodeId = nodeId;
8707         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8708         bool usePx = NodeModel::UsePXUnit(reinterpret_cast<ArkUI_Node*>(extraParam));
8709         double density = usePx ? 1 : PipelineBase::GetCurrentDensity();
8710         event.axisEvent.subKind = ON_AXIS;
8711         event.axisEvent.action = static_cast<int32_t>(info.GetAction());
8712         event.axisEvent.timeStamp = static_cast<double>(info.GetTimeStamp().time_since_epoch().count());
8713         event.axisEvent.sourceType = static_cast<int32_t>(info.GetSourceDevice());
8714         event.axisEvent.verticalAxis = static_cast<double>(info.GetVerticalAxis());
8715         event.axisEvent.horizontalAxis = static_cast<double>(info.GetHorizontalAxis());
8716         event.axisEvent.pinchAxisScale = static_cast<double>(info.GetPinchAxisScale());
8717         event.axisEvent.scrollStep = static_cast<int32_t>(info.GetScrollStep());
8718         event.axisEvent.propagation = false;
8719         event.axisEvent.actionTouchPoint.nodeX = info.GetLocalLocation().GetX() / density;
8720         event.axisEvent.actionTouchPoint.nodeY = info.GetLocalLocation().GetY() / density;
8721         event.axisEvent.actionTouchPoint.windowX = info.GetGlobalLocation().GetX() / density;
8722         event.axisEvent.actionTouchPoint.windowY = info.GetGlobalLocation().GetY() / density;
8723         event.axisEvent.actionTouchPoint.screenX = info.GetScreenLocation().GetX() / density;
8724         event.axisEvent.actionTouchPoint.screenY = info.GetScreenLocation().GetY() / density;
8725         event.axisEvent.targetDisplayId = info.GetTargetDisplayId();
8726 
8727         SendArkUISyncEvent(&event);
8728         info.SetStopPropagation(!event.axisEvent.propagation);
8729     };
8730     ViewAbstract::SetOnAxisEvent(frameNode, onEvent);
8731 }
8732 
SetOnAccessibilityActions(ArkUINodeHandle node,void * extraParam)8733 void SetOnAccessibilityActions(ArkUINodeHandle node, void* extraParam)
8734 {
8735     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8736     CHECK_NULL_VOID(frameNode);
8737     int32_t nodeId = frameNode->GetId();
8738     auto onEvent = [nodeId, extraParam](uint32_t actionType) {
8739         ArkUINodeEvent event;
8740         event.kind = COMPONENT_ASYNC_EVENT;
8741         event.nodeId = nodeId;
8742         event.extraParam = reinterpret_cast<intptr_t>(extraParam);
8743         event.componentAsyncEvent.subKind = ON_ACCESSIBILITY_ACTIONS;
8744         event.componentAsyncEvent.data[0].u32 = actionType;
8745         SendArkUISyncEvent(&event);
8746     };
8747     auto accessibilityProperty = frameNode->GetAccessibilityProperty<AccessibilityProperty>();
8748     accessibilityProperty->SetActions(onEvent);
8749 }
8750 
ResetOnAppear(ArkUINodeHandle node)8751 void ResetOnAppear(ArkUINodeHandle node)
8752 {
8753     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8754     CHECK_NULL_VOID(frameNode);
8755     ViewAbstract::DisableOnAppear(frameNode);
8756 }
8757 
ResetOnDisappear(ArkUINodeHandle node)8758 void ResetOnDisappear(ArkUINodeHandle node)
8759 {
8760     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8761     CHECK_NULL_VOID(frameNode);
8762     ViewAbstract::DisableOnDisappear(frameNode);
8763 }
8764 
ResetOnAttach(ArkUINodeHandle node)8765 void ResetOnAttach(ArkUINodeHandle node)
8766 {
8767     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8768     CHECK_NULL_VOID(frameNode);
8769     ViewAbstract::DisableOnAttach(frameNode);
8770 }
8771 
ResetOnDetach(ArkUINodeHandle node)8772 void ResetOnDetach(ArkUINodeHandle node)
8773 {
8774     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8775     CHECK_NULL_VOID(frameNode);
8776     ViewAbstract::DisableOnDetach(frameNode);
8777 }
8778 
ResetOnFocus(ArkUINodeHandle node)8779 void ResetOnFocus(ArkUINodeHandle node)
8780 {
8781     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8782     CHECK_NULL_VOID(frameNode);
8783     ViewAbstract::DisableOnFocus(frameNode);
8784 }
8785 
ResetOnBlur(ArkUINodeHandle node)8786 void ResetOnBlur(ArkUINodeHandle node)
8787 {
8788     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8789     CHECK_NULL_VOID(frameNode);
8790     ViewAbstract::DisableOnBlur(frameNode);
8791 }
8792 
ResetOnAreaChange(ArkUINodeHandle node)8793 void ResetOnAreaChange(ArkUINodeHandle node)
8794 {
8795     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8796     CHECK_NULL_VOID(frameNode);
8797     ViewAbstract::ResetAreaChanged(frameNode);
8798 }
8799 
ResetOnVisibleAreaChange(ArkUINodeHandle node)8800 void ResetOnVisibleAreaChange(ArkUINodeHandle node)
8801 {
8802     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8803     CHECK_NULL_VOID(frameNode);
8804     ViewAbstract::ResetVisibleChange(frameNode);
8805 }
8806 
ResetOnClick(ArkUINodeHandle node)8807 void ResetOnClick(ArkUINodeHandle node)
8808 {
8809     auto* uiNode = reinterpret_cast<UINode*>(node);
8810     CHECK_NULL_VOID(uiNode);
8811     if (uiNode->GetTag() == V2::SPAN_ETS_TAG) {
8812         SpanModelNG::ClearOnClick(uiNode);
8813     } else if (uiNode->GetTag() == V2::TEXT_ETS_TAG) {
8814         auto* frameNode = reinterpret_cast<FrameNode*>(node);
8815         TextModelNG::ClearOnClick(frameNode);
8816     } else {
8817         auto* frameNode = reinterpret_cast<FrameNode*>(node);
8818         ViewAbstract::DisableOnClick(frameNode);
8819     }
8820 }
8821 
ResetOnTouch(ArkUINodeHandle node)8822 void ResetOnTouch(ArkUINodeHandle node)
8823 {
8824     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8825     CHECK_NULL_VOID(frameNode);
8826     ViewAbstract::DisableOnTouch(frameNode);
8827 }
8828 
ResetOnTouchIntercept(ArkUINodeHandle node)8829 void ResetOnTouchIntercept(ArkUINodeHandle node)
8830 {
8831     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8832     CHECK_NULL_VOID(frameNode);
8833     ViewAbstract::SetOnTouchIntercept(frameNode, nullptr);
8834 }
8835 
ResetOnHover(ArkUINodeHandle node)8836 void ResetOnHover(ArkUINodeHandle node)
8837 {
8838     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8839     CHECK_NULL_VOID(frameNode);
8840     ViewAbstract::DisableOnHover(frameNode);
8841 }
8842 
ResetOnHoverMove(ArkUINodeHandle node)8843 void ResetOnHoverMove(ArkUINodeHandle node)
8844 {
8845     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8846     CHECK_NULL_VOID(frameNode);
8847     ViewAbstract::DisableOnHoverMove(frameNode);
8848 }
8849 
ResetOnMouse(ArkUINodeHandle node)8850 void ResetOnMouse(ArkUINodeHandle node)
8851 {
8852     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8853     CHECK_NULL_VOID(frameNode);
8854     ViewAbstract::DisableOnMouse(frameNode);
8855 }
8856 
ResetOnAxisEvent(ArkUINodeHandle node)8857 void ResetOnAxisEvent(ArkUINodeHandle node)
8858 {
8859     auto* frameNode = reinterpret_cast<FrameNode*>(node);
8860     CHECK_NULL_VOID(frameNode);
8861     ViewAbstract::DisableOnAxisEvent(frameNode);
8862 }
8863 } // namespace NodeModifier
8864 } // namespace OHOS::Ace::NG
8865