1 /*
2 * Copyright (c) 2022-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
16 #include "core/components_ng/base/view_abstract.h"
17
18 #include <cstdint>
19 #include <optional>
20 #include <string>
21 #include <utility>
22 #if !defined(PREVIEW) && !defined(ACE_UNITTEST) && defined(OHOS_PLATFORM)
23 #include "interfaces/inner_api/ui_session/ui_session_manager.h"
24 #endif
25
26 #include "base/geometry/dimension.h"
27 #include "base/geometry/matrix4.h"
28 #include "base/geometry/ng/offset_t.h"
29 #include "base/memory/ace_type.h"
30 #include "base/subwindow/subwindow.h"
31 #include "base/utils/system_properties.h"
32 #include "base/utils/utils.h"
33 #include "core/common/ace_application_info.h"
34 #include "base/log/log_wrapper.h"
35 #include "core/common/container.h"
36 #include "core/common/container_scope.h"
37 #include "core/components/common/layout/constants.h"
38 #include "core/components/common/properties/shadow.h"
39 #include "core/components/theme/shadow_theme.h"
40 #include "core/components_ng/base/frame_node.h"
41 #include "core/components_ng/base/view_stack_processor.h"
42 #include "core/components_ng/layout/layout_property.h"
43 #include "core/components_ng/pattern/bubble/bubble_pattern.h"
44 #include "core/components_ng/pattern/bubble/bubble_view.h"
45 #include "core/components_ng/pattern/dialog/dialog_pattern.h"
46 #include "core/components_ng/pattern/menu/menu_pattern.h"
47 #include "core/components_ng/pattern/menu/menu_view.h"
48 #include "core/components_ng/pattern/menu/preview/menu_preview_pattern.h"
49 #include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
50 #include "core/components_ng/pattern/option/option_paint_property.h"
51 #include "core/components_ng/pattern/text/span_node.h"
52 #include "core/components_ng/property/border_property.h"
53 #include "core/components_ng/property/calc_length.h"
54 #include "core/components_ng/property/measure_property.h"
55 #include "core/components_ng/property/property.h"
56 #include "core/components_ng/property/safe_area_insets.h"
57 #include "core/components_v2/inspector/inspector_constants.h"
58 #include "core/image/image_source_info.h"
59 #include "core/pipeline_ng/pipeline_context.h"
60 #include "core/pipeline_ng/ui_task_scheduler.h"
61
62 namespace OHOS::Ace::NG {
63
SetWidth(const CalcLength & width)64 void ViewAbstract::SetWidth(const CalcLength& width)
65 {
66 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
67 return;
68 }
69 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
70 CHECK_NULL_VOID(frameNode);
71 auto layoutProperty = frameNode->GetLayoutProperty();
72 CHECK_NULL_VOID(layoutProperty);
73 // get previously user defined ideal height
74 std::optional<CalcLength> height = std::nullopt;
75 auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
76 if (layoutConstraint && layoutConstraint->selfIdealSize) {
77 height = layoutConstraint->selfIdealSize->Height();
78 }
79 layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
80 }
81
SetHeight(const CalcLength & height)82 void ViewAbstract::SetHeight(const CalcLength& height)
83 {
84 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
85 return;
86 }
87 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
88 CHECK_NULL_VOID(frameNode);
89 auto layoutProperty = frameNode->GetLayoutProperty();
90 CHECK_NULL_VOID(layoutProperty);
91 // get previously user defined ideal width
92 std::optional<CalcLength> width = std::nullopt;
93 auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
94 if (layoutConstraint && layoutConstraint->selfIdealSize) {
95 width = layoutConstraint->selfIdealSize->Width();
96 }
97 layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
98 }
99
SetClickEffectLevel(const ClickEffectLevel & level,float scaleValue)100 void ViewAbstract::SetClickEffectLevel(const ClickEffectLevel& level, float scaleValue)
101 {
102 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
103 return;
104 }
105 ClickEffectInfo clickEffectInfo;
106 clickEffectInfo.level = level;
107 clickEffectInfo.scaleNumber = scaleValue;
108 ACE_UPDATE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo);
109 }
110
ClearWidthOrHeight(bool isWidth)111 void ViewAbstract::ClearWidthOrHeight(bool isWidth)
112 {
113 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
114 return;
115 }
116 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
117 CHECK_NULL_VOID(frameNode);
118 auto layoutProperty = frameNode->GetLayoutProperty();
119 CHECK_NULL_VOID(layoutProperty);
120 layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
121 }
122
SetMinWidth(const CalcLength & width)123 void ViewAbstract::SetMinWidth(const CalcLength& width)
124 {
125 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
126 return;
127 }
128 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
129 CHECK_NULL_VOID(frameNode);
130 auto layoutProperty = frameNode->GetLayoutProperty();
131 CHECK_NULL_VOID(layoutProperty);
132 layoutProperty->UpdateCalcMinSize(CalcSize(width, std::nullopt));
133 }
134
SetMinHeight(const CalcLength & height)135 void ViewAbstract::SetMinHeight(const CalcLength& height)
136 {
137 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
138 return;
139 }
140 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
141 CHECK_NULL_VOID(frameNode);
142 auto layoutProperty = frameNode->GetLayoutProperty();
143 CHECK_NULL_VOID(layoutProperty);
144 layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, height));
145 }
146
ResetMinSize(bool resetWidth)147 void ViewAbstract::ResetMinSize(bool resetWidth)
148 {
149 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
150 return;
151 }
152 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
153 CHECK_NULL_VOID(frameNode);
154 auto layoutProperty = frameNode->GetLayoutProperty();
155 CHECK_NULL_VOID(layoutProperty);
156 layoutProperty->ResetCalcMinSize(resetWidth);
157 }
158
SetMaxWidth(const CalcLength & width)159 void ViewAbstract::SetMaxWidth(const CalcLength& width)
160 {
161 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
162 return;
163 }
164 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
165 CHECK_NULL_VOID(frameNode);
166 auto layoutProperty = frameNode->GetLayoutProperty();
167 CHECK_NULL_VOID(layoutProperty);
168 layoutProperty->UpdateCalcMaxSize(CalcSize(width, std::nullopt));
169 }
170
SetMaxHeight(const CalcLength & height)171 void ViewAbstract::SetMaxHeight(const CalcLength& height)
172 {
173 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
174 return;
175 }
176 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
177 CHECK_NULL_VOID(frameNode);
178 auto layoutProperty = frameNode->GetLayoutProperty();
179 CHECK_NULL_VOID(layoutProperty);
180 layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, height));
181 }
182
ResetMaxSize(bool resetWidth)183 void ViewAbstract::ResetMaxSize(bool resetWidth)
184 {
185 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
186 return;
187 }
188 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
189 CHECK_NULL_VOID(frameNode);
190 auto layoutProperty = frameNode->GetLayoutProperty();
191 CHECK_NULL_VOID(layoutProperty);
192 layoutProperty->ResetCalcMaxSize(resetWidth);
193 }
194
SetAspectRatio(float ratio)195 void ViewAbstract::SetAspectRatio(float ratio)
196 {
197 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
198 return;
199 }
200 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio);
201 }
202
ResetAspectRatio()203 void ViewAbstract::ResetAspectRatio()
204 {
205 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
206 return;
207 }
208 ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, AspectRatio);
209 }
210
SetBackgroundAlign(const Alignment & align)211 void ViewAbstract::SetBackgroundAlign(const Alignment& align)
212 {
213 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
214 return;
215 }
216 ACE_UPDATE_RENDER_CONTEXT(BackgroundAlign, align);
217 }
218
SetBackgroundColor(const Color & color)219 void ViewAbstract::SetBackgroundColor(const Color& color)
220 {
221 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
222 return;
223 }
224
225 Color updateColor = color;
226 auto pipeline = PipelineContext::GetCurrentContext();
227 if (pipeline != nullptr) {
228 pipeline->CheckNeedUpdateBackgroundColor(updateColor);
229 }
230
231 ACE_UPDATE_RENDER_CONTEXT(BackgroundColor, updateColor);
232 }
233
SetBackgroundColor(FrameNode * frameNode,const Color & color)234 void ViewAbstract::SetBackgroundColor(FrameNode* frameNode, const Color& color)
235 {
236 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundColor, color, frameNode);
237 }
238
SetBackgroundImage(const ImageSourceInfo & src)239 void ViewAbstract::SetBackgroundImage(const ImageSourceInfo& src)
240 {
241 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
242 return;
243 }
244 auto pipeline = PipelineContext::GetCurrentContext();
245 if (pipeline != nullptr) {
246 bool disableSetImage = pipeline->CheckNeedDisableUpdateBackgroundImage();
247 if (disableSetImage) {
248 return;
249 }
250 }
251 ACE_UPDATE_RENDER_CONTEXT(BackgroundImage, src);
252 }
253
SetBackgroundImage(FrameNode * frameNode,const ImageSourceInfo & src)254 void ViewAbstract::SetBackgroundImage(FrameNode* frameNode, const ImageSourceInfo& src)
255 {
256 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImage, src, frameNode);
257 }
258
SetBackgroundImageRepeat(const ImageRepeat & imageRepeat)259 void ViewAbstract::SetBackgroundImageRepeat(const ImageRepeat& imageRepeat)
260 {
261 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
262 return;
263 }
264 ACE_UPDATE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat);
265 }
266
SetBackgroundImageRepeat(FrameNode * frameNode,const ImageRepeat & imageRepeat)267 void ViewAbstract::SetBackgroundImageRepeat(FrameNode* frameNode, const ImageRepeat& imageRepeat)
268 {
269 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat, frameNode);
270 }
271
SetBackgroundImageSize(const BackgroundImageSize & bgImgSize)272 void ViewAbstract::SetBackgroundImageSize(const BackgroundImageSize& bgImgSize)
273 {
274 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
275 return;
276 }
277 ACE_UPDATE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize);
278 }
279
SetBackgroundImageSize(FrameNode * frameNode,const BackgroundImageSize & bgImgSize)280 void ViewAbstract::SetBackgroundImageSize(FrameNode* frameNode, const BackgroundImageSize& bgImgSize)
281 {
282 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize, frameNode);
283 }
284
SetBackgroundImagePosition(const BackgroundImagePosition & bgImgPosition)285 void ViewAbstract::SetBackgroundImagePosition(const BackgroundImagePosition& bgImgPosition)
286 {
287 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
288 return;
289 }
290 ACE_UPDATE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition);
291 }
292
SetBackgroundImagePosition(FrameNode * frameNode,const BackgroundImagePosition & bgImgPosition)293 void ViewAbstract::SetBackgroundImagePosition(FrameNode* frameNode, const BackgroundImagePosition& bgImgPosition)
294 {
295 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition, frameNode);
296 }
297
SetBackgroundBlurStyle(const BlurStyleOption & bgBlurStyle)298 void ViewAbstract::SetBackgroundBlurStyle(const BlurStyleOption& bgBlurStyle)
299 {
300 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
301 return;
302 }
303 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
304 CHECK_NULL_VOID(frameNode);
305 auto target = frameNode->GetRenderContext();
306 if (target) {
307 if (target->GetBackgroundEffect().has_value()) {
308 target->UpdateBackgroundEffect(std::nullopt);
309 }
310 target->UpdateBackBlurStyle(bgBlurStyle);
311 if (target->GetBackBlurRadius().has_value()) {
312 target->UpdateBackBlurRadius(Dimension());
313 }
314 }
315 }
316
SetForegroundEffect(float radius)317 void ViewAbstract::SetForegroundEffect(float radius)
318 {
319 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
320 return;
321 }
322 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
323 CHECK_NULL_VOID(frameNode);
324 auto target = frameNode->GetRenderContext();
325 if (target) {
326 target->UpdateForegroundEffect(radius);
327 }
328 }
329
SetMotionBlur(const MotionBlurOption & motionBlurOption)330 void ViewAbstract::SetMotionBlur(const MotionBlurOption &motionBlurOption)
331 {
332 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
333 return;
334 }
335 ACE_UPDATE_RENDER_CONTEXT(MotionBlur, motionBlurOption);
336 }
337
SetBackgroundEffect(const EffectOption & effectOption)338 void ViewAbstract::SetBackgroundEffect(const EffectOption& effectOption)
339 {
340 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
341 return;
342 }
343 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
344 CHECK_NULL_VOID(frameNode);
345 auto target = frameNode->GetRenderContext();
346 if (target) {
347 if (target->GetBackBlurRadius().has_value()) {
348 target->UpdateBackBlurRadius(Dimension());
349 }
350 if (target->GetBackBlurStyle().has_value()) {
351 target->UpdateBackBlurStyle(std::nullopt);
352 }
353 target->UpdateBackgroundEffect(effectOption);
354 }
355 }
356
SetForegroundBlurStyle(const BlurStyleOption & fgBlurStyle)357 void ViewAbstract::SetForegroundBlurStyle(const BlurStyleOption& fgBlurStyle)
358 {
359 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
360 return;
361 }
362 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
363 CHECK_NULL_VOID(frameNode);
364 auto target = frameNode->GetRenderContext();
365 if (target) {
366 target->UpdateFrontBlurStyle(fgBlurStyle);
367 if (target->GetFrontBlurRadius().has_value()) {
368 target->UpdateFrontBlurRadius(Dimension());
369 }
370 }
371 }
372
SetSphericalEffect(double radio)373 void ViewAbstract::SetSphericalEffect(double radio)
374 {
375 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
376 return;
377 }
378 ACE_UPDATE_RENDER_CONTEXT(SphericalEffect, radio);
379 }
380
SetPixelStretchEffect(PixStretchEffectOption & option)381 void ViewAbstract::SetPixelStretchEffect(PixStretchEffectOption& option)
382 {
383 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
384 return;
385 }
386 ACE_UPDATE_RENDER_CONTEXT(PixelStretchEffect, option);
387 }
388
SetLightUpEffect(double radio)389 void ViewAbstract::SetLightUpEffect(double radio)
390 {
391 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
392 return;
393 }
394 ACE_UPDATE_RENDER_CONTEXT(LightUpEffect, radio);
395 }
396
SetLayoutWeight(float value)397 void ViewAbstract::SetLayoutWeight(float value)
398 {
399 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
400 return;
401 }
402 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, static_cast<float>(value));
403 }
404
SetPixelRound(uint8_t value)405 void ViewAbstract::SetPixelRound(uint8_t value)
406 {
407 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
408 return;
409 }
410 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, PixelRound, value);
411 }
412
SetPixelRound(FrameNode * frameNode,uint8_t value)413 void ViewAbstract::SetPixelRound(FrameNode* frameNode, uint8_t value)
414 {
415 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, PixelRound, value, frameNode);
416 }
417
SetLayoutDirection(TextDirection value)418 void ViewAbstract::SetLayoutDirection(TextDirection value)
419 {
420 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
421 return;
422 }
423 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value);
424 }
425
SetAlignRules(const std::map<AlignDirection,AlignRule> & alignRules)426 void ViewAbstract::SetAlignRules(const std::map<AlignDirection, AlignRule>& alignRules)
427 {
428 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
429 return;
430 }
431 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules);
432 }
433
SetChainStyle(const ChainInfo & chainInfo)434 void ViewAbstract::SetChainStyle(const ChainInfo& chainInfo)
435 {
436 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
437 return;
438 }
439 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, ChainStyle, chainInfo);
440 }
441
SetBias(const BiasPair & biasPair)442 void ViewAbstract::SetBias(const BiasPair& biasPair)
443 {
444 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
445 return;
446 }
447 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Bias, biasPair);
448 }
449
SetAlignSelf(FlexAlign value)450 void ViewAbstract::SetAlignSelf(FlexAlign value)
451 {
452 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
453 return;
454 }
455 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value);
456 }
457
SetFlexShrink(float value)458 void ViewAbstract::SetFlexShrink(float value)
459 {
460 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
461 return;
462 }
463 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value);
464 }
465
ResetFlexShrink()466 void ViewAbstract::ResetFlexShrink()
467 {
468 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
469 return;
470 }
471 ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, FlexShrink);
472 }
473
SetFlexGrow(float value)474 void ViewAbstract::SetFlexGrow(float value)
475 {
476 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
477 return;
478 }
479 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value);
480 }
481
SetFlexBasis(const Dimension & value)482 void ViewAbstract::SetFlexBasis(const Dimension& value)
483 {
484 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
485 return;
486 }
487 if (LessNotEqual(value.Value(), 0.0f)) {
488 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension());
489 return;
490 }
491 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value);
492 }
493
SetDisplayIndex(int32_t value)494 void ViewAbstract::SetDisplayIndex(int32_t value)
495 {
496 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
497 return;
498 }
499 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value);
500 }
501
SetPadding(const CalcLength & value)502 void ViewAbstract::SetPadding(const CalcLength& value)
503 {
504 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
505 return;
506 }
507 PaddingProperty padding;
508 padding.SetEdges(value);
509 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding);
510 }
511
SetPadding(const PaddingProperty & value)512 void ViewAbstract::SetPadding(const PaddingProperty& value)
513 {
514 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
515 return;
516 }
517 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, value);
518 }
519
SetMargin(const CalcLength & value)520 void ViewAbstract::SetMargin(const CalcLength& value)
521 {
522 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
523 return;
524 }
525 MarginProperty margin;
526 margin.SetEdges(value);
527 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin);
528 }
529
SetMargin(const MarginProperty & value)530 void ViewAbstract::SetMargin(const MarginProperty& value)
531 {
532 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
533 return;
534 }
535 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, value);
536 }
537
SetBorderRadius(const Dimension & value)538 void ViewAbstract::SetBorderRadius(const Dimension& value)
539 {
540 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
541 return;
542 }
543 BorderRadiusProperty borderRadius;
544 borderRadius.SetRadius(value);
545 borderRadius.multiValued = false;
546 ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius);
547 }
548
SetBorderRadius(const BorderRadiusProperty & value)549 void ViewAbstract::SetBorderRadius(const BorderRadiusProperty& value)
550 {
551 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
552 return;
553 }
554 ACE_UPDATE_RENDER_CONTEXT(BorderRadius, value);
555 }
556
SetBorderColor(const Color & value)557 void ViewAbstract::SetBorderColor(const Color& value)
558 {
559 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
560 return;
561 }
562 BorderColorProperty borderColor;
563 borderColor.SetColor(value);
564 ACE_UPDATE_RENDER_CONTEXT(BorderColor, borderColor);
565 }
566
SetBorderColor(const BorderColorProperty & value)567 void ViewAbstract::SetBorderColor(const BorderColorProperty& value)
568 {
569 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
570 return;
571 }
572 ACE_UPDATE_RENDER_CONTEXT(BorderColor, value);
573 }
574
SetBorderWidth(const Dimension & value)575 void ViewAbstract::SetBorderWidth(const Dimension& value)
576 {
577 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
578 return;
579 }
580 BorderWidthProperty borderWidth;
581 if (Negative(value.Value())) {
582 borderWidth.SetBorderWidth(Dimension(0));
583 } else {
584 borderWidth.SetBorderWidth(value);
585 }
586 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth);
587 ACE_UPDATE_RENDER_CONTEXT(BorderWidth, borderWidth);
588 }
589
SetBorderWidth(const BorderWidthProperty & value)590 void ViewAbstract::SetBorderWidth(const BorderWidthProperty& value)
591 {
592 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
593 return;
594 }
595 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value);
596 ACE_UPDATE_RENDER_CONTEXT(BorderWidth, value);
597 }
598
SetBorderStyle(const BorderStyle & value)599 void ViewAbstract::SetBorderStyle(const BorderStyle& value)
600 {
601 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
602 return;
603 }
604 BorderStyleProperty borderStyle;
605 borderStyle.SetBorderStyle(value);
606 ACE_UPDATE_RENDER_CONTEXT(BorderStyle, borderStyle);
607 }
608
SetBorderStyle(FrameNode * frameNode,const BorderStyle & value)609 void ViewAbstract::SetBorderStyle(FrameNode* frameNode, const BorderStyle& value)
610 {
611 BorderStyleProperty borderStyle;
612 borderStyle.SetBorderStyle(value);
613 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, borderStyle, frameNode);
614 }
615
SetBorderStyle(const BorderStyleProperty & value)616 void ViewAbstract::SetBorderStyle(const BorderStyleProperty& value)
617 {
618 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
619 return;
620 }
621 ACE_UPDATE_RENDER_CONTEXT(BorderStyle, value);
622 }
623
SetBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)624 void ViewAbstract::SetBorderStyle(FrameNode* frameNode, const BorderStyleProperty& value)
625 {
626 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, value, frameNode);
627 }
628
SetDashGap(const Dimension & value)629 void ViewAbstract::SetDashGap(const Dimension& value)
630 {
631 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
632 return;
633 }
634 BorderWidthProperty dashGap;
635 dashGap.SetBorderWidth(value);
636
637 ACE_UPDATE_RENDER_CONTEXT(DashGap, dashGap);
638 }
639
SetDashGap(FrameNode * frameNode,const Dimension & value)640 void ViewAbstract::SetDashGap(FrameNode *frameNode, const Dimension& value)
641 {
642 BorderWidthProperty dashGap;
643 dashGap.SetBorderWidth(value);
644
645 ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, dashGap, frameNode);
646 }
647
SetDashGap(const BorderWidthProperty & value)648 void ViewAbstract::SetDashGap(const BorderWidthProperty& value)
649 {
650 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
651 return;
652 }
653 ACE_UPDATE_RENDER_CONTEXT(DashGap, value);
654 }
655
SetDashGap(FrameNode * frameNode,const BorderWidthProperty & value)656 void ViewAbstract::SetDashGap(FrameNode *frameNode, const BorderWidthProperty& value)
657 {
658 ACE_UPDATE_NODE_RENDER_CONTEXT(DashGap, value, frameNode);
659 }
660
SetDashWidth(const Dimension & value)661 void ViewAbstract::SetDashWidth(const Dimension& value)
662 {
663 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
664 return;
665 }
666 BorderWidthProperty dashWidth;
667 dashWidth.SetBorderWidth(value);
668
669 ACE_UPDATE_RENDER_CONTEXT(DashWidth, dashWidth);
670 }
671
SetDashWidth(FrameNode * frameNode,const Dimension & value)672 void ViewAbstract::SetDashWidth(FrameNode *frameNode, const Dimension& value)
673 {
674 BorderWidthProperty dashWidth;
675 dashWidth.SetBorderWidth(value);
676
677 ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, dashWidth, frameNode);
678 }
679
SetDashWidth(const BorderWidthProperty & value)680 void ViewAbstract::SetDashWidth(const BorderWidthProperty& value)
681 {
682 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
683 return;
684 }
685 ACE_UPDATE_RENDER_CONTEXT(DashWidth, value);
686 }
687
SetDashWidth(FrameNode * frameNode,const BorderWidthProperty & value)688 void ViewAbstract::SetDashWidth(FrameNode *frameNode, const BorderWidthProperty& value)
689 {
690 ACE_UPDATE_NODE_RENDER_CONTEXT(DashWidth, value, frameNode);
691 }
692
SetOuterBorderRadius(const Dimension & value)693 void ViewAbstract::SetOuterBorderRadius(const Dimension& value)
694 {
695 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
696 return;
697 }
698 BorderRadiusProperty borderRadius;
699 borderRadius.SetRadius(value);
700 borderRadius.multiValued = false;
701 ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, borderRadius);
702 }
703
SetOuterBorderRadius(FrameNode * frameNode,const Dimension & value)704 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const Dimension& value)
705 {
706 BorderRadiusProperty borderRadius;
707 borderRadius.SetRadius(value);
708 borderRadius.multiValued = false;
709 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, borderRadius, frameNode);
710 }
711
SetOuterBorderRadius(const BorderRadiusProperty & value)712 void ViewAbstract::SetOuterBorderRadius(const BorderRadiusProperty& value)
713 {
714 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
715 return;
716 }
717 ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, value);
718 }
719
SetOuterBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)720 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const BorderRadiusProperty& value)
721 {
722 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, value, frameNode);
723 }
724
SetOuterBorderColor(const Color & value)725 void ViewAbstract::SetOuterBorderColor(const Color& value)
726 {
727 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
728 return;
729 }
730 BorderColorProperty borderColor;
731 borderColor.SetColor(value);
732 ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, borderColor);
733 }
734
SetOuterBorderColor(FrameNode * frameNode,const Color & value)735 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const Color& value)
736 {
737 BorderColorProperty borderColor;
738 borderColor.SetColor(value);
739 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, borderColor, frameNode);
740 }
741
SetOuterBorderColor(const BorderColorProperty & value)742 void ViewAbstract::SetOuterBorderColor(const BorderColorProperty& value)
743 {
744 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
745 return;
746 }
747 ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, value);
748 }
749
SetOuterBorderColor(FrameNode * frameNode,const BorderColorProperty & value)750 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const BorderColorProperty& value)
751 {
752 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, value, frameNode);
753 }
754
SetOuterBorderWidth(const Dimension & value)755 void ViewAbstract::SetOuterBorderWidth(const Dimension& value)
756 {
757 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
758 return;
759 }
760 BorderWidthProperty borderWidth;
761 if (Negative(value.Value())) {
762 borderWidth.SetBorderWidth(Dimension(0));
763 } else {
764 borderWidth.SetBorderWidth(value);
765 }
766 ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, borderWidth);
767 }
768
SetOuterBorderWidth(FrameNode * frameNode,const Dimension & value)769 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const Dimension& value)
770 {
771 BorderWidthProperty borderWidth;
772 if (Negative(value.Value())) {
773 borderWidth.SetBorderWidth(Dimension(0));
774 } else {
775 borderWidth.SetBorderWidth(value);
776 }
777 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, borderWidth, frameNode);
778 }
779
SetOuterBorderWidth(const BorderWidthProperty & value)780 void ViewAbstract::SetOuterBorderWidth(const BorderWidthProperty& value)
781 {
782 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
783 return;
784 }
785 ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, value);
786 }
787
SetOuterBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)788 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value)
789 {
790 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, value, frameNode);
791 }
792
SetOuterBorderStyle(const BorderStyleProperty & value)793 void ViewAbstract::SetOuterBorderStyle(const BorderStyleProperty& value)
794 {
795 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
796 return;
797 }
798 ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, value);
799 }
800
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)801 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyleProperty& value)
802 {
803 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, value, frameNode);
804 }
805
SetOuterBorderStyle(const BorderStyle & value)806 void ViewAbstract::SetOuterBorderStyle(const BorderStyle& value)
807 {
808 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
809 return;
810 }
811 BorderStyleProperty borderStyle;
812 borderStyle.SetBorderStyle(value);
813 ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, borderStyle);
814 }
815
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyle & value)816 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyle& value)
817 {
818 BorderStyleProperty borderStyle;
819 borderStyle.SetBorderStyle(value);
820 ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, borderStyle, frameNode);
821 }
822
DisableOnClick()823 void ViewAbstract::DisableOnClick()
824 {
825 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
826 CHECK_NULL_VOID(gestureHub);
827 gestureHub->ClearUserOnClick();
828 }
829
DisableOnTouch()830 void ViewAbstract::DisableOnTouch()
831 {
832 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
833 CHECK_NULL_VOID(gestureHub);
834 gestureHub->ClearUserOnTouch();
835 }
836
DisableOnKeyEvent()837 void ViewAbstract::DisableOnKeyEvent()
838 {
839 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
840 CHECK_NULL_VOID(focusHub);
841 focusHub->ClearUserOnKey();
842 }
843
DisableOnHover()844 void ViewAbstract::DisableOnHover()
845 {
846 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
847 CHECK_NULL_VOID(eventHub);
848 eventHub->ClearUserOnHover();
849 }
850
DisableOnAccessibilityHover()851 void ViewAbstract::DisableOnAccessibilityHover()
852 {
853 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
854 CHECK_NULL_VOID(eventHub);
855 eventHub->ClearUserOnAccessibilityHover();
856 }
857
DisableOnMouse()858 void ViewAbstract::DisableOnMouse()
859 {
860 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
861 CHECK_NULL_VOID(eventHub);
862 eventHub->ClearUserOnMouse();
863 }
864
DisableOnAppear()865 void ViewAbstract::DisableOnAppear()
866 {
867 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
868 CHECK_NULL_VOID(eventHub);
869 eventHub->ClearUserOnAppear();
870 }
871
DisableOnDisAppear()872 void ViewAbstract::DisableOnDisAppear()
873 {
874 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
875 CHECK_NULL_VOID(eventHub);
876 eventHub->ClearUserOnDisAppear();
877 }
878
DisableOnAttach()879 void ViewAbstract::DisableOnAttach()
880 {
881 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
882 CHECK_NULL_VOID(eventHub);
883 eventHub->ClearOnAttach();
884 }
885
DisableOnDetach()886 void ViewAbstract::DisableOnDetach()
887 {
888 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
889 CHECK_NULL_VOID(eventHub);
890 eventHub->ClearOnDetach();
891 }
892
DisableOnAreaChange()893 void ViewAbstract::DisableOnAreaChange()
894 {
895 auto pipeline = PipelineContext::GetCurrentContext();
896 CHECK_NULL_VOID(pipeline);
897 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
898 CHECK_NULL_VOID(frameNode);
899 frameNode->ClearUserOnAreaChange();
900 }
901
DisableOnFocus()902 void ViewAbstract::DisableOnFocus()
903 {
904 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
905 CHECK_NULL_VOID(focusHub);
906 focusHub->ClearUserOnFocus();
907 }
908
DisableOnBlur()909 void ViewAbstract::DisableOnBlur()
910 {
911 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
912 CHECK_NULL_VOID(focusHub);
913 focusHub->ClearUserOnBlur();
914 }
915
DisableOnClick(FrameNode * frameNode)916 void ViewAbstract::DisableOnClick(FrameNode* frameNode)
917 {
918 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
919 CHECK_NULL_VOID(gestureHub);
920 gestureHub->ClearUserOnClick();
921 }
922
DisableOnTouch(FrameNode * frameNode)923 void ViewAbstract::DisableOnTouch(FrameNode* frameNode)
924 {
925 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
926 CHECK_NULL_VOID(gestureHub);
927 gestureHub->ClearUserOnTouch();
928 }
929
DisableOnKeyEvent(FrameNode * frameNode)930 void ViewAbstract::DisableOnKeyEvent(FrameNode* frameNode)
931 {
932 auto focusHub = frameNode->GetOrCreateFocusHub();
933 CHECK_NULL_VOID(focusHub);
934 focusHub->ClearUserOnKey();
935 }
936
DisableOnHover(FrameNode * frameNode)937 void ViewAbstract::DisableOnHover(FrameNode* frameNode)
938 {
939 auto eventHub = frameNode->GetOrCreateInputEventHub();
940 CHECK_NULL_VOID(eventHub);
941 eventHub->ClearUserOnHover();
942 }
943
DisableOnMouse(FrameNode * frameNode)944 void ViewAbstract::DisableOnMouse(FrameNode* frameNode)
945 {
946 auto eventHub = frameNode->GetOrCreateInputEventHub();
947 CHECK_NULL_VOID(eventHub);
948 eventHub->ClearUserOnMouse();
949 }
950
DisableOnAppear(FrameNode * frameNode)951 void ViewAbstract::DisableOnAppear(FrameNode* frameNode)
952 {
953 auto eventHub = frameNode->GetEventHub<EventHub>();
954 CHECK_NULL_VOID(eventHub);
955 eventHub->ClearUserOnAppear();
956 }
957
DisableOnDisappear(FrameNode * frameNode)958 void ViewAbstract::DisableOnDisappear(FrameNode* frameNode)
959 {
960 auto eventHub = frameNode->GetEventHub<EventHub>();
961 CHECK_NULL_VOID(eventHub);
962 eventHub->ClearUserOnDisAppear();
963 }
964
DisableOnAttach(FrameNode * frameNode)965 void ViewAbstract::DisableOnAttach(FrameNode* frameNode)
966 {
967 auto eventHub = frameNode->GetEventHub<EventHub>();
968 CHECK_NULL_VOID(eventHub);
969 eventHub->ClearOnAttach();
970 }
971
DisableOnDetach(FrameNode * frameNode)972 void ViewAbstract::DisableOnDetach(FrameNode* frameNode)
973 {
974 auto eventHub = frameNode->GetEventHub<EventHub>();
975 CHECK_NULL_VOID(eventHub);
976 eventHub->ClearOnDetach();
977 }
978
DisableOnFocus(FrameNode * frameNode)979 void ViewAbstract::DisableOnFocus(FrameNode* frameNode)
980 {
981 auto focusHub = frameNode->GetOrCreateFocusHub();
982 CHECK_NULL_VOID(focusHub);
983 focusHub->ClearUserOnFocus();
984 }
985
DisableOnBlur(FrameNode * frameNode)986 void ViewAbstract::DisableOnBlur(FrameNode* frameNode)
987 {
988 auto focusHub = frameNode->GetOrCreateFocusHub();
989 CHECK_NULL_VOID(focusHub);
990 focusHub->ClearUserOnBlur();
991 }
992
DisableOnAreaChange(FrameNode * frameNode)993 void ViewAbstract::DisableOnAreaChange(FrameNode* frameNode)
994 {
995 CHECK_NULL_VOID(frameNode);
996 frameNode->ClearUserOnAreaChange();
997 }
998
SetOnClick(GestureEventFunc && clickEventFunc,double distanceThreshold)999 void ViewAbstract::SetOnClick(GestureEventFunc&& clickEventFunc, double distanceThreshold)
1000 {
1001 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1002 CHECK_NULL_VOID(frameNode);
1003 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1004 CHECK_NULL_VOID(gestureHub);
1005 gestureHub->SetUserOnClick(std::move(clickEventFunc), distanceThreshold);
1006
1007 auto focusHub = frameNode->GetOrCreateFocusHub();
1008 CHECK_NULL_VOID(focusHub);
1009 focusHub->SetFocusable(true, false);
1010 }
1011
SetOnGestureJudgeBegin(GestureJudgeFunc && gestureJudgeFunc)1012 void ViewAbstract::SetOnGestureJudgeBegin(GestureJudgeFunc&& gestureJudgeFunc)
1013 {
1014 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1015 CHECK_NULL_VOID(gestureHub);
1016 gestureHub->SetOnGestureJudgeBegin(std::move(gestureJudgeFunc));
1017 }
1018
SetOnTouchIntercept(TouchInterceptFunc && touchInterceptFunc)1019 void ViewAbstract::SetOnTouchIntercept(TouchInterceptFunc&& touchInterceptFunc)
1020 {
1021 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1022 CHECK_NULL_VOID(gestureHub);
1023 gestureHub->SetOnTouchIntercept(std::move(touchInterceptFunc));
1024 }
1025
SetShouldBuiltInRecognizerParallelWith(NG::ShouldBuiltInRecognizerParallelWithFunc && shouldBuiltInRecognizerParallelWithFunc)1026 void ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
1027 NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc)
1028 {
1029 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1030 CHECK_NULL_VOID(gestureHub);
1031 gestureHub->SetShouldBuildinRecognizerParallelWithFunc(std::move(shouldBuiltInRecognizerParallelWithFunc));
1032 }
1033
SetOnGestureRecognizerJudgeBegin(GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc,bool exposeInnerGestureFlag)1034 void ViewAbstract::SetOnGestureRecognizerJudgeBegin(
1035 GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc, bool exposeInnerGestureFlag)
1036 {
1037 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1038 CHECK_NULL_VOID(frameNode);
1039 frameNode->SetExposeInnerGestureFlag(exposeInnerGestureFlag);
1040
1041 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1042 CHECK_NULL_VOID(gestureHub);
1043 gestureHub->SetOnGestureRecognizerJudgeBegin(std::move(gestureRecognizerJudgeFunc));
1044 }
1045
SetOnTouch(TouchEventFunc && touchEventFunc)1046 void ViewAbstract::SetOnTouch(TouchEventFunc&& touchEventFunc)
1047 {
1048 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1049 CHECK_NULL_VOID(gestureHub);
1050 gestureHub->SetTouchEvent(std::move(touchEventFunc));
1051 }
1052
SetOnMouse(OnMouseEventFunc && onMouseEventFunc)1053 void ViewAbstract::SetOnMouse(OnMouseEventFunc&& onMouseEventFunc)
1054 {
1055 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1056 CHECK_NULL_VOID(eventHub);
1057 eventHub->SetMouseEvent(std::move(onMouseEventFunc));
1058 }
1059
SetOnHover(OnHoverFunc && onHoverEventFunc)1060 void ViewAbstract::SetOnHover(OnHoverFunc&& onHoverEventFunc)
1061 {
1062 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1063 CHECK_NULL_VOID(eventHub);
1064 eventHub->SetHoverEvent(std::move(onHoverEventFunc));
1065 }
1066
SetOnAccessibilityHover(OnAccessibilityHoverFunc && onAccessibilityHoverEventFunc)1067 void ViewAbstract::SetOnAccessibilityHover(OnAccessibilityHoverFunc &&onAccessibilityHoverEventFunc)
1068 {
1069 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1070 CHECK_NULL_VOID(eventHub);
1071 eventHub->SetAccessibilityHoverEvent(std::move(onAccessibilityHoverEventFunc));
1072 }
1073
SetHoverEffect(HoverEffectType hoverEffect)1074 void ViewAbstract::SetHoverEffect(HoverEffectType hoverEffect)
1075 {
1076 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1077 CHECK_NULL_VOID(eventHub);
1078 eventHub->SetHoverEffect(hoverEffect);
1079 }
1080
SetHoverEffectAuto(HoverEffectType hoverEffect)1081 void ViewAbstract::SetHoverEffectAuto(HoverEffectType hoverEffect)
1082 {
1083 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
1084 CHECK_NULL_VOID(eventHub);
1085 eventHub->SetHoverEffectAuto(hoverEffect);
1086 }
1087
SetEnabled(bool enabled)1088 void ViewAbstract::SetEnabled(bool enabled)
1089 {
1090 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1091 CHECK_NULL_VOID(frameNode);
1092 auto eventHub = frameNode->GetEventHub<EventHub>();
1093 if (eventHub) {
1094 eventHub->SetEnabled(enabled);
1095 }
1096
1097 // The SetEnabled of focusHub must be after at eventHub
1098 auto focusHub = frameNode->GetOrCreateFocusHub();
1099 if (focusHub) {
1100 focusHub->SetEnabled(enabled);
1101 }
1102 }
1103
SetFocusable(bool focusable)1104 void ViewAbstract::SetFocusable(bool focusable)
1105 {
1106 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1107 CHECK_NULL_VOID(focusHub);
1108 focusHub->SetFocusable(focusable);
1109 }
1110
SetOnFocus(OnFocusFunc && onFocusCallback)1111 void ViewAbstract::SetOnFocus(OnFocusFunc&& onFocusCallback)
1112 {
1113 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1114 CHECK_NULL_VOID(focusHub);
1115 focusHub->SetOnFocusCallback(std::move(onFocusCallback));
1116 }
1117
SetOnBlur(OnBlurFunc && onBlurCallback)1118 void ViewAbstract::SetOnBlur(OnBlurFunc&& onBlurCallback)
1119 {
1120 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1121 CHECK_NULL_VOID(focusHub);
1122 focusHub->SetOnBlurCallback(std::move(onBlurCallback));
1123 }
1124
SetOnKeyEvent(OnKeyCallbackFunc && onKeyCallback)1125 void ViewAbstract::SetOnKeyEvent(OnKeyCallbackFunc&& onKeyCallback)
1126 {
1127 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1128 CHECK_NULL_VOID(focusHub);
1129 focusHub->SetOnKeyCallback(std::move(onKeyCallback));
1130 }
1131
SetTabIndex(int32_t index)1132 void ViewAbstract::SetTabIndex(int32_t index)
1133 {
1134 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1135 CHECK_NULL_VOID(focusHub);
1136 focusHub->SetTabIndex(index);
1137 }
1138
SetFocusOnTouch(bool isSet)1139 void ViewAbstract::SetFocusOnTouch(bool isSet)
1140 {
1141 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1142 CHECK_NULL_VOID(focusHub);
1143 focusHub->SetIsFocusOnTouch(isSet);
1144 }
1145
SetFocusBoxStyle(const NG::FocusBoxStyle & style)1146 void ViewAbstract::SetFocusBoxStyle(const NG::FocusBoxStyle& style)
1147 {
1148 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1149 CHECK_NULL_VOID(focusHub);
1150 focusHub->GetFocusBox().SetStyle(style);
1151 }
1152
SetDefaultFocus(bool isSet)1153 void ViewAbstract::SetDefaultFocus(bool isSet)
1154 {
1155 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1156 CHECK_NULL_VOID(focusHub);
1157 focusHub->SetIsDefaultFocus(isSet);
1158 }
1159
SetGroupDefaultFocus(bool isSet)1160 void ViewAbstract::SetGroupDefaultFocus(bool isSet)
1161 {
1162 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1163 CHECK_NULL_VOID(focusHub);
1164 focusHub->SetIsDefaultGroupFocus(isSet);
1165 }
1166
SetOnAppear(std::function<void ()> && onAppear)1167 void ViewAbstract::SetOnAppear(std::function<void()>&& onAppear)
1168 {
1169 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1170 CHECK_NULL_VOID(eventHub);
1171 eventHub->SetOnAppear(std::move(onAppear));
1172 }
1173
SetOnDisappear(std::function<void ()> && onDisappear)1174 void ViewAbstract::SetOnDisappear(std::function<void()>&& onDisappear)
1175 {
1176 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1177 CHECK_NULL_VOID(eventHub);
1178 eventHub->SetOnDisappear(std::move(onDisappear));
1179 }
1180
SetOnAttach(std::function<void ()> && onAttach)1181 void ViewAbstract::SetOnAttach(std::function<void()> &&onAttach)
1182 {
1183 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1184 CHECK_NULL_VOID(eventHub);
1185 eventHub->SetOnAttach(std::move(onAttach));
1186 }
1187
SetOnDetach(std::function<void ()> && onDetach)1188 void ViewAbstract::SetOnDetach(std::function<void()> &&onDetach)
1189 {
1190 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1191 CHECK_NULL_VOID(eventHub);
1192 eventHub->SetOnDetach(std::move(onDetach));
1193 }
1194
SetOnAreaChanged(std::function<void (const RectF & oldRect,const OffsetF & oldOrigin,const RectF & rect,const OffsetF & origin)> && onAreaChanged)1195 void ViewAbstract::SetOnAreaChanged(
1196 std::function<void(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin)>&&
1197 onAreaChanged)
1198 {
1199 auto pipeline = PipelineContext::GetCurrentContext();
1200 CHECK_NULL_VOID(pipeline);
1201 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1202 CHECK_NULL_VOID(frameNode);
1203 frameNode->SetOnAreaChangeCallback(std::move(onAreaChanged));
1204 pipeline->AddOnAreaChangeNode(frameNode->GetId());
1205 }
1206
SetOnSizeChanged(std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)1207 void ViewAbstract::SetOnSizeChanged(std::function<void(const RectF &oldRect, const RectF &rect)> &&onSizeChanged)
1208 {
1209 auto pipeline = PipelineContext::GetCurrentContext();
1210 CHECK_NULL_VOID(pipeline);
1211 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1212 CHECK_NULL_VOID(frameNode);
1213 frameNode->SetOnSizeChangeCallback(std::move(onSizeChanged));
1214 }
1215
SetOnVisibleChange(std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList)1216 void ViewAbstract::SetOnVisibleChange(std::function<void(bool, double)> &&onVisibleChange,
1217 const std::vector<double> &ratioList)
1218 {
1219 auto pipeline = PipelineContext::GetCurrentContext();
1220 CHECK_NULL_VOID(pipeline);
1221 auto frameNode = AceType::Claim(ViewStackProcessor::GetInstance()->GetMainFrameNode());
1222 CHECK_NULL_VOID(frameNode);
1223 frameNode->CleanVisibleAreaUserCallback();
1224 pipeline->AddVisibleAreaChangeNode(frameNode, ratioList, onVisibleChange);
1225 }
1226
SetOnVisibleChange(FrameNode * frameNode,std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList)1227 void ViewAbstract::SetOnVisibleChange(FrameNode* frameNode, std::function<void(bool, double)>&& onVisibleChange,
1228 const std::vector<double> &ratioList)
1229 {
1230 CHECK_NULL_VOID(frameNode);
1231 auto pipeline = frameNode->GetContext();
1232 CHECK_NULL_VOID(pipeline);
1233 frameNode->CleanVisibleAreaUserCallback();
1234 pipeline->AddVisibleAreaChangeNode(AceType::Claim<FrameNode>(frameNode), ratioList, onVisibleChange);
1235 }
1236
GetColorBlend(FrameNode * frameNode)1237 Color ViewAbstract::GetColorBlend(FrameNode* frameNode)
1238 {
1239 Color defaultColor = Color::TRANSPARENT;
1240 CHECK_NULL_RETURN(frameNode, defaultColor);
1241 const auto& target = frameNode->GetRenderContext();
1242 CHECK_NULL_RETURN(target, defaultColor);
1243 return target->GetFrontColorBlendValue(defaultColor);
1244 }
1245
ResetAreaChanged(FrameNode * frameNode)1246 void ViewAbstract::ResetAreaChanged(FrameNode* frameNode)
1247 {
1248 CHECK_NULL_VOID(frameNode);
1249 auto pipeline = frameNode->GetContext();
1250 CHECK_NULL_VOID(pipeline);
1251 frameNode->ClearUserOnAreaChange();
1252 pipeline->RemoveOnAreaChangeNode(frameNode->GetId());
1253 }
1254
ResetVisibleChange(FrameNode * frameNode)1255 void ViewAbstract::ResetVisibleChange(FrameNode* frameNode)
1256 {
1257 CHECK_NULL_VOID(frameNode);
1258 auto pipeline = frameNode->GetContext();
1259 CHECK_NULL_VOID(pipeline);
1260 frameNode->CleanVisibleAreaUserCallback();
1261 pipeline->RemoveVisibleAreaChangeNode(frameNode->GetId());
1262 }
1263
SetResponseRegion(const std::vector<DimensionRect> & responseRegion)1264 void ViewAbstract::SetResponseRegion(const std::vector<DimensionRect>& responseRegion)
1265 {
1266 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1267 CHECK_NULL_VOID(gestureHub);
1268 gestureHub->SetResponseRegion(responseRegion);
1269 }
1270
SetMouseResponseRegion(const std::vector<DimensionRect> & mouseRegion)1271 void ViewAbstract::SetMouseResponseRegion(const std::vector<DimensionRect>& mouseRegion)
1272 {
1273 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1274 CHECK_NULL_VOID(gestureHub);
1275 gestureHub->SetMouseResponseRegion(mouseRegion);
1276 }
1277
SetTouchable(bool touchable)1278 void ViewAbstract::SetTouchable(bool touchable)
1279 {
1280 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1281 CHECK_NULL_VOID(gestureHub);
1282 gestureHub->SetTouchable(touchable);
1283 }
1284
SetMonopolizeEvents(bool monopolizeEvents)1285 void ViewAbstract::SetMonopolizeEvents(bool monopolizeEvents)
1286 {
1287 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1288 CHECK_NULL_VOID(gestureHub);
1289 gestureHub->SetMonopolizeEvents(monopolizeEvents);
1290 }
1291
SetHitTestMode(HitTestMode hitTestMode)1292 void ViewAbstract::SetHitTestMode(HitTestMode hitTestMode)
1293 {
1294 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1295 CHECK_NULL_VOID(gestureHub);
1296 gestureHub->SetHitTestMode(hitTestMode);
1297 }
1298
SetOnTouchTestFunc(NG::OnChildTouchTestFunc && onChildTouchTest)1299 void ViewAbstract::SetOnTouchTestFunc(NG::OnChildTouchTestFunc&& onChildTouchTest)
1300 {
1301 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1302 CHECK_NULL_VOID(gestureHub);
1303 gestureHub->SetOnTouchTestFunc(std::move(onChildTouchTest));
1304 }
1305
AddDragFrameNodeToManager()1306 void ViewAbstract::AddDragFrameNodeToManager()
1307 {
1308 auto pipeline = PipelineContext::GetCurrentContext();
1309 CHECK_NULL_VOID(pipeline);
1310 auto dragDropManager = pipeline->GetDragDropManager();
1311 CHECK_NULL_VOID(dragDropManager);
1312 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1313 CHECK_NULL_VOID(frameNode);
1314
1315 dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
1316 }
1317
AddDragFrameNodeToManager(FrameNode * frameNode)1318 void ViewAbstract::AddDragFrameNodeToManager(FrameNode* frameNode)
1319 {
1320 CHECK_NULL_VOID(frameNode);
1321 auto pipeline = frameNode->GetContext();
1322 CHECK_NULL_VOID(pipeline);
1323 auto dragDropManager = pipeline->GetDragDropManager();
1324 CHECK_NULL_VOID(dragDropManager);
1325
1326 dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(frameNode));
1327 }
1328
SetDraggable(bool draggable)1329 void ViewAbstract::SetDraggable(bool draggable)
1330 {
1331 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1332 CHECK_NULL_VOID(frameNode);
1333 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1334 CHECK_NULL_VOID(gestureHub);
1335 if (draggable) {
1336 if (!frameNode->IsDraggable()) {
1337 gestureHub->InitDragDropEvent();
1338 }
1339 } else {
1340 gestureHub->RemoveDragEvent();
1341 }
1342 frameNode->SetCustomerDraggable(draggable);
1343 }
1344
SetDragPreviewOptions(const DragPreviewOption & previewOption)1345 void ViewAbstract::SetDragPreviewOptions(const DragPreviewOption& previewOption)
1346 {
1347 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1348 CHECK_NULL_VOID(frameNode);
1349 frameNode->SetDragPreviewOptions(previewOption);
1350 }
1351
SetOnDragStart(std::function<DragDropInfo (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragStart)1352 void ViewAbstract::SetOnDragStart(
1353 std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart)
1354 {
1355 auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1356 CHECK_NULL_VOID(gestureHub);
1357 gestureHub->InitDragDropEvent();
1358
1359 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1360 CHECK_NULL_VOID(eventHub);
1361 eventHub->SetOnDragStart(std::move(onDragStart));
1362 }
1363
SetOnDragStart(FrameNode * frameNode,std::function<DragDropInfo (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragStart)1364 void ViewAbstract::SetOnDragStart(FrameNode* frameNode,
1365 std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragStart)
1366 {
1367 CHECK_NULL_VOID(frameNode);
1368 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
1369 CHECK_NULL_VOID(gestureHub);
1370 gestureHub->InitDragDropEvent();
1371
1372 auto eventHub = frameNode->GetEventHub<EventHub>();
1373 CHECK_NULL_VOID(eventHub);
1374 eventHub->SetOnDragStart(std::move(onDragStart));
1375 }
1376
SetOnDragEnter(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragEnter)1377 void ViewAbstract::SetOnDragEnter(FrameNode* frameNode,
1378 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
1379 {
1380 CHECK_NULL_VOID(frameNode);
1381 auto eventHub = frameNode->GetEventHub<EventHub>();
1382 CHECK_NULL_VOID(eventHub);
1383 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
1384
1385 AddDragFrameNodeToManager(frameNode);
1386 }
1387
SetOnDragMove(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragMove)1388 void ViewAbstract::SetOnDragMove(FrameNode* frameNode,
1389 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove)
1390 {
1391 CHECK_NULL_VOID(frameNode);
1392 auto eventHub = frameNode->GetEventHub<EventHub>();
1393 CHECK_NULL_VOID(eventHub);
1394 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
1395
1396 AddDragFrameNodeToManager(frameNode);
1397 }
1398
SetOnDragLeave(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragLeave)1399 void ViewAbstract::SetOnDragLeave(FrameNode* frameNode,
1400 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave)
1401 {
1402 CHECK_NULL_VOID(frameNode);
1403 auto eventHub = frameNode->GetEventHub<EventHub>();
1404 CHECK_NULL_VOID(eventHub);
1405 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
1406
1407 AddDragFrameNodeToManager(frameNode);
1408 }
1409
SetOnPreDrag(std::function<void (const PreDragStatus)> && onPreDragFunc)1410 void ViewAbstract::SetOnPreDrag(std::function<void(const PreDragStatus)>&& onPreDragFunc)
1411 {
1412 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1413 CHECK_NULL_VOID(eventHub);
1414 eventHub->SetOnPreDrag(std::move(onPreDragFunc));
1415 }
1416
SetOnPreDrag(FrameNode * frameNode,std::function<void (const PreDragStatus)> && onPreDragFunc)1417 void ViewAbstract::SetOnPreDrag(FrameNode* frameNode, std::function<void(const PreDragStatus)>&& onPreDragFunc)
1418 {
1419 CHECK_NULL_VOID(frameNode);
1420 auto eventHub = frameNode->GetEventHub<EventHub>();
1421 CHECK_NULL_VOID(eventHub);
1422 eventHub->SetOnPreDrag(std::move(onPreDragFunc));
1423 }
1424
SetOnDragEnter(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragEnter)1425 void ViewAbstract::SetOnDragEnter(
1426 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragEnter)
1427 {
1428 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1429 CHECK_NULL_VOID(eventHub);
1430 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
1431
1432 AddDragFrameNodeToManager();
1433 }
1434
SetOnDragLeave(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragLeave)1435 void ViewAbstract::SetOnDragLeave(
1436 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragLeave)
1437 {
1438 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1439 CHECK_NULL_VOID(eventHub);
1440 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
1441
1442 AddDragFrameNodeToManager();
1443 }
1444
SetOnDragMove(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragMove)1445 void ViewAbstract::SetOnDragMove(
1446 std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDragMove)
1447 {
1448 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1449 CHECK_NULL_VOID(eventHub);
1450 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
1451
1452 AddDragFrameNodeToManager();
1453 }
1454
SetOnDrop(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDrop)1455 void ViewAbstract::SetOnDrop(std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDrop)
1456 {
1457 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1458 CHECK_NULL_VOID(eventHub);
1459 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
1460
1461 AddDragFrameNodeToManager();
1462 }
1463
SetOnDragEnd(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &)> && onDragEnd)1464 void ViewAbstract::SetOnDragEnd(std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd)
1465 {
1466 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1467 CHECK_NULL_VOID(eventHub);
1468 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
1469
1470 AddDragFrameNodeToManager();
1471 }
1472
SetOnDragEnd(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &)> && onDragEnd)1473 void ViewAbstract::SetOnDragEnd(
1474 FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&)>&& onDragEnd)
1475 {
1476 CHECK_NULL_VOID(frameNode);
1477 auto eventHub = frameNode->GetEventHub<EventHub>();
1478 CHECK_NULL_VOID(eventHub);
1479 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
1480
1481 AddDragFrameNodeToManager(frameNode);
1482 }
1483
SetOnDrop(FrameNode * frameNode,std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDrop)1484 void ViewAbstract::SetOnDrop(
1485 FrameNode* frameNode, std::function<void(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&)>&& onDrop)
1486 {
1487 CHECK_NULL_VOID(frameNode);
1488 auto eventHub = frameNode->GetEventHub<EventHub>();
1489 CHECK_NULL_VOID(eventHub);
1490
1491 eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
1492
1493 AddDragFrameNodeToManager(frameNode);
1494 }
1495
SetAlign(Alignment alignment)1496 void ViewAbstract::SetAlign(Alignment alignment)
1497 {
1498 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1499 return;
1500 }
1501 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment);
1502 }
1503
SetAlign(FrameNode * frameNode,Alignment alignment)1504 void ViewAbstract::SetAlign(FrameNode* frameNode, Alignment alignment)
1505 {
1506 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment, frameNode);
1507 }
1508
SetVisibility(VisibleType visible)1509 void ViewAbstract::SetVisibility(VisibleType visible)
1510 {
1511 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1512 return;
1513 }
1514 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1515 CHECK_NULL_VOID(frameNode);
1516 auto layoutProperty = frameNode->GetLayoutProperty();
1517 if (layoutProperty) {
1518 layoutProperty->UpdateVisibility(visible, true);
1519 }
1520
1521 auto focusHub = frameNode->GetOrCreateFocusHub();
1522 if (focusHub) {
1523 focusHub->SetShow(visible == VisibleType::VISIBLE);
1524 }
1525 }
1526
SetGeometryTransition(const std::string & id,bool followWithoutTransition,bool doRegisterSharedTransition)1527 void ViewAbstract::SetGeometryTransition(const std::string& id,
1528 bool followWithoutTransition, bool doRegisterSharedTransition)
1529 {
1530 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1531 CHECK_NULL_VOID(frameNode);
1532 auto layoutProperty = frameNode->GetLayoutProperty();
1533 if (layoutProperty) {
1534 layoutProperty->UpdateGeometryTransition(id, followWithoutTransition, doRegisterSharedTransition);
1535 }
1536 }
1537
SetGeometryTransition(FrameNode * frameNode,const std::string & id,bool followWithoutTransition,bool doRegisterSharedTransition)1538 void ViewAbstract::SetGeometryTransition(FrameNode *frameNode, const std::string& id,
1539 bool followWithoutTransition, bool doRegisterSharedTransition)
1540 {
1541 CHECK_NULL_VOID(frameNode);
1542 auto layoutProperty = frameNode->GetLayoutProperty();
1543 if (layoutProperty) {
1544 layoutProperty->UpdateGeometryTransition(id, followWithoutTransition, doRegisterSharedTransition);
1545 }
1546 }
1547
GetGeometryTransition(FrameNode * frameNode,bool * followWithoutTransition,bool * doRegisterSharedTransition)1548 const std::string ViewAbstract::GetGeometryTransition(FrameNode* frameNode,
1549 bool* followWithoutTransition, bool* doRegisterSharedTransition)
1550 {
1551 CHECK_NULL_RETURN(frameNode, "");
1552 auto layoutProperty = frameNode->GetLayoutProperty();
1553 if (layoutProperty) {
1554 auto geometryTransition = layoutProperty->GetGeometryTransition();
1555 if (geometryTransition) {
1556 *followWithoutTransition = geometryTransition->GetFollowWithoutTransition();
1557 *doRegisterSharedTransition = geometryTransition->GetDoRegisterSharedTransition();
1558 return geometryTransition->GetId();
1559 }
1560 }
1561 return "";
1562 }
1563
SetOpacity(double opacity)1564 void ViewAbstract::SetOpacity(double opacity)
1565 {
1566 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1567 return;
1568 }
1569 ACE_UPDATE_RENDER_CONTEXT(Opacity, opacity);
1570 }
SetAllowDrop(const std::set<std::string> & allowDrop)1571 void ViewAbstract::SetAllowDrop(const std::set<std::string>& allowDrop)
1572 {
1573 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1574 CHECK_NULL_VOID(frameNode);
1575 frameNode->SetAllowDrop(allowDrop);
1576 }
1577
SetDrawModifier(const RefPtr<NG::DrawModifier> & drawModifier)1578 void ViewAbstract::SetDrawModifier(const RefPtr<NG::DrawModifier>& drawModifier)
1579 {
1580 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1581 CHECK_NULL_VOID(frameNode);
1582 frameNode->SetDrawModifier(drawModifier);
1583 }
1584
GetFrameNode()1585 void* ViewAbstract::GetFrameNode()
1586 {
1587 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1588 return static_cast<void*>(frameNode);
1589 }
1590
SetDragPreview(const NG::DragDropInfo & info)1591 void ViewAbstract::SetDragPreview(const NG::DragDropInfo& info)
1592 {
1593 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1594 CHECK_NULL_VOID(frameNode);
1595 frameNode->SetDragPreview(info);
1596 }
1597
SetPosition(const OffsetT<Dimension> & value)1598 void ViewAbstract::SetPosition(const OffsetT<Dimension>& value)
1599 {
1600 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1601 return;
1602 }
1603 ACE_RESET_RENDER_CONTEXT(RenderContext, PositionEdges);
1604 ACE_UPDATE_RENDER_CONTEXT(Position, value);
1605 }
1606
SetPositionEdges(const EdgesParam & value)1607 void ViewAbstract::SetPositionEdges(const EdgesParam& value)
1608 {
1609 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1610 return;
1611 }
1612 ACE_RESET_RENDER_CONTEXT(RenderContext, Position);
1613 ACE_UPDATE_RENDER_CONTEXT(PositionEdges, value);
1614 }
1615
SetOffset(const OffsetT<Dimension> & value)1616 void ViewAbstract::SetOffset(const OffsetT<Dimension>& value)
1617 {
1618 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1619 return;
1620 }
1621 ACE_RESET_RENDER_CONTEXT(RenderContext, OffsetEdges);
1622 ACE_UPDATE_RENDER_CONTEXT(Offset, value);
1623 }
1624
SetOffsetEdges(const EdgesParam & value)1625 void ViewAbstract::SetOffsetEdges(const EdgesParam& value)
1626 {
1627 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1628 return;
1629 }
1630 ACE_RESET_RENDER_CONTEXT(RenderContext, Offset);
1631 ACE_UPDATE_RENDER_CONTEXT(OffsetEdges, value);
1632 }
1633
MarkAnchor(const OffsetT<Dimension> & value)1634 void ViewAbstract::MarkAnchor(const OffsetT<Dimension>& value)
1635 {
1636 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1637 return;
1638 }
1639 ACE_UPDATE_RENDER_CONTEXT(Anchor, value);
1640 }
1641
ResetPosition()1642 void ViewAbstract::ResetPosition()
1643 {
1644 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1645 return;
1646 }
1647 ACE_RESET_RENDER_CONTEXT(RenderContext, Position);
1648 ACE_RESET_RENDER_CONTEXT(RenderContext, PositionEdges);
1649 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1650 CHECK_NULL_VOID(frameNode);
1651 auto parentNode = frameNode->GetAncestorNodeOfFrame();
1652 CHECK_NULL_VOID(parentNode);
1653
1654 // Row/Column/Flex measure and layout differently depending on whether the child nodes have position property.
1655 if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG ||
1656 parentNode->GetTag() == V2::FLEX_ETS_TAG) {
1657 frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1658 } else {
1659 auto renderContext = frameNode->GetRenderContext();
1660 CHECK_NULL_VOID(renderContext);
1661 renderContext->RecalculatePosition();
1662 }
1663 }
1664
SetZIndex(int32_t value)1665 void ViewAbstract::SetZIndex(int32_t value)
1666 {
1667 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1668 return;
1669 }
1670 ACE_UPDATE_RENDER_CONTEXT(ZIndex, value);
1671 }
1672
SetScale(const NG::VectorF & value)1673 void ViewAbstract::SetScale(const NG::VectorF& value)
1674 {
1675 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1676 return;
1677 }
1678 ACE_UPDATE_RENDER_CONTEXT(TransformScale, value);
1679 }
1680
SetScale(FrameNode * frameNode,const NG::VectorF & value)1681 void ViewAbstract::SetScale(FrameNode* frameNode, const NG::VectorF& value)
1682 {
1683 ACE_UPDATE_NODE_RENDER_CONTEXT(TransformScale, value, frameNode);
1684 }
1685
SetPivot(const DimensionOffset & value)1686 void ViewAbstract::SetPivot(const DimensionOffset& value)
1687 {
1688 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1689 return;
1690 }
1691 ACE_UPDATE_RENDER_CONTEXT(TransformCenter, value);
1692 }
1693
SetPivot(FrameNode * frameNode,const DimensionOffset & value)1694 void ViewAbstract::SetPivot(FrameNode* frameNode, const DimensionOffset& value)
1695 {
1696 ACE_UPDATE_NODE_RENDER_CONTEXT(TransformCenter, value, frameNode);
1697 }
1698
SetTranslate(const NG::TranslateOptions & value)1699 void ViewAbstract::SetTranslate(const NG::TranslateOptions& value)
1700 {
1701 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1702 return;
1703 }
1704 ACE_UPDATE_RENDER_CONTEXT(TransformTranslate, value);
1705 }
1706
SetTranslate(FrameNode * frameNode,const NG::TranslateOptions & value)1707 void ViewAbstract::SetTranslate(FrameNode* frameNode, const NG::TranslateOptions& value)
1708 {
1709 ACE_UPDATE_NODE_RENDER_CONTEXT(TransformTranslate, value, frameNode);
1710 }
1711
SetRotate(const NG::Vector5F & value)1712 void ViewAbstract::SetRotate(const NG::Vector5F& value)
1713 {
1714 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1715 return;
1716 }
1717 ACE_UPDATE_RENDER_CONTEXT(TransformRotate, value);
1718 }
1719
SetRotate(FrameNode * frameNode,const NG::Vector5F & value)1720 void ViewAbstract::SetRotate(FrameNode* frameNode, const NG::Vector5F& value)
1721 {
1722 ACE_UPDATE_NODE_RENDER_CONTEXT(TransformRotate, value, frameNode);
1723 }
1724
SetTransformMatrix(const Matrix4 & matrix)1725 void ViewAbstract::SetTransformMatrix(const Matrix4& matrix)
1726 {
1727 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1728 return;
1729 }
1730 ACE_UPDATE_RENDER_CONTEXT(TransformMatrix, matrix);
1731 }
1732
BindPopup(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode,const RefPtr<UINode> & customNode)1733 void ViewAbstract::BindPopup(
1734 const RefPtr<PopupParam>& param, const RefPtr<FrameNode>& targetNode, const RefPtr<UINode>& customNode)
1735 {
1736 TAG_LOGD(AceLogTag::ACE_DIALOG, "bind popup enter");
1737 CHECK_NULL_VOID(targetNode);
1738 auto targetId = targetNode->GetId();
1739 auto targetTag = targetNode->GetTag();
1740 auto context = targetNode->GetContext();
1741 CHECK_NULL_VOID(context);
1742 auto instanceId = context->GetInstanceId();
1743
1744 auto overlayManager = context->GetOverlayManager();
1745 CHECK_NULL_VOID(overlayManager);
1746 auto popupInfo = overlayManager->GetPopupInfo(targetId);
1747 auto isShow = param->IsShow();
1748 auto isUseCustom = param->IsUseCustom();
1749 auto showInSubWindow = param->IsShowInSubWindow();
1750 // subwindow model needs to use subContainer to get popupInfo
1751 if (showInSubWindow) {
1752 auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(instanceId);
1753 if (subwindow) {
1754 subwindow->GetPopupInfoNG(targetId, popupInfo);
1755 }
1756 }
1757
1758 auto popupId = popupInfo.popupId;
1759 auto popupNode = popupInfo.popupNode;
1760 RefPtr<BubblePattern> popupPattern;
1761 if (popupNode) {
1762 popupPattern = popupNode->GetPattern<BubblePattern>();
1763 }
1764
1765 if (popupInfo.isCurrentOnShow) {
1766 // Entering / Normal / Exiting
1767 bool popupShowing = popupPattern ? popupPattern->IsOnShow() : false;
1768 popupInfo.markNeedUpdate = popupShowing || !isShow;
1769 } else {
1770 // Invisable
1771 if (!isShow) {
1772 TAG_LOGW(AceLogTag::ACE_DIALOG, "Popup is already hidden");
1773 return;
1774 }
1775 popupInfo.markNeedUpdate = true;
1776 }
1777
1778 // Create new popup.
1779 if (popupInfo.popupId == -1 || !popupNode) {
1780 if (!isUseCustom) {
1781 popupNode = BubbleView::CreateBubbleNode(targetTag, targetId, param);
1782 } else {
1783 CHECK_NULL_VOID(customNode);
1784 popupNode = BubbleView::CreateCustomBubbleNode(targetTag, targetId, customNode, param);
1785 }
1786 if (popupNode) {
1787 popupId = popupNode->GetId();
1788 }
1789 if (!showInSubWindow) {
1790 // erase popup when target node destroy
1791 auto destructor = [id = targetNode->GetId()]() {
1792 auto pipeline = NG::PipelineContext::GetCurrentContext();
1793 CHECK_NULL_VOID(pipeline);
1794 auto overlayManager = pipeline->GetOverlayManager();
1795 CHECK_NULL_VOID(overlayManager);
1796 overlayManager->ErasePopup(id);
1797 SubwindowManager::GetInstance()->HideSubWindowNG();
1798 };
1799 targetNode->PushDestroyCallback(destructor);
1800 } else {
1801 // erase popup in subwindow when target node destroy
1802 auto destructor = [id = targetNode->GetId(), containerId = instanceId]() {
1803 auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(containerId);
1804 CHECK_NULL_VOID(subwindow);
1805 auto overlayManager = subwindow->GetOverlayManager();
1806 CHECK_NULL_VOID(overlayManager);
1807 overlayManager->ErasePopup(id);
1808 SubwindowManager::GetInstance()->HideSubWindowNG();
1809 };
1810 targetNode->PushDestroyCallback(destructor);
1811 }
1812 } else {
1813 // use param to update PopupParm
1814 if (!isUseCustom) {
1815 BubbleView::UpdatePopupParam(popupId, param, targetNode);
1816 popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1817 } else {
1818 BubbleView::UpdateCustomPopupParam(popupId, param);
1819 popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1820 }
1821 }
1822 // update PopupInfo props
1823 popupInfo.popupId = popupId;
1824 popupInfo.popupNode = popupNode;
1825 popupInfo.isBlockEvent = param->IsBlockEvent();
1826 if (popupNode) {
1827 popupNode->MarkModifyDone();
1828 popupPattern = popupNode->GetPattern<BubblePattern>();
1829 }
1830 popupInfo.focusable = param->GetFocusable();
1831 popupInfo.target = AceType::WeakClaim(AceType::RawPtr(targetNode));
1832 popupInfo.targetSize = SizeF(param->GetTargetSize().Width(), param->GetTargetSize().Height());
1833 popupInfo.targetOffset = OffsetF(param->GetTargetOffset().GetX(), param->GetTargetOffset().GetY());
1834 if (showInSubWindow) {
1835 if (isShow) {
1836 SubwindowManager::GetInstance()->ShowPopupNG(
1837 targetNode, popupInfo, param->GetOnWillDismiss(), param->GetInteractiveDismiss());
1838 } else {
1839 SubwindowManager::GetInstance()->HidePopupNG(targetId);
1840 }
1841 return;
1842 }
1843 if (isShow) {
1844 if (popupInfo.isCurrentOnShow != isShow) {
1845 overlayManager->ShowPopup(targetId, popupInfo, param->GetOnWillDismiss(), param->GetInteractiveDismiss());
1846 }
1847 } else {
1848 overlayManager->HidePopup(targetId, popupInfo);
1849 }
1850 }
1851
DismissPopup()1852 void ViewAbstract::DismissPopup()
1853 {
1854 auto context = PipelineContext::GetCurrentContext();
1855 CHECK_NULL_VOID(context);
1856 auto overlayManager = context->GetOverlayManager();
1857 CHECK_NULL_VOID(overlayManager);
1858 overlayManager->DismissPopup();
1859 }
1860
DismissDialog()1861 void ViewAbstract::DismissDialog()
1862 {
1863 auto context = PipelineContext::GetCurrentContext();
1864 CHECK_NULL_VOID(context);
1865 auto overlayManager = context->GetOverlayManager();
1866 CHECK_NULL_VOID(overlayManager);
1867 auto rootNode = overlayManager->GetRootNode().Upgrade();
1868 CHECK_NULL_VOID(rootNode);
1869 RefPtr<FrameNode> overlay;
1870 if (overlayManager->GetDismissDialogId()) {
1871 overlay = overlayManager->GetDialog(overlayManager->GetDismissDialogId());
1872 } else {
1873 overlay = AceType::DynamicCast<FrameNode>(rootNode->GetLastChild());
1874 }
1875 CHECK_NULL_VOID(overlay);
1876 auto pattern = overlay->GetPattern();
1877 CHECK_NULL_VOID(pattern);
1878 auto dialogPattern = AceType::DynamicCast<DialogPattern>(pattern);
1879 if (dialogPattern) {
1880 overlayManager->RemoveDialog(overlay, false);
1881 if (overlayManager->isMaskNode(dialogPattern->GetHost()->GetId())) {
1882 overlayManager->PopModalDialog(dialogPattern->GetHost()->GetId());
1883 }
1884 #if !defined(PREVIEW) && !defined(ACE_UNITTEST) && defined(OHOS_PLATFORM)
1885 UiSessionManager::GetInstance().ReportComponentChangeEvent("onVisibleChange", "destroy");
1886 #endif
1887 }
1888 }
1889
BindMenuWithItems(std::vector<OptionParam> && params,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,const MenuParam & menuParam)1890 void ViewAbstract::BindMenuWithItems(std::vector<OptionParam>&& params, const RefPtr<FrameNode>& targetNode,
1891 const NG::OffsetF& offset, const MenuParam& menuParam)
1892 {
1893 TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with items enter");
1894 CHECK_NULL_VOID(targetNode);
1895
1896 if (params.empty()) {
1897 return;
1898 }
1899 auto menuNode =
1900 MenuView::Create(std::move(params), targetNode->GetId(), targetNode->GetTag(), MenuType::MENU, menuParam);
1901 CHECK_NULL_VOID(menuNode);
1902 auto menuWrapperPattern = menuNode->GetPattern<MenuWrapperPattern>();
1903 CHECK_NULL_VOID(menuWrapperPattern);
1904 menuWrapperPattern->RegisterMenuCallback(menuNode, menuParam);
1905 menuWrapperPattern->SetMenuTransitionEffect(menuNode, menuParam);
1906 auto pipeline = PipelineBase::GetCurrentContext();
1907 CHECK_NULL_VOID(pipeline);
1908 auto theme = pipeline->GetTheme<SelectTheme>();
1909 CHECK_NULL_VOID(theme);
1910 auto expandDisplay = theme->GetExpandDisplay();
1911
1912 auto pipelineContext = targetNode->GetContext();
1913 CHECK_NULL_VOID(pipelineContext);
1914 auto overlayManager = pipelineContext->GetOverlayManager();
1915 CHECK_NULL_VOID(overlayManager);
1916
1917 if (expandDisplay && menuParam.isShowInSubWindow && targetNode->GetTag() != V2::SELECT_ETS_TAG) {
1918 bool isShown = SubwindowManager::GetInstance()->GetShown();
1919 if (!isShown) {
1920 SubwindowManager::GetInstance()->ShowMenuNG(menuNode, menuParam, targetNode, offset);
1921 } else {
1922 auto menuNode = overlayManager->GetMenuNode(targetNode->GetId());
1923 SubwindowManager::GetInstance()->HideMenuNG(menuNode, targetNode->GetId());
1924 }
1925 return;
1926 }
1927
1928 overlayManager->ShowMenu(targetNode->GetId(), offset, menuNode);
1929 }
1930
BindMenuWithCustomNode(std::function<void ()> && buildFunc,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,MenuParam menuParam,std::function<void ()> && previewBuildFunc)1931 void ViewAbstract::BindMenuWithCustomNode(std::function<void()>&& buildFunc, const RefPtr<FrameNode>& targetNode,
1932 const NG::OffsetF& offset, MenuParam menuParam, std::function<void()>&& previewBuildFunc)
1933 {
1934 if (!buildFunc || !targetNode) {
1935 return;
1936 }
1937 #ifdef PREVIEW
1938 // unable to use the subWindow in the Previewer.
1939 menuParam.type = MenuType::MENU;
1940 #endif
1941 TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with custom node enter");
1942 auto pipeline = PipelineBase::GetCurrentContext();
1943 CHECK_NULL_VOID(pipeline);
1944 auto theme = pipeline->GetTheme<SelectTheme>();
1945 CHECK_NULL_VOID(theme);
1946 auto expandDisplay = theme->GetExpandDisplay();
1947 auto pipelineContext = targetNode->GetContext();
1948 CHECK_NULL_VOID(pipelineContext);
1949 auto overlayManager = pipelineContext->GetOverlayManager();
1950 CHECK_NULL_VOID(overlayManager);
1951 if (menuParam.type == MenuType::CONTEXT_MENU) {
1952 SubwindowManager::GetInstance()->ShowMenuNG(
1953 std::move(buildFunc), std::move(previewBuildFunc), menuParam, targetNode, offset);
1954 return;
1955 }
1956 if (menuParam.type == MenuType::MENU && expandDisplay && menuParam.isShowInSubWindow &&
1957 targetNode->GetTag() != V2::SELECT_ETS_TAG) {
1958 bool isShown = SubwindowManager::GetInstance()->GetShown();
1959 if (!isShown) {
1960 SubwindowManager::GetInstance()->ShowMenuNG(
1961 std::move(buildFunc), std::move(previewBuildFunc), menuParam, targetNode, offset);
1962 } else {
1963 auto menuNode = overlayManager->GetMenuNode(targetNode->GetId());
1964 SubwindowManager::GetInstance()->HideMenuNG(menuNode, targetNode->GetId());
1965 }
1966 return;
1967 }
1968 NG::ScopedViewStackProcessor builderViewStackProcessor;
1969 buildFunc();
1970 auto customNode = NG::ViewStackProcessor::GetInstance()->Finish();
1971 RefPtr<NG::UINode> previewCustomNode;
1972 if (previewBuildFunc && menuParam.previewMode == MenuPreviewMode::CUSTOM) {
1973 previewBuildFunc();
1974 previewCustomNode = NG::ViewStackProcessor::GetInstance()->Finish();
1975 }
1976 auto menuNode =
1977 NG::MenuView::Create(customNode, targetNode->GetId(), targetNode->GetTag(), menuParam, true, previewCustomNode);
1978 auto menuWrapperPattern = menuNode->GetPattern<NG::MenuWrapperPattern>();
1979 CHECK_NULL_VOID(menuWrapperPattern);
1980 menuWrapperPattern->RegisterMenuCallback(menuNode, menuParam);
1981 menuWrapperPattern->SetMenuTransitionEffect(menuNode, menuParam);
1982 overlayManager->ShowMenu(targetNode->GetId(), offset, menuNode);
1983 }
1984
SetBackdropBlur(const Dimension & radius,const BlurOption & blurOption)1985 void ViewAbstract::SetBackdropBlur(const Dimension& radius, const BlurOption& blurOption)
1986 {
1987 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1988 return;
1989 }
1990 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1991 CHECK_NULL_VOID(frameNode);
1992 auto target = frameNode->GetRenderContext();
1993 if (target) {
1994 if (target->GetBackgroundEffect().has_value()) {
1995 target->UpdateBackgroundEffect(std::nullopt);
1996 }
1997 target->UpdateBackBlur(radius, blurOption);
1998 if (target->GetBackBlurStyle().has_value()) {
1999 target->UpdateBackBlurStyle(std::nullopt);
2000 }
2001 }
2002 }
2003
SetBackdropBlur(FrameNode * frameNode,const Dimension & radius,const BlurOption & blurOption)2004 void ViewAbstract::SetBackdropBlur(FrameNode *frameNode, const Dimension &radius, const BlurOption &blurOption)
2005 {
2006 CHECK_NULL_VOID(frameNode);
2007 auto target = frameNode->GetRenderContext();
2008 if (target) {
2009 if (target->GetBackgroundEffect().has_value()) {
2010 target->UpdateBackgroundEffect(std::nullopt);
2011 }
2012 target->UpdateBackBlur(radius, blurOption);
2013 if (target->GetBackBlurStyle().has_value()) {
2014 target->UpdateBackBlurStyle(std::nullopt);
2015 }
2016 }
2017 }
2018
SetLinearGradientBlur(const NG::LinearGradientBlurPara & blurPara)2019 void ViewAbstract::SetLinearGradientBlur(const NG::LinearGradientBlurPara& blurPara)
2020 {
2021 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2022 return;
2023 }
2024 ACE_UPDATE_RENDER_CONTEXT(LinearGradientBlur, blurPara);
2025 }
2026
SetDynamicLightUp(float rate,float lightUpDegree)2027 void ViewAbstract::SetDynamicLightUp(float rate, float lightUpDegree)
2028 {
2029 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2030 return;
2031 }
2032 ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpRate, rate);
2033 ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree);
2034 }
2035
SetBgDynamicBrightness(const BrightnessOption & brightnessOption)2036 void ViewAbstract::SetBgDynamicBrightness(const BrightnessOption& brightnessOption)
2037 {
2038 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2039 return;
2040 }
2041 ACE_UPDATE_RENDER_CONTEXT(BgDynamicBrightnessOption, brightnessOption);
2042 }
2043
SetFgDynamicBrightness(const BrightnessOption & brightnessOption)2044 void ViewAbstract::SetFgDynamicBrightness(const BrightnessOption& brightnessOption)
2045 {
2046 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2047 return;
2048 }
2049 ACE_UPDATE_RENDER_CONTEXT(FgDynamicBrightnessOption, brightnessOption);
2050 }
2051
SetBrightnessBlender(const OHOS::Rosen::BrightnessBlender * brightnessBlender)2052 void ViewAbstract::SetBrightnessBlender(const OHOS::Rosen::BrightnessBlender* brightnessBlender)
2053 {
2054 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2055 return;
2056 }
2057 ACE_UPDATE_RENDER_CONTEXT(BrightnessBlender, brightnessBlender);
2058 }
2059
SetFrontBlur(const Dimension & radius,const BlurOption & blurOption)2060 void ViewAbstract::SetFrontBlur(const Dimension& radius, const BlurOption& blurOption)
2061 {
2062 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2063 return;
2064 }
2065 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2066 CHECK_NULL_VOID(frameNode);
2067 auto target = frameNode->GetRenderContext();
2068 if (target) {
2069 target->UpdateFrontBlur(radius, blurOption);
2070 if (target->GetFrontBlurStyle().has_value()) {
2071 target->UpdateFrontBlurStyle(std::nullopt);
2072 }
2073 }
2074 }
2075
SetDynamicDim(float DimDegree)2076 void ViewAbstract::SetDynamicDim(float DimDegree)
2077 {
2078 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2079 return;
2080 }
2081 ACE_UPDATE_RENDER_CONTEXT(DynamicDimDegree, DimDegree);
2082 }
2083
SetFrontBlur(FrameNode * frameNode,const Dimension & radius,const BlurOption & blurOption)2084 void ViewAbstract::SetFrontBlur(FrameNode *frameNode, const Dimension &radius, const BlurOption &blurOption)
2085 {
2086 CHECK_NULL_VOID(frameNode);
2087 auto target = frameNode->GetRenderContext();
2088 if (target) {
2089 target->UpdateFrontBlur(radius, blurOption);
2090 if (target->GetFrontBlurStyle().has_value()) {
2091 target->UpdateFrontBlurStyle(std::nullopt);
2092 }
2093 }
2094 }
2095
SetBackShadow(const Shadow & shadow)2096 void ViewAbstract::SetBackShadow(const Shadow& shadow)
2097 {
2098 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2099 return;
2100 }
2101 ACE_UPDATE_RENDER_CONTEXT(BackShadow, shadow);
2102 }
2103
SetBackShadow(FrameNode * frameNode,const Shadow & shadow)2104 void ViewAbstract::SetBackShadow(FrameNode* frameNode, const Shadow& shadow)
2105 {
2106 ACE_UPDATE_NODE_RENDER_CONTEXT(BackShadow, shadow, frameNode);
2107 }
2108
SetBlendMode(BlendMode blendMode)2109 void ViewAbstract::SetBlendMode(BlendMode blendMode)
2110 {
2111 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2112 return;
2113 }
2114 ACE_UPDATE_RENDER_CONTEXT(BackBlendMode, blendMode);
2115 }
2116
SetBlendApplyType(BlendApplyType blendApplyType)2117 void ViewAbstract::SetBlendApplyType(BlendApplyType blendApplyType)
2118 {
2119 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2120 return;
2121 }
2122 ACE_UPDATE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType);
2123 }
2124
SetLinearGradient(const NG::Gradient & gradient)2125 void ViewAbstract::SetLinearGradient(const NG::Gradient& gradient)
2126 {
2127 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2128 return;
2129 }
2130 ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::LINEAR);
2131 ACE_UPDATE_RENDER_CONTEXT(LinearGradient, gradient);
2132 }
2133
SetSweepGradient(const NG::Gradient & gradient)2134 void ViewAbstract::SetSweepGradient(const NG::Gradient& gradient)
2135 {
2136 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2137 return;
2138 }
2139 ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::SWEEP);
2140 ACE_UPDATE_RENDER_CONTEXT(SweepGradient, gradient);
2141 }
2142
SetRadialGradient(const NG::Gradient & gradient)2143 void ViewAbstract::SetRadialGradient(const NG::Gradient& gradient)
2144 {
2145 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2146 return;
2147 }
2148 ACE_UPDATE_RENDER_CONTEXT(LastGradientType, NG::GradientType::RADIAL);
2149 ACE_UPDATE_RENDER_CONTEXT(RadialGradient, gradient);
2150 }
2151
SetInspectorId(const std::string & inspectorId)2152 void ViewAbstract::SetInspectorId(const std::string& inspectorId)
2153 {
2154 auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2155 if (uiNode) {
2156 if (uiNode->GetInspectorId().has_value() && uiNode->GetInspectorIdValue() != inspectorId) {
2157 ElementRegister::GetInstance()->RemoveFrameNodeByInspectorId(
2158 uiNode->GetInspectorIdValue(), uiNode->GetId());
2159 }
2160 uiNode->UpdateInspectorId(inspectorId);
2161 }
2162 }
2163
SetAutoEventParam(const std::string & param)2164 void ViewAbstract::SetAutoEventParam(const std::string& param)
2165 {
2166 auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2167 if (uiNode) {
2168 uiNode->UpdateAutoEventParam(param);
2169 }
2170 }
2171
SetRestoreId(int32_t restoreId)2172 void ViewAbstract::SetRestoreId(int32_t restoreId)
2173 {
2174 auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2175 if (uiNode) {
2176 uiNode->SetRestoreId(restoreId);
2177 }
2178 }
2179
SetDebugLine(const std::string & line)2180 void ViewAbstract::SetDebugLine(const std::string& line)
2181 {
2182 auto& uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
2183 if (uiNode) {
2184 uiNode->SetDebugLine(line);
2185 }
2186 }
2187
SetGrid(std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)2188 void ViewAbstract::SetGrid(std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
2189 {
2190 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2191 CHECK_NULL_VOID(frameNode);
2192 auto layoutProperty = frameNode->GetLayoutProperty();
2193 CHECK_NULL_VOID(layoutProperty);
2194 // frame node is mounted to parent when pop from stack later, no grid-container is added here
2195 layoutProperty->UpdateGridProperty(span, offset, type);
2196 }
2197
Pop()2198 void ViewAbstract::Pop()
2199 {
2200 ViewStackProcessor::GetInstance()->Pop();
2201 }
2202
SetTransition(const TransitionOptions & options)2203 void ViewAbstract::SetTransition(const TransitionOptions& options)
2204 {
2205 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2206 return;
2207 }
2208 ACE_UPDATE_RENDER_CONTEXT(Transition, options);
2209 }
2210
CleanTransition()2211 void ViewAbstract::CleanTransition()
2212 {
2213 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2214 return;
2215 }
2216 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2217 CHECK_NULL_VOID(frameNode);
2218 auto target = frameNode->GetRenderContext();
2219 if (target) {
2220 target->CleanTransition();
2221 }
2222 }
2223
SetChainedTransition(const RefPtr<NG::ChainedTransitionEffect> & effect,NG::TransitionFinishCallback && finishCallback)2224 void ViewAbstract::SetChainedTransition(
2225 const RefPtr<NG::ChainedTransitionEffect>& effect, NG::TransitionFinishCallback&& finishCallback)
2226 {
2227 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2228 return;
2229 }
2230 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2231 CHECK_NULL_VOID(frameNode);
2232 const auto& target = frameNode->GetRenderContext();
2233 if (target) {
2234 target->UpdateChainedTransition(effect);
2235 target->SetTransitionUserCallback(std::move(finishCallback));
2236 }
2237 }
2238
SetClipShape(const RefPtr<BasicShape> & basicShape)2239 void ViewAbstract::SetClipShape(const RefPtr<BasicShape>& basicShape)
2240 {
2241 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2242 return;
2243 }
2244 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2245 CHECK_NULL_VOID(frameNode);
2246 auto target = frameNode->GetRenderContext();
2247 if (target) {
2248 if (target->GetClipEdge().has_value()) {
2249 target->UpdateClipEdge(false);
2250 }
2251 target->UpdateClipShape(basicShape);
2252 }
2253 }
2254
SetClipShape(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)2255 void ViewAbstract::SetClipShape(FrameNode* frameNode, const RefPtr<BasicShape>& basicShape)
2256 {
2257 CHECK_NULL_VOID(frameNode);
2258 auto target = frameNode->GetRenderContext();
2259 if (target) {
2260 if (target->GetClipEdge().has_value()) {
2261 target->UpdateClipEdge(false);
2262 }
2263 target->UpdateClipShape(basicShape);
2264 }
2265 }
2266
SetClipEdge(bool isClip)2267 void ViewAbstract::SetClipEdge(bool isClip)
2268 {
2269 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2270 return;
2271 }
2272 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2273 CHECK_NULL_VOID(frameNode);
2274 auto target = frameNode->GetRenderContext();
2275 if (target) {
2276 if (target->GetClipShape().has_value()) {
2277 target->ResetClipShape();
2278 target->OnClipShapeUpdate(nullptr);
2279 }
2280 target->UpdateClipEdge(isClip);
2281 }
2282 }
2283
SetClipEdge(FrameNode * frameNode,bool isClip)2284 void ViewAbstract::SetClipEdge(FrameNode* frameNode, bool isClip)
2285 {
2286 CHECK_NULL_VOID(frameNode);
2287 auto target = frameNode->GetRenderContext();
2288 if (target) {
2289 if (target->GetClipShape().has_value()) {
2290 target->ResetClipShape();
2291 target->OnClipShapeUpdate(nullptr);
2292 }
2293 target->UpdateClipEdge(isClip);
2294 }
2295 }
2296
SetMask(const RefPtr<BasicShape> & basicShape)2297 void ViewAbstract::SetMask(const RefPtr<BasicShape>& basicShape)
2298 {
2299 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2300 return;
2301 }
2302 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2303 CHECK_NULL_VOID(frameNode);
2304 auto target = frameNode->GetRenderContext();
2305 if (target) {
2306 if (target->HasProgressMask()) {
2307 target->ResetProgressMask();
2308 target->OnProgressMaskUpdate(nullptr);
2309 }
2310 target->UpdateClipMask(basicShape);
2311 }
2312 }
2313
SetProgressMask(const RefPtr<ProgressMaskProperty> & progress)2314 void ViewAbstract::SetProgressMask(const RefPtr<ProgressMaskProperty>& progress)
2315 {
2316 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2317 return;
2318 }
2319 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2320 CHECK_NULL_VOID(frameNode);
2321 auto target = frameNode->GetRenderContext();
2322 if (target) {
2323 if (target->HasClipMask()) {
2324 target->ResetClipMask();
2325 target->OnClipMaskUpdate(nullptr);
2326 }
2327 target->UpdateProgressMask(progress);
2328 }
2329 }
2330
SetBrightness(const Dimension & brightness)2331 void ViewAbstract::SetBrightness(const Dimension& brightness)
2332 {
2333 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2334 return;
2335 }
2336 ACE_UPDATE_RENDER_CONTEXT(FrontBrightness, brightness);
2337 }
2338
SetBrightness(FrameNode * frameNode,const Dimension & brightness)2339 void ViewAbstract::SetBrightness(FrameNode* frameNode, const Dimension& brightness)
2340 {
2341 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontBrightness, brightness, frameNode);
2342 }
2343
SetGrayScale(const Dimension & grayScale)2344 void ViewAbstract::SetGrayScale(const Dimension& grayScale)
2345 {
2346 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2347 return;
2348 }
2349 ACE_UPDATE_RENDER_CONTEXT(FrontGrayScale, grayScale);
2350 }
2351
SetGrayScale(FrameNode * frameNode,const Dimension & grayScale)2352 void ViewAbstract::SetGrayScale(FrameNode* frameNode, const Dimension& grayScale)
2353 {
2354 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontGrayScale, grayScale, frameNode);
2355 }
2356
SetContrast(const Dimension & contrast)2357 void ViewAbstract::SetContrast(const Dimension& contrast)
2358 {
2359 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2360 return;
2361 }
2362 ACE_UPDATE_RENDER_CONTEXT(FrontContrast, contrast);
2363 }
2364
SetContrast(FrameNode * frameNode,const Dimension & contrast)2365 void ViewAbstract::SetContrast(FrameNode* frameNode, const Dimension& contrast)
2366 {
2367 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontContrast, contrast, frameNode);
2368 }
2369
SetSaturate(const Dimension & saturate)2370 void ViewAbstract::SetSaturate(const Dimension& saturate)
2371 {
2372 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2373 return;
2374 }
2375 ACE_UPDATE_RENDER_CONTEXT(FrontSaturate, saturate);
2376 }
2377
SetSaturate(FrameNode * frameNode,const Dimension & saturate)2378 void ViewAbstract::SetSaturate(FrameNode* frameNode, const Dimension& saturate)
2379 {
2380 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSaturate, saturate, frameNode);
2381 }
2382
SetSepia(const Dimension & sepia)2383 void ViewAbstract::SetSepia(const Dimension& sepia)
2384 {
2385 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2386 return;
2387 }
2388 ACE_UPDATE_RENDER_CONTEXT(FrontSepia, sepia);
2389 }
2390
SetSepia(FrameNode * frameNode,const Dimension & sepia)2391 void ViewAbstract::SetSepia(FrameNode* frameNode, const Dimension& sepia)
2392 {
2393 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSepia, sepia, frameNode);
2394 }
2395
SetInvert(const InvertVariant & invert)2396 void ViewAbstract::SetInvert(const InvertVariant& invert)
2397 {
2398 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2399 return;
2400 }
2401 ACE_UPDATE_RENDER_CONTEXT(FrontInvert, invert);
2402 }
2403
SetInvert(FrameNode * frameNode,const InvertVariant & invert)2404 void ViewAbstract::SetInvert(FrameNode* frameNode, const InvertVariant& invert)
2405 {
2406 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontInvert, invert, frameNode);
2407 }
2408
SetSystemBarEffect(bool systemBarEffect)2409 void ViewAbstract::SetSystemBarEffect(bool systemBarEffect)
2410 {
2411 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2412 return;
2413 }
2414 ACE_UPDATE_RENDER_CONTEXT(SystemBarEffect, systemBarEffect);
2415 }
2416
SetSystemBarEffect(FrameNode * frameNode,bool enable)2417 void ViewAbstract::SetSystemBarEffect(FrameNode *frameNode, bool enable)
2418 {
2419 ACE_UPDATE_NODE_RENDER_CONTEXT(SystemBarEffect, enable, frameNode);
2420 }
2421
SetHueRotate(float hueRotate)2422 void ViewAbstract::SetHueRotate(float hueRotate)
2423 {
2424 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2425 return;
2426 }
2427 ACE_UPDATE_RENDER_CONTEXT(FrontHueRotate, hueRotate);
2428 }
2429
SetHueRotate(FrameNode * frameNode,float hueRotate)2430 void ViewAbstract::SetHueRotate(FrameNode* frameNode, float hueRotate)
2431 {
2432 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontHueRotate, hueRotate, frameNode);
2433 }
2434
SetColorBlend(const Color & colorBlend)2435 void ViewAbstract::SetColorBlend(const Color& colorBlend)
2436 {
2437 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2438 return;
2439 }
2440 ACE_UPDATE_RENDER_CONTEXT(FrontColorBlend, colorBlend);
2441 }
2442
SetColorBlend(FrameNode * frameNode,const Color & colorBlend)2443 void ViewAbstract::SetColorBlend(FrameNode* frameNode, const Color& colorBlend)
2444 {
2445 ACE_UPDATE_NODE_RENDER_CONTEXT(FrontColorBlend, colorBlend, frameNode);
2446 }
2447
SetBorderImage(const RefPtr<BorderImage> & borderImage)2448 void ViewAbstract::SetBorderImage(const RefPtr<BorderImage>& borderImage)
2449 {
2450 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2451 return;
2452 }
2453 ACE_UPDATE_RENDER_CONTEXT(BorderImage, borderImage);
2454 }
2455
SetBorderImageSource(const std::string & bdImageSrc,const std::string & bundleName,const std::string & moduleName)2456 void ViewAbstract::SetBorderImageSource(
2457 const std::string& bdImageSrc, const std::string& bundleName, const std::string& moduleName)
2458 {
2459 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2460 return;
2461 }
2462 ImageSourceInfo imageSourceInfo(bdImageSrc, bundleName, moduleName);
2463 ACE_UPDATE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo);
2464 ACE_UPDATE_RENDER_CONTEXT(BorderSourceFromImage, true);
2465 }
2466
SetHasBorderImageSlice(bool tag)2467 void ViewAbstract::SetHasBorderImageSlice(bool tag)
2468 {
2469 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2470 return;
2471 }
2472 ACE_UPDATE_RENDER_CONTEXT(HasBorderImageSlice, tag);
2473 }
2474
SetHasBorderImageWidth(bool tag)2475 void ViewAbstract::SetHasBorderImageWidth(bool tag)
2476 {
2477 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2478 return;
2479 }
2480 ACE_UPDATE_RENDER_CONTEXT(HasBorderImageWidth, tag);
2481 }
2482
SetHasBorderImageOutset(bool tag)2483 void ViewAbstract::SetHasBorderImageOutset(bool tag)
2484 {
2485 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2486 return;
2487 }
2488 ACE_UPDATE_RENDER_CONTEXT(HasBorderImageOutset, tag);
2489 }
2490
SetHasBorderImageRepeat(bool tag)2491 void ViewAbstract::SetHasBorderImageRepeat(bool tag)
2492 {
2493 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2494 return;
2495 }
2496 ACE_UPDATE_RENDER_CONTEXT(HasBorderImageRepeat, tag);
2497 }
2498
SetBorderImageGradient(const Gradient & gradient)2499 void ViewAbstract::SetBorderImageGradient(const Gradient& gradient)
2500 {
2501 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2502 return;
2503 }
2504 ACE_UPDATE_RENDER_CONTEXT(BorderImageGradient, gradient);
2505 ACE_UPDATE_RENDER_CONTEXT(BorderSourceFromImage, false);
2506 }
2507
SetVisualEffect(const OHOS::Rosen::VisualEffect * visualEffect)2508 void ViewAbstract::SetVisualEffect(const OHOS::Rosen::VisualEffect* visualEffect)
2509 {
2510 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2511 return;
2512 }
2513 ACE_UPDATE_RENDER_CONTEXT(VisualEffect, visualEffect);
2514 }
2515
SetBackgroundFilter(const OHOS::Rosen::Filter * backgroundFilter)2516 void ViewAbstract::SetBackgroundFilter(const OHOS::Rosen::Filter* backgroundFilter)
2517 {
2518 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2519 return;
2520 }
2521 ACE_UPDATE_RENDER_CONTEXT(BackgroundFilter, backgroundFilter);
2522 }
2523
SetForegroundFilter(const OHOS::Rosen::Filter * foregroundFilter)2524 void ViewAbstract::SetForegroundFilter(const OHOS::Rosen::Filter* foregroundFilter)
2525 {
2526 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2527 return;
2528 }
2529 ACE_UPDATE_RENDER_CONTEXT(ForegroundFilter, foregroundFilter);
2530 }
2531
SetCompositingFilter(const OHOS::Rosen::Filter * compositingFilter)2532 void ViewAbstract::SetCompositingFilter(const OHOS::Rosen::Filter* compositingFilter)
2533 {
2534 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2535 return;
2536 }
2537 ACE_UPDATE_RENDER_CONTEXT(CompositingFilter, compositingFilter);
2538 }
2539
SetOverlay(const OverlayOptions & overlay)2540 void ViewAbstract::SetOverlay(const OverlayOptions& overlay)
2541 {
2542 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2543 return;
2544 }
2545 ACE_UPDATE_RENDER_CONTEXT(OverlayText, overlay);
2546 }
2547
SetOverlayBuilder(std::function<void ()> && buildFunc,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)2548 void ViewAbstract::SetOverlayBuilder(std::function<void()>&& buildFunc,
2549 const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
2550 const std::optional<Dimension>& offsetY)
2551 {
2552 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2553 return;
2554 }
2555 if (buildFunc) {
2556 auto buildNodeFunc = [func = std::move(buildFunc)]() -> RefPtr<UINode> {
2557 ScopedViewStackProcessor builderViewStackProcessor;
2558 func();
2559 auto customNode = ViewStackProcessor::GetInstance()->Finish();
2560 return customNode;
2561 };
2562 auto overlayNode = AceType::DynamicCast<FrameNode>(buildNodeFunc());
2563 CHECK_NULL_VOID(overlayNode);
2564 AddOverlayToFrameNode(overlayNode, align, offsetX, offsetY);
2565 } else {
2566 AddOverlayToFrameNode(nullptr, align, offsetX, offsetY);
2567 }
2568 }
2569
SetOverlayComponentContent(const RefPtr<NG::FrameNode> & contentNode,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)2570 void ViewAbstract::SetOverlayComponentContent(const RefPtr<NG::FrameNode>& contentNode,
2571 const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
2572 const std::optional<Dimension>& offsetY)
2573 {
2574 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2575 return;
2576 }
2577 AddOverlayToFrameNode(contentNode, align, offsetX, offsetY);
2578 }
2579
AddOverlayToFrameNode(const RefPtr<NG::FrameNode> & overlayNode,const std::optional<Alignment> & align,const std::optional<Dimension> & offsetX,const std::optional<Dimension> & offsetY)2580 void ViewAbstract::AddOverlayToFrameNode(const RefPtr<NG::FrameNode>& overlayNode,
2581 const std::optional<Alignment>& align, const std::optional<Dimension>& offsetX,
2582 const std::optional<Dimension>& offsetY)
2583 {
2584 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2585 CHECK_NULL_VOID(frameNode);
2586 if (overlayNode == nullptr) {
2587 frameNode->SetOverlayNode(nullptr);
2588 return;
2589 }
2590 frameNode->SetOverlayNode(overlayNode);
2591 overlayNode->SetParent(AceType::WeakClaim(frameNode));
2592 overlayNode->SetActive(true);
2593 overlayNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2594 auto layoutProperty = AceType::DynamicCast<LayoutProperty>(overlayNode->GetLayoutProperty());
2595 CHECK_NULL_VOID(layoutProperty);
2596 layoutProperty->SetIsOverlayNode(true);
2597 layoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT);
2598 layoutProperty->UpdateAlignment(align.value_or(Alignment::TOP_LEFT));
2599 layoutProperty->SetOverlayOffset(offsetX, offsetY);
2600 auto renderContext = overlayNode->GetRenderContext();
2601 CHECK_NULL_VOID(renderContext);
2602 renderContext->UpdateZIndex(INT32_MAX);
2603 auto focusHub = overlayNode->GetOrCreateFocusHub();
2604 CHECK_NULL_VOID(focusHub);
2605 focusHub->SetFocusable(false);
2606 }
2607
SetMotionPath(const MotionPathOption & motionPath)2608 void ViewAbstract::SetMotionPath(const MotionPathOption& motionPath)
2609 {
2610 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2611 return;
2612 }
2613 ACE_UPDATE_RENDER_CONTEXT(MotionPath, motionPath);
2614 }
2615
SetSharedTransition(const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)2616 void ViewAbstract::SetSharedTransition(
2617 const std::string& shareId, const std::shared_ptr<SharedTransitionOption>& option)
2618 {
2619 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2620 CHECK_NULL_VOID(frameNode);
2621 auto target = frameNode->GetRenderContext();
2622 if (target) {
2623 target->SetSharedTransitionOptions(option);
2624 target->SetShareId(shareId);
2625 }
2626 }
2627
SetMask(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)2628 void ViewAbstract::SetMask(FrameNode* frameNode, const RefPtr<BasicShape>& basicShape)
2629 {
2630 CHECK_NULL_VOID(frameNode);
2631 auto target = frameNode->GetRenderContext();
2632 if (target) {
2633 if (target->HasProgressMask()) {
2634 target->ResetProgressMask();
2635 target->OnProgressMaskUpdate(nullptr);
2636 }
2637 target->UpdateClipMask(basicShape);
2638 }
2639 }
2640
SetProgressMask(FrameNode * frameNode,const RefPtr<ProgressMaskProperty> & progress)2641 void ViewAbstract::SetProgressMask(FrameNode* frameNode, const RefPtr<ProgressMaskProperty>& progress)
2642 {
2643 CHECK_NULL_VOID(frameNode);
2644 auto target = frameNode->GetRenderContext();
2645 if (target) {
2646 if (target->HasClipMask()) {
2647 target->ResetClipMask();
2648 target->OnClipMaskUpdate(nullptr);
2649 }
2650 target->UpdateProgressMask(progress);
2651 }
2652 }
2653
SetUseEffect(bool useEffect)2654 void ViewAbstract::SetUseEffect(bool useEffect)
2655 {
2656 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2657 return;
2658 }
2659 ACE_UPDATE_RENDER_CONTEXT(UseEffect, useEffect);
2660 }
2661
SetFreeze(bool freeze)2662 void ViewAbstract::SetFreeze(bool freeze)
2663 {
2664 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2665 return;
2666 }
2667 ACE_UPDATE_RENDER_CONTEXT(Freeze, freeze);
2668 }
2669
SetUseShadowBatching(bool useShadowBatching)2670 void ViewAbstract::SetUseShadowBatching(bool useShadowBatching)
2671 {
2672 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2673 return;
2674 }
2675 ACE_UPDATE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching);
2676 }
2677
SetForegroundColor(const Color & color)2678 void ViewAbstract::SetForegroundColor(const Color& color)
2679 {
2680 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2681 return;
2682 }
2683 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2684 CHECK_NULL_VOID(frameNode);
2685 auto renderContext = frameNode->GetRenderContext();
2686 CHECK_NULL_VOID(renderContext);
2687 if (renderContext->GetForegroundColorStrategy().has_value()) {
2688 renderContext->UpdateForegroundColorStrategy(ForegroundColorStrategy::NONE);
2689 renderContext->ResetForegroundColorStrategy();
2690 }
2691 renderContext->UpdateForegroundColor(color);
2692 renderContext->UpdateForegroundColorFlag(true);
2693 }
2694
SetForegroundColorStrategy(const ForegroundColorStrategy & strategy)2695 void ViewAbstract::SetForegroundColorStrategy(const ForegroundColorStrategy& strategy)
2696 {
2697 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2698 return;
2699 }
2700 ACE_UPDATE_RENDER_CONTEXT(ForegroundColorStrategy, strategy);
2701 ACE_RESET_RENDER_CONTEXT(RenderContext, ForegroundColor);
2702 ACE_UPDATE_RENDER_CONTEXT(ForegroundColorFlag, true);
2703 }
2704
SetKeyboardShortcut(const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)2705 void ViewAbstract::SetKeyboardShortcut(
2706 const std::string& value, const std::vector<ModifierKey>& keys, std::function<void()>&& onKeyboardShortcutAction)
2707 {
2708 auto pipeline = PipelineContext::GetCurrentContext();
2709 CHECK_NULL_VOID(pipeline);
2710 auto eventManager = pipeline->GetEventManager();
2711 CHECK_NULL_VOID(eventManager);
2712 auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
2713 CHECK_NULL_VOID(eventHub);
2714 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2715 CHECK_NULL_VOID(frameNode);
2716 if (value.empty()) {
2717 eventHub->ClearSingleKeyboardShortcut();
2718 return;
2719 }
2720 auto key = eventManager->GetKeyboardShortcutKeys(keys);
2721 if ((key == 0 && value.length() == 1) || (key == 0 && keys.size() > 0 && value.length() > 1)) {
2722 return;
2723 }
2724 if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
2725 return;
2726 }
2727 eventHub->SetKeyboardShortcut(value, key, std::move(onKeyboardShortcutAction));
2728 eventManager->AddKeyboardShortcutNode(AceType::WeakClaim(frameNode));
2729 }
2730
CreateAnimatablePropertyFloat(const std::string & propertyName,float value,const std::function<void (float)> & onCallbackEvent)2731 void ViewAbstract::CreateAnimatablePropertyFloat(
2732 const std::string& propertyName, float value, const std::function<void(float)>& onCallbackEvent)
2733 {
2734 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2735 CHECK_NULL_VOID(frameNode);
2736 frameNode->CreateAnimatablePropertyFloat(propertyName, value, onCallbackEvent);
2737 }
2738
UpdateAnimatablePropertyFloat(const std::string & propertyName,float value)2739 void ViewAbstract::UpdateAnimatablePropertyFloat(const std::string& propertyName, float value)
2740 {
2741 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2742 CHECK_NULL_VOID(frameNode);
2743 frameNode->UpdateAnimatablePropertyFloat(propertyName, value);
2744 }
2745
CreateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value,std::function<void (const RefPtr<CustomAnimatableArithmetic> &)> & onCallbackEvent)2746 void ViewAbstract::CreateAnimatableArithmeticProperty(const std::string& propertyName,
2747 RefPtr<CustomAnimatableArithmetic>& value,
2748 std::function<void(const RefPtr<CustomAnimatableArithmetic>&)>& onCallbackEvent)
2749 {
2750 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2751 CHECK_NULL_VOID(frameNode);
2752 frameNode->CreateAnimatableArithmeticProperty(propertyName, value, onCallbackEvent);
2753 }
2754
UpdateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value)2755 void ViewAbstract::UpdateAnimatableArithmeticProperty(
2756 const std::string& propertyName, RefPtr<CustomAnimatableArithmetic>& value)
2757 {
2758 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2759 CHECK_NULL_VOID(frameNode);
2760 frameNode->UpdateAnimatableArithmeticProperty(propertyName, value);
2761 }
2762
SetObscured(const std::vector<ObscuredReasons> & reasons)2763 void ViewAbstract::SetObscured(const std::vector<ObscuredReasons>& reasons)
2764 {
2765 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2766 return;
2767 }
2768 ACE_UPDATE_RENDER_CONTEXT(Obscured, reasons);
2769 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2770 CHECK_NULL_VOID(frameNode);
2771 frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
2772 }
2773
SetPrivacySensitive(bool flag)2774 void ViewAbstract::SetPrivacySensitive(bool flag)
2775 {
2776 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2777 return;
2778 }
2779 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2780 CHECK_NULL_VOID(frameNode);
2781 frameNode->SetPrivacySensitive(flag);
2782 frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2783 }
2784
UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts & opts)2785 void ViewAbstract::UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts& opts)
2786 {
2787 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2788 return;
2789 }
2790 ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts);
2791 }
2792
SetRenderGroup(bool isRenderGroup)2793 void ViewAbstract::SetRenderGroup(bool isRenderGroup)
2794 {
2795 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2796 return;
2797 }
2798 ACE_UPDATE_RENDER_CONTEXT(RenderGroup, isRenderGroup);
2799 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2800 CHECK_NULL_VOID(frameNode);
2801 frameNode->SetApplicationRenderGroupMarked(true);
2802 }
2803
SetRenderFit(RenderFit renderFit)2804 void ViewAbstract::SetRenderFit(RenderFit renderFit)
2805 {
2806 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2807 return;
2808 }
2809 ACE_UPDATE_RENDER_CONTEXT(RenderFit, renderFit);
2810 }
2811
SetBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)2812 void ViewAbstract::SetBorderRadius(FrameNode* frameNode, const BorderRadiusProperty& value)
2813 {
2814 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, value, frameNode);
2815 }
2816
SetBorderRadius(FrameNode * frameNode,const Dimension & value)2817 void ViewAbstract::SetBorderRadius(FrameNode* frameNode, const Dimension& value)
2818 {
2819 BorderRadiusProperty borderRadius;
2820 borderRadius.SetRadius(value);
2821 borderRadius.multiValued = false;
2822 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, borderRadius, frameNode);
2823 }
2824
SetBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)2825 void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value)
2826 {
2827 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value, frameNode);
2828 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, value, frameNode);
2829 }
2830
SetBorderWidth(FrameNode * frameNode,const Dimension & value)2831 void ViewAbstract::SetBorderWidth(FrameNode* frameNode, const Dimension& value)
2832 {
2833 BorderWidthProperty borderWidth;
2834 if (Negative(value.Value())) {
2835 borderWidth.SetBorderWidth(Dimension(0));
2836 LOGW("border width is negative, reset to 0");
2837 } else {
2838 borderWidth.SetBorderWidth(value);
2839 }
2840 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth, frameNode);
2841 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, borderWidth, frameNode);
2842 }
2843
SetBorderColor(FrameNode * frameNode,const BorderColorProperty & value)2844 void ViewAbstract::SetBorderColor(FrameNode* frameNode, const BorderColorProperty& value)
2845 {
2846 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, value, frameNode);
2847 }
2848
SetBorderColor(FrameNode * frameNode,const Color & value)2849 void ViewAbstract::SetBorderColor(FrameNode* frameNode, const Color& value)
2850 {
2851 BorderColorProperty borderColor;
2852 borderColor.SetColor(value);
2853 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, borderColor, frameNode);
2854 }
2855
SetWidth(FrameNode * frameNode,const CalcLength & width)2856 void ViewAbstract::SetWidth(FrameNode* frameNode, const CalcLength& width)
2857 {
2858 CHECK_NULL_VOID(frameNode);
2859 auto layoutProperty = frameNode->GetLayoutProperty();
2860 CHECK_NULL_VOID(layoutProperty);
2861 // get previously user defined ideal height
2862 std::optional<CalcLength> height = std::nullopt;
2863 auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
2864 if (layoutConstraint && layoutConstraint->selfIdealSize) {
2865 height = layoutConstraint->selfIdealSize->Height();
2866 }
2867 layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
2868 }
2869
SetHeight(FrameNode * frameNode,const CalcLength & height)2870 void ViewAbstract::SetHeight(FrameNode* frameNode, const CalcLength& height)
2871 {
2872 CHECK_NULL_VOID(frameNode);
2873 auto layoutProperty = frameNode->GetLayoutProperty();
2874 CHECK_NULL_VOID(layoutProperty);
2875 std::optional<CalcLength> width = std::nullopt;
2876 auto&& layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
2877 if (layoutConstraint && layoutConstraint->selfIdealSize) {
2878 width = layoutConstraint->selfIdealSize->Width();
2879 }
2880 layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
2881 }
2882
ClearWidthOrHeight(FrameNode * frameNode,bool isWidth)2883 void ViewAbstract::ClearWidthOrHeight(FrameNode* frameNode, bool isWidth)
2884 {
2885 CHECK_NULL_VOID(frameNode);
2886 auto layoutProperty = frameNode->GetLayoutProperty();
2887 CHECK_NULL_VOID(layoutProperty);
2888 layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
2889 }
2890
SetPosition(FrameNode * frameNode,const OffsetT<Dimension> & value)2891 void ViewAbstract::SetPosition(FrameNode* frameNode, const OffsetT<Dimension>& value)
2892 {
2893 CHECK_NULL_VOID(frameNode);
2894 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode);
2895 ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode);
2896 }
2897
SetPositionEdges(FrameNode * frameNode,const EdgesParam & value)2898 void ViewAbstract::SetPositionEdges(FrameNode* frameNode, const EdgesParam& value)
2899 {
2900 CHECK_NULL_VOID(frameNode);
2901 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode);
2902 ACE_UPDATE_NODE_RENDER_CONTEXT(PositionEdges, value, frameNode);
2903 }
2904
ResetPosition(FrameNode * frameNode)2905 void ViewAbstract::ResetPosition(FrameNode* frameNode)
2906 {
2907 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Position, frameNode);
2908 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, PositionEdges, frameNode);
2909 CHECK_NULL_VOID(frameNode);
2910 auto parentNode = frameNode->GetAncestorNodeOfFrame();
2911 CHECK_NULL_VOID(parentNode);
2912 auto parentPattern = parentNode->GetPattern();
2913
2914 if (parentNode->GetTag() == V2::COLUMN_ETS_TAG || parentNode->GetTag() == V2::ROW_ETS_TAG ||
2915 parentNode->GetTag() == V2::FLEX_ETS_TAG) {
2916 frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
2917 } else {
2918 auto renderContext = frameNode->GetRenderContext();
2919 CHECK_NULL_VOID(renderContext);
2920 renderContext->RecalculatePosition();
2921 }
2922 }
2923
SetTransformMatrix(FrameNode * frameNode,const Matrix4 & matrix)2924 void ViewAbstract::SetTransformMatrix(FrameNode* frameNode, const Matrix4& matrix)
2925 {
2926 ACE_UPDATE_NODE_RENDER_CONTEXT(TransformMatrix, matrix, frameNode);
2927 }
2928
SetHitTestMode(FrameNode * frameNode,HitTestMode hitTestMode)2929 void ViewAbstract::SetHitTestMode(FrameNode* frameNode, HitTestMode hitTestMode)
2930 {
2931 CHECK_NULL_VOID(frameNode);
2932 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2933 CHECK_NULL_VOID(gestureHub);
2934 gestureHub->SetHitTestMode(hitTestMode);
2935 }
2936
SetOpacity(FrameNode * frameNode,double opacity)2937 void ViewAbstract::SetOpacity(FrameNode* frameNode, double opacity)
2938 {
2939 ACE_UPDATE_NODE_RENDER_CONTEXT(Opacity, opacity, frameNode);
2940 }
2941
SetZIndex(FrameNode * frameNode,int32_t value)2942 void ViewAbstract::SetZIndex(FrameNode* frameNode, int32_t value)
2943 {
2944 ACE_UPDATE_NODE_RENDER_CONTEXT(ZIndex, value, frameNode);
2945 }
2946
SetLinearGradient(FrameNode * frameNode,const NG::Gradient & gradient)2947 void ViewAbstract::SetLinearGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2948 {
2949 ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::LINEAR, frameNode);
2950 ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradient, gradient, frameNode);
2951 }
2952
SetSweepGradient(FrameNode * frameNode,const NG::Gradient & gradient)2953 void ViewAbstract::SetSweepGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2954 {
2955 ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::SWEEP, frameNode);
2956 ACE_UPDATE_NODE_RENDER_CONTEXT(SweepGradient, gradient, frameNode);
2957 }
2958
SetRadialGradient(FrameNode * frameNode,const NG::Gradient & gradient)2959 void ViewAbstract::SetRadialGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2960 {
2961 ACE_UPDATE_NODE_RENDER_CONTEXT(LastGradientType, NG::GradientType::RADIAL, frameNode);
2962 ACE_UPDATE_NODE_RENDER_CONTEXT(RadialGradient, gradient, frameNode);
2963 }
2964
SetOverlay(FrameNode * frameNode,const NG::OverlayOptions & overlay)2965 void ViewAbstract::SetOverlay(FrameNode* frameNode, const NG::OverlayOptions& overlay)
2966 {
2967 ACE_UPDATE_NODE_RENDER_CONTEXT(OverlayText, overlay, frameNode);
2968 }
2969
SetBorderImage(FrameNode * frameNode,const RefPtr<BorderImage> & borderImage)2970 void ViewAbstract::SetBorderImage(FrameNode* frameNode, const RefPtr<BorderImage>& borderImage)
2971 {
2972 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImage, borderImage, frameNode);
2973 }
2974
SetBorderImageSource(FrameNode * frameNode,const std::string & bdImageSrc)2975 void ViewAbstract::SetBorderImageSource(FrameNode* frameNode, const std::string& bdImageSrc)
2976 {
2977 ImageSourceInfo imageSourceInfo(bdImageSrc);
2978 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo, frameNode);
2979 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderSourceFromImage, true, frameNode);
2980 }
2981
SetHasBorderImageSlice(FrameNode * frameNode,bool tag)2982 void ViewAbstract::SetHasBorderImageSlice(FrameNode* frameNode, bool tag)
2983 {
2984 ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageSlice, tag, frameNode);
2985 }
2986
SetHasBorderImageWidth(FrameNode * frameNode,bool tag)2987 void ViewAbstract::SetHasBorderImageWidth(FrameNode* frameNode, bool tag)
2988 {
2989 ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageWidth, tag, frameNode);
2990 }
2991
SetHasBorderImageOutset(FrameNode * frameNode,bool tag)2992 void ViewAbstract::SetHasBorderImageOutset(FrameNode* frameNode, bool tag)
2993 {
2994 ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageOutset, tag, frameNode);
2995 }
2996
SetHasBorderImageRepeat(FrameNode * frameNode,bool tag)2997 void ViewAbstract::SetHasBorderImageRepeat(FrameNode* frameNode, bool tag)
2998 {
2999 ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageRepeat, tag, frameNode);
3000 }
3001
SetBorderImageGradient(FrameNode * frameNode,const NG::Gradient & gradient)3002 void ViewAbstract::SetBorderImageGradient(FrameNode* frameNode, const NG::Gradient& gradient)
3003 {
3004 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageGradient, gradient, frameNode);
3005 ACE_UPDATE_NODE_RENDER_CONTEXT(BorderSourceFromImage, false, frameNode);
3006 }
3007
SetForegroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & fgBlurStyle)3008 void ViewAbstract::SetForegroundBlurStyle(FrameNode* frameNode, const BlurStyleOption& fgBlurStyle)
3009 {
3010 const auto target = frameNode->GetRenderContext();
3011 if (target) {
3012 target->UpdateFrontBlurStyle(fgBlurStyle);
3013 if (target->GetFrontBlurRadius().has_value()) {
3014 target->UpdateFrontBlurRadius(Dimension());
3015 }
3016 }
3017 }
3018
SetLinearGradientBlur(FrameNode * frameNode,const NG::LinearGradientBlurPara & blurPara)3019 void ViewAbstract::SetLinearGradientBlur(FrameNode *frameNode, const NG::LinearGradientBlurPara& blurPara)
3020 {
3021 ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradientBlur, blurPara, frameNode);
3022 }
3023
SetMagnifier(FrameNode * frameNode,const MagnifierParams & magnifierOffset)3024 void ViewAbstract::SetMagnifier(FrameNode* frameNode, const MagnifierParams& magnifierOffset)
3025 {
3026 ACE_UPDATE_NODE_RENDER_CONTEXT(Magnifier, magnifierOffset, frameNode);
3027 }
3028
ReSetMagnifier(FrameNode * frameNode)3029 void ViewAbstract::ReSetMagnifier(FrameNode* frameNode)
3030 {
3031 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Magnifier, frameNode);
3032 }
3033
SetBackgroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & bgBlurStyle)3034 void ViewAbstract::SetBackgroundBlurStyle(FrameNode *frameNode, const BlurStyleOption& bgBlurStyle)
3035 {
3036 auto target = frameNode->GetRenderContext();
3037 if (target) {
3038 if (target->GetBackgroundEffect().has_value()) {
3039 target->UpdateBackgroundEffect(std::nullopt);
3040 }
3041 target->UpdateBackBlurStyle(bgBlurStyle);
3042 if (target->GetBackBlurRadius().has_value()) {
3043 target->UpdateBackBlurRadius(Dimension());
3044 }
3045 }
3046 }
3047
SetPixelStretchEffect(FrameNode * frameNode,PixStretchEffectOption & option)3048 void ViewAbstract::SetPixelStretchEffect(FrameNode* frameNode, PixStretchEffectOption& option)
3049 {
3050 ACE_UPDATE_NODE_RENDER_CONTEXT(PixelStretchEffect, option, frameNode);
3051 }
3052
SetLightUpEffect(FrameNode * frameNode,double radio)3053 void ViewAbstract::SetLightUpEffect(FrameNode* frameNode, double radio)
3054 {
3055 ACE_UPDATE_NODE_RENDER_CONTEXT(LightUpEffect, radio, frameNode);
3056 }
3057
SetSphericalEffect(FrameNode * frameNode,double radio)3058 void ViewAbstract::SetSphericalEffect(FrameNode* frameNode, double radio)
3059 {
3060 ACE_UPDATE_NODE_RENDER_CONTEXT(SphericalEffect, radio, frameNode);
3061 }
3062
SetRenderGroup(FrameNode * frameNode,bool isRenderGroup)3063 void ViewAbstract::SetRenderGroup(FrameNode* frameNode, bool isRenderGroup)
3064 {
3065 ACE_UPDATE_NODE_RENDER_CONTEXT(RenderGroup, isRenderGroup, frameNode);
3066 CHECK_NULL_VOID(frameNode);
3067 frameNode->SetApplicationRenderGroupMarked(true);
3068 }
3069
SetRenderFit(FrameNode * frameNode,RenderFit renderFit)3070 void ViewAbstract::SetRenderFit(FrameNode* frameNode, RenderFit renderFit)
3071 {
3072 ACE_UPDATE_NODE_RENDER_CONTEXT(RenderFit, renderFit, frameNode);
3073 }
3074
SetUseEffect(FrameNode * frameNode,bool useEffect)3075 void ViewAbstract::SetUseEffect(FrameNode* frameNode, bool useEffect)
3076 {
3077 ACE_UPDATE_NODE_RENDER_CONTEXT(UseEffect, useEffect, frameNode);
3078 }
3079
SetForegroundColor(FrameNode * frameNode,const Color & color)3080 void ViewAbstract::SetForegroundColor(FrameNode* frameNode, const Color& color)
3081 {
3082 auto renderContext = frameNode->GetRenderContext();
3083 CHECK_NULL_VOID(renderContext);
3084 if (renderContext->GetForegroundColorStrategy().has_value()) {
3085 renderContext->UpdateForegroundColorStrategy(ForegroundColorStrategy::NONE);
3086 renderContext->ResetForegroundColorStrategy();
3087 }
3088 renderContext->UpdateForegroundColor(color);
3089 renderContext->UpdateForegroundColorFlag(true);
3090 }
3091
SetForegroundColorStrategy(FrameNode * frameNode,const ForegroundColorStrategy & strategy)3092 void ViewAbstract::SetForegroundColorStrategy(FrameNode* frameNode, const ForegroundColorStrategy& strategy)
3093 {
3094 ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorStrategy, strategy, frameNode);
3095 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, ForegroundColor, frameNode);
3096 ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorFlag, true, frameNode);
3097 }
3098
SetLightPosition(const CalcDimension & positionX,const CalcDimension & positionY,const CalcDimension & positionZ)3099 void ViewAbstract::SetLightPosition(
3100 const CalcDimension& positionX, const CalcDimension& positionY, const CalcDimension& positionZ)
3101 {
3102 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3103 return;
3104 }
3105 ACE_UPDATE_RENDER_CONTEXT(LightPosition, TranslateOptions(positionX, positionY, positionZ));
3106 }
3107
SetLightIntensity(const float value)3108 void ViewAbstract::SetLightIntensity(const float value)
3109 {
3110 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3111 return;
3112 }
3113 ACE_UPDATE_RENDER_CONTEXT(LightIntensity, value);
3114 }
3115
SetLightColor(const Color & value)3116 void ViewAbstract::SetLightColor(const Color& value)
3117 {
3118 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3119 return;
3120 }
3121 ACE_UPDATE_RENDER_CONTEXT(LightColor, value);
3122 }
3123
SetLightIlluminated(const uint32_t value)3124 void ViewAbstract::SetLightIlluminated(const uint32_t value)
3125 {
3126 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3127 return;
3128 }
3129 ACE_UPDATE_RENDER_CONTEXT(LightIlluminated, value);
3130 }
3131
SetIlluminatedBorderWidth(const Dimension & value)3132 void ViewAbstract::SetIlluminatedBorderWidth(const Dimension& value)
3133 {
3134 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3135 return;
3136 }
3137 ACE_UPDATE_RENDER_CONTEXT(IlluminatedBorderWidth, value);
3138 }
3139
SetBloom(const float value)3140 void ViewAbstract::SetBloom(const float value)
3141 {
3142 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
3143 return;
3144 }
3145 ACE_UPDATE_RENDER_CONTEXT(Bloom, value);
3146 }
3147
SetLightPosition(FrameNode * frameNode,const CalcDimension & positionX,const CalcDimension & positionY,const CalcDimension & positionZ)3148 void ViewAbstract::SetLightPosition(FrameNode* frameNode, const CalcDimension& positionX,
3149 const CalcDimension& positionY, const CalcDimension& positionZ)
3150 {
3151 CHECK_NULL_VOID(frameNode);
3152 ACE_UPDATE_NODE_RENDER_CONTEXT(LightPosition, TranslateOptions(positionX, positionY, positionZ), frameNode);
3153 }
3154
SetLightIntensity(FrameNode * frameNode,const float value)3155 void ViewAbstract::SetLightIntensity(FrameNode* frameNode, const float value)
3156 {
3157 CHECK_NULL_VOID(frameNode);
3158 ACE_UPDATE_NODE_RENDER_CONTEXT(LightIntensity, value, frameNode);
3159 }
3160
SetLightColor(FrameNode * frameNode,const Color & value)3161 void ViewAbstract::SetLightColor(FrameNode* frameNode, const Color& value)
3162 {
3163 CHECK_NULL_VOID(frameNode);
3164 ACE_UPDATE_NODE_RENDER_CONTEXT(LightColor, value, frameNode);
3165 }
3166
SetLightIlluminated(FrameNode * frameNode,const uint32_t value)3167 void ViewAbstract::SetLightIlluminated(FrameNode* frameNode, const uint32_t value)
3168 {
3169 CHECK_NULL_VOID(frameNode);
3170 ACE_UPDATE_NODE_RENDER_CONTEXT(LightIlluminated, value, frameNode);
3171 }
3172
SetIlluminatedBorderWidth(FrameNode * frameNode,const Dimension & value)3173 void ViewAbstract::SetIlluminatedBorderWidth(FrameNode* frameNode, const Dimension& value)
3174 {
3175 CHECK_NULL_VOID(frameNode);
3176 ACE_UPDATE_NODE_RENDER_CONTEXT(IlluminatedBorderWidth, value, frameNode);
3177 }
3178
SetBloom(FrameNode * frameNode,const float value)3179 void ViewAbstract::SetBloom(FrameNode* frameNode, const float value)
3180 {
3181 CHECK_NULL_VOID(frameNode);
3182 ACE_UPDATE_NODE_RENDER_CONTEXT(Bloom, value, frameNode);
3183 }
3184
SetMotionPath(FrameNode * frameNode,const MotionPathOption & motionPath)3185 void ViewAbstract::SetMotionPath(FrameNode* frameNode, const MotionPathOption& motionPath)
3186 {
3187 ACE_UPDATE_NODE_RENDER_CONTEXT(MotionPath, motionPath, frameNode);
3188 }
3189
SetFocusOnTouch(FrameNode * frameNode,bool isSet)3190 void ViewAbstract::SetFocusOnTouch(FrameNode* frameNode, bool isSet)
3191 {
3192 CHECK_NULL_VOID(frameNode);
3193 auto focusHub = frameNode->GetOrCreateFocusHub();
3194 CHECK_NULL_VOID(focusHub);
3195 focusHub->SetIsFocusOnTouch(isSet);
3196 }
3197
SetGroupDefaultFocus(FrameNode * frameNode,bool isSet)3198 void ViewAbstract::SetGroupDefaultFocus(FrameNode* frameNode, bool isSet)
3199 {
3200 CHECK_NULL_VOID(frameNode);
3201 auto focusHub = frameNode->GetOrCreateFocusHub();
3202 CHECK_NULL_VOID(focusHub);
3203 focusHub->SetIsDefaultGroupFocus(isSet);
3204 }
3205
SetFocusable(FrameNode * frameNode,bool focusable)3206 void ViewAbstract::SetFocusable(FrameNode* frameNode, bool focusable)
3207 {
3208 CHECK_NULL_VOID(frameNode);
3209 auto focusHub = frameNode->GetOrCreateFocusHub();
3210 CHECK_NULL_VOID(focusHub);
3211 focusHub->SetFocusable(focusable);
3212 }
3213
SetFocusType(FrameNode * frameNode,FocusType focusType)3214 void ViewAbstract::SetFocusType(FrameNode* frameNode, FocusType focusType)
3215 {
3216 CHECK_NULL_VOID(frameNode);
3217 auto focusHub = frameNode->GetOrCreateFocusHub();
3218 CHECK_NULL_VOID(focusHub);
3219 focusHub->SetFocusType(focusType);
3220 }
3221
SetTouchable(FrameNode * frameNode,bool touchable)3222 void ViewAbstract::SetTouchable(FrameNode* frameNode, bool touchable)
3223 {
3224 CHECK_NULL_VOID(frameNode);
3225 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3226 CHECK_NULL_VOID(gestureHub);
3227 gestureHub->SetTouchable(touchable);
3228 }
3229
SetDefaultFocus(FrameNode * frameNode,bool isSet)3230 void ViewAbstract::SetDefaultFocus(FrameNode* frameNode, bool isSet)
3231 {
3232 CHECK_NULL_VOID(frameNode);
3233 auto focusHub = frameNode->GetOrCreateFocusHub();
3234 CHECK_NULL_VOID(focusHub);
3235 focusHub->SetIsDefaultFocus(isSet);
3236 }
3237
SetDisplayIndex(FrameNode * frameNode,int32_t value)3238 void ViewAbstract::SetDisplayIndex(FrameNode* frameNode, int32_t value)
3239 {
3240 CHECK_NULL_VOID(frameNode);
3241 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value, frameNode);
3242 }
3243
SetOffset(FrameNode * frameNode,const OffsetT<Dimension> & value)3244 void ViewAbstract::SetOffset(FrameNode* frameNode, const OffsetT<Dimension>& value)
3245 {
3246 CHECK_NULL_VOID(frameNode);
3247 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, OffsetEdges, frameNode);
3248 ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, value, frameNode);
3249 }
3250
SetOffsetEdges(FrameNode * frameNode,const EdgesParam & value)3251 void ViewAbstract::SetOffsetEdges(FrameNode* frameNode, const EdgesParam& value)
3252 {
3253 CHECK_NULL_VOID(frameNode);
3254 ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, Offset, frameNode);
3255 ACE_UPDATE_NODE_RENDER_CONTEXT(OffsetEdges, value, frameNode);
3256 }
3257
MarkAnchor(FrameNode * frameNode,const OffsetT<Dimension> & value)3258 void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT<Dimension>& value)
3259 {
3260 CHECK_NULL_VOID(frameNode);
3261 ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, value, frameNode);
3262 }
3263
SetVisibility(FrameNode * frameNode,VisibleType visible)3264 void ViewAbstract::SetVisibility(FrameNode* frameNode, VisibleType visible)
3265 {
3266 CHECK_NULL_VOID(frameNode);
3267 auto layoutProperty = frameNode->GetLayoutProperty();
3268 if (layoutProperty) {
3269 layoutProperty->UpdateVisibility(visible, true);
3270 }
3271
3272 auto focusHub = frameNode->GetOrCreateFocusHub();
3273 if (focusHub) {
3274 focusHub->SetShow(visible == VisibleType::VISIBLE);
3275 }
3276 }
3277
SetPadding(FrameNode * frameNode,const CalcLength & value)3278 void ViewAbstract::SetPadding(FrameNode* frameNode, const CalcLength& value)
3279 {
3280 CHECK_NULL_VOID(frameNode);
3281 PaddingProperty padding;
3282 padding.SetEdges(value);
3283 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding, frameNode);
3284 }
3285
SetPadding(FrameNode * frameNode,const PaddingProperty & value)3286 void ViewAbstract::SetPadding(FrameNode* frameNode, const PaddingProperty& value)
3287 {
3288 CHECK_NULL_VOID(frameNode);
3289 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, value, frameNode);
3290 }
3291
SetMargin(FrameNode * frameNode,const CalcLength & value)3292 void ViewAbstract::SetMargin(FrameNode* frameNode, const CalcLength& value)
3293 {
3294 CHECK_NULL_VOID(frameNode);
3295 MarginProperty margin;
3296 margin.SetEdges(value);
3297 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin, frameNode);
3298 }
3299
SetMargin(FrameNode * frameNode,const PaddingProperty & value)3300 void ViewAbstract::SetMargin(FrameNode* frameNode, const PaddingProperty& value)
3301 {
3302 CHECK_NULL_VOID(frameNode);
3303 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, value, frameNode);
3304 }
3305
SetLayoutDirection(FrameNode * frameNode,TextDirection value)3306 void ViewAbstract::SetLayoutDirection(FrameNode* frameNode, TextDirection value)
3307 {
3308 CHECK_NULL_VOID(frameNode);
3309 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value, frameNode);
3310 }
3311
UpdateSafeAreaExpandOpts(FrameNode * frameNode,const SafeAreaExpandOpts & opts)3312 void ViewAbstract::UpdateSafeAreaExpandOpts(FrameNode* frameNode, const SafeAreaExpandOpts& opts)
3313 {
3314 CHECK_NULL_VOID(frameNode);
3315 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts, frameNode);
3316 }
3317
SetAspectRatio(FrameNode * frameNode,float ratio)3318 void ViewAbstract::SetAspectRatio(FrameNode* frameNode, float ratio)
3319 {
3320 CHECK_NULL_VOID(frameNode);
3321 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio, frameNode);
3322 }
3323
SetAlignSelf(FrameNode * frameNode,FlexAlign value)3324 void ViewAbstract::SetAlignSelf(FrameNode* frameNode, FlexAlign value)
3325 {
3326 CHECK_NULL_VOID(frameNode);
3327 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value, frameNode);
3328 }
3329
SetFlexBasis(FrameNode * frameNode,const Dimension & value)3330 void ViewAbstract::SetFlexBasis(FrameNode* frameNode, const Dimension& value)
3331 {
3332 CHECK_NULL_VOID(frameNode);
3333 if (LessNotEqual(value.Value(), 0.0f)) {
3334 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension(), frameNode);
3335 return;
3336 }
3337 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value, frameNode);
3338 }
3339
ResetFlexShrink(FrameNode * frameNode)3340 void ViewAbstract::ResetFlexShrink(FrameNode* frameNode)
3341 {
3342 CHECK_NULL_VOID(frameNode);
3343 ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, frameNode);
3344 }
3345
SetFlexShrink(FrameNode * frameNode,float value)3346 void ViewAbstract::SetFlexShrink(FrameNode* frameNode, float value)
3347 {
3348 CHECK_NULL_VOID(frameNode);
3349 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value, frameNode);
3350 }
3351
SetFlexGrow(FrameNode * frameNode,float value)3352 void ViewAbstract::SetFlexGrow(FrameNode* frameNode, float value)
3353 {
3354 CHECK_NULL_VOID(frameNode);
3355 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value, frameNode);
3356 }
3357
SetLayoutWeight(FrameNode * frameNode,float value)3358 void ViewAbstract::SetLayoutWeight(FrameNode* frameNode, float value)
3359 {
3360 CHECK_NULL_VOID(frameNode);
3361 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, value, frameNode);
3362 }
3363
ResetMaxSize(FrameNode * frameNode,bool resetWidth)3364 void ViewAbstract::ResetMaxSize(FrameNode* frameNode, bool resetWidth)
3365 {
3366 CHECK_NULL_VOID(frameNode);
3367 auto layoutProperty = frameNode->GetLayoutProperty();
3368 CHECK_NULL_VOID(layoutProperty);
3369 layoutProperty->ResetCalcMaxSize(resetWidth);
3370 }
3371
ResetMinSize(FrameNode * frameNode,bool resetWidth)3372 void ViewAbstract::ResetMinSize(FrameNode* frameNode, bool resetWidth)
3373 {
3374 CHECK_NULL_VOID(frameNode);
3375 auto layoutProperty = frameNode->GetLayoutProperty();
3376 CHECK_NULL_VOID(layoutProperty);
3377 layoutProperty->ResetCalcMinSize(resetWidth);
3378 }
3379
SetMinWidth(FrameNode * frameNode,const CalcLength & minWidth)3380 void ViewAbstract::SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth)
3381 {
3382 CHECK_NULL_VOID(frameNode);
3383 auto layoutProperty = frameNode->GetLayoutProperty();
3384 CHECK_NULL_VOID(layoutProperty);
3385 layoutProperty->UpdateCalcMinSize(CalcSize(minWidth, std::nullopt));
3386 }
3387
SetMaxWidth(FrameNode * frameNode,const CalcLength & maxWidth)3388 void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth)
3389 {
3390 CHECK_NULL_VOID(frameNode);
3391 auto layoutProperty = frameNode->GetLayoutProperty();
3392 CHECK_NULL_VOID(layoutProperty);
3393 layoutProperty->UpdateCalcMaxSize(CalcSize(maxWidth, std::nullopt));
3394 }
3395
SetMinHeight(FrameNode * frameNode,const CalcLength & minHeight)3396 void ViewAbstract::SetMinHeight(FrameNode* frameNode, const CalcLength& minHeight)
3397 {
3398 CHECK_NULL_VOID(frameNode);
3399 auto layoutProperty = frameNode->GetLayoutProperty();
3400 CHECK_NULL_VOID(layoutProperty);
3401 layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, minHeight));
3402 }
3403
SetMaxHeight(FrameNode * frameNode,const CalcLength & maxHeight)3404 void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeight)
3405 {
3406 CHECK_NULL_VOID(frameNode);
3407 auto layoutProperty = frameNode->GetLayoutProperty();
3408 CHECK_NULL_VOID(layoutProperty);
3409 layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, maxHeight));
3410 }
3411
SetAlignRules(FrameNode * frameNode,const std::map<AlignDirection,AlignRule> & alignRules)3412 void ViewAbstract::SetAlignRules(FrameNode* frameNode, const std::map<AlignDirection, AlignRule>& alignRules)
3413 {
3414 CHECK_NULL_VOID(frameNode);
3415 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules, frameNode);
3416 }
3417
GetAlignRules(FrameNode * frameNode)3418 std::map<AlignDirection, AlignRule> ViewAbstract::GetAlignRules(FrameNode* frameNode)
3419 {
3420 std::map<AlignDirection, AlignRule> alignRules;
3421 CHECK_NULL_RETURN(frameNode, alignRules);
3422 auto layoutProperty = frameNode->GetLayoutProperty();
3423 CHECK_NULL_RETURN(layoutProperty, alignRules);
3424 CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), alignRules);
3425 return layoutProperty->GetFlexItemProperty()->GetAlignRules().value_or(alignRules);
3426 }
3427
ResetAlignRules(FrameNode * frameNode)3428 void ViewAbstract::ResetAlignRules(FrameNode* frameNode)
3429 {
3430 CHECK_NULL_VOID(frameNode);
3431 auto layoutProperty = frameNode->GetLayoutProperty();
3432 CHECK_NULL_VOID(layoutProperty);
3433 CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
3434 return layoutProperty->GetFlexItemProperty()->ResetAlignRules();
3435 }
3436
SetChainStyle(FrameNode * frameNode,const ChainInfo & chainInfo)3437 void ViewAbstract::SetChainStyle(FrameNode* frameNode, const ChainInfo& chainInfo)
3438 {
3439 CHECK_NULL_VOID(frameNode);
3440 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, ChainStyle, chainInfo, frameNode);
3441 }
3442
GetChainStyle(FrameNode * frameNode)3443 ChainInfo ViewAbstract::GetChainStyle(FrameNode* frameNode)
3444 {
3445 ChainInfo chainInfo;
3446 CHECK_NULL_RETURN(frameNode, chainInfo);
3447 auto layoutProperty = frameNode->GetLayoutProperty();
3448 CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), chainInfo);
3449 layoutProperty->GetFlexItemProperty()->GetHorizontalChainStyle().value_or(chainInfo);
3450 if (chainInfo.direction.has_value()) {
3451 return chainInfo;
3452 }
3453 return layoutProperty->GetFlexItemProperty()->GetVerticalChainStyle().value_or(chainInfo);
3454 }
3455
ResetChainStyle(FrameNode * frameNode)3456 void ViewAbstract::ResetChainStyle(FrameNode* frameNode)
3457 {
3458 CHECK_NULL_VOID(frameNode);
3459 ChainInfo nullChainInfo;
3460 auto layoutProperty = frameNode->GetLayoutProperty();
3461 CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
3462 layoutProperty->GetFlexItemProperty()->UpdateHorizontalChainStyle(nullChainInfo);
3463 layoutProperty->GetFlexItemProperty()->UpdateVerticalChainStyle(nullChainInfo);
3464 }
3465
SetGrid(FrameNode * frameNode,std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)3466 void ViewAbstract::SetGrid(
3467 FrameNode* frameNode, std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
3468 {
3469 CHECK_NULL_VOID(frameNode);
3470 auto layoutProperty = frameNode->GetLayoutProperty();
3471 CHECK_NULL_VOID(layoutProperty);
3472 // frame node is mounted to parent when pop from stack later, no grid-container is added here
3473 layoutProperty->UpdateGridProperty(span, offset, type);
3474 }
3475
ResetAspectRatio(FrameNode * frameNode)3476 void ViewAbstract::ResetAspectRatio(FrameNode* frameNode)
3477 {
3478 ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, frameNode);
3479 }
3480
SetAllowDrop(FrameNode * frameNode,const std::set<std::string> & allowDrop)3481 void ViewAbstract::SetAllowDrop(FrameNode* frameNode, const std::set<std::string>& allowDrop)
3482 {
3483 CHECK_NULL_VOID(frameNode);
3484 frameNode->SetAllowDrop(allowDrop);
3485 }
3486
SetInspectorId(FrameNode * frameNode,const std::string & inspectorId)3487 void ViewAbstract::SetInspectorId(FrameNode* frameNode, const std::string& inspectorId)
3488 {
3489 if (frameNode) {
3490 if (frameNode->GetInspectorId().has_value() && frameNode->GetInspectorIdValue() != inspectorId) {
3491 ElementRegister::GetInstance()->RemoveFrameNodeByInspectorId(
3492 frameNode->GetInspectorIdValue(), frameNode->GetId());
3493 }
3494 frameNode->UpdateInspectorId(inspectorId);
3495 }
3496 }
3497
SetRestoreId(FrameNode * frameNode,int32_t restoreId)3498 void ViewAbstract::SetRestoreId(FrameNode* frameNode, int32_t restoreId)
3499 {
3500 if (frameNode) {
3501 frameNode->SetRestoreId(restoreId);
3502 }
3503 }
3504
SetTabIndex(FrameNode * frameNode,int32_t index)3505 void ViewAbstract::SetTabIndex(FrameNode* frameNode, int32_t index)
3506 {
3507 CHECK_NULL_VOID(frameNode);
3508 auto focusHub = frameNode->GetOrCreateFocusHub();
3509 CHECK_NULL_VOID(focusHub);
3510 focusHub->SetTabIndex(index);
3511 }
3512
SetObscured(FrameNode * frameNode,const std::vector<ObscuredReasons> & reasons)3513 void ViewAbstract::SetObscured(FrameNode* frameNode, const std::vector<ObscuredReasons>& reasons)
3514 {
3515 CHECK_NULL_VOID(frameNode);
3516 ACE_UPDATE_NODE_RENDER_CONTEXT(Obscured, reasons, frameNode);
3517 frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
3518 }
3519
SetForegroundEffect(FrameNode * frameNode,float radius)3520 void ViewAbstract::SetForegroundEffect(FrameNode* frameNode, float radius)
3521 {
3522 CHECK_NULL_VOID(frameNode);
3523 auto target = frameNode->GetRenderContext();
3524 if (target) {
3525 target->UpdateForegroundEffect(radius);
3526 }
3527 }
3528
SetMotionBlur(FrameNode * frameNode,const MotionBlurOption & motionBlurOption)3529 void ViewAbstract::SetMotionBlur(FrameNode* frameNode, const MotionBlurOption& motionBlurOption)
3530 {
3531 ACE_UPDATE_NODE_RENDER_CONTEXT(MotionBlur, motionBlurOption, frameNode);
3532 }
3533
SetBackgroundEffect(FrameNode * frameNode,const EffectOption & effectOption)3534 void ViewAbstract::SetBackgroundEffect(FrameNode* frameNode, const EffectOption &effectOption)
3535 {
3536 CHECK_NULL_VOID(frameNode);
3537 auto target = frameNode->GetRenderContext();
3538 if (target) {
3539 if (target->GetBackBlurRadius().has_value()) {
3540 target->UpdateBackBlurRadius(Dimension());
3541 }
3542 if (target->GetBackBlurStyle().has_value()) {
3543 target->UpdateBackBlurStyle(std::nullopt);
3544 }
3545 target->UpdateBackgroundEffect(effectOption);
3546 }
3547 }
3548
SetDynamicLightUp(FrameNode * frameNode,float rate,float lightUpDegree)3549 void ViewAbstract::SetDynamicLightUp(FrameNode* frameNode, float rate, float lightUpDegree)
3550 {
3551 ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpRate, rate, frameNode);
3552 ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree, frameNode);
3553 }
3554
SetBgDynamicBrightness(FrameNode * frameNode,const BrightnessOption & brightnessOption)3555 void ViewAbstract::SetBgDynamicBrightness(FrameNode* frameNode, const BrightnessOption& brightnessOption)
3556 {
3557 CHECK_NULL_VOID(frameNode);
3558 ACE_UPDATE_NODE_RENDER_CONTEXT(BgDynamicBrightnessOption, brightnessOption, frameNode);
3559 }
3560
SetFgDynamicBrightness(FrameNode * frameNode,const BrightnessOption & brightnessOption)3561 void ViewAbstract::SetFgDynamicBrightness(FrameNode* frameNode, const BrightnessOption& brightnessOption)
3562 {
3563 CHECK_NULL_VOID(frameNode);
3564 ACE_UPDATE_NODE_RENDER_CONTEXT(FgDynamicBrightnessOption, brightnessOption, frameNode);
3565 }
3566
SetBrightnessBlender(FrameNode * frameNode,const OHOS::Rosen::BrightnessBlender * brightnessBlender)3567 void ViewAbstract::SetBrightnessBlender(FrameNode* frameNode, const OHOS::Rosen::BrightnessBlender* brightnessBlender)
3568 {
3569 CHECK_NULL_VOID(frameNode);
3570 ACE_UPDATE_NODE_RENDER_CONTEXT(BrightnessBlender, brightnessBlender, frameNode);
3571 }
3572
SetDragPreviewOptions(FrameNode * frameNode,const DragPreviewOption & previewOption)3573 void ViewAbstract::SetDragPreviewOptions(FrameNode* frameNode, const DragPreviewOption& previewOption)
3574 {
3575 CHECK_NULL_VOID(frameNode);
3576 frameNode->SetDragPreviewOptions(previewOption);
3577 }
3578
SetDragPreview(FrameNode * frameNode,const DragDropInfo & dragDropInfo)3579 void ViewAbstract::SetDragPreview(FrameNode* frameNode, const DragDropInfo& dragDropInfo)
3580 {
3581 CHECK_NULL_VOID(frameNode);
3582 frameNode->SetDragPreview(dragDropInfo);
3583 }
3584
SetResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & responseRegion)3585 void ViewAbstract::SetResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& responseRegion)
3586 {
3587 CHECK_NULL_VOID(frameNode);
3588 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3589 CHECK_NULL_VOID(gestureHub);
3590 gestureHub->SetResponseRegion(responseRegion);
3591 }
3592
SetMouseResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & mouseResponseRegion)3593 void ViewAbstract::SetMouseResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& mouseResponseRegion)
3594 {
3595 CHECK_NULL_VOID(frameNode);
3596 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3597 CHECK_NULL_VOID(gestureHub);
3598 gestureHub->SetMouseResponseRegion(mouseResponseRegion);
3599 }
3600
SetSharedTransition(FrameNode * frameNode,const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)3601 void ViewAbstract::SetSharedTransition(
3602 FrameNode* frameNode, const std::string& shareId, const std::shared_ptr<SharedTransitionOption>& option)
3603 {
3604 CHECK_NULL_VOID(frameNode);
3605 const auto& target = frameNode->GetRenderContext();
3606 if (target) {
3607 target->SetSharedTransitionOptions(option);
3608 target->SetShareId(shareId);
3609 }
3610 }
3611
SetTransition(FrameNode * frameNode,const TransitionOptions & options)3612 void ViewAbstract::SetTransition(FrameNode* frameNode, const TransitionOptions& options)
3613 {
3614 ACE_UPDATE_NODE_RENDER_CONTEXT(Transition, options, frameNode);
3615 }
3616
CleanTransition(FrameNode * frameNode)3617 void ViewAbstract::CleanTransition(FrameNode* frameNode)
3618 {
3619 CHECK_NULL_VOID(frameNode);
3620 const auto& renderContext = frameNode->GetRenderContext();
3621 if (renderContext) {
3622 renderContext->CleanTransition();
3623 }
3624 }
3625
SetChainedTransition(FrameNode * frameNode,const RefPtr<NG::ChainedTransitionEffect> & effect,NG::TransitionFinishCallback && finishCallback)3626 void ViewAbstract::SetChainedTransition(FrameNode* frameNode, const RefPtr<NG::ChainedTransitionEffect>& effect,
3627 NG::TransitionFinishCallback&& finishCallback)
3628 {
3629 CHECK_NULL_VOID(frameNode);
3630 const auto& target = frameNode->GetRenderContext();
3631 if (target) {
3632 target->UpdateChainedTransition(effect);
3633 target->SetTransitionUserCallback(std::move(finishCallback));
3634 }
3635 }
3636
SetEnabled(FrameNode * frameNode,bool enabled)3637 void ViewAbstract::SetEnabled(FrameNode* frameNode, bool enabled)
3638 {
3639 CHECK_NULL_VOID(frameNode);
3640 auto eventHub = frameNode->GetEventHub<EventHub>();
3641 if (eventHub) {
3642 eventHub->SetEnabled(enabled);
3643 }
3644 auto focusHub = frameNode->GetOrCreateFocusHub();
3645 if (focusHub) {
3646 focusHub->SetEnabled(enabled);
3647 }
3648 }
3649
SetUseShadowBatching(FrameNode * frameNode,bool useShadowBatching)3650 void ViewAbstract::SetUseShadowBatching(FrameNode* frameNode, bool useShadowBatching)
3651 {
3652 ACE_UPDATE_NODE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching, frameNode);
3653 }
3654
SetBlendMode(FrameNode * frameNode,BlendMode blendMode)3655 void ViewAbstract::SetBlendMode(FrameNode* frameNode, BlendMode blendMode)
3656 {
3657 ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendMode, blendMode, frameNode);
3658 }
3659
SetBlendApplyType(FrameNode * frameNode,BlendApplyType blendApplyType)3660 void ViewAbstract::SetBlendApplyType(FrameNode* frameNode, BlendApplyType blendApplyType)
3661 {
3662 ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType, frameNode);
3663 }
3664
SetMonopolizeEvents(FrameNode * frameNode,bool monopolizeEvents)3665 void ViewAbstract::SetMonopolizeEvents(FrameNode* frameNode, bool monopolizeEvents)
3666 {
3667 CHECK_NULL_VOID(frameNode);
3668 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3669 CHECK_NULL_VOID(gestureHub);
3670 gestureHub->SetMonopolizeEvents(monopolizeEvents);
3671 }
3672
SetDraggable(FrameNode * frameNode,bool draggable)3673 void ViewAbstract::SetDraggable(FrameNode* frameNode, bool draggable)
3674 {
3675 CHECK_NULL_VOID(frameNode);
3676 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3677 CHECK_NULL_VOID(gestureHub);
3678 if (draggable) {
3679 if (!frameNode->IsDraggable()) {
3680 gestureHub->InitDragDropEvent();
3681 }
3682 } else {
3683 gestureHub->RemoveDragEvent();
3684 }
3685 frameNode->SetDraggable(draggable);
3686 }
3687
SetHoverEffect(FrameNode * frameNode,HoverEffectType hoverEffect)3688 void ViewAbstract::SetHoverEffect(FrameNode* frameNode, HoverEffectType hoverEffect)
3689 {
3690 CHECK_NULL_VOID(frameNode);
3691 auto eventHub = frameNode->GetOrCreateInputEventHub();
3692 CHECK_NULL_VOID(eventHub);
3693 eventHub->SetHoverEffect(hoverEffect);
3694 }
3695
SetClickEffectLevel(FrameNode * frameNode,const ClickEffectLevel & level,float scaleValue)3696 void ViewAbstract::SetClickEffectLevel(FrameNode* frameNode, const ClickEffectLevel& level, float scaleValue)
3697 {
3698 ClickEffectInfo clickEffectInfo;
3699 clickEffectInfo.level = level;
3700 clickEffectInfo.scaleNumber = scaleValue;
3701 ACE_UPDATE_NODE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo, frameNode);
3702 }
3703
SetKeyboardShortcut(FrameNode * frameNode,const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)3704 void ViewAbstract::SetKeyboardShortcut(FrameNode* frameNode, const std::string& value,
3705 const std::vector<ModifierKey>& keys, std::function<void()>&& onKeyboardShortcutAction)
3706 {
3707 CHECK_NULL_VOID(frameNode);
3708 auto pipeline = frameNode->GetContext();
3709 CHECK_NULL_VOID(pipeline);
3710 auto eventManager = pipeline->GetEventManager();
3711 CHECK_NULL_VOID(eventManager);
3712 auto eventHub = frameNode->GetEventHub<EventHub>();
3713 CHECK_NULL_VOID(eventHub);
3714 auto frameNodeRef = AceType::Claim<FrameNode>(frameNode);
3715 if (value.empty() || keys.empty()) {
3716 eventHub->ClearSingleKeyboardShortcut();
3717 return;
3718 }
3719 auto key = eventManager->GetKeyboardShortcutKeys(keys);
3720 if ((key == 0 && value.length() == 1) || (key == 0 && !keys.empty() && value.length() > 1)) {
3721 return;
3722 }
3723 if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
3724 return;
3725 }
3726 eventHub->SetKeyboardShortcut(value, key, onKeyboardShortcutAction);
3727 eventManager->AddKeyboardShortcutNode(WeakPtr<NG::FrameNode>(frameNodeRef));
3728 }
3729
SetOnAppear(FrameNode * frameNode,std::function<void ()> && onAppear)3730 void ViewAbstract::SetOnAppear(FrameNode* frameNode, std::function<void()> &&onAppear)
3731 {
3732 CHECK_NULL_VOID(frameNode);
3733 auto eventHub = frameNode->GetEventHub<EventHub>();
3734 CHECK_NULL_VOID(eventHub);
3735 eventHub->SetOnAppear(std::move(onAppear));
3736 }
3737
SetOnDisappear(FrameNode * frameNode,std::function<void ()> && onDisappear)3738 void ViewAbstract::SetOnDisappear(FrameNode* frameNode, std::function<void()> &&onDisappear)
3739 {
3740 CHECK_NULL_VOID(frameNode);
3741 auto eventHub = frameNode->GetEventHub<EventHub>();
3742 CHECK_NULL_VOID(eventHub);
3743 eventHub->SetOnDisappear(std::move(onDisappear));
3744 }
3745
SetOnAttach(FrameNode * frameNode,std::function<void ()> && onAttach)3746 void ViewAbstract::SetOnAttach(FrameNode* frameNode, std::function<void()> &&onAttach)
3747 {
3748 CHECK_NULL_VOID(frameNode);
3749 auto eventHub = frameNode->GetEventHub<EventHub>();
3750 CHECK_NULL_VOID(eventHub);
3751 eventHub->SetOnAttach(std::move(onAttach));
3752 }
3753
SetOnDetach(FrameNode * frameNode,std::function<void ()> && onDetach)3754 void ViewAbstract::SetOnDetach(FrameNode* frameNode, std::function<void()> &&onDetach)
3755 {
3756 CHECK_NULL_VOID(frameNode);
3757 auto eventHub = frameNode->GetEventHub<EventHub>();
3758 CHECK_NULL_VOID(eventHub);
3759 eventHub->SetOnDetach(std::move(onDetach));
3760 }
3761
SetOnAreaChanged(FrameNode * frameNode,std::function<void (const RectF & oldRect,const OffsetF & oldOrigin,const RectF & rect,const OffsetF & origin)> && onAreaChanged)3762 void ViewAbstract::SetOnAreaChanged(FrameNode* frameNode, std::function<void(const RectF &oldRect,
3763 const OffsetF &oldOrigin, const RectF &rect, const OffsetF &origin)> &&onAreaChanged)
3764 {
3765 CHECK_NULL_VOID(frameNode);
3766 auto pipeline = frameNode->GetContext();
3767 CHECK_NULL_VOID(pipeline);
3768 frameNode->SetOnAreaChangeCallback(std::move(onAreaChanged));
3769 pipeline->AddOnAreaChangeNode(frameNode->GetId());
3770 }
3771
SetOnFocus(FrameNode * frameNode,OnFocusFunc && onFocusCallback)3772 void ViewAbstract::SetOnFocus(FrameNode* frameNode, OnFocusFunc &&onFocusCallback)
3773 {
3774 CHECK_NULL_VOID(frameNode);
3775 auto focusHub = frameNode->GetOrCreateFocusHub();
3776 focusHub->SetOnFocusCallback(std::move(onFocusCallback));
3777 }
3778
SetOnBlur(FrameNode * frameNode,OnBlurFunc && onBlurCallback)3779 void ViewAbstract::SetOnBlur(FrameNode* frameNode, OnBlurFunc &&onBlurCallback)
3780 {
3781 CHECK_NULL_VOID(frameNode);
3782 auto focusHub = frameNode->GetOrCreateFocusHub();
3783 focusHub->SetOnBlurCallback(std::move(onBlurCallback));
3784 }
3785
SetOnClick(FrameNode * frameNode,GestureEventFunc && clickEventFunc,double distanceThreshold)3786 void ViewAbstract::SetOnClick(FrameNode* frameNode, GestureEventFunc&& clickEventFunc, double distanceThreshold)
3787 {
3788 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3789 CHECK_NULL_VOID(gestureHub);
3790 gestureHub->SetUserOnClick(std::move(clickEventFunc), distanceThreshold);
3791
3792 auto focusHub = frameNode->GetFocusHub();
3793 CHECK_NULL_VOID(focusHub);
3794 focusHub->SetFocusable(true, false);
3795 }
3796
SetOnTouch(FrameNode * frameNode,TouchEventFunc && touchEventFunc)3797 void ViewAbstract::SetOnTouch(FrameNode* frameNode, TouchEventFunc &&touchEventFunc)
3798 {
3799 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3800 CHECK_NULL_VOID(gestureHub);
3801 gestureHub->SetTouchEvent(std::move(touchEventFunc));
3802 }
3803
SetOnMouse(FrameNode * frameNode,OnMouseEventFunc && onMouseEventFunc)3804 void ViewAbstract::SetOnMouse(FrameNode* frameNode, OnMouseEventFunc &&onMouseEventFunc)
3805 {
3806 auto eventHub = frameNode->GetOrCreateInputEventHub();
3807 CHECK_NULL_VOID(eventHub);
3808 eventHub->SetMouseEvent(std::move(onMouseEventFunc));
3809 }
3810
SetOnHover(FrameNode * frameNode,OnHoverFunc && onHoverEventFunc)3811 void ViewAbstract::SetOnHover(FrameNode* frameNode, OnHoverFunc &&onHoverEventFunc)
3812 {
3813 auto eventHub = frameNode->GetOrCreateInputEventHub();
3814 CHECK_NULL_VOID(eventHub);
3815 eventHub->SetHoverEvent(std::move(onHoverEventFunc));
3816 }
3817
SetOnKeyEvent(FrameNode * frameNode,OnKeyCallbackFunc && onKeyCallback)3818 void ViewAbstract::SetOnKeyEvent(FrameNode* frameNode, OnKeyCallbackFunc &&onKeyCallback)
3819 {
3820 auto focusHub = frameNode->GetOrCreateFocusHub();
3821 CHECK_NULL_VOID(focusHub);
3822 focusHub->SetOnKeyCallback(std::move(onKeyCallback));
3823 }
3824
GetFocusable(FrameNode * frameNode)3825 bool ViewAbstract::GetFocusable(FrameNode* frameNode)
3826 {
3827 CHECK_NULL_RETURN(frameNode, false);
3828 auto focusHub = frameNode->GetOrCreateFocusHub();
3829 CHECK_NULL_RETURN(focusHub, false);
3830 return focusHub->IsFocusable();
3831 }
3832
GetDefaultFocus(FrameNode * frameNode)3833 bool ViewAbstract::GetDefaultFocus(FrameNode* frameNode)
3834 {
3835 CHECK_NULL_RETURN(frameNode, false);
3836 auto focusHub = frameNode->GetOrCreateFocusHub();
3837 CHECK_NULL_RETURN(focusHub, false);
3838 return focusHub->IsDefaultFocus();
3839 }
3840
GetResponseRegion(FrameNode * frameNode)3841 std::vector<DimensionRect> ViewAbstract::GetResponseRegion(FrameNode* frameNode)
3842 {
3843 std::vector<DimensionRect> defaultRect;
3844 CHECK_NULL_RETURN(frameNode, defaultRect);
3845 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
3846 CHECK_NULL_RETURN(gestureHub, defaultRect);
3847 return gestureHub->GetResponseRegion();
3848 }
3849
GetOverlay(FrameNode * frameNode)3850 NG::OverlayOptions ViewAbstract::GetOverlay(FrameNode* frameNode)
3851 {
3852 NG::OverlayOptions defaultOptions;
3853 const auto& target = frameNode->GetRenderContext();
3854 return target->GetOverlayTextValue(defaultOptions);
3855 }
3856
SetNeedFocus(FrameNode * frameNode,bool value)3857 void ViewAbstract::SetNeedFocus(FrameNode* frameNode, bool value)
3858 {
3859 CHECK_NULL_VOID(frameNode);
3860 auto focusHub = frameNode->GetOrCreateFocusHub();
3861 CHECK_NULL_VOID(focusHub);
3862 auto context = frameNode->GetContext();
3863 CHECK_NULL_VOID(context);
3864 auto instanceId = context->GetInstanceId();
3865 ContainerScope scope(instanceId);
3866 if (value) {
3867 focusHub->RequestFocus();
3868 } else {
3869 focusHub->LostFocusToViewRoot();
3870 }
3871 }
3872
GetNeedFocus(FrameNode * frameNode)3873 bool ViewAbstract::GetNeedFocus(FrameNode* frameNode)
3874 {
3875 CHECK_NULL_RETURN(frameNode, false);
3876 auto focusHub = frameNode->GetOrCreateFocusHub();
3877 CHECK_NULL_RETURN(focusHub, false);
3878 return focusHub->IsCurrentFocus();
3879 }
3880
GetOpacity(FrameNode * frameNode)3881 double ViewAbstract::GetOpacity(FrameNode* frameNode)
3882 {
3883 double opacity = 1.0f;
3884 const auto& target = frameNode->GetRenderContext();
3885 CHECK_NULL_RETURN(target, opacity);
3886 return target->GetOpacityValue(opacity);
3887 }
3888
GetBorderWidth(FrameNode * frameNode)3889 BorderWidthProperty ViewAbstract::GetBorderWidth(FrameNode* frameNode)
3890 {
3891 Dimension defaultDimension(0);
3892 BorderWidthProperty borderWidths = { defaultDimension, defaultDimension, defaultDimension, defaultDimension };
3893 const auto& target = frameNode->GetRenderContext();
3894 CHECK_NULL_RETURN(target, borderWidths);
3895 return target->GetBorderWidthValue(borderWidths);
3896 }
3897
GetLayoutBorderWidth(FrameNode * frameNode)3898 BorderWidthProperty ViewAbstract::GetLayoutBorderWidth(FrameNode* frameNode)
3899 {
3900 Dimension defaultDimen = Dimension(0, DimensionUnit::VP);
3901 BorderWidthProperty borderWidths;
3902 borderWidths.topDimen = std::optional<Dimension>(defaultDimen);
3903 borderWidths.rightDimen = std::optional<Dimension>(defaultDimen);
3904 borderWidths.bottomDimen = std::optional<Dimension>(defaultDimen);
3905 borderWidths.leftDimen = std::optional<Dimension>(defaultDimen);
3906 const auto& layoutProperty = frameNode->GetLayoutProperty();
3907 CHECK_NULL_RETURN(layoutProperty, borderWidths);
3908 const auto& property = layoutProperty->GetBorderWidthProperty();
3909 CHECK_NULL_RETURN(property, borderWidths);
3910 borderWidths.topDimen = std::optional<Dimension>(property->topDimen);
3911 borderWidths.rightDimen = std::optional<Dimension>(property->rightDimen);
3912 borderWidths.bottomDimen = std::optional<Dimension>(property->bottomDimen);
3913 borderWidths.leftDimen = std::optional<Dimension>(property->leftDimen);
3914 return borderWidths;
3915 }
3916
GetBorderRadius(FrameNode * frameNode)3917 BorderRadiusProperty ViewAbstract::GetBorderRadius(FrameNode* frameNode)
3918 {
3919 Dimension defaultDimension(0);
3920 BorderRadiusProperty borderRadius = { defaultDimension, defaultDimension, defaultDimension, defaultDimension };
3921 const auto& target = frameNode->GetRenderContext();
3922 CHECK_NULL_RETURN(target, borderRadius);
3923 return target->GetBorderRadiusValue(borderRadius);
3924 }
3925
GetBorderColor(FrameNode * frameNode)3926 BorderColorProperty ViewAbstract::GetBorderColor(FrameNode* frameNode)
3927 {
3928 Color defaultColor(0xff000000);
3929 BorderColorProperty borderColors = { defaultColor, defaultColor, defaultColor, defaultColor };
3930 const auto& target = frameNode->GetRenderContext();
3931 CHECK_NULL_RETURN(target, borderColors);
3932 return target->GetBorderColorValue(borderColors);
3933 }
3934
GetBorderStyle(FrameNode * frameNode)3935 BorderStyleProperty ViewAbstract::GetBorderStyle(FrameNode* frameNode)
3936 {
3937 BorderStyle defaultStyle = BorderStyle::SOLID;
3938 BorderStyleProperty borderStyles = { defaultStyle, defaultStyle, defaultStyle, defaultStyle };
3939 const auto& target = frameNode->GetRenderContext();
3940 CHECK_NULL_RETURN(target, borderStyles);
3941 return target->GetBorderStyleValue(borderStyles);
3942 }
3943
GetZIndex(FrameNode * frameNode)3944 int ViewAbstract::GetZIndex(FrameNode* frameNode)
3945 {
3946 int zindex = 0;
3947 const auto& target = frameNode->GetRenderContext();
3948 CHECK_NULL_RETURN(target, zindex);
3949 return target->GetZIndexValue(zindex);
3950 }
3951
GetVisibility(FrameNode * frameNode)3952 VisibleType ViewAbstract::GetVisibility(FrameNode* frameNode)
3953 {
3954 VisibleType visibility = VisibleType::VISIBLE;
3955 ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE(LayoutProperty, Visibility, visibility, frameNode, visibility);
3956 return visibility;
3957 }
3958
GetClip(FrameNode * frameNode)3959 bool ViewAbstract::GetClip(FrameNode* frameNode)
3960 {
3961 bool value = false;
3962 const auto& target = frameNode->GetRenderContext();
3963 CHECK_NULL_RETURN(target, value);
3964 return target->GetClipEdgeValue(value);
3965 }
3966
GetClipShape(FrameNode * frameNode)3967 RefPtr<BasicShape> ViewAbstract::GetClipShape(FrameNode* frameNode)
3968 {
3969 RefPtr<BasicShape> value = AceType::MakeRefPtr<BasicShape>();
3970 const auto& target = frameNode->GetRenderContext();
3971 CHECK_NULL_RETURN(target, value);
3972 return target->GetClipShapeValue(value);
3973 }
3974
GetTransform(FrameNode * frameNode)3975 Matrix4 ViewAbstract::GetTransform(FrameNode* frameNode)
3976 {
3977 Matrix4 value;
3978 const auto& target = frameNode->GetRenderContext();
3979 CHECK_NULL_RETURN(target, value);
3980 return target->GetTransformMatrixValue(value);
3981 }
3982
GetHitTestBehavior(FrameNode * frameNode)3983 HitTestMode ViewAbstract::GetHitTestBehavior(FrameNode* frameNode)
3984 {
3985 auto gestureHub = frameNode->GetHitTestMode();
3986 return gestureHub;
3987 }
3988
GetPosition(FrameNode * frameNode)3989 OffsetT<Dimension> ViewAbstract::GetPosition(FrameNode* frameNode)
3990 {
3991 Dimension PositionX(0, DimensionUnit::VP);
3992 Dimension PositionY(0, DimensionUnit::VP);
3993 OffsetT<Dimension> position(PositionX, PositionY);
3994 const auto& target = frameNode->GetRenderContext();
3995 CHECK_NULL_RETURN(target, position);
3996 return target->GetPositionValue(position);
3997 }
3998
GetShadow(FrameNode * frameNode)3999 std::optional<Shadow> ViewAbstract::GetShadow(FrameNode* frameNode)
4000 {
4001 Shadow value;
4002 const auto& target = frameNode->GetRenderContext();
4003 CHECK_NULL_RETURN(target, value);
4004 return target->GetBackShadowValue(value);
4005 }
4006
GetSweepGradient(FrameNode * frameNode)4007 NG::Gradient ViewAbstract::GetSweepGradient(FrameNode* frameNode)
4008 {
4009 Gradient value;
4010 value.CreateGradientWithType(NG::GradientType::SWEEP);
4011 const auto& target = frameNode->GetRenderContext();
4012 CHECK_NULL_RETURN(target, value);
4013 return target->GetSweepGradientValue(value);
4014 }
4015
GetRadialGradient(FrameNode * frameNode)4016 NG::Gradient ViewAbstract::GetRadialGradient(FrameNode* frameNode)
4017 {
4018 Gradient value;
4019 value.CreateGradientWithType(NG::GradientType::RADIAL);
4020 const auto& target = frameNode->GetRenderContext();
4021 CHECK_NULL_RETURN(target, value);
4022 return target->GetRadialGradientValue(value);
4023 }
4024
GetMask(FrameNode * frameNode)4025 RefPtr<BasicShape> ViewAbstract::GetMask(FrameNode* frameNode)
4026 {
4027 RefPtr<BasicShape> value = AceType::MakeRefPtr<BasicShape>();
4028 const auto& target = frameNode->GetRenderContext();
4029 CHECK_NULL_RETURN(target, nullptr);
4030 if (target->HasClipMask()) {
4031 return target->GetClipMaskValue(value);
4032 }
4033 return nullptr;
4034 }
4035
GetMaskProgress(FrameNode * frameNode)4036 RefPtr<ProgressMaskProperty> ViewAbstract::GetMaskProgress(FrameNode* frameNode)
4037 {
4038 RefPtr<ProgressMaskProperty> value = AceType::MakeRefPtr<ProgressMaskProperty>();
4039 const auto& target = frameNode->GetRenderContext();
4040 CHECK_NULL_RETURN(target, nullptr);
4041 if (target->HasProgressMask()) {
4042 return target->GetProgressMaskValue(value);
4043 }
4044 return nullptr;
4045 }
4046
GetBlendMode(FrameNode * frameNode)4047 BlendMode ViewAbstract::GetBlendMode(FrameNode* frameNode)
4048 {
4049 BlendMode value = BlendMode::NONE;
4050 auto target = frameNode->GetRenderContext();
4051 CHECK_NULL_RETURN(target, value);
4052 return target->GetBackBlendModeValue(value);
4053 }
4054
GetDirection(FrameNode * frameNode)4055 TextDirection ViewAbstract::GetDirection(FrameNode* frameNode)
4056 {
4057 TextDirection direction = TextDirection::AUTO;
4058 auto target = frameNode->GetLayoutProperty<LayoutProperty>();
4059 direction = target->GetLayoutDirection();
4060 return direction;
4061 }
4062
GetAlignSelf(FrameNode * frameNode)4063 FlexAlign ViewAbstract::GetAlignSelf(FrameNode* frameNode)
4064 {
4065 FlexAlign value = FlexAlign::AUTO;
4066 const auto& flexItemProperty = frameNode->GetLayoutProperty()->GetFlexItemProperty();
4067 CHECK_NULL_RETURN(flexItemProperty, value);
4068 auto getValue = flexItemProperty->GetAlignSelf();
4069 if (getValue.has_value()) {
4070 return getValue.value();
4071 }
4072 return value;
4073 }
4074
GetFlexGrow(FrameNode * frameNode)4075 float ViewAbstract::GetFlexGrow(FrameNode* frameNode)
4076 {
4077 float value = 0.0f;
4078 const auto& layoutProperty = frameNode->GetLayoutProperty();
4079 CHECK_NULL_RETURN(layoutProperty, value);
4080 const auto& property = layoutProperty->GetFlexItemProperty();
4081 CHECK_NULL_RETURN(property, value);
4082 auto getValue = property->GetFlexGrow();
4083 if (getValue.has_value()) {
4084 return getValue.value();
4085 }
4086 return value;
4087 }
4088
GetFlexShrink(FrameNode * frameNode)4089 float ViewAbstract::GetFlexShrink(FrameNode* frameNode)
4090 {
4091 float value = 0.0f;
4092 const auto& layoutProperty = frameNode->GetLayoutProperty();
4093 CHECK_NULL_RETURN(layoutProperty, value);
4094 const auto& property = layoutProperty->GetFlexItemProperty();
4095 CHECK_NULL_RETURN(property, value);
4096 auto getValue = property->GetFlexShrink();
4097 if (getValue.has_value()) {
4098 return getValue.value();
4099 }
4100 return value;
4101 }
4102
GetFlexBasis(FrameNode * frameNode)4103 Dimension ViewAbstract::GetFlexBasis(FrameNode* frameNode)
4104 {
4105 Dimension value;
4106 const auto& layoutProperty = frameNode->GetLayoutProperty();
4107 CHECK_NULL_RETURN(layoutProperty, value);
4108 const auto& property = layoutProperty->GetFlexItemProperty();
4109 CHECK_NULL_RETURN(property, value);
4110 auto getValue = property->GetFlexBasis();
4111 if (getValue.has_value()) {
4112 return getValue.value();
4113 }
4114 return value;
4115 }
4116
GetMinWidth(FrameNode * frameNode)4117 Dimension ViewAbstract::GetMinWidth(FrameNode* frameNode)
4118 {
4119 Dimension value = Dimension(0.0f);
4120 const auto& layoutProperty = frameNode->GetLayoutProperty();
4121 CHECK_NULL_RETURN(layoutProperty, value);
4122 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4123 CHECK_NULL_RETURN(property, value);
4124 auto size = property->minSize;
4125 if (size.has_value()) {
4126 auto width = size->Width();
4127 if (width.has_value()) {
4128 return width.value().GetDimension();
4129 }
4130 }
4131 return value;
4132 }
4133
GetMaxWidth(FrameNode * frameNode)4134 Dimension ViewAbstract::GetMaxWidth(FrameNode* frameNode)
4135 {
4136 Dimension value = Dimension(0.0f);
4137 const auto& layoutProperty = frameNode->GetLayoutProperty();
4138 CHECK_NULL_RETURN(layoutProperty, value);
4139 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4140 CHECK_NULL_RETURN(property, value);
4141 auto size = property->maxSize;
4142 if (size.has_value()) {
4143 auto width = size->Width();
4144 if (width.has_value()) {
4145 return width.value().GetDimension();
4146 }
4147 }
4148 return value;
4149 }
4150
GetMinHeight(FrameNode * frameNode)4151 Dimension ViewAbstract::GetMinHeight(FrameNode* frameNode)
4152 {
4153 Dimension value = Dimension(0.0f);
4154 const auto& layoutProperty = frameNode->GetLayoutProperty();
4155 CHECK_NULL_RETURN(layoutProperty, value);
4156 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4157 CHECK_NULL_RETURN(property, value);
4158 auto size = property->minSize;
4159 if (size.has_value()) {
4160 auto height = size->Height();
4161 if (height.has_value()) {
4162 return height.value().GetDimension();
4163 }
4164 }
4165 return value;
4166 }
4167
GetMaxHeight(FrameNode * frameNode)4168 Dimension ViewAbstract::GetMaxHeight(FrameNode* frameNode)
4169 {
4170 Dimension value = Dimension(0.0f);
4171 const auto& layoutProperty = frameNode->GetLayoutProperty();
4172 CHECK_NULL_RETURN(layoutProperty, value);
4173 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4174 CHECK_NULL_RETURN(property, value);
4175 auto size = property->maxSize;
4176 if (size.has_value()) {
4177 auto height = size->Height();
4178 if (height.has_value()) {
4179 return height.value().GetDimension();
4180 }
4181 }
4182 return value;
4183 }
4184
GetGrayScale(FrameNode * frameNode)4185 Dimension ViewAbstract::GetGrayScale(FrameNode* frameNode)
4186 {
4187 Dimension value;
4188 auto target = frameNode->GetRenderContext();
4189 CHECK_NULL_RETURN(target, value);
4190 return target->GetFrontGrayScaleValue(value);
4191 }
4192
GetInvert(FrameNode * frameNode)4193 InvertVariant ViewAbstract::GetInvert(FrameNode* frameNode)
4194 {
4195 InvertVariant value = 0.0f;
4196 auto target = frameNode->GetRenderContext();
4197 CHECK_NULL_RETURN(target, value);
4198 return target->GetFrontInvertValue(value);
4199 }
4200
GetSepia(FrameNode * frameNode)4201 Dimension ViewAbstract::GetSepia(FrameNode* frameNode)
4202 {
4203 Dimension value;
4204 auto target = frameNode->GetRenderContext();
4205 CHECK_NULL_RETURN(target, value);
4206 return target->GetFrontSepiaValue(value);
4207 }
4208
GetContrast(FrameNode * frameNode)4209 Dimension ViewAbstract::GetContrast(FrameNode* frameNode)
4210 {
4211 Dimension value(1.0f);
4212 auto target = frameNode->GetRenderContext();
4213 CHECK_NULL_RETURN(target, value);
4214 return target->GetFrontContrastValue(value);
4215 }
4216
GetForegroundColor(FrameNode * frameNode)4217 Color ViewAbstract::GetForegroundColor(FrameNode* frameNode)
4218 {
4219 Color value;
4220 auto target = frameNode->GetRenderContext();
4221 CHECK_NULL_RETURN(target, value);
4222 return target->GetForegroundColorValue(value);
4223 }
4224
GetScale(FrameNode * frameNode)4225 NG::VectorF ViewAbstract::GetScale(FrameNode* frameNode)
4226 {
4227 NG::VectorF defaultVector = { 1.0f, 1.0f };
4228 CHECK_NULL_RETURN(frameNode, defaultVector);
4229 auto renderContext = frameNode->GetRenderContext();
4230 CHECK_NULL_RETURN(renderContext, defaultVector);
4231 return renderContext->GetTransformScale().value_or(defaultVector);
4232 }
4233
GetRotate(FrameNode * frameNode)4234 NG::Vector5F ViewAbstract::GetRotate(FrameNode* frameNode)
4235 {
4236 NG::Vector5F defaultVector = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
4237 CHECK_NULL_RETURN(frameNode, defaultVector);
4238 auto renderContext = frameNode->GetRenderContext();
4239 CHECK_NULL_RETURN(renderContext, defaultVector);
4240 return renderContext->GetTransformRotate().value_or(defaultVector);
4241 }
4242
GetBrightness(FrameNode * frameNode)4243 Dimension ViewAbstract::GetBrightness(FrameNode* frameNode)
4244 {
4245 Dimension defaultBrightness(1.0);
4246 CHECK_NULL_RETURN(frameNode, defaultBrightness);
4247 auto renderContext = frameNode->GetRenderContext();
4248 CHECK_NULL_RETURN(renderContext, defaultBrightness);
4249 return renderContext->GetFrontBrightness().value_or(defaultBrightness);
4250 }
4251
GetSaturate(FrameNode * frameNode)4252 Dimension ViewAbstract::GetSaturate(FrameNode* frameNode)
4253 {
4254 Dimension defaultSaturate(1.0);
4255 CHECK_NULL_RETURN(frameNode, defaultSaturate);
4256 auto renderContext = frameNode->GetRenderContext();
4257 CHECK_NULL_RETURN(renderContext, defaultSaturate);
4258 return renderContext->GetFrontSaturate().value_or(defaultSaturate);
4259 }
4260
GetBackgroundImagePosition(FrameNode * frameNode)4261 BackgroundImagePosition ViewAbstract::GetBackgroundImagePosition(FrameNode* frameNode)
4262 {
4263 BackgroundImagePosition defaultImagePosition;
4264 CHECK_NULL_RETURN(frameNode, defaultImagePosition);
4265 auto renderContext = frameNode->GetRenderContext();
4266 CHECK_NULL_RETURN(renderContext, defaultImagePosition);
4267 return renderContext->GetBackgroundImagePosition().value_or(defaultImagePosition);
4268 }
4269
GetFrontBlur(FrameNode * frameNode)4270 Dimension ViewAbstract::GetFrontBlur(FrameNode* frameNode)
4271 {
4272 Dimension value;
4273 auto target = frameNode->GetRenderContext();
4274 CHECK_NULL_RETURN(target, value);
4275 auto& property = target->GetForeground();
4276 CHECK_NULL_RETURN(property, value);
4277 auto getValue = property->propBlurRadius;
4278 if (getValue.has_value()) {
4279 return getValue.value();
4280 }
4281 return value;
4282 }
4283
GetLinearGradient(FrameNode * frameNode)4284 NG::Gradient ViewAbstract::GetLinearGradient(FrameNode *frameNode)
4285 {
4286 NG::Gradient value;
4287 value.CreateGradientWithType(NG::GradientType::LINEAR);
4288 auto target = frameNode->GetRenderContext();
4289 CHECK_NULL_RETURN(target, value);
4290 return target->GetLinearGradientValue(value);
4291 }
4292
GetAlign(FrameNode * frameNode)4293 Alignment ViewAbstract::GetAlign(FrameNode *frameNode)
4294 {
4295 Alignment value = Alignment::CENTER;
4296 const auto& layoutProperty = frameNode->GetLayoutProperty();
4297 CHECK_NULL_RETURN(layoutProperty, value);
4298 const auto& property = layoutProperty->GetPositionProperty();
4299 CHECK_NULL_RETURN(property, value);
4300 auto getValue = property->GetAlignment();
4301 if (getValue.has_value()) {
4302 return getValue.value();
4303 }
4304 return value;
4305 }
4306
GetWidth(FrameNode * frameNode)4307 Dimension ViewAbstract::GetWidth(FrameNode* frameNode)
4308 {
4309 Dimension value = Dimension(-1.0f);
4310 const auto& layoutProperty = frameNode->GetLayoutProperty();
4311 CHECK_NULL_RETURN(layoutProperty, value);
4312 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4313 CHECK_NULL_RETURN(property, value);
4314 auto size = property->selfIdealSize;
4315 if (size.has_value()) {
4316 auto width = size->Width();
4317 if (width.has_value()) {
4318 return width.value().GetDimension();
4319 }
4320 }
4321 return value;
4322 }
4323
GetHeight(FrameNode * frameNode)4324 Dimension ViewAbstract::GetHeight(FrameNode* frameNode)
4325 {
4326 Dimension value = Dimension(-1.0f);
4327 const auto& layoutProperty = frameNode->GetLayoutProperty();
4328 CHECK_NULL_RETURN(layoutProperty, value);
4329 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4330 CHECK_NULL_RETURN(property, value);
4331 auto size = property->selfIdealSize;
4332 if (size.has_value()) {
4333 auto height = size->Height();
4334 if (height.has_value()) {
4335 return height.value().GetDimension();
4336 }
4337 }
4338 return value;
4339 }
4340
GetBackgroundColor(FrameNode * frameNode)4341 Color ViewAbstract::GetBackgroundColor(FrameNode* frameNode)
4342 {
4343 Color value;
4344 auto target = frameNode->GetRenderContext();
4345 CHECK_NULL_RETURN(target, value);
4346 return target->GetBackgroundColorValue(value);
4347 }
4348
GetBackgroundImageSrc(FrameNode * frameNode)4349 std::string ViewAbstract::GetBackgroundImageSrc(FrameNode* frameNode)
4350 {
4351 auto target = frameNode->GetRenderContext();
4352 CHECK_NULL_RETURN(target, "");
4353 if (target->GetBackgroundImage().has_value()) {
4354 return target->GetBackgroundImage()->GetSrc();
4355 }
4356 return "";
4357 }
4358
GetBackgroundImageRepeat(FrameNode * frameNode)4359 ImageRepeat ViewAbstract::GetBackgroundImageRepeat(FrameNode* frameNode)
4360 {
4361 ImageRepeat value = ImageRepeat::NO_REPEAT;
4362 auto target = frameNode->GetRenderContext();
4363 CHECK_NULL_RETURN(target, value);
4364 if (target->GetBackgroundImageRepeat().has_value()) {
4365 return target->GetBackgroundImageRepeat().value();
4366 }
4367 return value;
4368 }
4369
GetPadding(FrameNode * frameNode)4370 PaddingProperty ViewAbstract::GetPadding(FrameNode* frameNode)
4371 {
4372 CalcLength defaultDimen = CalcLength(0, DimensionUnit::VP);
4373 PaddingProperty paddings;
4374 paddings.top = std::optional<CalcLength>(defaultDimen);
4375 paddings.right = std::optional<CalcLength>(defaultDimen);
4376 paddings.bottom = std::optional<CalcLength>(defaultDimen);
4377 paddings.left = std::optional<CalcLength>(defaultDimen);
4378 const auto& layoutProperty = frameNode->GetLayoutProperty();
4379 CHECK_NULL_RETURN(layoutProperty, paddings);
4380 const auto& property = layoutProperty->GetPaddingProperty();
4381 CHECK_NULL_RETURN(property, paddings);
4382 paddings.top = std::optional<CalcLength>(property->top);
4383 paddings.right = std::optional<CalcLength>(property->right);
4384 paddings.bottom = std::optional<CalcLength>(property->bottom);
4385 paddings.left = std::optional<CalcLength>(property->left);
4386 return paddings;
4387 }
4388
GetConfigSize(FrameNode * frameNode)4389 std::optional<CalcSize> ViewAbstract::GetConfigSize(FrameNode* frameNode)
4390 {
4391 auto value = std::optional<CalcSize>();
4392 const auto& layoutProperty = frameNode->GetLayoutProperty();
4393 CHECK_NULL_RETURN(layoutProperty, value);
4394 const auto& property = layoutProperty->GetCalcLayoutConstraint();
4395 CHECK_NULL_RETURN(property, value);
4396 auto size = property->selfIdealSize;
4397 if (size.has_value()) {
4398 value = size;
4399 }
4400 return value;
4401 }
4402
GetKey(FrameNode * frameNode)4403 std::string ViewAbstract::GetKey(FrameNode* frameNode)
4404 {
4405 std::string value;
4406 CHECK_NULL_RETURN(frameNode, value);
4407 return value = frameNode->GetInspectorIdValue();
4408 }
4409
GetEnabled(FrameNode * frameNode)4410 bool ViewAbstract::GetEnabled(FrameNode* frameNode)
4411 {
4412 auto eventHub = frameNode->GetEventHub<EventHub>();
4413 CHECK_NULL_RETURN(eventHub, false);
4414 return eventHub->IsEnabled();
4415 }
4416
GetMargin(FrameNode * frameNode)4417 MarginProperty ViewAbstract::GetMargin(FrameNode* frameNode)
4418 {
4419 CalcLength defaultDimen = CalcLength(0, DimensionUnit::VP);
4420 MarginProperty margins;
4421 margins.top = std::optional<CalcLength>(defaultDimen);
4422 margins.right = std::optional<CalcLength>(defaultDimen);
4423 margins.bottom = std::optional<CalcLength>(defaultDimen);
4424 margins.left = std::optional<CalcLength>(defaultDimen);
4425 const auto& layoutProperty = frameNode->GetLayoutProperty();
4426 CHECK_NULL_RETURN(layoutProperty, margins);
4427 const auto& property = layoutProperty->GetMarginProperty();
4428 CHECK_NULL_RETURN(property, margins);
4429 margins.top = std::optional<CalcLength>(property->top);
4430 margins.right = std::optional<CalcLength>(property->right);
4431 margins.bottom = std::optional<CalcLength>(property->bottom);
4432 margins.left = std::optional<CalcLength>(property->left);
4433 return margins;
4434 }
4435
GetTranslate(FrameNode * frameNode)4436 TranslateOptions ViewAbstract::GetTranslate(FrameNode* frameNode)
4437 {
4438 TranslateOptions value(0.0f, 0.0f, 0.0f);
4439 auto target = frameNode->GetRenderContext();
4440 CHECK_NULL_RETURN(target, value);
4441 return target->GetTransformTranslateValue(value);
4442 }
4443
GetAspectRatio(FrameNode * frameNode)4444 float ViewAbstract::GetAspectRatio(FrameNode* frameNode)
4445 {
4446 float aspectRatio = 1.0f;
4447 const auto& layoutProperty = frameNode->GetLayoutProperty();
4448 CHECK_NULL_RETURN(layoutProperty, aspectRatio);
4449 aspectRatio = layoutProperty->GetAspectRatio();
4450 return aspectRatio;
4451 }
4452
SetJSFrameNodeOnClick(FrameNode * frameNode,GestureEventFunc && clickEventFunc)4453 void ViewAbstract::SetJSFrameNodeOnClick(FrameNode* frameNode, GestureEventFunc&& clickEventFunc)
4454 {
4455 CHECK_NULL_VOID(frameNode);
4456 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4457 CHECK_NULL_VOID(gestureHub);
4458 gestureHub->SetJSFrameNodeOnClick(std::move(clickEventFunc));
4459 }
4460
ClearJSFrameNodeOnClick(FrameNode * frameNode)4461 void ViewAbstract::ClearJSFrameNodeOnClick(FrameNode* frameNode)
4462 {
4463 CHECK_NULL_VOID(frameNode);
4464 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4465 CHECK_NULL_VOID(gestureHub);
4466 gestureHub->ClearJSFrameNodeOnClick();
4467 }
4468
SetJSFrameNodeOnTouch(FrameNode * frameNode,TouchEventFunc && touchEventFunc)4469 void ViewAbstract::SetJSFrameNodeOnTouch(FrameNode* frameNode, TouchEventFunc&& touchEventFunc)
4470 {
4471 CHECK_NULL_VOID(frameNode);
4472 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4473 CHECK_NULL_VOID(gestureHub);
4474 gestureHub->SetJSFrameNodeOnTouchEvent(std::move(touchEventFunc));
4475 }
4476
ClearJSFrameNodeOnTouch(FrameNode * frameNode)4477 void ViewAbstract::ClearJSFrameNodeOnTouch(FrameNode* frameNode)
4478 {
4479 CHECK_NULL_VOID(frameNode);
4480 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4481 CHECK_NULL_VOID(gestureHub);
4482 gestureHub->ClearJSFrameNodeOnTouch();
4483 }
4484
SetJSFrameNodeOnAppear(FrameNode * frameNode,std::function<void ()> && onAppear)4485 void ViewAbstract::SetJSFrameNodeOnAppear(FrameNode* frameNode, std::function<void()>&& onAppear)
4486 {
4487 CHECK_NULL_VOID(frameNode);
4488 auto eventHub = frameNode->GetEventHub<NG::EventHub>();
4489 CHECK_NULL_VOID(eventHub);
4490 eventHub->SetJSFrameNodeOnAppear(std::move(onAppear));
4491 }
4492
ClearJSFrameNodeOnAppear(FrameNode * frameNode)4493 void ViewAbstract::ClearJSFrameNodeOnAppear(FrameNode* frameNode)
4494 {
4495 CHECK_NULL_VOID(frameNode);
4496 auto eventHub = frameNode->GetEventHub<NG::EventHub>();
4497 CHECK_NULL_VOID(eventHub);
4498 eventHub->ClearJSFrameNodeOnAppear();
4499 }
4500
SetJSFrameNodeOnDisappear(FrameNode * frameNode,std::function<void ()> && onDisappear)4501 void ViewAbstract::SetJSFrameNodeOnDisappear(FrameNode* frameNode, std::function<void()>&& onDisappear)
4502 {
4503 CHECK_NULL_VOID(frameNode);
4504 auto eventHub = frameNode->GetEventHub<NG::EventHub>();
4505 CHECK_NULL_VOID(eventHub);
4506 eventHub->SetJSFrameNodeOnDisappear(std::move(onDisappear));
4507 }
4508
ClearJSFrameNodeOnDisappear(FrameNode * frameNode)4509 void ViewAbstract::ClearJSFrameNodeOnDisappear(FrameNode* frameNode)
4510 {
4511 CHECK_NULL_VOID(frameNode);
4512 auto eventHub = frameNode->GetEventHub<NG::EventHub>();
4513 CHECK_NULL_VOID(eventHub);
4514 eventHub->ClearJSFrameNodeOnDisappear();
4515 }
4516
SetJSFrameNodeOnKeyCallback(FrameNode * frameNode,OnKeyCallbackFunc && onKeyCallback)4517 void ViewAbstract::SetJSFrameNodeOnKeyCallback(FrameNode* frameNode, OnKeyCallbackFunc&& onKeyCallback)
4518 {
4519 CHECK_NULL_VOID(frameNode);
4520 auto focusHub = frameNode->GetOrCreateFocusHub();
4521 CHECK_NULL_VOID(focusHub);
4522 focusHub->SetJSFrameNodeOnKeyCallback(std::move(onKeyCallback));
4523 }
4524
ClearJSFrameNodeOnKeyCallback(FrameNode * frameNode)4525 void ViewAbstract::ClearJSFrameNodeOnKeyCallback(FrameNode* frameNode)
4526 {
4527 CHECK_NULL_VOID(frameNode);
4528 auto focusHub = frameNode->GetOrCreateFocusHub();
4529 CHECK_NULL_VOID(focusHub);
4530 focusHub->ClearJSFrameNodeOnKeyCallback();
4531 }
4532
SetJSFrameNodeOnFocusCallback(FrameNode * frameNode,OnFocusFunc && onFocusCallback)4533 void ViewAbstract::SetJSFrameNodeOnFocusCallback(FrameNode* frameNode, OnFocusFunc&& onFocusCallback)
4534 {
4535 CHECK_NULL_VOID(frameNode);
4536 auto focusHub = frameNode->GetOrCreateFocusHub();
4537 CHECK_NULL_VOID(focusHub);
4538 focusHub->SetJSFrameNodeOnFocusCallback(std::move(onFocusCallback));
4539 }
4540
ClearJSFrameNodeOnFocusCallback(FrameNode * frameNode)4541 void ViewAbstract::ClearJSFrameNodeOnFocusCallback(FrameNode* frameNode)
4542 {
4543 CHECK_NULL_VOID(frameNode);
4544 auto focusHub = frameNode->GetOrCreateFocusHub();
4545 CHECK_NULL_VOID(focusHub);
4546 focusHub->ClearJSFrameNodeOnFocusCallback();
4547 }
4548
SetJSFrameNodeOnBlurCallback(FrameNode * frameNode,OnBlurFunc && onBlurCallback)4549 void ViewAbstract::SetJSFrameNodeOnBlurCallback(FrameNode* frameNode, OnBlurFunc&& onBlurCallback)
4550 {
4551 CHECK_NULL_VOID(frameNode);
4552 auto focusHub = frameNode->GetOrCreateFocusHub();
4553 CHECK_NULL_VOID(focusHub);
4554 focusHub->SetJSFrameNodeOnBlurCallback(std::move(onBlurCallback));
4555 }
4556
ClearJSFrameNodeOnBlurCallback(FrameNode * frameNode)4557 void ViewAbstract::ClearJSFrameNodeOnBlurCallback(FrameNode* frameNode)
4558 {
4559 CHECK_NULL_VOID(frameNode);
4560 auto focusHub = frameNode->GetOrCreateFocusHub();
4561 CHECK_NULL_VOID(focusHub);
4562 focusHub->ClearJSFrameNodeOnBlurCallback();
4563 }
4564
SetJSFrameNodeOnHover(FrameNode * frameNode,OnHoverFunc && onHoverEventFunc)4565 void ViewAbstract::SetJSFrameNodeOnHover(FrameNode* frameNode, OnHoverFunc&& onHoverEventFunc)
4566 {
4567 CHECK_NULL_VOID(frameNode);
4568 auto eventHub = frameNode->GetOrCreateInputEventHub();
4569 CHECK_NULL_VOID(eventHub);
4570 eventHub->SetJSFrameNodeOnHoverEvent(std::move(onHoverEventFunc));
4571 }
4572
ClearJSFrameNodeOnHover(FrameNode * frameNode)4573 void ViewAbstract::ClearJSFrameNodeOnHover(FrameNode* frameNode)
4574 {
4575 CHECK_NULL_VOID(frameNode);
4576 auto eventHub = frameNode->GetOrCreateInputEventHub();
4577 CHECK_NULL_VOID(eventHub);
4578 eventHub->ClearJSFrameNodeOnHover();
4579 }
4580
SetJSFrameNodeOnMouse(FrameNode * frameNode,OnMouseEventFunc && onMouseEventFunc)4581 void ViewAbstract::SetJSFrameNodeOnMouse(FrameNode* frameNode, OnMouseEventFunc&& onMouseEventFunc)
4582 {
4583 CHECK_NULL_VOID(frameNode);
4584 auto eventHub = frameNode->GetOrCreateInputEventHub();
4585 CHECK_NULL_VOID(eventHub);
4586 eventHub->SetJSFrameNodeOnMouseEvent(std::move(onMouseEventFunc));
4587 }
4588
ClearJSFrameNodeOnMouse(FrameNode * frameNode)4589 void ViewAbstract::ClearJSFrameNodeOnMouse(FrameNode* frameNode)
4590 {
4591 CHECK_NULL_VOID(frameNode);
4592 auto eventHub = frameNode->GetOrCreateInputEventHub();
4593 CHECK_NULL_VOID(eventHub);
4594 eventHub->ClearJSFrameNodeOnMouse();
4595 }
4596
GetBlendApplyType(FrameNode * frameNode)4597 BlendApplyType ViewAbstract::GetBlendApplyType(FrameNode* frameNode)
4598 {
4599 BlendApplyType value = BlendApplyType::FAST;
4600 const auto& target = frameNode->GetRenderContext();
4601 CHECK_NULL_RETURN(target, value);
4602 return target->GetBackBlendApplyTypeValue(value);
4603 }
4604
SetJSFrameNodeOnSizeChange(FrameNode * frameNode,std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)4605 void ViewAbstract::SetJSFrameNodeOnSizeChange(
4606 FrameNode* frameNode, std::function<void(const RectF& oldRect, const RectF& rect)>&& onSizeChanged)
4607 {
4608 CHECK_NULL_VOID(frameNode);
4609 frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(onSizeChanged));
4610 }
4611
ClearJSFrameNodeOnSizeChange(FrameNode * frameNode)4612 void ViewAbstract::ClearJSFrameNodeOnSizeChange(FrameNode* frameNode)
4613 {
4614 CHECK_NULL_VOID(frameNode);
4615 auto eventHub = frameNode->GetEventHub<NG::EventHub>();
4616 CHECK_NULL_VOID(eventHub);
4617 eventHub->ClearJSFrameNodeOnSizeChange();
4618 }
4619
SetJSFrameNodeOnVisibleAreaApproximateChange(FrameNode * frameNode,const std::function<void (bool,double)> && jsCallback,const std::vector<double> & ratioList,int32_t interval)4620 void ViewAbstract::SetJSFrameNodeOnVisibleAreaApproximateChange(FrameNode* frameNode,
4621 const std::function<void(bool, double)>&& jsCallback, const std::vector<double>& ratioList,
4622 int32_t interval)
4623 {
4624 CHECK_NULL_VOID(frameNode);
4625 auto pipeline = frameNode->GetContext();
4626 CHECK_NULL_VOID(pipeline);
4627 frameNode->CleanVisibleAreaUserCallback(true);
4628
4629 constexpr uint32_t minInterval = 100; // 100ms
4630 if (interval < 0 || static_cast<uint32_t>(interval) < minInterval) {
4631 interval = minInterval;
4632 }
4633 VisibleCallbackInfo callback;
4634 callback.callback = std::move(jsCallback);
4635 callback.isCurrentVisible = false;
4636 callback.period = static_cast<uint32_t>(interval);
4637 pipeline->AddVisibleAreaChangeNode(frameNode->GetId());
4638 frameNode->SetVisibleAreaUserCallback(ratioList, callback);
4639 }
4640
ClearJSFrameNodeOnVisibleAreaApproximateChange(FrameNode * frameNode)4641 void ViewAbstract::ClearJSFrameNodeOnVisibleAreaApproximateChange(FrameNode* frameNode)
4642 {
4643 CHECK_NULL_VOID(frameNode);
4644 frameNode->CleanVisibleAreaUserCallback(true);
4645 }
4646
SetOnGestureJudgeBegin(FrameNode * frameNode,GestureJudgeFunc && gestureJudgeFunc)4647 void ViewAbstract::SetOnGestureJudgeBegin(FrameNode* frameNode, GestureJudgeFunc&& gestureJudgeFunc)
4648 {
4649 CHECK_NULL_VOID(frameNode);
4650 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4651 CHECK_NULL_VOID(gestureHub);
4652 gestureHub->SetOnGestureJudgeBegin(std::move(gestureJudgeFunc));
4653 }
4654
SetOnSizeChanged(FrameNode * frameNode,std::function<void (const RectF & oldRect,const RectF & rect)> && onSizeChanged)4655 void ViewAbstract::SetOnSizeChanged(
4656 FrameNode* frameNode, std::function<void(const RectF& oldRect, const RectF& rect)>&& onSizeChanged)
4657 {
4658 CHECK_NULL_VOID(frameNode);
4659 frameNode->SetOnSizeChangeCallback(std::move(onSizeChanged));
4660 }
4661
SetOnGestureRecognizerJudgeBegin(FrameNode * frameNode,GestureRecognizerJudgeFunc && gestureRecognizerJudgeFunc)4662 void ViewAbstract::SetOnGestureRecognizerJudgeBegin(
4663 FrameNode* frameNode, GestureRecognizerJudgeFunc&& gestureRecognizerJudgeFunc)
4664 {
4665 CHECK_NULL_VOID(frameNode);
4666 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4667 CHECK_NULL_VOID(gestureHub);
4668 gestureHub->SetOnGestureRecognizerJudgeBegin(std::move(gestureRecognizerJudgeFunc));
4669 }
4670
SetShouldBuiltInRecognizerParallelWith(FrameNode * frameNode,NG::ShouldBuiltInRecognizerParallelWithFunc && shouldBuiltInRecognizerParallelWithFunc)4671 void ViewAbstract::SetShouldBuiltInRecognizerParallelWith(
4672 FrameNode* frameNode, NG::ShouldBuiltInRecognizerParallelWithFunc&& shouldBuiltInRecognizerParallelWithFunc)
4673 {
4674 CHECK_NULL_VOID(frameNode);
4675 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4676 CHECK_NULL_VOID(gestureHub);
4677 gestureHub->SetShouldBuildinRecognizerParallelWithFunc(std::move(shouldBuiltInRecognizerParallelWithFunc));
4678 }
4679
SetFocusBoxStyle(FrameNode * frameNode,const NG::FocusBoxStyle & style)4680 void ViewAbstract::SetFocusBoxStyle(FrameNode* frameNode, const NG::FocusBoxStyle& style)
4681 {
4682 CHECK_NULL_VOID(frameNode);
4683 auto focusHub = frameNode->GetOrCreateFocusHub();
4684 CHECK_NULL_VOID(focusHub);
4685 focusHub->GetFocusBox().SetStyle(style);
4686 }
4687
SetDragEventStrictReportingEnabled(bool dragEventStrictReportingEnabled)4688 void ViewAbstract::SetDragEventStrictReportingEnabled(bool dragEventStrictReportingEnabled)
4689 {
4690 auto pipeline = PipelineContext::GetCurrentContext();
4691 CHECK_NULL_VOID(pipeline);
4692 auto dragDropManager = pipeline->GetDragDropManager();
4693 CHECK_NULL_VOID(dragDropManager);
4694 dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
4695 }
4696
SetDragEventStrictReportingEnabled(int32_t instanceId,bool dragEventStrictReportingEnabled)4697 void ViewAbstract::SetDragEventStrictReportingEnabled(int32_t instanceId, bool dragEventStrictReportingEnabled)
4698 {
4699 auto pipeline = PipelineContext::GetContextByContainerId(instanceId);
4700 CHECK_NULL_VOID(pipeline);
4701 auto dragDropManager = pipeline->GetDragDropManager();
4702 CHECK_NULL_VOID(dragDropManager);
4703 dragDropManager->SetEventStrictReportingEnabled(dragEventStrictReportingEnabled);
4704 }
4705
SetDisallowDropForcedly(bool isDisallowDropForcedly)4706 void ViewAbstract::SetDisallowDropForcedly(bool isDisallowDropForcedly)
4707 {
4708 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
4709 CHECK_NULL_VOID(frameNode);
4710 frameNode->SetDisallowDropForcedly(isDisallowDropForcedly);
4711 }
4712
SetBackgroundImageResizableSlice(const ImageResizableSlice & slice)4713 void ViewAbstract::SetBackgroundImageResizableSlice(const ImageResizableSlice& slice)
4714 {
4715 if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
4716 return;
4717 }
4718 ACE_UPDATE_RENDER_CONTEXT(BackgroundImageResizableSlice, slice);
4719 }
4720
SetBackgroundImageResizableSlice(FrameNode * frameNode,const ImageResizableSlice & slice)4721 void ViewAbstract::SetBackgroundImageResizableSlice(FrameNode* frameNode, const ImageResizableSlice& slice)
4722 {
4723 ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageResizableSlice, slice, frameNode);
4724 }
SetOnTouchIntercept(FrameNode * frameNode,TouchInterceptFunc && touchInterceptFunc)4725 void ViewAbstract::SetOnTouchIntercept(FrameNode* frameNode, TouchInterceptFunc&& touchInterceptFunc)
4726 {
4727 auto gestureHub = frameNode->GetOrCreateGestureEventHub();
4728 CHECK_NULL_VOID(gestureHub);
4729 gestureHub->SetOnTouchIntercept(std::move(touchInterceptFunc));
4730 }
4731
GetLayoutWeight(FrameNode * frameNode)4732 float ViewAbstract::GetLayoutWeight(FrameNode* frameNode)
4733 {
4734 float layoutWeight = 0.0f;
4735 CHECK_NULL_RETURN(frameNode, layoutWeight);
4736 auto layoutProperty = frameNode->GetLayoutProperty();
4737 CHECK_NULL_RETURN(layoutProperty, layoutWeight);
4738 auto& magicItemProperty = layoutProperty->GetMagicItemProperty();
4739 if (magicItemProperty.HasLayoutWeight()) {
4740 return magicItemProperty.GetLayoutWeight().value_or(layoutWeight);
4741 }
4742 return layoutWeight;
4743 }
4744
GetDisplayIndex(FrameNode * frameNode)4745 int32_t ViewAbstract::GetDisplayIndex(FrameNode* frameNode)
4746 {
4747 int32_t defaultDisplayIndex = 0;
4748 CHECK_NULL_RETURN(frameNode, defaultDisplayIndex);
4749 const auto& layoutProperty = frameNode->GetLayoutProperty();
4750 CHECK_NULL_RETURN(layoutProperty, defaultDisplayIndex);
4751 const auto& flexItemProperty = layoutProperty->GetFlexItemProperty();
4752 CHECK_NULL_RETURN(flexItemProperty, defaultDisplayIndex);
4753 return flexItemProperty->GetDisplayIndex().value_or(defaultDisplayIndex);
4754 }
4755
GetOuterBorderWidth(FrameNode * frameNode)4756 NG::BorderWidthProperty ViewAbstract::GetOuterBorderWidth(FrameNode* frameNode)
4757 {
4758 BorderWidthProperty borderWidth;
4759 CHECK_NULL_RETURN(frameNode, borderWidth);
4760 auto context = frameNode->GetRenderContext();
4761 CHECK_NULL_RETURN(context, borderWidth);
4762 auto outBorderWidth = context->GetOuterBorder()->GetOuterBorderWidth();
4763 CHECK_NULL_RETURN(outBorderWidth, borderWidth);
4764 return outBorderWidth.value_or(borderWidth);
4765 }
4766
SetBias(FrameNode * frameNode,const BiasPair & biasPair)4767 void ViewAbstract::SetBias(FrameNode* frameNode, const BiasPair& biasPair)
4768 {
4769 CHECK_NULL_VOID(frameNode);
4770 ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Bias, biasPair, frameNode);
4771 }
4772
GetBias(FrameNode * frameNode)4773 BiasPair ViewAbstract::GetBias(FrameNode* frameNode)
4774 {
4775 BiasPair biasPair(-1.0f, -1.0f);
4776 CHECK_NULL_RETURN(frameNode, biasPair);
4777 auto layoutProperty = frameNode->GetLayoutProperty();
4778 CHECK_NULL_RETURN(layoutProperty, biasPair);
4779 CHECK_NULL_RETURN(layoutProperty->GetFlexItemProperty(), biasPair);
4780 return layoutProperty->GetFlexItemProperty()->GetBias().value_or(biasPair);
4781 }
4782
ResetBias(FrameNode * frameNode)4783 void ViewAbstract::ResetBias(FrameNode* frameNode)
4784 {
4785 CHECK_NULL_VOID(frameNode);
4786 auto layoutProperty = frameNode->GetLayoutProperty();
4787 CHECK_NULL_VOID(layoutProperty);
4788 CHECK_NULL_VOID(layoutProperty->GetFlexItemProperty());
4789 layoutProperty->GetFlexItemProperty()->ResetBias();
4790 }
4791
GetRenderFit(FrameNode * frameNode)4792 RenderFit ViewAbstract::GetRenderFit(FrameNode* frameNode)
4793 {
4794 RenderFit defalutRenderFit = RenderFit::TOP_LEFT;
4795 CHECK_NULL_RETURN(frameNode, defalutRenderFit);
4796 auto renderContext = frameNode->GetRenderContext();
4797 CHECK_NULL_RETURN(renderContext, defalutRenderFit);
4798 return renderContext->GetRenderFit().value_or(defalutRenderFit);
4799 }
4800
GetOuterBorderColor(FrameNode * frameNode)4801 BorderColorProperty ViewAbstract::GetOuterBorderColor(FrameNode* frameNode)
4802 {
4803 Color defaultColor(0xff000000);
4804 BorderColorProperty borderColors = { defaultColor, defaultColor, defaultColor, defaultColor };
4805 CHECK_NULL_RETURN(frameNode, borderColors);
4806 const auto& target = frameNode->GetRenderContext();
4807 CHECK_NULL_RETURN(target, borderColors);
4808 return target->GetOuterBorderColorValue(borderColors);
4809 }
4810
GetRenderGroup(FrameNode * frameNode)4811 bool ViewAbstract::GetRenderGroup(FrameNode* frameNode)
4812 {
4813 CHECK_NULL_RETURN(frameNode, false);
4814 const auto& target = frameNode->GetRenderContext();
4815 CHECK_NULL_RETURN(target, false);
4816 return target->GetRenderGroupValue(false);
4817 }
4818
SetLayoutRect(FrameNode * frameNode,const NG::RectF & rect)4819 void ViewAbstract::SetLayoutRect(FrameNode* frameNode, const NG::RectF& rect)
4820 {
4821 CHECK_NULL_VOID(frameNode);
4822 frameNode->SetIsMeasureBoundary(true);
4823 const auto& layoutProperty = frameNode->GetLayoutProperty();
4824 CHECK_NULL_VOID(layoutProperty);
4825 layoutProperty->SetLayoutRect(rect);
4826 }
4827
ResetLayoutRect(FrameNode * frameNode)4828 void ViewAbstract::ResetLayoutRect(FrameNode* frameNode)
4829 {
4830 CHECK_NULL_VOID(frameNode);
4831 frameNode->SetIsMeasureBoundary(false);
4832 const auto& layoutProperty = frameNode->GetLayoutProperty();
4833 CHECK_NULL_VOID(layoutProperty);
4834 layoutProperty->ResetLayoutRect();
4835 }
4836
GetLayoutRect(FrameNode * frameNode)4837 NG::RectF ViewAbstract::GetLayoutRect(FrameNode* frameNode)
4838 {
4839 CHECK_NULL_RETURN(frameNode, NG::RectF());
4840 const auto& layoutProperty = frameNode->GetLayoutProperty();
4841 CHECK_NULL_RETURN(layoutProperty, NG::RectF());
4842 return layoutProperty->GetLayoutRect().value_or(NG::RectF());
4843 }
4844
GetFocusOnTouch(FrameNode * frameNode)4845 bool ViewAbstract::GetFocusOnTouch(FrameNode* frameNode)
4846 {
4847 CHECK_NULL_RETURN(frameNode, false);
4848 auto focusHub = frameNode->GetFocusHub();
4849 CHECK_NULL_RETURN(focusHub, false);
4850 return focusHub->IsFocusOnTouch().value_or(false);
4851 }
4852
SetFocusScopeId(const std::string & focusScopeId,bool isGroup)4853 void ViewAbstract::SetFocusScopeId(const std::string& focusScopeId, bool isGroup)
4854 {
4855 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
4856 CHECK_NULL_VOID(focusHub);
4857 focusHub->SetFocusScopeId(focusScopeId, isGroup);
4858 }
4859
SetFocusScopePriority(const std::string & focusScopeId,const uint32_t focusPriority)4860 void ViewAbstract::SetFocusScopePriority(const std::string& focusScopeId, const uint32_t focusPriority)
4861 {
4862 auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
4863 CHECK_NULL_VOID(focusHub);
4864 focusHub->SetFocusScopePriority(focusScopeId, focusPriority);
4865 }
4866
SetFocusScopeId(FrameNode * frameNode,const std::string & focusScopeId,bool isGroup)4867 void ViewAbstract::SetFocusScopeId(FrameNode* frameNode, const std::string& focusScopeId, bool isGroup)
4868 {
4869 CHECK_NULL_VOID(frameNode);
4870 auto focusHub = frameNode->GetOrCreateFocusHub();
4871 CHECK_NULL_VOID(focusHub);
4872 focusHub->SetFocusScopeId(focusScopeId, isGroup);
4873 }
4874
SetFocusScopePriority(FrameNode * frameNode,const std::string & focusScopeId,const uint32_t focusPriority)4875 void ViewAbstract::SetFocusScopePriority(FrameNode* frameNode, const std::string& focusScopeId,
4876 const uint32_t focusPriority)
4877 {
4878 CHECK_NULL_VOID(frameNode);
4879 auto focusHub = frameNode->GetOrCreateFocusHub();
4880 CHECK_NULL_VOID(focusHub);
4881 focusHub->SetFocusScopePriority(focusScopeId, focusPriority);
4882 }
4883
GetSafeAreaExpandType(FrameNode * frameNode)4884 uint32_t ViewAbstract::GetSafeAreaExpandType(FrameNode* frameNode)
4885 {
4886 uint32_t value = SAFE_AREA_TYPE_ALL;
4887 CHECK_NULL_RETURN(frameNode, value);
4888 const auto& layoutProperty = frameNode->GetLayoutProperty();
4889 CHECK_NULL_RETURN(layoutProperty, value);
4890 const auto& SafeAreaExpandOpts = layoutProperty->GetSafeAreaExpandOpts();
4891 CHECK_NULL_RETURN(SafeAreaExpandOpts, value);
4892 if (SafeAreaExpandOpts->type > 0) {
4893 value = SafeAreaExpandOpts->type;
4894 }
4895 return value;
4896 }
4897
GetSafeAreaExpandEdges(FrameNode * frameNode)4898 uint32_t ViewAbstract::GetSafeAreaExpandEdges(FrameNode* frameNode)
4899 {
4900 uint32_t value = SAFE_AREA_EDGE_ALL;
4901 CHECK_NULL_RETURN(frameNode, value);
4902 const auto& layoutProperty = frameNode->GetLayoutProperty();
4903 CHECK_NULL_RETURN(layoutProperty, value);
4904 const auto& SafeAreaExpandOpts = layoutProperty->GetSafeAreaExpandOpts();
4905 CHECK_NULL_RETURN(SafeAreaExpandOpts, value);
4906 if (SafeAreaExpandOpts->edges > 0) {
4907 value = SafeAreaExpandOpts->edges;
4908 }
4909 return value;
4910 }
4911
SetPositionLocalizedEdges(bool needLocalized)4912 void ViewAbstract::SetPositionLocalizedEdges(bool needLocalized)
4913 {
4914 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
4915 CHECK_NULL_VOID(frameNode);
4916 auto layoutProperty = frameNode->GetLayoutProperty();
4917 CHECK_NULL_VOID(layoutProperty);
4918 layoutProperty->UpdateNeedPositionLocalizedEdges(needLocalized);
4919 }
4920
SetLocalizedMarkAnchor(bool needLocalized)4921 void ViewAbstract::SetLocalizedMarkAnchor(bool needLocalized)
4922 {
4923 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
4924 CHECK_NULL_VOID(frameNode);
4925 auto layoutProperty = frameNode->GetLayoutProperty();
4926 CHECK_NULL_VOID(layoutProperty);
4927 layoutProperty->UpdatNeedMarkAnchorPosition(needLocalized);
4928 }
4929
SetOffsetLocalizedEdges(bool needLocalized)4930 void ViewAbstract::SetOffsetLocalizedEdges(bool needLocalized)
4931 {
4932 auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
4933 CHECK_NULL_VOID(frameNode);
4934 auto layoutProperty = frameNode->GetLayoutProperty();
4935 CHECK_NULL_VOID(layoutProperty);
4936 layoutProperty->UpdateNeedOffsetLocalizedEdges(needLocalized);
4937 }
4938
SetSystemColorModeChangeEvent(FrameNode * frameNode,std::function<void (int32_t)> && onColorModeChange)4939 void ViewAbstract::SetSystemColorModeChangeEvent(
4940 FrameNode* frameNode, std::function<void(int32_t)>&& onColorModeChange)
4941 {
4942 CHECK_NULL_VOID(frameNode);
4943 frameNode->SetNDKColorModeUpdateCallback(std::move(onColorModeChange));
4944 }
4945
SetSystemFontChangeEvent(FrameNode * frameNode,std::function<void (float,float)> && onFontChange)4946 void ViewAbstract::SetSystemFontChangeEvent(FrameNode* frameNode, std::function<void(float, float)>&& onFontChange)
4947 {
4948 CHECK_NULL_VOID(frameNode);
4949 frameNode->SetNDKFontUpdateCallback(std::move(onFontChange));
4950 }
4951
AddCustomProperty(FrameNode * frameNode,const std::string & key,const std::string & value)4952 void ViewAbstract::AddCustomProperty(FrameNode* frameNode, const std::string& key, const std::string& value)
4953 {
4954 CHECK_NULL_VOID(frameNode);
4955 frameNode->AddCustomProperty(key, value);
4956 }
4957
RemoveCustomProperty(FrameNode * frameNode,const std::string & key)4958 void ViewAbstract::RemoveCustomProperty(FrameNode* frameNode, const std::string& key)
4959 {
4960 CHECK_NULL_VOID(frameNode);
4961 frameNode->RemoveCustomProperty(key);
4962 }
4963
4964 } // namespace OHOS::Ace::NG
4965