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