• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 <utility>
21 
22 #include "base/geometry/dimension.h"
23 #include "base/geometry/ng/offset_t.h"
24 #include "base/memory/ace_type.h"
25 #include "base/subwindow/subwindow.h"
26 #include "base/utils/system_properties.h"
27 #include "base/utils/utils.h"
28 #include "base/log/log_wrapper.h"
29 #include "core/common/container.h"
30 #include "core/components_ng/base/frame_node.h"
31 #include "core/components_ng/base/view_stack_processor.h"
32 #include "core/components_ng/layout/layout_property.h"
33 #include "core/components_ng/pattern/bubble/bubble_pattern.h"
34 #include "core/components_ng/pattern/bubble/bubble_view.h"
35 #include "core/components_ng/pattern/menu/menu_pattern.h"
36 #include "core/components_ng/pattern/menu/menu_view.h"
37 #include "core/components_ng/pattern/menu/preview/menu_preview_pattern.h"
38 #include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
39 #include "core/components_ng/pattern/option/option_paint_property.h"
40 #include "core/components_ng/pattern/text/span_node.h"
41 #include "core/components_ng/property/calc_length.h"
42 #include "core/components_ng/property/safe_area_insets.h"
43 #include "core/image/image_source_info.h"
44 #include "core/pipeline_ng/pipeline_context.h"
45 #include "core/pipeline_ng/ui_task_scheduler.h"
46 
47 namespace OHOS::Ace::NG {
48 namespace {
49 // common function to bind menu
BindMenu(const RefPtr<FrameNode> & menuNode,int32_t targetId,const NG::OffsetF & offset)50 void BindMenu(const RefPtr<FrameNode> &menuNode, int32_t targetId, const NG::OffsetF &offset)
51 {
52     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu enter");
53     auto container = Container::Current();
54     CHECK_NULL_VOID(container);
55     auto pipelineContext = container->GetPipelineContext();
56     CHECK_NULL_VOID(pipelineContext);
57     auto context = AceType::DynamicCast<NG::PipelineContext>(pipelineContext);
58     CHECK_NULL_VOID(context);
59     auto overlayManager = context->GetOverlayManager();
60     CHECK_NULL_VOID(overlayManager);
61     // pass in menuNode to register it in OverlayManager
62     overlayManager->ShowMenu(targetId, offset, menuNode);
63 }
64 
RegisterMenuCallback(const RefPtr<FrameNode> & menuWrapperNode,const MenuParam & menuParam)65 void RegisterMenuCallback(const RefPtr<FrameNode> &menuWrapperNode, const MenuParam &menuParam)
66 {
67     TAG_LOGD(AceLogTag::ACE_DIALOG, "register menu enter");
68     CHECK_NULL_VOID(menuWrapperNode);
69     auto pattern = menuWrapperNode->GetPattern<MenuWrapperPattern>();
70     CHECK_NULL_VOID(pattern);
71     pattern->RegisterMenuAppearCallback(menuParam.onAppear);
72     pattern->RegisterMenuDisappearCallback(menuParam.onDisappear);
73     pattern->RegisterMenuAboutToAppearCallback(menuParam.aboutToAppear);
74     pattern->RegisterMenuAboutToDisappearCallback(menuParam.aboutToDisappear);
75     pattern->RegisterMenuStateChangeCallback(menuParam.onStateChange);
76 }
77 } // namespace
78 
SetWidth(const CalcLength & width)79 void ViewAbstract::SetWidth(const CalcLength &width)
80 {
81     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
82         return;
83     }
84     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
85     CHECK_NULL_VOID(frameNode);
86     auto layoutProperty = frameNode->GetLayoutProperty();
87     CHECK_NULL_VOID(layoutProperty);
88     // get previously user defined ideal height
89     std::optional<CalcLength> height = std::nullopt;
90     auto &&layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
91     if (layoutConstraint && layoutConstraint->selfIdealSize) {
92         height = layoutConstraint->selfIdealSize->Height();
93     }
94     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
95 }
96 
SetHeight(const CalcLength & height)97 void ViewAbstract::SetHeight(const CalcLength &height)
98 {
99     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
100         return;
101     }
102     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
103     CHECK_NULL_VOID(frameNode);
104     auto layoutProperty = frameNode->GetLayoutProperty();
105     CHECK_NULL_VOID(layoutProperty);
106     // get previously user defined ideal width
107     std::optional<CalcLength> width = std::nullopt;
108     auto &&layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
109     if (layoutConstraint && layoutConstraint->selfIdealSize) {
110         width = layoutConstraint->selfIdealSize->Width();
111     }
112     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
113 }
114 
SetClickEffectLevel(const ClickEffectLevel & level,float scaleValue)115 void ViewAbstract::SetClickEffectLevel(const ClickEffectLevel &level, float scaleValue)
116 {
117     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
118         return;
119     }
120     ClickEffectInfo clickEffectInfo;
121     clickEffectInfo.level = level;
122     clickEffectInfo.scaleNumber = scaleValue;
123     ACE_UPDATE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo);
124 }
125 
ClearWidthOrHeight(bool isWidth)126 void ViewAbstract::ClearWidthOrHeight(bool isWidth)
127 {
128     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
129         return;
130     }
131     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
132     CHECK_NULL_VOID(frameNode);
133     auto layoutProperty = frameNode->GetLayoutProperty();
134     CHECK_NULL_VOID(layoutProperty);
135     layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
136 }
137 
SetMinWidth(const CalcLength & width)138 void ViewAbstract::SetMinWidth(const CalcLength &width)
139 {
140     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
141         return;
142     }
143     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
144     CHECK_NULL_VOID(frameNode);
145     auto layoutProperty = frameNode->GetLayoutProperty();
146     CHECK_NULL_VOID(layoutProperty);
147     layoutProperty->UpdateCalcMinSize(CalcSize(width, std::nullopt));
148 }
149 
SetMinHeight(const CalcLength & height)150 void ViewAbstract::SetMinHeight(const CalcLength &height)
151 {
152     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
153         return;
154     }
155     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
156     CHECK_NULL_VOID(frameNode);
157     auto layoutProperty = frameNode->GetLayoutProperty();
158     CHECK_NULL_VOID(layoutProperty);
159     layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, height));
160 }
161 
ResetMinSize(bool resetWidth)162 void ViewAbstract::ResetMinSize(bool resetWidth)
163 {
164     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
165         return;
166     }
167     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
168     CHECK_NULL_VOID(frameNode);
169     auto layoutProperty = frameNode->GetLayoutProperty();
170     CHECK_NULL_VOID(layoutProperty);
171     layoutProperty->ResetCalcMinSize(resetWidth);
172 }
173 
SetMaxWidth(const CalcLength & width)174 void ViewAbstract::SetMaxWidth(const CalcLength &width)
175 {
176     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
177         return;
178     }
179     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
180     CHECK_NULL_VOID(frameNode);
181     auto layoutProperty = frameNode->GetLayoutProperty();
182     CHECK_NULL_VOID(layoutProperty);
183     layoutProperty->UpdateCalcMaxSize(CalcSize(width, std::nullopt));
184 }
185 
SetMaxHeight(const CalcLength & height)186 void ViewAbstract::SetMaxHeight(const CalcLength &height)
187 {
188     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
189         return;
190     }
191     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
192     CHECK_NULL_VOID(frameNode);
193     auto layoutProperty = frameNode->GetLayoutProperty();
194     CHECK_NULL_VOID(layoutProperty);
195     layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, height));
196 }
197 
ResetMaxSize(bool resetWidth)198 void ViewAbstract::ResetMaxSize(bool resetWidth)
199 {
200     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
201         return;
202     }
203     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
204     CHECK_NULL_VOID(frameNode);
205     auto layoutProperty = frameNode->GetLayoutProperty();
206     CHECK_NULL_VOID(layoutProperty);
207     layoutProperty->ResetCalcMaxSize(resetWidth);
208 }
209 
SetAspectRatio(float ratio)210 void ViewAbstract::SetAspectRatio(float ratio)
211 {
212     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
213         return;
214     }
215     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio);
216 }
217 
ResetAspectRatio()218 void ViewAbstract::ResetAspectRatio()
219 {
220     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
221         return;
222     }
223     ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, AspectRatio);
224 }
225 
SetBackgroundAlign(const Alignment & align)226 void ViewAbstract::SetBackgroundAlign(const Alignment &align)
227 {
228     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
229         return;
230     }
231     ACE_UPDATE_RENDER_CONTEXT(BackgroundAlign, align);
232 }
233 
SetBackgroundColor(const Color & color)234 void ViewAbstract::SetBackgroundColor(const Color &color)
235 {
236     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
237         return;
238     }
239     ACE_UPDATE_RENDER_CONTEXT(BackgroundColor, color);
240 }
241 
SetBackgroundColor(FrameNode * frameNode,const Color & color)242 void ViewAbstract::SetBackgroundColor(FrameNode *frameNode, const Color &color)
243 {
244     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundColor, color, frameNode);
245 }
246 
SetBackgroundImage(const ImageSourceInfo & src)247 void ViewAbstract::SetBackgroundImage(const ImageSourceInfo &src)
248 {
249     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
250         return;
251     }
252     ACE_UPDATE_RENDER_CONTEXT(BackgroundImage, src);
253 }
254 
SetBackgroundImage(FrameNode * frameNode,const ImageSourceInfo & src)255 void ViewAbstract::SetBackgroundImage(FrameNode *frameNode, const ImageSourceInfo &src)
256 {
257     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImage, src, frameNode);
258 }
259 
SetBackgroundImageRepeat(const ImageRepeat & imageRepeat)260 void ViewAbstract::SetBackgroundImageRepeat(const ImageRepeat &imageRepeat)
261 {
262     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
263         return;
264     }
265     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat);
266 }
267 
SetBackgroundImageRepeat(FrameNode * frameNode,const ImageRepeat & imageRepeat)268 void ViewAbstract::SetBackgroundImageRepeat(FrameNode *frameNode, const ImageRepeat &imageRepeat)
269 {
270     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageRepeat, imageRepeat, frameNode);
271 }
272 
SetBackgroundImageSize(const BackgroundImageSize & bgImgSize)273 void ViewAbstract::SetBackgroundImageSize(const BackgroundImageSize &bgImgSize)
274 {
275     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
276         return;
277     }
278     ACE_UPDATE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize);
279 }
280 
SetBackgroundImageSize(FrameNode * frameNode,const BackgroundImageSize & bgImgSize)281 void ViewAbstract::SetBackgroundImageSize(FrameNode *frameNode, const BackgroundImageSize &bgImgSize)
282 {
283     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageSize, bgImgSize, frameNode);
284 }
285 
SetBackgroundImagePosition(const BackgroundImagePosition & bgImgPosition)286 void ViewAbstract::SetBackgroundImagePosition(const BackgroundImagePosition &bgImgPosition)
287 {
288     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
289         return;
290     }
291     ACE_UPDATE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition);
292 }
293 
SetBackgroundImagePosition(FrameNode * frameNode,const BackgroundImagePosition & bgImgPosition)294 void ViewAbstract::SetBackgroundImagePosition(FrameNode *frameNode, const BackgroundImagePosition &bgImgPosition)
295 {
296     ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImagePosition, bgImgPosition, frameNode);
297 }
298 
SetBackgroundBlurStyle(const BlurStyleOption & bgBlurStyle)299 void ViewAbstract::SetBackgroundBlurStyle(const BlurStyleOption &bgBlurStyle)
300 {
301     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
302         return;
303     }
304     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
305     CHECK_NULL_VOID(frameNode);
306     auto target = frameNode->GetRenderContext();
307     if (target) {
308         if (target->GetBackgroundEffect().has_value()) {
309             target->UpdateBackgroundEffect(std::nullopt);
310         }
311         target->UpdateBackBlurStyle(bgBlurStyle);
312         if (target->GetBackBlurRadius().has_value()) {
313             target->UpdateBackBlurRadius(Dimension());
314         }
315     }
316 }
317 
SetBackgroundEffect(const EffectOption & effectOption)318 void ViewAbstract::SetBackgroundEffect(const EffectOption &effectOption)
319 {
320     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
321         return;
322     }
323     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
324     CHECK_NULL_VOID(frameNode);
325     auto target = frameNode->GetRenderContext();
326     if (target) {
327         if (target->GetBackBlurRadius().has_value()) {
328             target->UpdateBackBlurRadius(Dimension());
329         }
330         if (target->GetBackBlurStyle().has_value()) {
331             target->UpdateBackBlurStyle(std::nullopt);
332         }
333         target->UpdateBackgroundEffect(effectOption);
334     }
335 }
336 
SetForegroundBlurStyle(const BlurStyleOption & fgBlurStyle)337 void ViewAbstract::SetForegroundBlurStyle(const BlurStyleOption &fgBlurStyle)
338 {
339     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
340         return;
341     }
342     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
343     CHECK_NULL_VOID(frameNode);
344     auto target = frameNode->GetRenderContext();
345     if (target) {
346         target->UpdateFrontBlurStyle(fgBlurStyle);
347         if (target->GetFrontBlurRadius().has_value()) {
348             target->UpdateFrontBlurRadius(Dimension());
349         }
350     }
351 }
352 
SetSphericalEffect(double radio)353 void ViewAbstract::SetSphericalEffect(double radio)
354 {
355     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
356         return;
357     }
358     ACE_UPDATE_RENDER_CONTEXT(SphericalEffect, radio);
359 }
360 
SetPixelStretchEffect(PixStretchEffectOption & option)361 void ViewAbstract::SetPixelStretchEffect(PixStretchEffectOption &option)
362 {
363     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
364         return;
365     }
366     ACE_UPDATE_RENDER_CONTEXT(PixelStretchEffect, option);
367 }
368 
SetLightUpEffect(double radio)369 void ViewAbstract::SetLightUpEffect(double radio)
370 {
371     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
372         return;
373     }
374     ACE_UPDATE_RENDER_CONTEXT(LightUpEffect, radio);
375 }
376 
SetLayoutWeight(float value)377 void ViewAbstract::SetLayoutWeight(float value)
378 {
379     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
380         return;
381     }
382     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, static_cast<float>(value));
383 }
384 
SetPixelRound(uint8_t value)385 void ViewAbstract::SetPixelRound(uint8_t value)
386 {
387     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
388         return;
389     }
390     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, PixelRound, value);
391 }
392 
SetLayoutDirection(TextDirection value)393 void ViewAbstract::SetLayoutDirection(TextDirection value)
394 {
395     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
396         return;
397     }
398     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value);
399 }
400 
SetAlignRules(const std::map<AlignDirection,AlignRule> & alignRules)401 void ViewAbstract::SetAlignRules(const std::map<AlignDirection, AlignRule> &alignRules)
402 {
403     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
404         return;
405     }
406     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules);
407 }
408 
SetBias(const BiasPair & biasPair)409 void ViewAbstract::SetBias(const BiasPair& biasPair)
410 {
411     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
412         return;
413     }
414     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Bias, biasPair);
415 }
416 
SetAlignSelf(FlexAlign value)417 void ViewAbstract::SetAlignSelf(FlexAlign value)
418 {
419     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
420         return;
421     }
422     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value);
423 }
424 
SetFlexShrink(float value)425 void ViewAbstract::SetFlexShrink(float value)
426 {
427     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
428         return;
429     }
430     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value);
431 }
432 
ResetFlexShrink()433 void ViewAbstract::ResetFlexShrink()
434 {
435     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
436         return;
437     }
438     ACE_RESET_LAYOUT_PROPERTY(LayoutProperty, FlexShrink);
439 }
440 
SetFlexGrow(float value)441 void ViewAbstract::SetFlexGrow(float value)
442 {
443     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
444         return;
445     }
446     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value);
447 }
448 
SetFlexBasis(const Dimension & value)449 void ViewAbstract::SetFlexBasis(const Dimension &value)
450 {
451     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
452         return;
453     }
454     if (LessNotEqual(value.Value(), 0.0f)) {
455         ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension());
456         return;
457     }
458     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value);
459 }
460 
SetDisplayIndex(int32_t value)461 void ViewAbstract::SetDisplayIndex(int32_t value)
462 {
463     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
464         return;
465     }
466     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value);
467 }
468 
SetPadding(const CalcLength & value)469 void ViewAbstract::SetPadding(const CalcLength &value)
470 {
471     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
472         return;
473     }
474     PaddingProperty padding;
475     padding.SetEdges(value);
476     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding);
477 }
478 
SetPadding(const PaddingProperty & value)479 void ViewAbstract::SetPadding(const PaddingProperty &value)
480 {
481     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
482         return;
483     }
484     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Padding, value);
485 }
486 
SetMargin(const CalcLength & value)487 void ViewAbstract::SetMargin(const CalcLength &value)
488 {
489     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
490         return;
491     }
492     MarginProperty margin;
493     margin.SetEdges(value);
494     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin);
495 }
496 
SetMargin(const MarginProperty & value)497 void ViewAbstract::SetMargin(const MarginProperty &value)
498 {
499     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
500         return;
501     }
502     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Margin, value);
503 }
504 
SetBorderRadius(const Dimension & value)505 void ViewAbstract::SetBorderRadius(const Dimension &value)
506 {
507     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
508         return;
509     }
510     BorderRadiusProperty borderRadius;
511     borderRadius.SetRadius(value);
512     borderRadius.multiValued = false;
513     ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius);
514 }
515 
SetBorderRadius(const BorderRadiusProperty & value)516 void ViewAbstract::SetBorderRadius(const BorderRadiusProperty &value)
517 {
518     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
519         return;
520     }
521     ACE_UPDATE_RENDER_CONTEXT(BorderRadius, value);
522 }
523 
SetBorderColor(const Color & value)524 void ViewAbstract::SetBorderColor(const Color &value)
525 {
526     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
527         return;
528     }
529     BorderColorProperty borderColor;
530     borderColor.SetColor(value);
531     ACE_UPDATE_RENDER_CONTEXT(BorderColor, borderColor);
532 }
533 
SetBorderColor(const BorderColorProperty & value)534 void ViewAbstract::SetBorderColor(const BorderColorProperty &value)
535 {
536     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
537         return;
538     }
539     ACE_UPDATE_RENDER_CONTEXT(BorderColor, value);
540 }
541 
SetBorderWidth(const Dimension & value)542 void ViewAbstract::SetBorderWidth(const Dimension &value)
543 {
544     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
545         return;
546     }
547     BorderWidthProperty borderWidth;
548     if (Negative(value.Value())) {
549         borderWidth.SetBorderWidth(Dimension(0));
550     } else {
551         borderWidth.SetBorderWidth(value);
552     }
553     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth);
554     ACE_UPDATE_RENDER_CONTEXT(BorderWidth, borderWidth);
555 }
556 
SetBorderWidth(const BorderWidthProperty & value)557 void ViewAbstract::SetBorderWidth(const BorderWidthProperty &value)
558 {
559     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
560         return;
561     }
562     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value);
563     ACE_UPDATE_RENDER_CONTEXT(BorderWidth, value);
564 }
565 
SetBorderStyle(const BorderStyle & value)566 void ViewAbstract::SetBorderStyle(const BorderStyle &value)
567 {
568     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
569         return;
570     }
571     BorderStyleProperty borderStyle;
572     borderStyle.SetBorderStyle(value);
573     ACE_UPDATE_RENDER_CONTEXT(BorderStyle, borderStyle);
574 }
575 
SetBorderStyle(FrameNode * frameNode,const BorderStyle & value)576 void ViewAbstract::SetBorderStyle(FrameNode *frameNode, const BorderStyle &value)
577 {
578     BorderStyleProperty borderStyle;
579     borderStyle.SetBorderStyle(value);
580     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, borderStyle, frameNode);
581 }
582 
SetBorderStyle(const BorderStyleProperty & value)583 void ViewAbstract::SetBorderStyle(const BorderStyleProperty &value)
584 {
585     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
586         return;
587     }
588     ACE_UPDATE_RENDER_CONTEXT(BorderStyle, value);
589 }
590 
SetBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)591 void ViewAbstract::SetBorderStyle(FrameNode *frameNode, const BorderStyleProperty &value)
592 {
593     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderStyle, value, frameNode);
594 }
595 
SetOuterBorderRadius(const Dimension & value)596 void ViewAbstract::SetOuterBorderRadius(const Dimension& value)
597 {
598     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
599         return;
600     }
601     BorderRadiusProperty borderRadius;
602     borderRadius.SetRadius(value);
603     borderRadius.multiValued = false;
604     ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, borderRadius);
605 }
606 
SetOuterBorderRadius(FrameNode * frameNode,const Dimension & value)607 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const Dimension& value)
608 {
609     BorderRadiusProperty borderRadius;
610     borderRadius.SetRadius(value);
611     borderRadius.multiValued = false;
612     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, borderRadius, frameNode);
613 }
614 
SetOuterBorderRadius(const BorderRadiusProperty & value)615 void ViewAbstract::SetOuterBorderRadius(const BorderRadiusProperty& value)
616 {
617     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
618         return;
619     }
620     ACE_UPDATE_RENDER_CONTEXT(OuterBorderRadius, value);
621 }
622 
SetOuterBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)623 void ViewAbstract::SetOuterBorderRadius(FrameNode* frameNode, const BorderRadiusProperty& value)
624 {
625     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderRadius, value, frameNode);
626 }
627 
SetOuterBorderColor(const Color & value)628 void ViewAbstract::SetOuterBorderColor(const Color& value)
629 {
630     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
631         return;
632     }
633     BorderColorProperty borderColor;
634     borderColor.SetColor(value);
635     ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, borderColor);
636 }
637 
SetOuterBorderColor(FrameNode * frameNode,const Color & value)638 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const Color& value)
639 {
640     BorderColorProperty borderColor;
641     borderColor.SetColor(value);
642     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, borderColor, frameNode);
643 }
644 
SetOuterBorderColor(const BorderColorProperty & value)645 void ViewAbstract::SetOuterBorderColor(const BorderColorProperty& value)
646 {
647     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
648         return;
649     }
650     ACE_UPDATE_RENDER_CONTEXT(OuterBorderColor, value);
651 }
652 
SetOuterBorderColor(FrameNode * frameNode,const BorderColorProperty & value)653 void ViewAbstract::SetOuterBorderColor(FrameNode* frameNode, const BorderColorProperty& value)
654 {
655     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderColor, value, frameNode);
656 }
657 
SetOuterBorderWidth(const Dimension & value)658 void ViewAbstract::SetOuterBorderWidth(const Dimension& value)
659 {
660     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
661         return;
662     }
663     BorderWidthProperty borderWidth;
664     if (Negative(value.Value())) {
665         borderWidth.SetBorderWidth(Dimension(0));
666     } else {
667         borderWidth.SetBorderWidth(value);
668     }
669     ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, borderWidth);
670 }
671 
SetOuterBorderWidth(FrameNode * frameNode,const Dimension & value)672 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const Dimension& value)
673 {
674     BorderWidthProperty borderWidth;
675     if (Negative(value.Value())) {
676         borderWidth.SetBorderWidth(Dimension(0));
677     } else {
678         borderWidth.SetBorderWidth(value);
679     }
680     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, borderWidth, frameNode);
681 }
682 
SetOuterBorderWidth(const BorderWidthProperty & value)683 void ViewAbstract::SetOuterBorderWidth(const BorderWidthProperty& value)
684 {
685     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
686         return;
687     }
688     ACE_UPDATE_RENDER_CONTEXT(OuterBorderWidth, value);
689 }
690 
SetOuterBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)691 void ViewAbstract::SetOuterBorderWidth(FrameNode* frameNode, const BorderWidthProperty& value)
692 {
693     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderWidth, value, frameNode);
694 }
695 
SetOuterBorderStyle(const BorderStyleProperty & value)696 void ViewAbstract::SetOuterBorderStyle(const BorderStyleProperty& value)
697 {
698     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
699         return;
700     }
701     ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, value);
702 }
703 
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyleProperty & value)704 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyleProperty& value)
705 {
706     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, value, frameNode);
707 }
708 
SetOuterBorderStyle(const BorderStyle & value)709 void ViewAbstract::SetOuterBorderStyle(const BorderStyle& value)
710 {
711     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
712         return;
713     }
714     BorderStyleProperty borderStyle;
715     borderStyle.SetBorderStyle(value);
716     ACE_UPDATE_RENDER_CONTEXT(OuterBorderStyle, borderStyle);
717 }
718 
SetOuterBorderStyle(FrameNode * frameNode,const BorderStyle & value)719 void ViewAbstract::SetOuterBorderStyle(FrameNode* frameNode, const BorderStyle& value)
720 {
721     BorderStyleProperty borderStyle;
722     borderStyle.SetBorderStyle(value);
723     ACE_UPDATE_NODE_RENDER_CONTEXT(OuterBorderStyle, borderStyle, frameNode);
724 }
725 
DisableOnClick()726 void ViewAbstract::DisableOnClick()
727 {
728     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
729     CHECK_NULL_VOID(gestureHub);
730     gestureHub->ClearUserOnClick();
731 }
732 
DisableOnTouch()733 void ViewAbstract::DisableOnTouch()
734 {
735     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
736     CHECK_NULL_VOID(gestureHub);
737     gestureHub->ClearUserOnTouch();
738 }
739 
DisableOnKeyEvent()740 void ViewAbstract::DisableOnKeyEvent()
741 {
742     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
743     CHECK_NULL_VOID(focusHub);
744     focusHub->ClearUserOnKey();
745 }
746 
DisableOnHover()747 void ViewAbstract::DisableOnHover()
748 {
749     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
750     CHECK_NULL_VOID(eventHub);
751     eventHub->ClearUserOnHover();
752 }
753 
DisableOnMouse()754 void ViewAbstract::DisableOnMouse()
755 {
756     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
757     CHECK_NULL_VOID(eventHub);
758     eventHub->ClearUserOnMouse();
759 }
760 
DisableOnAppear()761 void ViewAbstract::DisableOnAppear()
762 {
763     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
764     CHECK_NULL_VOID(eventHub);
765     eventHub->ClearUserOnAppear();
766 }
767 
DisableOnDisAppear()768 void ViewAbstract::DisableOnDisAppear()
769 {
770     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
771     CHECK_NULL_VOID(eventHub);
772     eventHub->ClearUserOnDisAppear();
773 }
774 
DisableOnAreaChange()775 void ViewAbstract::DisableOnAreaChange()
776 {
777     auto pipeline = PipelineContext::GetCurrentContext();
778     CHECK_NULL_VOID(pipeline);
779     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
780     CHECK_NULL_VOID(frameNode);
781     frameNode->ClearUserOnAreaChange();
782 }
783 
DisableOnFocus()784 void ViewAbstract::DisableOnFocus()
785 {
786     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
787     CHECK_NULL_VOID(focusHub);
788     focusHub->ClearUserOnFocus();
789 }
790 
DisableOnBlur()791 void ViewAbstract::DisableOnBlur()
792 {
793     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
794     CHECK_NULL_VOID(focusHub);
795     focusHub->ClearUserOnBlur();
796 }
797 
SetOnClick(GestureEventFunc && clickEventFunc)798 void ViewAbstract::SetOnClick(GestureEventFunc &&clickEventFunc)
799 {
800     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
801     CHECK_NULL_VOID(gestureHub);
802     gestureHub->SetUserOnClick(std::move(clickEventFunc));
803 }
804 
SetOnGestureJudgeBegin(GestureJudgeFunc && gestureJudgeFunc)805 void ViewAbstract::SetOnGestureJudgeBegin(GestureJudgeFunc &&gestureJudgeFunc)
806 {
807     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
808     CHECK_NULL_VOID(gestureHub);
809     gestureHub->SetOnGestureJudgeBegin(std::move(gestureJudgeFunc));
810 }
811 
SetOnTouch(TouchEventFunc && touchEventFunc)812 void ViewAbstract::SetOnTouch(TouchEventFunc &&touchEventFunc)
813 {
814     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
815     CHECK_NULL_VOID(gestureHub);
816     gestureHub->SetTouchEvent(std::move(touchEventFunc));
817 }
818 
SetOnMouse(OnMouseEventFunc && onMouseEventFunc)819 void ViewAbstract::SetOnMouse(OnMouseEventFunc &&onMouseEventFunc)
820 {
821     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
822     CHECK_NULL_VOID(eventHub);
823     eventHub->SetMouseEvent(std::move(onMouseEventFunc));
824 }
825 
SetOnHover(OnHoverFunc && onHoverEventFunc)826 void ViewAbstract::SetOnHover(OnHoverFunc &&onHoverEventFunc)
827 {
828     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
829     CHECK_NULL_VOID(eventHub);
830     eventHub->SetHoverEvent(std::move(onHoverEventFunc));
831 }
832 
SetHoverEffect(HoverEffectType hoverEffect)833 void ViewAbstract::SetHoverEffect(HoverEffectType hoverEffect)
834 {
835     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
836     CHECK_NULL_VOID(eventHub);
837     eventHub->SetHoverEffect(hoverEffect);
838 }
839 
SetHoverEffectAuto(HoverEffectType hoverEffect)840 void ViewAbstract::SetHoverEffectAuto(HoverEffectType hoverEffect)
841 {
842     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeInputEventHub();
843     CHECK_NULL_VOID(eventHub);
844     eventHub->SetHoverEffectAuto(hoverEffect);
845 }
846 
SetEnabled(bool enabled)847 void ViewAbstract::SetEnabled(bool enabled)
848 {
849     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
850     if (eventHub) {
851         eventHub->SetEnabled(enabled);
852     }
853 
854     // The SetEnabled of focusHub must be after at eventHub
855     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
856     if (focusHub) {
857         focusHub->SetEnabled(enabled);
858     }
859 }
860 
SetFocusable(bool focusable)861 void ViewAbstract::SetFocusable(bool focusable)
862 {
863     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
864     CHECK_NULL_VOID(focusHub);
865     focusHub->SetFocusable(focusable);
866 }
867 
SetOnFocus(OnFocusFunc && onFocusCallback)868 void ViewAbstract::SetOnFocus(OnFocusFunc &&onFocusCallback)
869 {
870     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
871     CHECK_NULL_VOID(focusHub);
872     focusHub->SetOnFocusCallback(std::move(onFocusCallback));
873 }
874 
SetOnBlur(OnBlurFunc && onBlurCallback)875 void ViewAbstract::SetOnBlur(OnBlurFunc &&onBlurCallback)
876 {
877     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
878     CHECK_NULL_VOID(focusHub);
879     focusHub->SetOnBlurCallback(std::move(onBlurCallback));
880 }
881 
SetOnKeyEvent(OnKeyCallbackFunc && onKeyCallback)882 void ViewAbstract::SetOnKeyEvent(OnKeyCallbackFunc &&onKeyCallback)
883 {
884     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
885     CHECK_NULL_VOID(focusHub);
886     focusHub->SetOnKeyCallback(std::move(onKeyCallback));
887 }
888 
SetTabIndex(int32_t index)889 void ViewAbstract::SetTabIndex(int32_t index)
890 {
891     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
892     CHECK_NULL_VOID(focusHub);
893     focusHub->SetTabIndex(index);
894 }
895 
SetFocusOnTouch(bool isSet)896 void ViewAbstract::SetFocusOnTouch(bool isSet)
897 {
898     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
899     CHECK_NULL_VOID(focusHub);
900     focusHub->SetIsFocusOnTouch(isSet);
901 }
902 
SetDefaultFocus(bool isSet)903 void ViewAbstract::SetDefaultFocus(bool isSet)
904 {
905     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
906     CHECK_NULL_VOID(focusHub);
907     focusHub->SetIsDefaultFocus(isSet);
908 }
909 
SetGroupDefaultFocus(bool isSet)910 void ViewAbstract::SetGroupDefaultFocus(bool isSet)
911 {
912     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
913     CHECK_NULL_VOID(focusHub);
914     focusHub->SetIsDefaultGroupFocus(isSet);
915 }
916 
SetOnAppear(std::function<void ()> && onAppear)917 void ViewAbstract::SetOnAppear(std::function<void()> &&onAppear)
918 {
919     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
920     CHECK_NULL_VOID(eventHub);
921     eventHub->SetOnAppear(std::move(onAppear));
922 }
923 
SetOnDisappear(std::function<void ()> && onDisappear)924 void ViewAbstract::SetOnDisappear(std::function<void()> &&onDisappear)
925 {
926     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
927     CHECK_NULL_VOID(eventHub);
928     eventHub->SetOnDisappear(std::move(onDisappear));
929 }
930 
SetOnAreaChanged(std::function<void (const RectF & oldRect,const OffsetF & oldOrigin,const RectF & rect,const OffsetF & origin)> && onAreaChanged)931 void ViewAbstract::SetOnAreaChanged(std::function<void(const RectF &oldRect, const OffsetF &oldOrigin,
932     const RectF &rect, const OffsetF &origin)> &&onAreaChanged)
933 {
934     auto pipeline = PipelineContext::GetCurrentContext();
935     CHECK_NULL_VOID(pipeline);
936     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
937     CHECK_NULL_VOID(frameNode);
938     frameNode->SetOnAreaChangeCallback(std::move(onAreaChanged));
939     pipeline->AddOnAreaChangeNode(frameNode->GetId());
940 }
941 
SetOnVisibleChange(std::function<void (bool,double)> && onVisibleChange,const std::vector<double> & ratioList)942 void ViewAbstract::SetOnVisibleChange(std::function<void(bool, double)> &&onVisibleChange,
943     const std::vector<double> &ratioList)
944 {
945     auto pipeline = PipelineContext::GetCurrentContext();
946     CHECK_NULL_VOID(pipeline);
947     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
948     CHECK_NULL_VOID(frameNode);
949     frameNode->ClearVisibleAreaUserCallback();
950 
951     for (const auto &ratio : ratioList) {
952         pipeline->AddVisibleAreaChangeNode(frameNode, ratio, onVisibleChange);
953     }
954 }
955 
SetResponseRegion(const std::vector<DimensionRect> & responseRegion)956 void ViewAbstract::SetResponseRegion(const std::vector<DimensionRect> &responseRegion)
957 {
958     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
959     CHECK_NULL_VOID(gestureHub);
960     gestureHub->SetResponseRegion(responseRegion);
961 }
962 
SetMouseResponseRegion(const std::vector<DimensionRect> & mouseRegion)963 void ViewAbstract::SetMouseResponseRegion(const std::vector<DimensionRect> &mouseRegion)
964 {
965     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
966     CHECK_NULL_VOID(gestureHub);
967     gestureHub->SetMouseResponseRegion(mouseRegion);
968 }
969 
SetTouchable(bool touchable)970 void ViewAbstract::SetTouchable(bool touchable)
971 {
972     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
973     CHECK_NULL_VOID(gestureHub);
974     gestureHub->SetTouchable(touchable);
975 }
976 
SetMonopolizeEvents(bool monopolizeEvents)977 void ViewAbstract::SetMonopolizeEvents(bool monopolizeEvents)
978 {
979     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
980     CHECK_NULL_VOID(gestureHub);
981     gestureHub->SetMonopolizeEvents(monopolizeEvents);
982 }
983 
SetHitTestMode(HitTestMode hitTestMode)984 void ViewAbstract::SetHitTestMode(HitTestMode hitTestMode)
985 {
986     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
987     CHECK_NULL_VOID(gestureHub);
988     gestureHub->SetHitTestMode(hitTestMode);
989 }
990 
SetOnTouchTestFunc(NG::OnChildTouchTestFunc && onChildTouchTest)991 void ViewAbstract::SetOnTouchTestFunc(NG::OnChildTouchTestFunc&& onChildTouchTest)
992 {
993     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
994     CHECK_NULL_VOID(gestureHub);
995     gestureHub->SetOnTouchTestFunc(std::move(onChildTouchTest));
996 }
997 
AddDragFrameNodeToManager()998 void ViewAbstract::AddDragFrameNodeToManager()
999 {
1000     auto pipeline = PipelineContext::GetCurrentContext();
1001     CHECK_NULL_VOID(pipeline);
1002     auto dragDropManager = pipeline->GetDragDropManager();
1003     CHECK_NULL_VOID(dragDropManager);
1004     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1005     CHECK_NULL_VOID(frameNode);
1006 
1007     dragDropManager->AddDragFrameNode(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1008 }
1009 
SetDraggable(bool draggable)1010 void ViewAbstract::SetDraggable(bool draggable)
1011 {
1012     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1013     CHECK_NULL_VOID(frameNode);
1014     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1015     CHECK_NULL_VOID(gestureHub);
1016     if (draggable) {
1017         if (!frameNode->IsDraggable()) {
1018             gestureHub->InitDragDropEvent();
1019         }
1020     } else {
1021         gestureHub->RemoveDragEvent();
1022     }
1023     frameNode->SetCustomerDraggable(draggable);
1024 }
1025 
SetDragPreviewOptions(const DragPreviewOption & previewOption)1026 void ViewAbstract::SetDragPreviewOptions(const DragPreviewOption& previewOption)
1027 {
1028     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1029     CHECK_NULL_VOID(frameNode);
1030     frameNode->SetDragPreviewOptions(previewOption);
1031 }
1032 
SetOnDragStart(std::function<DragDropInfo (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragStart)1033 void ViewAbstract::SetOnDragStart(
1034     std::function<DragDropInfo(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragStart)
1035 {
1036     auto gestureHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeGestureEventHub();
1037     CHECK_NULL_VOID(gestureHub);
1038     gestureHub->InitDragDropEvent();
1039 
1040     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1041     CHECK_NULL_VOID(eventHub);
1042     eventHub->SetOnDragStart(std::move(onDragStart));
1043 }
1044 
SetOnDragEnter(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragEnter)1045 void ViewAbstract::SetOnDragEnter(
1046     std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragEnter)
1047 {
1048     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1049     CHECK_NULL_VOID(eventHub);
1050     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_ENTER, std::move(onDragEnter));
1051 
1052     AddDragFrameNodeToManager();
1053 }
1054 
SetOnDragLeave(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragLeave)1055 void ViewAbstract::SetOnDragLeave(
1056     std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragLeave)
1057 {
1058     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1059     CHECK_NULL_VOID(eventHub);
1060     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_LEAVE, std::move(onDragLeave));
1061 
1062     AddDragFrameNodeToManager();
1063 }
1064 
SetOnDragMove(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDragMove)1065 void ViewAbstract::SetOnDragMove(
1066     std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDragMove)
1067 {
1068     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1069     CHECK_NULL_VOID(eventHub);
1070     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_MOVE, std::move(onDragMove));
1071 
1072     AddDragFrameNodeToManager();
1073 }
1074 
SetOnDrop(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &,const std::string &)> && onDrop)1075 void ViewAbstract::SetOnDrop(std::function<void(const RefPtr<OHOS::Ace::DragEvent> &, const std::string &)> &&onDrop)
1076 {
1077     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1078     CHECK_NULL_VOID(eventHub);
1079     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_DROP, std::move(onDrop));
1080 
1081     AddDragFrameNodeToManager();
1082 }
1083 
SetOnDragEnd(std::function<void (const RefPtr<OHOS::Ace::DragEvent> &)> && onDragEnd)1084 void ViewAbstract::SetOnDragEnd(std::function<void(const RefPtr<OHOS::Ace::DragEvent> &)> &&onDragEnd)
1085 {
1086     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
1087     CHECK_NULL_VOID(eventHub);
1088     eventHub->SetCustomerOnDragFunc(DragFuncType::DRAG_END, std::move(onDragEnd));
1089 
1090     AddDragFrameNodeToManager();
1091 }
1092 
SetAlign(Alignment alignment)1093 void ViewAbstract::SetAlign(Alignment alignment)
1094 {
1095     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1096         return;
1097     }
1098     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment);
1099 }
1100 
SetAlign(FrameNode * frameNode,Alignment alignment)1101 void ViewAbstract::SetAlign(FrameNode *frameNode, Alignment alignment)
1102 {
1103     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment, frameNode);
1104 }
1105 
SetVisibility(VisibleType visible)1106 void ViewAbstract::SetVisibility(VisibleType visible)
1107 {
1108     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1109         return;
1110     }
1111     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1112     CHECK_NULL_VOID(frameNode);
1113     auto layoutProperty = frameNode->GetLayoutProperty();
1114     if (layoutProperty) {
1115         layoutProperty->UpdateVisibility(visible, true);
1116     }
1117 
1118     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
1119     if (focusHub) {
1120         focusHub->SetShow(visible == VisibleType::VISIBLE);
1121     }
1122 }
1123 
SetGeometryTransition(const std::string & id,bool followWithoutTransition)1124 void ViewAbstract::SetGeometryTransition(const std::string &id, bool followWithoutTransition)
1125 {
1126     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1127     CHECK_NULL_VOID(frameNode);
1128     auto layoutProperty = frameNode->GetLayoutProperty();
1129     if (layoutProperty) {
1130         layoutProperty->UpdateGeometryTransition(id, followWithoutTransition);
1131     }
1132 }
1133 
SetGeometryTransition(FrameNode * frameNode,const std::string & id,bool followWithoutTransition)1134 void ViewAbstract::SetGeometryTransition(FrameNode *frameNode, const std::string &id, bool followWithoutTransition)
1135 {
1136     CHECK_NULL_VOID(frameNode);
1137     auto layoutProperty = frameNode->GetLayoutProperty();
1138     if (layoutProperty) {
1139         layoutProperty->UpdateGeometryTransition(id, followWithoutTransition);
1140     }
1141 }
1142 
SetOpacity(double opacity)1143 void ViewAbstract::SetOpacity(double opacity)
1144 {
1145     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1146         return;
1147     }
1148     ACE_UPDATE_RENDER_CONTEXT(Opacity, opacity);
1149 }
SetAllowDrop(const std::set<std::string> & allowDrop)1150 void ViewAbstract::SetAllowDrop(const std::set<std::string> &allowDrop)
1151 {
1152     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1153     CHECK_NULL_VOID(frameNode);
1154     frameNode->SetAllowDrop(allowDrop);
1155 }
1156 
SetDragPreview(const NG::DragDropInfo & info)1157 void ViewAbstract::SetDragPreview(const NG::DragDropInfo& info)
1158 {
1159     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1160     CHECK_NULL_VOID(frameNode);
1161     frameNode->SetDragPreview(info);
1162 }
1163 
SetPosition(const OffsetT<Dimension> & value)1164 void ViewAbstract::SetPosition(const OffsetT<Dimension> &value)
1165 {
1166     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1167         return;
1168     }
1169     ACE_UPDATE_RENDER_CONTEXT(Position, value);
1170 }
1171 
SetOffset(const OffsetT<Dimension> & value)1172 void ViewAbstract::SetOffset(const OffsetT<Dimension> &value)
1173 {
1174     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1175         return;
1176     }
1177     ACE_UPDATE_RENDER_CONTEXT(Offset, value);
1178 }
1179 
MarkAnchor(const OffsetT<Dimension> & value)1180 void ViewAbstract::MarkAnchor(const OffsetT<Dimension> &value)
1181 {
1182     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1183         return;
1184     }
1185     ACE_UPDATE_RENDER_CONTEXT(Anchor, value);
1186 }
1187 
SetZIndex(int32_t value)1188 void ViewAbstract::SetZIndex(int32_t value)
1189 {
1190     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1191         return;
1192     }
1193     ACE_UPDATE_RENDER_CONTEXT(ZIndex, value);
1194 }
1195 
SetScale(const NG::VectorF & value)1196 void ViewAbstract::SetScale(const NG::VectorF &value)
1197 {
1198     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1199         return;
1200     }
1201     ACE_UPDATE_RENDER_CONTEXT(TransformScale, value);
1202 }
1203 
SetScale(FrameNode * frameNode,const NG::VectorF & value)1204 void ViewAbstract::SetScale(FrameNode *frameNode, const NG::VectorF &value)
1205 {
1206     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformScale, value, frameNode);
1207 }
1208 
SetPivot(const DimensionOffset & value)1209 void ViewAbstract::SetPivot(const DimensionOffset &value)
1210 {
1211     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1212         return;
1213     }
1214     ACE_UPDATE_RENDER_CONTEXT(TransformCenter, value);
1215 }
1216 
SetPivot(FrameNode * frameNode,const DimensionOffset & value)1217 void ViewAbstract::SetPivot(FrameNode *frameNode, const DimensionOffset &value)
1218 {
1219     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformCenter, value, frameNode);
1220 }
1221 
SetTranslate(const NG::TranslateOptions & value)1222 void ViewAbstract::SetTranslate(const NG::TranslateOptions &value)
1223 {
1224     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1225         return;
1226     }
1227     ACE_UPDATE_RENDER_CONTEXT(TransformTranslate, value);
1228 }
1229 
SetTranslate(FrameNode * frameNode,const NG::TranslateOptions & value)1230 void ViewAbstract::SetTranslate(FrameNode *frameNode, const NG::TranslateOptions &value)
1231 {
1232     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformTranslate, value, frameNode);
1233 }
1234 
SetRotate(const NG::Vector5F & value)1235 void ViewAbstract::SetRotate(const NG::Vector5F &value)
1236 {
1237     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1238         return;
1239     }
1240     ACE_UPDATE_RENDER_CONTEXT(TransformRotate, value);
1241 }
1242 
SetRotate(FrameNode * frameNode,const NG::Vector5F & value)1243 void ViewAbstract::SetRotate(FrameNode *frameNode, const NG::Vector5F &value)
1244 {
1245     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformRotate, value, frameNode);
1246 }
1247 
SetTransformMatrix(const Matrix4 & matrix)1248 void ViewAbstract::SetTransformMatrix(const Matrix4 &matrix)
1249 {
1250     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1251         return;
1252     }
1253     ACE_UPDATE_RENDER_CONTEXT(TransformMatrix, matrix);
1254 }
1255 
BindPopup(const RefPtr<PopupParam> & param,const RefPtr<FrameNode> & targetNode,const RefPtr<UINode> & customNode)1256 void ViewAbstract::BindPopup(const RefPtr<PopupParam> &param, const RefPtr<FrameNode> &targetNode,
1257     const RefPtr<UINode> &customNode)
1258 {
1259     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind popup enter");
1260     CHECK_NULL_VOID(targetNode);
1261     auto targetId = targetNode->GetId();
1262     auto targetTag = targetNode->GetTag();
1263     auto container = Container::Current();
1264     CHECK_NULL_VOID(container);
1265     auto pipelineContext = container->GetPipelineContext();
1266     CHECK_NULL_VOID(pipelineContext);
1267     auto context = AceType::DynamicCast<NG::PipelineContext>(pipelineContext);
1268     CHECK_NULL_VOID(context);
1269     auto overlayManager = context->GetOverlayManager();
1270     CHECK_NULL_VOID(overlayManager);
1271     auto popupInfo = overlayManager->GetPopupInfo(targetId);
1272     auto isShow = param->IsShow();
1273     auto isUseCustom = param->IsUseCustom();
1274     auto showInSubWindow = param->IsShowInSubWindow();
1275     popupInfo.focusable = param->GetFocusable();
1276     // subwindow model needs to use subContainer to get popupInfo
1277     if (showInSubWindow) {
1278         auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(Container::CurrentId());
1279         if (subwindow) {
1280             subwindow->GetPopupInfoNG(targetId, popupInfo);
1281         }
1282     }
1283 
1284     auto popupId = popupInfo.popupId;
1285     auto popupNode = popupInfo.popupNode;
1286     RefPtr<BubblePattern> popupPattern;
1287     if (popupNode) {
1288         popupPattern = popupNode->GetPattern<BubblePattern>();
1289     }
1290 
1291     if (popupInfo.isCurrentOnShow) {
1292         // Entering / Normal / Exiting
1293         bool popupShowing = popupPattern ? popupPattern->IsOnShow() : false;
1294         popupInfo.markNeedUpdate = popupShowing || !isShow;
1295     } else {
1296         // Invisable
1297         if (!isShow) {
1298             TAG_LOGW(AceLogTag::ACE_DIALOG, "get isShow failed");
1299             return;
1300         }
1301         popupInfo.markNeedUpdate = true;
1302     }
1303 
1304     // Create new popup.
1305     if (popupInfo.popupId == -1 || !popupNode) {
1306         if (!isUseCustom) {
1307             popupNode = BubbleView::CreateBubbleNode(targetTag, targetId, param);
1308         } else {
1309             CHECK_NULL_VOID(customNode);
1310             popupNode = BubbleView::CreateCustomBubbleNode(targetTag, targetId, customNode, param);
1311         }
1312         if (popupNode) {
1313             popupId = popupNode->GetId();
1314         }
1315         if (!showInSubWindow) {
1316             // erase popup when target node destroy
1317             auto destructor = [id = targetNode->GetId()]() {
1318                 auto pipeline = NG::PipelineContext::GetCurrentContext();
1319                 CHECK_NULL_VOID(pipeline);
1320                 auto overlayManager = pipeline->GetOverlayManager();
1321                 CHECK_NULL_VOID(overlayManager);
1322                 overlayManager->ErasePopup(id);
1323                 SubwindowManager::GetInstance()->HideSubWindowNG();
1324             };
1325             targetNode->PushDestroyCallback(destructor);
1326         } else {
1327             // erase popup in subwindow when target node destroy
1328             auto destructor = [id = targetNode->GetId(), containerId = Container::CurrentId()]() {
1329                 auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(containerId);
1330                 CHECK_NULL_VOID(subwindow);
1331                 auto overlayManager = subwindow->GetOverlayManager();
1332                 CHECK_NULL_VOID(overlayManager);
1333                 overlayManager->ErasePopup(id);
1334                 SubwindowManager::GetInstance()->HideSubWindowNG();
1335             };
1336             targetNode->PushDestroyCallback(destructor);
1337         }
1338     } else {
1339         // use param to update PopupParm
1340         if (!isUseCustom) {
1341             BubbleView::UpdatePopupParam(popupId, param, targetNode);
1342             popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1343         } else {
1344             BubbleView::UpdateCustomPopupParam(popupId, param);
1345             popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
1346         }
1347     }
1348     // update PopupInfo props
1349     popupInfo.popupId = popupId;
1350     popupInfo.popupNode = popupNode;
1351     popupInfo.isBlockEvent = param->IsBlockEvent();
1352     if (popupNode) {
1353         popupNode->MarkModifyDone();
1354         popupPattern = popupNode->GetPattern<BubblePattern>();
1355     }
1356     popupInfo.target = AceType::WeakClaim(AceType::RawPtr(targetNode));
1357     popupInfo.targetSize = SizeF(param->GetTargetSize().Width(), param->GetTargetSize().Height());
1358     popupInfo.targetOffset = OffsetF(param->GetTargetOffset().GetX(), param->GetTargetOffset().GetY());
1359     if (showInSubWindow) {
1360         if (isShow) {
1361             SubwindowManager::GetInstance()->ShowPopupNG(targetId, popupInfo);
1362         } else {
1363             SubwindowManager::GetInstance()->HidePopupNG(targetId);
1364         }
1365         return;
1366     }
1367     if (!popupInfo.isCurrentOnShow) {
1368         targetNode->OnAccessibilityEvent(AccessibilityEventType::CHANGE,
1369             WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
1370     }
1371     if (isShow) {
1372         if (popupInfo.isCurrentOnShow != isShow) {
1373             overlayManager->ShowPopup(targetId, popupInfo);
1374         }
1375     } else {
1376         overlayManager->HidePopup(targetId, popupInfo);
1377     }
1378 }
1379 
BindMenuWithItems(std::vector<OptionParam> && params,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,const MenuParam & menuParam)1380 void ViewAbstract::BindMenuWithItems(std::vector<OptionParam> &&params, const RefPtr<FrameNode> &targetNode,
1381     const NG::OffsetF &offset, const MenuParam &menuParam)
1382 {
1383     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with items enter");
1384     CHECK_NULL_VOID(targetNode);
1385 
1386     if (params.empty()) {
1387         return;
1388     }
1389     auto menuNode =
1390         MenuView::Create(std::move(params), targetNode->GetId(), targetNode->GetTag(), MenuType::MENU, menuParam);
1391     RegisterMenuCallback(menuNode, menuParam);
1392     auto pipeline = PipelineBase::GetCurrentContext();
1393     CHECK_NULL_VOID(pipeline);
1394     auto theme = pipeline->GetTheme<SelectTheme>();
1395     CHECK_NULL_VOID(theme);
1396     auto expandDisplay = theme->GetExpandDisplay();
1397     if (expandDisplay && menuParam.isShowInSubWindow && targetNode->GetTag() != V2::SELECT_ETS_TAG) {
1398         SubwindowManager::GetInstance()->ShowMenuNG(menuNode, targetNode->GetId(), offset, menuParam.isAboveApps);
1399         return;
1400     }
1401     BindMenu(menuNode, targetNode->GetId(), offset);
1402 }
1403 
BindMenuWithCustomNode(const RefPtr<UINode> & customNode,const RefPtr<FrameNode> & targetNode,const NG::OffsetF & offset,const MenuParam & menuParam,const RefPtr<UINode> & previewCustomNode)1404 void ViewAbstract::BindMenuWithCustomNode(const RefPtr<UINode>& customNode, const RefPtr<FrameNode>& targetNode,
1405     const NG::OffsetF& offset, const MenuParam& menuParam, const RefPtr<UINode>& previewCustomNode)
1406 {
1407     TAG_LOGD(AceLogTag::ACE_DIALOG, "bind menu with custom node enter");
1408     auto pipeline = PipelineBase::GetCurrentContext();
1409     CHECK_NULL_VOID(pipeline);
1410     auto theme = pipeline->GetTheme<SelectTheme>();
1411     CHECK_NULL_VOID(theme);
1412     auto expandDisplay = theme->GetExpandDisplay();
1413     CHECK_NULL_VOID(customNode);
1414     CHECK_NULL_VOID(targetNode);
1415     auto menuNode =
1416         MenuView::Create(customNode, targetNode->GetId(), targetNode->GetTag(), menuParam, true, previewCustomNode);
1417     RegisterMenuCallback(menuNode, menuParam);
1418     if (menuParam.type == MenuType::CONTEXT_MENU) {
1419         SubwindowManager::GetInstance()->ShowMenuNG(menuNode, targetNode->GetId(), offset, menuParam.isAboveApps);
1420         return;
1421     }
1422     if (menuParam.type == MenuType::MENU && expandDisplay && menuParam.isShowInSubWindow &&
1423         targetNode->GetTag() != V2::SELECT_ETS_TAG) {
1424         bool isShown = SubwindowManager::GetInstance()->GetShown();
1425         if (!isShown) {
1426             SubwindowManager::GetInstance()->ShowMenuNG(menuNode, targetNode->GetId(), offset, menuParam.isAboveApps);
1427         } else {
1428             SubwindowManager::GetInstance()->HideMenuNG(menuNode, targetNode->GetId());
1429         }
1430         return;
1431     }
1432     BindMenu(menuNode, targetNode->GetId(), offset);
1433 }
1434 
ShowMenu(int32_t targetId,const NG::OffsetF & offset,bool isShowInSubWindow,bool isContextMenu)1435 void ViewAbstract::ShowMenu(int32_t targetId, const NG::OffsetF &offset, bool isShowInSubWindow, bool isContextMenu)
1436 {
1437     TAG_LOGD(AceLogTag::ACE_DIALOG, "show menu enter");
1438     auto pipeline = PipelineBase::GetCurrentContext();
1439     CHECK_NULL_VOID(pipeline);
1440     auto theme = pipeline->GetTheme<SelectTheme>();
1441     CHECK_NULL_VOID(theme);
1442     auto expandDisplay = theme->GetExpandDisplay();
1443     if (isContextMenu || (expandDisplay && isShowInSubWindow)) {
1444         SubwindowManager::GetInstance()->ShowMenuNG(nullptr, targetId, offset);
1445         return;
1446     }
1447     auto container = Container::Current();
1448     CHECK_NULL_VOID(container);
1449     auto pipelineContext = container->GetPipelineContext();
1450     CHECK_NULL_VOID(pipelineContext);
1451     auto context = AceType::DynamicCast<NG::PipelineContext>(pipelineContext);
1452     CHECK_NULL_VOID(context);
1453     auto overlayManager = context->GetOverlayManager();
1454     CHECK_NULL_VOID(overlayManager);
1455 
1456     overlayManager->ShowMenu(targetId, offset, nullptr);
1457 }
1458 
SetBackdropBlur(const Dimension & radius,const BlurOption & blurOption)1459 void ViewAbstract::SetBackdropBlur(const Dimension &radius, const BlurOption &blurOption)
1460 {
1461     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1462         return;
1463     }
1464     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1465     CHECK_NULL_VOID(frameNode);
1466     auto target = frameNode->GetRenderContext();
1467     if (target) {
1468         if (target->GetBackgroundEffect().has_value()) {
1469             target->UpdateBackgroundEffect(std::nullopt);
1470         }
1471         target->UpdateBackBlur(radius, blurOption);
1472         if (target->GetBackBlurStyle().has_value()) {
1473             target->UpdateBackBlurStyle(std::nullopt);
1474         }
1475     }
1476 }
1477 
SetBackdropBlur(FrameNode * frameNode,const Dimension & radius)1478 void ViewAbstract::SetBackdropBlur(FrameNode *frameNode, const Dimension &radius)
1479 {
1480     CHECK_NULL_VOID(frameNode);
1481     auto target = frameNode->GetRenderContext();
1482     if (target) {
1483         if (target->GetBackgroundEffect().has_value()) {
1484             target->UpdateBackgroundEffect(std::nullopt);
1485         }
1486         target->UpdateBackBlurRadius(radius);
1487         if (target->GetBackBlurStyle().has_value()) {
1488             target->UpdateBackBlurStyle(std::nullopt);
1489         }
1490     }
1491 }
1492 
SetLinearGradientBlur(const NG::LinearGradientBlurPara & blurPara)1493 void ViewAbstract::SetLinearGradientBlur(const NG::LinearGradientBlurPara& blurPara)
1494 {
1495     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1496         return;
1497     }
1498     ACE_UPDATE_RENDER_CONTEXT(LinearGradientBlur, blurPara);
1499 }
1500 
SetDynamicLightUp(float rate,float lightUpDegree)1501 void ViewAbstract::SetDynamicLightUp(float rate, float lightUpDegree)
1502 {
1503     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1504         return;
1505     }
1506     ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpRate, rate);
1507     ACE_UPDATE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree);
1508 }
1509 
SetFrontBlur(const Dimension & radius,const BlurOption & blurOption)1510 void ViewAbstract::SetFrontBlur(const Dimension &radius, const BlurOption &blurOption)
1511 {
1512     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1513         return;
1514     }
1515     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1516     CHECK_NULL_VOID(frameNode);
1517     auto target = frameNode->GetRenderContext();
1518     if (target) {
1519         target->UpdateFrontBlur(radius, blurOption);
1520         if (target->GetFrontBlurStyle().has_value()) {
1521             target->UpdateFrontBlurStyle(std::nullopt);
1522         }
1523     }
1524 }
1525 
SetFrontBlur(FrameNode * frameNode,const Dimension & radius)1526 void ViewAbstract::SetFrontBlur(FrameNode *frameNode, const Dimension &radius)
1527 {
1528     CHECK_NULL_VOID(frameNode);
1529     auto target = frameNode->GetRenderContext();
1530     if (target) {
1531         target->UpdateFrontBlurRadius(radius);
1532         if (target->GetFrontBlurStyle().has_value()) {
1533             target->UpdateFrontBlurStyle(std::nullopt);
1534         }
1535     }
1536 }
1537 
SetBackShadow(const Shadow & shadow)1538 void ViewAbstract::SetBackShadow(const Shadow &shadow)
1539 {
1540     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1541         return;
1542     }
1543     ACE_UPDATE_RENDER_CONTEXT(BackShadow, shadow);
1544 }
1545 
SetBackShadow(FrameNode * frameNode,const Shadow & shadow)1546 void ViewAbstract::SetBackShadow(FrameNode *frameNode, const Shadow &shadow)
1547 {
1548     ACE_UPDATE_NODE_RENDER_CONTEXT(BackShadow, shadow, frameNode);
1549 }
1550 
SetBlendMode(BlendMode blendMode)1551 void ViewAbstract::SetBlendMode(BlendMode blendMode)
1552 {
1553     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1554         return;
1555     }
1556     ACE_UPDATE_RENDER_CONTEXT(BackBlendMode, blendMode);
1557 }
1558 
SetBlendApplyType(BlendApplyType blendApplyType)1559 void ViewAbstract::SetBlendApplyType(BlendApplyType blendApplyType)
1560 {
1561     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1562         return;
1563     }
1564     ACE_UPDATE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType);
1565 }
1566 
SetLinearGradient(const NG::Gradient & gradient)1567 void ViewAbstract::SetLinearGradient(const NG::Gradient &gradient)
1568 {
1569     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1570         return;
1571     }
1572     ACE_UPDATE_RENDER_CONTEXT(LinearGradient, gradient);
1573 }
1574 
SetSweepGradient(const NG::Gradient & gradient)1575 void ViewAbstract::SetSweepGradient(const NG::Gradient &gradient)
1576 {
1577     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1578         return;
1579     }
1580     ACE_UPDATE_RENDER_CONTEXT(SweepGradient, gradient);
1581 }
1582 
SetRadialGradient(const NG::Gradient & gradient)1583 void ViewAbstract::SetRadialGradient(const NG::Gradient &gradient)
1584 {
1585     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1586         return;
1587     }
1588     ACE_UPDATE_RENDER_CONTEXT(RadialGradient, gradient);
1589 }
1590 
SetInspectorId(const std::string & inspectorId)1591 void ViewAbstract::SetInspectorId(const std::string &inspectorId)
1592 {
1593     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
1594     if (uiNode) {
1595         uiNode->UpdateInspectorId(inspectorId);
1596     }
1597 }
1598 
SetAutoEventParam(const std::string & param)1599 void ViewAbstract::SetAutoEventParam(const std::string& param)
1600 {
1601     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
1602     if (uiNode) {
1603         uiNode->UpdateAutoEventParam(param);
1604     }
1605 }
1606 
SetRestoreId(int32_t restoreId)1607 void ViewAbstract::SetRestoreId(int32_t restoreId)
1608 {
1609     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
1610     if (uiNode) {
1611         uiNode->SetRestoreId(restoreId);
1612     }
1613 }
1614 
SetDebugLine(const std::string & line)1615 void ViewAbstract::SetDebugLine(const std::string &line)
1616 {
1617     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
1618     if (uiNode) {
1619         uiNode->SetDebugLine(line);
1620     }
1621 }
1622 
SetGrid(std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)1623 void ViewAbstract::SetGrid(std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
1624 {
1625     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1626     CHECK_NULL_VOID(frameNode);
1627     auto layoutProperty = frameNode->GetLayoutProperty();
1628     CHECK_NULL_VOID(layoutProperty);
1629     // frame node is mounted to parent when pop from stack later, no grid-container is added here
1630     layoutProperty->UpdateGridProperty(span, offset, type);
1631 }
1632 
Pop()1633 void ViewAbstract::Pop()
1634 {
1635     ViewStackProcessor::GetInstance()->Pop();
1636 }
1637 
SetTransition(const TransitionOptions & options)1638 void ViewAbstract::SetTransition(const TransitionOptions &options)
1639 {
1640     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1641         return;
1642     }
1643     ACE_UPDATE_RENDER_CONTEXT(Transition, options);
1644 }
1645 
SetChainedTransition(const RefPtr<NG::ChainedTransitionEffect> & effect)1646 void ViewAbstract::SetChainedTransition(const RefPtr<NG::ChainedTransitionEffect> &effect)
1647 {
1648     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1649         return;
1650     }
1651     ACE_UPDATE_RENDER_CONTEXT(ChainedTransition, effect);
1652 }
1653 
SetClipShape(const RefPtr<BasicShape> & basicShape)1654 void ViewAbstract::SetClipShape(const RefPtr<BasicShape> &basicShape)
1655 {
1656     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1657         return;
1658     }
1659     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1660     CHECK_NULL_VOID(frameNode);
1661     auto target = frameNode->GetRenderContext();
1662     if (target) {
1663         if (target->GetClipEdge().has_value()) {
1664             target->UpdateClipEdge(false);
1665         }
1666         target->UpdateClipShape(basicShape);
1667     }
1668 }
1669 
SetClipShape(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)1670 void ViewAbstract::SetClipShape(FrameNode *frameNode, const RefPtr<BasicShape> &basicShape)
1671 {
1672     CHECK_NULL_VOID(frameNode);
1673     auto target = frameNode->GetRenderContext();
1674     if (target) {
1675         if (target->GetClipEdge().has_value()) {
1676             target->UpdateClipEdge(false);
1677         }
1678         target->UpdateClipShape(basicShape);
1679     }
1680 }
1681 
SetClipEdge(bool isClip)1682 void ViewAbstract::SetClipEdge(bool isClip)
1683 {
1684     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1685         return;
1686     }
1687     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1688     CHECK_NULL_VOID(frameNode);
1689     auto target = frameNode->GetRenderContext();
1690     if (target) {
1691         if (target->GetClipShape().has_value()) {
1692             target->ResetClipShape();
1693             target->OnClipShapeUpdate(nullptr);
1694         }
1695         target->UpdateClipEdge(isClip);
1696     }
1697 }
1698 
SetClipEdge(FrameNode * frameNode,bool isClip)1699 void ViewAbstract::SetClipEdge(FrameNode *frameNode, bool isClip)
1700 {
1701     CHECK_NULL_VOID(frameNode);
1702     auto target = frameNode->GetRenderContext();
1703     if (target) {
1704         if (target->GetClipShape().has_value()) {
1705             target->ResetClipShape();
1706             target->OnClipShapeUpdate(nullptr);
1707         }
1708         target->UpdateClipEdge(isClip);
1709     }
1710 }
1711 
SetMask(const RefPtr<BasicShape> & basicShape)1712 void ViewAbstract::SetMask(const RefPtr<BasicShape> &basicShape)
1713 {
1714     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1715         return;
1716     }
1717     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1718     CHECK_NULL_VOID(frameNode);
1719     auto target = frameNode->GetRenderContext();
1720     if (target) {
1721         if (target->HasProgressMask()) {
1722             target->ResetProgressMask();
1723             target->OnProgressMaskUpdate(nullptr);
1724         }
1725         target->UpdateClipMask(basicShape);
1726     }
1727 }
1728 
SetProgressMask(const RefPtr<ProgressMaskProperty> & progress)1729 void ViewAbstract::SetProgressMask(const RefPtr<ProgressMaskProperty> &progress)
1730 {
1731     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1732         return;
1733     }
1734     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1735     CHECK_NULL_VOID(frameNode);
1736     auto target = frameNode->GetRenderContext();
1737     if (target) {
1738         if (target->HasClipMask()) {
1739             target->ResetClipMask();
1740             target->OnClipMaskUpdate(nullptr);
1741         }
1742         target->UpdateProgressMask(progress);
1743     }
1744 }
1745 
SetBrightness(const Dimension & brightness)1746 void ViewAbstract::SetBrightness(const Dimension &brightness)
1747 {
1748     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1749         return;
1750     }
1751     ACE_UPDATE_RENDER_CONTEXT(FrontBrightness, brightness);
1752 }
1753 
SetBrightness(FrameNode * frameNode,const Dimension & brightness)1754 void ViewAbstract::SetBrightness(FrameNode *frameNode, const Dimension &brightness)
1755 {
1756     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontBrightness, brightness, frameNode);
1757 }
1758 
SetGrayScale(const Dimension & grayScale)1759 void ViewAbstract::SetGrayScale(const Dimension &grayScale)
1760 {
1761     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1762         return;
1763     }
1764     ACE_UPDATE_RENDER_CONTEXT(FrontGrayScale, grayScale);
1765 }
1766 
SetGrayScale(FrameNode * frameNode,const Dimension & grayScale)1767 void ViewAbstract::SetGrayScale(FrameNode *frameNode, const Dimension &grayScale)
1768 {
1769     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontGrayScale, grayScale, frameNode);
1770 }
1771 
SetContrast(const Dimension & contrast)1772 void ViewAbstract::SetContrast(const Dimension &contrast)
1773 {
1774     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1775         return;
1776     }
1777     ACE_UPDATE_RENDER_CONTEXT(FrontContrast, contrast);
1778 }
1779 
SetContrast(FrameNode * frameNode,const Dimension & contrast)1780 void ViewAbstract::SetContrast(FrameNode *frameNode, const Dimension &contrast)
1781 {
1782     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontContrast, contrast, frameNode);
1783 }
1784 
SetSaturate(const Dimension & saturate)1785 void ViewAbstract::SetSaturate(const Dimension &saturate)
1786 {
1787     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1788         return;
1789     }
1790     ACE_UPDATE_RENDER_CONTEXT(FrontSaturate, saturate);
1791 }
1792 
SetSaturate(FrameNode * frameNode,const Dimension & saturate)1793 void ViewAbstract::SetSaturate(FrameNode *frameNode, const Dimension &saturate)
1794 {
1795     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSaturate, saturate, frameNode);
1796 }
1797 
SetSepia(const Dimension & sepia)1798 void ViewAbstract::SetSepia(const Dimension &sepia)
1799 {
1800     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1801         return;
1802     }
1803     ACE_UPDATE_RENDER_CONTEXT(FrontSepia, sepia);
1804 }
1805 
SetSepia(FrameNode * frameNode,const Dimension & sepia)1806 void ViewAbstract::SetSepia(FrameNode *frameNode, const Dimension &sepia)
1807 {
1808     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontSepia, sepia, frameNode);
1809 }
1810 
SetInvert(const InvertVariant & invert)1811 void ViewAbstract::SetInvert(const InvertVariant &invert)
1812 {
1813     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1814         return;
1815     }
1816     ACE_UPDATE_RENDER_CONTEXT(FrontInvert, invert);
1817 }
1818 
SetInvert(FrameNode * frameNode,const InvertVariant & invert)1819 void ViewAbstract::SetInvert(FrameNode *frameNode, const InvertVariant &invert)
1820 {
1821     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontInvert, invert, frameNode);
1822 }
1823 
SetSystemBarEffect(bool systemBarEffect)1824 void ViewAbstract::SetSystemBarEffect(bool systemBarEffect)
1825 {
1826     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1827         return;
1828     }
1829     ACE_UPDATE_RENDER_CONTEXT(SystemBarEffect, systemBarEffect);
1830 }
1831 
SetHueRotate(float hueRotate)1832 void ViewAbstract::SetHueRotate(float hueRotate)
1833 {
1834     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1835         return;
1836     }
1837     ACE_UPDATE_RENDER_CONTEXT(FrontHueRotate, hueRotate);
1838 }
1839 
SetHueRotate(FrameNode * frameNode,float hueRotate)1840 void ViewAbstract::SetHueRotate(FrameNode *frameNode, float hueRotate)
1841 {
1842     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontHueRotate, hueRotate, frameNode);
1843 }
1844 
SetColorBlend(const Color & colorBlend)1845 void ViewAbstract::SetColorBlend(const Color &colorBlend)
1846 {
1847     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1848         return;
1849     }
1850     ACE_UPDATE_RENDER_CONTEXT(FrontColorBlend, colorBlend);
1851 }
1852 
SetColorBlend(FrameNode * frameNode,const Color & colorBlend)1853 void ViewAbstract::SetColorBlend(FrameNode *frameNode, const Color &colorBlend)
1854 {
1855     ACE_UPDATE_NODE_RENDER_CONTEXT(FrontColorBlend, colorBlend, frameNode);
1856 }
1857 
SetBorderImage(const RefPtr<BorderImage> & borderImage)1858 void ViewAbstract::SetBorderImage(const RefPtr<BorderImage> &borderImage)
1859 {
1860     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1861         return;
1862     }
1863     ACE_UPDATE_RENDER_CONTEXT(BorderImage, borderImage);
1864 }
1865 
SetBorderImageSource(const std::string & bdImageSrc)1866 void ViewAbstract::SetBorderImageSource(const std::string &bdImageSrc)
1867 {
1868     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1869         return;
1870     }
1871     ImageSourceInfo imageSourceInfo(bdImageSrc);
1872     ACE_UPDATE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo);
1873 }
1874 
SetHasBorderImageSlice(bool tag)1875 void ViewAbstract::SetHasBorderImageSlice(bool tag)
1876 {
1877     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1878         return;
1879     }
1880     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageSlice, tag);
1881 }
1882 
SetHasBorderImageWidth(bool tag)1883 void ViewAbstract::SetHasBorderImageWidth(bool tag)
1884 {
1885     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1886         return;
1887     }
1888     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageWidth, tag);
1889 }
1890 
SetHasBorderImageOutset(bool tag)1891 void ViewAbstract::SetHasBorderImageOutset(bool tag)
1892 {
1893     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1894         return;
1895     }
1896     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageOutset, tag);
1897 }
1898 
SetHasBorderImageRepeat(bool tag)1899 void ViewAbstract::SetHasBorderImageRepeat(bool tag)
1900 {
1901     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1902         return;
1903     }
1904     ACE_UPDATE_RENDER_CONTEXT(HasBorderImageRepeat, tag);
1905 }
1906 
SetBorderImageGradient(const Gradient & gradient)1907 void ViewAbstract::SetBorderImageGradient(const Gradient &gradient)
1908 {
1909     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1910         return;
1911     }
1912     ACE_UPDATE_RENDER_CONTEXT(BorderImageGradient, gradient);
1913 }
1914 
SetOverlay(const OverlayOptions & overlay)1915 void ViewAbstract::SetOverlay(const OverlayOptions &overlay)
1916 {
1917     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1918         return;
1919     }
1920     ACE_UPDATE_RENDER_CONTEXT(OverlayText, overlay);
1921 }
1922 
SetMotionPath(const MotionPathOption & motionPath)1923 void ViewAbstract::SetMotionPath(const MotionPathOption &motionPath)
1924 {
1925     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1926         return;
1927     }
1928     ACE_UPDATE_RENDER_CONTEXT(MotionPath, motionPath);
1929 }
1930 
SetSharedTransition(const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)1931 void ViewAbstract::SetSharedTransition(const std::string &shareId,
1932     const std::shared_ptr<SharedTransitionOption> &option)
1933 {
1934     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
1935     CHECK_NULL_VOID(frameNode);
1936     auto target = frameNode->GetRenderContext();
1937     if (target) {
1938         target->SetSharedTransitionOptions(option);
1939         target->SetShareId(shareId);
1940     }
1941 }
1942 
SetMask(FrameNode * frameNode,const RefPtr<BasicShape> & basicShape)1943 void ViewAbstract::SetMask(FrameNode* frameNode, const RefPtr<BasicShape>& basicShape)
1944 {
1945     CHECK_NULL_VOID(frameNode);
1946     auto target = frameNode->GetRenderContext();
1947     if (target) {
1948         if (target->HasProgressMask()) {
1949             target->ResetProgressMask();
1950             target->OnProgressMaskUpdate(nullptr);
1951         }
1952         target->UpdateClipMask(basicShape);
1953     }
1954 }
1955 
SetProgressMask(FrameNode * frameNode,const RefPtr<ProgressMaskProperty> & progress)1956 void ViewAbstract::SetProgressMask(FrameNode* frameNode, const RefPtr<ProgressMaskProperty>& progress)
1957 {
1958     CHECK_NULL_VOID(frameNode);
1959     auto target = frameNode->GetRenderContext();
1960     if (target) {
1961         if (target->HasClipMask()) {
1962             target->ResetClipMask();
1963             target->OnClipMaskUpdate(nullptr);
1964         }
1965         target->UpdateProgressMask(progress);
1966     }
1967 }
1968 
SetUseEffect(bool useEffect)1969 void ViewAbstract::SetUseEffect(bool useEffect)
1970 {
1971     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1972         return;
1973     }
1974     ACE_UPDATE_RENDER_CONTEXT(UseEffect, useEffect);
1975 }
1976 
SetFreeze(bool freeze)1977 void ViewAbstract::SetFreeze(bool freeze)
1978 {
1979     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1980         return;
1981     }
1982     ACE_UPDATE_RENDER_CONTEXT(Freeze, freeze);
1983 }
1984 
SetUseShadowBatching(bool useShadowBatching)1985 void ViewAbstract::SetUseShadowBatching(bool useShadowBatching)
1986 {
1987     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1988         return;
1989     }
1990     ACE_UPDATE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching);
1991 }
1992 
SetForegroundColor(const Color & color)1993 void ViewAbstract::SetForegroundColor(const Color &color)
1994 {
1995     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
1996         return;
1997     }
1998     ACE_UPDATE_RENDER_CONTEXT(ForegroundColor, color);
1999     ACE_RESET_RENDER_CONTEXT(RenderContext, ForegroundColorStrategy);
2000     ACE_UPDATE_RENDER_CONTEXT(ForegroundColorFlag, true);
2001 }
2002 
SetForegroundColorStrategy(const ForegroundColorStrategy & strategy)2003 void ViewAbstract::SetForegroundColorStrategy(const ForegroundColorStrategy &strategy)
2004 {
2005     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2006         return;
2007     }
2008     ACE_UPDATE_RENDER_CONTEXT(ForegroundColorStrategy, strategy);
2009     ACE_RESET_RENDER_CONTEXT(RenderContext, ForegroundColor);
2010     ACE_UPDATE_RENDER_CONTEXT(ForegroundColorFlag, true);
2011 }
2012 
SetKeyboardShortcut(const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)2013 void ViewAbstract::SetKeyboardShortcut(const std::string &value, const std::vector<ModifierKey> &keys,
2014     std::function<void()> &&onKeyboardShortcutAction)
2015 {
2016     auto pipeline = PipelineContext::GetCurrentContext();
2017     CHECK_NULL_VOID(pipeline);
2018     auto eventManager = pipeline->GetEventManager();
2019     CHECK_NULL_VOID(eventManager);
2020     auto eventHub = ViewStackProcessor::GetInstance()->GetMainFrameNodeEventHub<EventHub>();
2021     CHECK_NULL_VOID(eventHub);
2022     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2023     CHECK_NULL_VOID(frameNode);
2024     if (value.empty() || (keys.size() == 0 && value.length() == 1)) {
2025         eventHub->SetKeyboardShortcut("", 0, nullptr);
2026         return;
2027     }
2028     auto key = eventManager->GetKeyboardShortcutKeys(keys);
2029     if ((key == 0 && value.length() == 1) || (key == 0 && keys.size() > 0 && value.length() > 1)) {
2030         return;
2031     }
2032     if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
2033         return;
2034     }
2035     eventHub->SetKeyboardShortcut(value, key, std::move(onKeyboardShortcutAction));
2036     eventManager->AddKeyboardShortcutNode(WeakPtr<NG::FrameNode>(frameNode));
2037 }
2038 
CreateAnimatablePropertyFloat(const std::string & propertyName,float value,const std::function<void (float)> & onCallbackEvent)2039 void ViewAbstract::CreateAnimatablePropertyFloat(const std::string &propertyName, float value,
2040     const std::function<void(float)> &onCallbackEvent)
2041 {
2042     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2043     CHECK_NULL_VOID(frameNode);
2044     frameNode->CreateAnimatablePropertyFloat(propertyName, value, onCallbackEvent);
2045 }
2046 
UpdateAnimatablePropertyFloat(const std::string & propertyName,float value)2047 void ViewAbstract::UpdateAnimatablePropertyFloat(const std::string &propertyName, float value)
2048 {
2049     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2050     CHECK_NULL_VOID(frameNode);
2051     frameNode->UpdateAnimatablePropertyFloat(propertyName, value);
2052 }
2053 
CreateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value,std::function<void (const RefPtr<CustomAnimatableArithmetic> &)> & onCallbackEvent)2054 void ViewAbstract::CreateAnimatableArithmeticProperty(const std::string &propertyName,
2055     RefPtr<CustomAnimatableArithmetic> &value,
2056     std::function<void(const RefPtr<CustomAnimatableArithmetic> &)> &onCallbackEvent)
2057 {
2058     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2059     CHECK_NULL_VOID(frameNode);
2060     frameNode->CreateAnimatableArithmeticProperty(propertyName, value, onCallbackEvent);
2061 }
2062 
UpdateAnimatableArithmeticProperty(const std::string & propertyName,RefPtr<CustomAnimatableArithmetic> & value)2063 void ViewAbstract::UpdateAnimatableArithmeticProperty(const std::string &propertyName,
2064     RefPtr<CustomAnimatableArithmetic> &value)
2065 {
2066     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2067     CHECK_NULL_VOID(frameNode);
2068     frameNode->UpdateAnimatableArithmeticProperty(propertyName, value);
2069 }
2070 
SetObscured(const std::vector<ObscuredReasons> & reasons)2071 void ViewAbstract::SetObscured(const std::vector<ObscuredReasons> &reasons)
2072 {
2073     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2074         return;
2075     }
2076     ACE_UPDATE_RENDER_CONTEXT(Obscured, reasons);
2077     auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
2078     CHECK_NULL_VOID(frameNode);
2079     frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
2080 }
2081 
UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts & opts)2082 void ViewAbstract::UpdateSafeAreaExpandOpts(const SafeAreaExpandOpts &opts)
2083 {
2084     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2085         return;
2086     }
2087     ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts);
2088 }
2089 
SetRenderGroup(bool isRenderGroup)2090 void ViewAbstract::SetRenderGroup(bool isRenderGroup)
2091 {
2092     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2093         return;
2094     }
2095     ACE_UPDATE_RENDER_CONTEXT(RenderGroup, isRenderGroup);
2096 }
2097 
SetRenderFit(RenderFit renderFit)2098 void ViewAbstract::SetRenderFit(RenderFit renderFit)
2099 {
2100     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2101         return;
2102     }
2103     ACE_UPDATE_RENDER_CONTEXT(RenderFit, renderFit);
2104 }
2105 
SetBorderRadius(FrameNode * frameNode,const BorderRadiusProperty & value)2106 void ViewAbstract::SetBorderRadius(FrameNode *frameNode, const BorderRadiusProperty &value)
2107 {
2108     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, value, frameNode);
2109 }
2110 
SetBorderRadius(FrameNode * frameNode,const Dimension & value)2111 void ViewAbstract::SetBorderRadius(FrameNode *frameNode, const Dimension &value)
2112 {
2113     BorderRadiusProperty borderRadius;
2114     borderRadius.SetRadius(value);
2115     borderRadius.multiValued = false;
2116     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderRadius, borderRadius, frameNode);
2117 }
2118 
SetBorderWidth(FrameNode * frameNode,const BorderWidthProperty & value)2119 void ViewAbstract::SetBorderWidth(FrameNode *frameNode, const BorderWidthProperty &value)
2120 {
2121     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, value, frameNode);
2122     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, value, frameNode);
2123 }
2124 
SetBorderWidth(FrameNode * frameNode,const Dimension & value)2125 void ViewAbstract::SetBorderWidth(FrameNode *frameNode, const Dimension &value)
2126 {
2127     BorderWidthProperty borderWidth;
2128     if (Negative(value.Value())) {
2129         borderWidth.SetBorderWidth(Dimension(0));
2130         LOGW("border width is negative, reset to 0");
2131     } else {
2132         borderWidth.SetBorderWidth(value);
2133     }
2134     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, BorderWidth, borderWidth, frameNode);
2135     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderWidth, borderWidth, frameNode);
2136 }
2137 
SetBorderColor(FrameNode * frameNode,const BorderColorProperty & value)2138 void ViewAbstract::SetBorderColor(FrameNode *frameNode, const BorderColorProperty &value)
2139 {
2140     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, value, frameNode);
2141 }
2142 
SetBorderColor(FrameNode * frameNode,const Color & value)2143 void ViewAbstract::SetBorderColor(FrameNode *frameNode, const Color &value)
2144 {
2145     BorderColorProperty borderColor;
2146     borderColor.SetColor(value);
2147     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderColor, borderColor, frameNode);
2148 }
2149 
SetWidth(FrameNode * frameNode,const CalcLength & width)2150 void ViewAbstract::SetWidth(FrameNode *frameNode, const CalcLength &width)
2151 {
2152     CHECK_NULL_VOID(frameNode);
2153     auto layoutProperty = frameNode->GetLayoutProperty();
2154     CHECK_NULL_VOID(layoutProperty);
2155     // get previously user defined ideal height
2156     std::optional<CalcLength> height = std::nullopt;
2157     auto &&layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
2158     if (layoutConstraint && layoutConstraint->selfIdealSize) {
2159         height = layoutConstraint->selfIdealSize->Height();
2160     }
2161     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
2162 }
2163 
SetHeight(FrameNode * frameNode,const CalcLength & height)2164 void ViewAbstract::SetHeight(FrameNode *frameNode, const CalcLength &height)
2165 {
2166     CHECK_NULL_VOID(frameNode);
2167     auto layoutProperty = frameNode->GetLayoutProperty();
2168     CHECK_NULL_VOID(layoutProperty);
2169     std::optional<CalcLength> width = std::nullopt;
2170     auto &&layoutConstraint = layoutProperty->GetCalcLayoutConstraint();
2171     if (layoutConstraint && layoutConstraint->selfIdealSize) {
2172         width = layoutConstraint->selfIdealSize->Width();
2173     }
2174     layoutProperty->UpdateUserDefinedIdealSize(CalcSize(width, height));
2175 }
2176 
ClearWidthOrHeight(FrameNode * frameNode,bool isWidth)2177 void ViewAbstract::ClearWidthOrHeight(FrameNode *frameNode, bool isWidth)
2178 {
2179     CHECK_NULL_VOID(frameNode);
2180     auto layoutProperty = frameNode->GetLayoutProperty();
2181     CHECK_NULL_VOID(layoutProperty);
2182     layoutProperty->ClearUserDefinedIdealSize(isWidth, !isWidth);
2183 }
2184 
SetPosition(FrameNode * frameNode,const OffsetT<Dimension> & value)2185 void ViewAbstract::SetPosition(FrameNode *frameNode, const OffsetT<Dimension> &value)
2186 {
2187     ACE_UPDATE_NODE_RENDER_CONTEXT(Position, value, frameNode);
2188 }
2189 
SetTransformMatrix(FrameNode * frameNode,const Matrix4 & matrix)2190 void ViewAbstract::SetTransformMatrix(FrameNode *frameNode, const Matrix4 &matrix)
2191 {
2192     ACE_UPDATE_NODE_RENDER_CONTEXT(TransformMatrix, matrix, frameNode);
2193 }
2194 
SetHitTestMode(FrameNode * frameNode,HitTestMode hitTestMode)2195 void ViewAbstract::SetHitTestMode(FrameNode *frameNode, HitTestMode hitTestMode)
2196 {
2197     CHECK_NULL_VOID(frameNode);
2198     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2199     CHECK_NULL_VOID(gestureHub);
2200     gestureHub->SetHitTestMode(hitTestMode);
2201 }
2202 
SetOpacity(FrameNode * frameNode,double opacity)2203 void ViewAbstract::SetOpacity(FrameNode *frameNode, double opacity)
2204 {
2205     ACE_UPDATE_NODE_RENDER_CONTEXT(Opacity, opacity, frameNode);
2206 }
2207 
SetZIndex(FrameNode * frameNode,int32_t value)2208 void ViewAbstract::SetZIndex(FrameNode *frameNode, int32_t value)
2209 {
2210     ACE_UPDATE_NODE_RENDER_CONTEXT(ZIndex, value, frameNode);
2211 }
2212 
SetLinearGradient(FrameNode * frameNode,const NG::Gradient & gradient)2213 void ViewAbstract::SetLinearGradient(FrameNode *frameNode, const NG::Gradient &gradient)
2214 {
2215     ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradient, gradient, frameNode);
2216 }
2217 
SetSweepGradient(FrameNode * frameNode,const NG::Gradient & gradient)2218 void ViewAbstract::SetSweepGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2219 {
2220     ACE_UPDATE_NODE_RENDER_CONTEXT(SweepGradient, gradient, frameNode);
2221 }
2222 
SetRadialGradient(FrameNode * frameNode,const NG::Gradient & gradient)2223 void ViewAbstract::SetRadialGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2224 {
2225     ACE_UPDATE_NODE_RENDER_CONTEXT(RadialGradient, gradient, frameNode);
2226 }
2227 
SetOverlay(FrameNode * frameNode,const NG::OverlayOptions & overlay)2228 void ViewAbstract::SetOverlay(FrameNode* frameNode, const NG::OverlayOptions& overlay)
2229 {
2230     ACE_UPDATE_NODE_RENDER_CONTEXT(OverlayText, overlay, frameNode);
2231 }
2232 
SetBorderImage(FrameNode * frameNode,const RefPtr<BorderImage> & borderImage)2233 void ViewAbstract::SetBorderImage(FrameNode* frameNode, const RefPtr<BorderImage>& borderImage)
2234 {
2235     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImage, borderImage, frameNode);
2236 }
2237 
SetBorderImageSource(FrameNode * frameNode,const std::string & bdImageSrc)2238 void ViewAbstract::SetBorderImageSource(FrameNode* frameNode, const std::string& bdImageSrc)
2239 {
2240     ImageSourceInfo imageSourceInfo(bdImageSrc);
2241     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageSource, imageSourceInfo, frameNode);
2242 }
2243 
SetHasBorderImageSlice(FrameNode * frameNode,bool tag)2244 void ViewAbstract::SetHasBorderImageSlice(FrameNode* frameNode, bool tag)
2245 {
2246     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageSlice, tag, frameNode);
2247 }
2248 
SetHasBorderImageWidth(FrameNode * frameNode,bool tag)2249 void ViewAbstract::SetHasBorderImageWidth(FrameNode* frameNode, bool tag)
2250 {
2251     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageWidth, tag, frameNode);
2252 }
2253 
SetHasBorderImageOutset(FrameNode * frameNode,bool tag)2254 void ViewAbstract::SetHasBorderImageOutset(FrameNode* frameNode, bool tag)
2255 {
2256     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageOutset, tag, frameNode);
2257 }
2258 
SetHasBorderImageRepeat(FrameNode * frameNode,bool tag)2259 void ViewAbstract::SetHasBorderImageRepeat(FrameNode* frameNode, bool tag)
2260 {
2261     ACE_UPDATE_NODE_RENDER_CONTEXT(HasBorderImageRepeat, tag, frameNode);
2262 }
2263 
SetBorderImageGradient(FrameNode * frameNode,const NG::Gradient & gradient)2264 void ViewAbstract::SetBorderImageGradient(FrameNode* frameNode, const NG::Gradient& gradient)
2265 {
2266     ACE_UPDATE_NODE_RENDER_CONTEXT(BorderImageGradient, gradient, frameNode);
2267 }
2268 
SetForegroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & fgBlurStyle)2269 void ViewAbstract::SetForegroundBlurStyle(FrameNode* frameNode, const BlurStyleOption& fgBlurStyle)
2270 {
2271     const auto& target = frameNode->GetRenderContext();
2272     if (target) {
2273         target->UpdateFrontBlurStyle(fgBlurStyle);
2274         if (target->GetFrontBlurRadius().has_value()) {
2275             target->UpdateFrontBlurRadius(Dimension());
2276         }
2277     }
2278 }
2279 
SetLinearGradientBlur(FrameNode * frameNode,const NG::LinearGradientBlurPara & blurPara)2280 void ViewAbstract::SetLinearGradientBlur(FrameNode *frameNode, const NG::LinearGradientBlurPara& blurPara)
2281 {
2282     ACE_UPDATE_NODE_RENDER_CONTEXT(LinearGradientBlur, blurPara, frameNode);
2283 }
2284 
SetBackgroundBlurStyle(FrameNode * frameNode,const BlurStyleOption & bgBlurStyle)2285 void ViewAbstract::SetBackgroundBlurStyle(FrameNode *frameNode, const BlurStyleOption &bgBlurStyle)
2286 {
2287     auto target = frameNode->GetRenderContext();
2288     if (target) {
2289         if (target->GetBackgroundEffect().has_value()) {
2290             target->UpdateBackgroundEffect(std::nullopt);
2291         }
2292         target->UpdateBackBlurStyle(bgBlurStyle);
2293         if (target->GetBackBlurRadius().has_value()) {
2294             target->UpdateBackBlurRadius(Dimension());
2295         }
2296     }
2297 }
2298 
SetPixelStretchEffect(FrameNode * frameNode,PixStretchEffectOption & option)2299 void ViewAbstract::SetPixelStretchEffect(FrameNode* frameNode, PixStretchEffectOption& option)
2300 {
2301     ACE_UPDATE_NODE_RENDER_CONTEXT(PixelStretchEffect, option, frameNode);
2302 }
2303 
SetLightUpEffect(FrameNode * frameNode,double radio)2304 void ViewAbstract::SetLightUpEffect(FrameNode* frameNode, double radio)
2305 {
2306     ACE_UPDATE_NODE_RENDER_CONTEXT(LightUpEffect, radio, frameNode);
2307 }
2308 
SetSphericalEffect(FrameNode * frameNode,double radio)2309 void ViewAbstract::SetSphericalEffect(FrameNode* frameNode, double radio)
2310 {
2311     ACE_UPDATE_NODE_RENDER_CONTEXT(SphericalEffect, radio, frameNode);
2312 }
2313 
SetRenderGroup(FrameNode * frameNode,bool isRenderGroup)2314 void ViewAbstract::SetRenderGroup(FrameNode* frameNode, bool isRenderGroup)
2315 {
2316     ACE_UPDATE_NODE_RENDER_CONTEXT(RenderGroup, isRenderGroup, frameNode);
2317 }
2318 
SetRenderFit(FrameNode * frameNode,RenderFit renderFit)2319 void ViewAbstract::SetRenderFit(FrameNode* frameNode, RenderFit renderFit)
2320 {
2321     ACE_UPDATE_NODE_RENDER_CONTEXT(RenderFit, renderFit, frameNode);
2322 }
2323 
SetUseEffect(FrameNode * frameNode,bool useEffect)2324 void ViewAbstract::SetUseEffect(FrameNode* frameNode, bool useEffect)
2325 {
2326     ACE_UPDATE_NODE_RENDER_CONTEXT(UseEffect, useEffect, frameNode);
2327 }
2328 
SetForegroundColor(FrameNode * frameNode,const Color & color)2329 void ViewAbstract::SetForegroundColor(FrameNode* frameNode, const Color& color)
2330 {
2331     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColor, color, frameNode);
2332     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, ForegroundColorStrategy, frameNode);
2333     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorFlag, true, frameNode);
2334 }
2335 
SetForegroundColorStrategy(FrameNode * frameNode,const ForegroundColorStrategy & strategy)2336 void ViewAbstract::SetForegroundColorStrategy(FrameNode* frameNode, const ForegroundColorStrategy& strategy)
2337 {
2338     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorStrategy, strategy, frameNode);
2339     ACE_RESET_NODE_RENDER_CONTEXT(RenderContext, ForegroundColor, frameNode);
2340     ACE_UPDATE_NODE_RENDER_CONTEXT(ForegroundColorFlag, true, frameNode);
2341 }
2342 
SetLightPosition(const CalcDimension & positionX,const CalcDimension & positionY,const CalcDimension & positionZ)2343 void ViewAbstract::SetLightPosition(
2344     const CalcDimension& positionX, const CalcDimension& positionY, const CalcDimension& positionZ)
2345 {
2346     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2347         return;
2348     }
2349     ACE_UPDATE_RENDER_CONTEXT(LightPosition, TranslateOptions(positionX, positionY, positionZ));
2350 }
2351 
SetLightIntensity(const float value)2352 void ViewAbstract::SetLightIntensity(const float value)
2353 {
2354     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2355         return;
2356     }
2357     ACE_UPDATE_RENDER_CONTEXT(LightIntensity, value);
2358 }
2359 
SetLightIlluminated(const uint32_t value)2360 void ViewAbstract::SetLightIlluminated(const uint32_t value)
2361 {
2362     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2363         return;
2364     }
2365     ACE_UPDATE_RENDER_CONTEXT(LightIlluminated, value);
2366 }
2367 
SetIlluminatedBorderWidth(const Dimension & value)2368 void ViewAbstract::SetIlluminatedBorderWidth(const Dimension& value)
2369 {
2370     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2371         return;
2372     }
2373     ACE_UPDATE_RENDER_CONTEXT(IlluminatedBorderWidth, value);
2374 }
2375 
SetBloom(const float value)2376 void ViewAbstract::SetBloom(const float value)
2377 {
2378     if (!ViewStackProcessor::GetInstance()->IsCurrentVisualStateProcess()) {
2379         return;
2380     }
2381     ACE_UPDATE_RENDER_CONTEXT(Bloom, value);
2382 }
2383 
SetMotionPath(FrameNode * frameNode,const MotionPathOption & motionPath)2384 void ViewAbstract::SetMotionPath(FrameNode* frameNode, const MotionPathOption& motionPath)
2385 {
2386     ACE_UPDATE_NODE_RENDER_CONTEXT(MotionPath, motionPath, frameNode);
2387 }
2388 
SetFocusOnTouch(FrameNode * frameNode,bool isSet)2389 void ViewAbstract::SetFocusOnTouch(FrameNode* frameNode, bool isSet)
2390 {
2391     CHECK_NULL_VOID(frameNode);
2392     auto focusHub = frameNode->GetOrCreateFocusHub();
2393     CHECK_NULL_VOID(focusHub);
2394     focusHub->SetIsFocusOnTouch(isSet);
2395 }
2396 
SetGroupDefaultFocus(FrameNode * frameNode,bool isSet)2397 void ViewAbstract::SetGroupDefaultFocus(FrameNode* frameNode, bool isSet)
2398 {
2399     CHECK_NULL_VOID(frameNode);
2400     auto focusHub = frameNode->GetOrCreateFocusHub();
2401     CHECK_NULL_VOID(focusHub);
2402     focusHub->SetIsDefaultGroupFocus(isSet);
2403 }
2404 
SetFocusable(FrameNode * frameNode,bool focusable)2405 void ViewAbstract::SetFocusable(FrameNode* frameNode, bool focusable)
2406 {
2407     CHECK_NULL_VOID(frameNode);
2408     auto focusHub = frameNode->GetOrCreateFocusHub();
2409     CHECK_NULL_VOID(focusHub);
2410     focusHub->SetFocusable(focusable);
2411 }
2412 
SetTouchable(FrameNode * frameNode,bool touchable)2413 void ViewAbstract::SetTouchable(FrameNode* frameNode, bool touchable)
2414 {
2415     CHECK_NULL_VOID(frameNode);
2416     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2417     CHECK_NULL_VOID(gestureHub);
2418     gestureHub->SetTouchable(touchable);
2419 }
2420 
SetDefaultFocus(FrameNode * frameNode,bool isSet)2421 void ViewAbstract::SetDefaultFocus(FrameNode* frameNode, bool isSet)
2422 {
2423     CHECK_NULL_VOID(frameNode);
2424     auto focusHub = frameNode->GetOrCreateFocusHub();
2425     CHECK_NULL_VOID(focusHub);
2426     focusHub->SetIsDefaultFocus(isSet);
2427 }
2428 
SetDisplayIndex(FrameNode * frameNode,int32_t value)2429 void ViewAbstract::SetDisplayIndex(FrameNode* frameNode, int32_t value)
2430 {
2431     CHECK_NULL_VOID(frameNode);
2432     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, DisplayIndex, value, frameNode);
2433 }
2434 
SetOffset(FrameNode * frameNode,const OffsetT<Dimension> & value)2435 void ViewAbstract::SetOffset(FrameNode* frameNode, const OffsetT<Dimension>& value)
2436 {
2437     CHECK_NULL_VOID(frameNode);
2438     ACE_UPDATE_NODE_RENDER_CONTEXT(Offset, value, frameNode);
2439 }
2440 
MarkAnchor(FrameNode * frameNode,const OffsetT<Dimension> & value)2441 void ViewAbstract::MarkAnchor(FrameNode* frameNode, const OffsetT<Dimension>& value)
2442 {
2443     CHECK_NULL_VOID(frameNode);
2444     ACE_UPDATE_NODE_RENDER_CONTEXT(Anchor, value, frameNode);
2445 }
2446 
SetVisibility(FrameNode * frameNode,VisibleType visible)2447 void ViewAbstract::SetVisibility(FrameNode* frameNode, VisibleType visible)
2448 {
2449     CHECK_NULL_VOID(frameNode);
2450     auto layoutProperty = frameNode->GetLayoutProperty();
2451     if (layoutProperty) {
2452         layoutProperty->UpdateVisibility(visible, true);
2453     }
2454 
2455     auto focusHub = ViewStackProcessor::GetInstance()->GetOrCreateMainFrameNodeFocusHub();
2456     if (focusHub) {
2457         focusHub->SetShow(visible == VisibleType::VISIBLE);
2458     }
2459 }
2460 
SetPadding(FrameNode * frameNode,const CalcLength & value)2461 void ViewAbstract::SetPadding(FrameNode* frameNode, const CalcLength& value)
2462 {
2463     CHECK_NULL_VOID(frameNode);
2464     PaddingProperty padding;
2465     padding.SetEdges(value);
2466     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, padding, frameNode);
2467 }
2468 
SetPadding(FrameNode * frameNode,const PaddingProperty & value)2469 void ViewAbstract::SetPadding(FrameNode* frameNode, const PaddingProperty& value)
2470 {
2471     CHECK_NULL_VOID(frameNode);
2472     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Padding, value, frameNode);
2473 }
2474 
SetMargin(FrameNode * frameNode,const CalcLength & value)2475 void ViewAbstract::SetMargin(FrameNode* frameNode, const CalcLength& value)
2476 {
2477     CHECK_NULL_VOID(frameNode);
2478     MarginProperty margin;
2479     margin.SetEdges(value);
2480     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, margin, frameNode);
2481 }
2482 
SetMargin(FrameNode * frameNode,const PaddingProperty & value)2483 void ViewAbstract::SetMargin(FrameNode* frameNode, const PaddingProperty& value)
2484 {
2485     CHECK_NULL_VOID(frameNode);
2486     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Margin, value, frameNode);
2487 }
2488 
SetLayoutDirection(FrameNode * frameNode,TextDirection value)2489 void ViewAbstract::SetLayoutDirection(FrameNode* frameNode, TextDirection value)
2490 {
2491     CHECK_NULL_VOID(frameNode);
2492     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutDirection, value, frameNode);
2493 }
2494 
UpdateSafeAreaExpandOpts(FrameNode * frameNode,const SafeAreaExpandOpts & opts)2495 void ViewAbstract::UpdateSafeAreaExpandOpts(FrameNode* frameNode, const SafeAreaExpandOpts& opts)
2496 {
2497     CHECK_NULL_VOID(frameNode);
2498     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, SafeAreaExpandOpts, opts, frameNode);
2499 }
2500 
SetAspectRatio(FrameNode * frameNode,float ratio)2501 void ViewAbstract::SetAspectRatio(FrameNode* frameNode, float ratio)
2502 {
2503     CHECK_NULL_VOID(frameNode);
2504     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, ratio, frameNode);
2505 }
2506 
SetAlignSelf(FrameNode * frameNode,FlexAlign value)2507 void ViewAbstract::SetAlignSelf(FrameNode* frameNode, FlexAlign value)
2508 {
2509     CHECK_NULL_VOID(frameNode);
2510     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignSelf, value, frameNode);
2511 }
2512 
SetFlexBasis(FrameNode * frameNode,const Dimension & value)2513 void ViewAbstract::SetFlexBasis(FrameNode* frameNode, const Dimension& value)
2514 {
2515     CHECK_NULL_VOID(frameNode);
2516     if (LessNotEqual(value.Value(), 0.0f)) {
2517         ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, Dimension(), frameNode);
2518         return;
2519     }
2520     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexBasis, value, frameNode);
2521 }
2522 
ResetFlexShrink(FrameNode * frameNode)2523 void ViewAbstract::ResetFlexShrink(FrameNode* frameNode)
2524 {
2525     CHECK_NULL_VOID(frameNode);
2526     ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, frameNode);
2527 }
2528 
SetFlexShrink(FrameNode * frameNode,float value)2529 void ViewAbstract::SetFlexShrink(FrameNode* frameNode, float value)
2530 {
2531     CHECK_NULL_VOID(frameNode);
2532     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexShrink, value, frameNode);
2533 }
2534 
SetFlexGrow(FrameNode * frameNode,float value)2535 void ViewAbstract::SetFlexGrow(FrameNode* frameNode, float value)
2536 {
2537     CHECK_NULL_VOID(frameNode);
2538     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value, frameNode);
2539 }
2540 
SetLayoutWeight(FrameNode * frameNode,int32_t value)2541 void ViewAbstract::SetLayoutWeight(FrameNode* frameNode, int32_t value)
2542 {
2543     CHECK_NULL_VOID(frameNode);
2544     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, static_cast<float>(value), frameNode);
2545 }
2546 
ResetMaxSize(FrameNode * frameNode,bool resetWidth)2547 void ViewAbstract::ResetMaxSize(FrameNode* frameNode, bool resetWidth)
2548 {
2549     CHECK_NULL_VOID(frameNode);
2550     auto layoutProperty = frameNode->GetLayoutProperty();
2551     CHECK_NULL_VOID(layoutProperty);
2552     layoutProperty->ResetCalcMaxSize(resetWidth);
2553 }
2554 
ResetMinSize(FrameNode * frameNode,bool resetWidth)2555 void ViewAbstract::ResetMinSize(FrameNode* frameNode, bool resetWidth)
2556 {
2557     CHECK_NULL_VOID(frameNode);
2558     auto layoutProperty = frameNode->GetLayoutProperty();
2559     CHECK_NULL_VOID(layoutProperty);
2560     layoutProperty->ResetCalcMinSize(resetWidth);
2561 }
2562 
SetMinWidth(FrameNode * frameNode,const CalcLength & minWidth)2563 void ViewAbstract::SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth)
2564 {
2565     CHECK_NULL_VOID(frameNode);
2566     auto layoutProperty = frameNode->GetLayoutProperty();
2567     CHECK_NULL_VOID(layoutProperty);
2568     layoutProperty->UpdateCalcMinSize(CalcSize(minWidth, std::nullopt));
2569 }
2570 
SetMaxWidth(FrameNode * frameNode,const CalcLength & maxWidth)2571 void ViewAbstract::SetMaxWidth(FrameNode* frameNode, const CalcLength& maxWidth)
2572 {
2573     CHECK_NULL_VOID(frameNode);
2574     auto layoutProperty = frameNode->GetLayoutProperty();
2575     CHECK_NULL_VOID(layoutProperty);
2576     layoutProperty->UpdateCalcMaxSize(CalcSize(maxWidth, std::nullopt));
2577 }
2578 
SetMinHeight(FrameNode * frameNode,const CalcLength & minHeight)2579 void ViewAbstract::SetMinHeight(FrameNode* frameNode, const CalcLength& minHeight)
2580 {
2581     CHECK_NULL_VOID(frameNode);
2582     auto layoutProperty = frameNode->GetLayoutProperty();
2583     CHECK_NULL_VOID(layoutProperty);
2584     layoutProperty->UpdateCalcMinSize(CalcSize(std::nullopt, minHeight));
2585 }
2586 
SetMaxHeight(FrameNode * frameNode,const CalcLength & maxHeight)2587 void ViewAbstract::SetMaxHeight(FrameNode* frameNode, const CalcLength& maxHeight)
2588 {
2589     CHECK_NULL_VOID(frameNode);
2590     auto layoutProperty = frameNode->GetLayoutProperty();
2591     CHECK_NULL_VOID(layoutProperty);
2592     layoutProperty->UpdateCalcMaxSize(CalcSize(std::nullopt, maxHeight));
2593 }
2594 
SetAlignRules(FrameNode * frameNode,const std::map<AlignDirection,AlignRule> & alignRules)2595 void ViewAbstract::SetAlignRules(FrameNode* frameNode, const std::map<AlignDirection, AlignRule>& alignRules)
2596 {
2597     CHECK_NULL_VOID(frameNode);
2598     ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, AlignRules, alignRules, frameNode);
2599 }
2600 
SetGrid(FrameNode * frameNode,std::optional<int32_t> span,std::optional<int32_t> offset,GridSizeType type)2601 void ViewAbstract::SetGrid(
2602     FrameNode* frameNode, std::optional<int32_t> span, std::optional<int32_t> offset, GridSizeType type)
2603 {
2604     CHECK_NULL_VOID(frameNode);
2605     auto layoutProperty = frameNode->GetLayoutProperty();
2606     CHECK_NULL_VOID(layoutProperty);
2607     // frame node is mounted to parent when pop from stack later, no grid-container is added here
2608     layoutProperty->UpdateGridProperty(span, offset, type);
2609 }
2610 
ResetAspectRatio(FrameNode * frameNode)2611 void ViewAbstract::ResetAspectRatio(FrameNode* frameNode)
2612 {
2613     ACE_RESET_NODE_LAYOUT_PROPERTY(LayoutProperty, AspectRatio, frameNode);
2614 }
2615 
SetAllowDrop(FrameNode * frameNode,const std::set<std::string> & allowDrop)2616 void ViewAbstract::SetAllowDrop(FrameNode* frameNode, const std::set<std::string>& allowDrop)
2617 {
2618     CHECK_NULL_VOID(frameNode);
2619     frameNode->SetAllowDrop(allowDrop);
2620 }
2621 
SetInspectorId(FrameNode * frameNode,const std::string & inspectorId)2622 void ViewAbstract::SetInspectorId(FrameNode* frameNode, const std::string& inspectorId)
2623 {
2624     if (frameNode) {
2625         frameNode->UpdateInspectorId(inspectorId);
2626     }
2627 }
2628 
SetRestoreId(FrameNode * frameNode,int32_t restoreId)2629 void ViewAbstract::SetRestoreId(FrameNode* frameNode, int32_t restoreId)
2630 {
2631     if (frameNode) {
2632         frameNode->SetRestoreId(restoreId);
2633     }
2634 }
2635 
SetTabIndex(FrameNode * frameNode,int32_t index)2636 void ViewAbstract::SetTabIndex(FrameNode* frameNode, int32_t index)
2637 {
2638     CHECK_NULL_VOID(frameNode);
2639     auto focusHub = frameNode->GetOrCreateFocusHub();
2640     CHECK_NULL_VOID(focusHub);
2641     focusHub->SetTabIndex(index);
2642 }
2643 
SetObscured(FrameNode * frameNode,const std::vector<ObscuredReasons> & reasons)2644 void ViewAbstract::SetObscured(FrameNode* frameNode, const std::vector<ObscuredReasons>& reasons)
2645 {
2646     CHECK_NULL_VOID(frameNode);
2647     ACE_UPDATE_NODE_RENDER_CONTEXT(Obscured, reasons, frameNode);
2648     frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
2649 }
2650 
SetBackgroundEffect(FrameNode * frameNode,const EffectOption & effectOption)2651 void ViewAbstract::SetBackgroundEffect(FrameNode* frameNode, const EffectOption &effectOption)
2652 {
2653     CHECK_NULL_VOID(frameNode);
2654     auto target = frameNode->GetRenderContext();
2655     if (target) {
2656         if (target->GetBackBlurRadius().has_value()) {
2657             target->UpdateBackBlurRadius(Dimension());
2658         }
2659         if (target->GetBackBlurStyle().has_value()) {
2660             target->UpdateBackBlurStyle(std::nullopt);
2661         }
2662         target->UpdateBackgroundEffect(effectOption);
2663     }
2664 }
2665 
SetDynamicLightUp(FrameNode * frameNode,float rate,float lightUpDegree)2666 void ViewAbstract::SetDynamicLightUp(FrameNode* frameNode, float rate, float lightUpDegree)
2667 {
2668     ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpRate, rate, frameNode);
2669     ACE_UPDATE_NODE_RENDER_CONTEXT(DynamicLightUpDegree, lightUpDegree, frameNode);
2670 }
2671 
SetDragPreviewOptions(FrameNode * frameNode,const DragPreviewOption & previewOption)2672 void ViewAbstract::SetDragPreviewOptions(FrameNode* frameNode, const DragPreviewOption& previewOption)
2673 {
2674     CHECK_NULL_VOID(frameNode);
2675     frameNode->SetDragPreviewOptions(previewOption);
2676 }
2677 
SetResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & responseRegion)2678 void ViewAbstract::SetResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& responseRegion)
2679 {
2680     CHECK_NULL_VOID(frameNode);
2681     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2682     CHECK_NULL_VOID(gestureHub);
2683     gestureHub->SetResponseRegion(responseRegion);
2684 }
2685 
SetMouseResponseRegion(FrameNode * frameNode,const std::vector<DimensionRect> & mouseResponseRegion)2686 void ViewAbstract::SetMouseResponseRegion(FrameNode* frameNode, const std::vector<DimensionRect>& mouseResponseRegion)
2687 {
2688     CHECK_NULL_VOID(frameNode);
2689     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2690     CHECK_NULL_VOID(gestureHub);
2691     gestureHub->SetMouseResponseRegion(mouseResponseRegion);
2692 }
2693 
SetSharedTransition(FrameNode * frameNode,const std::string & shareId,const std::shared_ptr<SharedTransitionOption> & option)2694 void ViewAbstract::SetSharedTransition(
2695     FrameNode* frameNode, const std::string& shareId, const std::shared_ptr<SharedTransitionOption>& option)
2696 {
2697     const auto& target = frameNode->GetRenderContext();
2698     if (target) {
2699         target->SetSharedTransitionOptions(option);
2700         target->SetShareId(shareId);
2701     }
2702 }
2703 
SetTransition(FrameNode * frameNode,const TransitionOptions & options)2704 void ViewAbstract::SetTransition(FrameNode* frameNode, const TransitionOptions& options)
2705 {
2706     ACE_UPDATE_NODE_RENDER_CONTEXT(Transition, options, frameNode);
2707 }
2708 
SetChainedTransition(FrameNode * frameNode,const RefPtr<NG::ChainedTransitionEffect> & effect)2709 void ViewAbstract::SetChainedTransition(FrameNode* frameNode, const RefPtr<NG::ChainedTransitionEffect>& effect)
2710 {
2711     ACE_UPDATE_NODE_RENDER_CONTEXT(ChainedTransition, effect, frameNode);
2712 }
2713 
SetEnabled(FrameNode * frameNode,bool enabled)2714 void ViewAbstract::SetEnabled(FrameNode* frameNode, bool enabled)
2715 {
2716     CHECK_NULL_VOID(frameNode);
2717     auto eventHub = frameNode->GetEventHub<EventHub>();
2718     if (eventHub) {
2719         eventHub->SetEnabled(enabled);
2720     }
2721     auto focusHub = frameNode->GetOrCreateFocusHub();
2722     if (focusHub) {
2723         focusHub->SetEnabled(enabled);
2724     }
2725 }
2726 
SetUseShadowBatching(FrameNode * frameNode,bool useShadowBatching)2727 void ViewAbstract::SetUseShadowBatching(FrameNode* frameNode, bool useShadowBatching)
2728 {
2729     ACE_UPDATE_NODE_RENDER_CONTEXT(UseShadowBatching, useShadowBatching, frameNode);
2730 }
2731 
SetBlendMode(FrameNode * frameNode,BlendMode blendMode)2732 void ViewAbstract::SetBlendMode(FrameNode* frameNode, BlendMode blendMode)
2733 {
2734     ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendMode, blendMode, frameNode);
2735 }
2736 
SetBlendApplyType(FrameNode * frameNode,BlendApplyType blendApplyType)2737 void ViewAbstract::SetBlendApplyType(FrameNode* frameNode, BlendApplyType blendApplyType)
2738 {
2739     ACE_UPDATE_NODE_RENDER_CONTEXT(BackBlendApplyType, blendApplyType, frameNode);
2740 }
2741 
SetMonopolizeEvents(FrameNode * frameNode,bool monopolizeEvents)2742 void ViewAbstract::SetMonopolizeEvents(FrameNode* frameNode, bool monopolizeEvents)
2743 {
2744     CHECK_NULL_VOID(frameNode);
2745     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2746     CHECK_NULL_VOID(gestureHub);
2747     gestureHub->SetMonopolizeEvents(monopolizeEvents);
2748 }
2749 
SetDraggable(FrameNode * frameNode,bool draggable)2750 void ViewAbstract::SetDraggable(FrameNode* frameNode, bool draggable)
2751 {
2752     CHECK_NULL_VOID(frameNode);
2753     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
2754     CHECK_NULL_VOID(gestureHub);
2755     if (draggable) {
2756         if (!frameNode->IsDraggable()) {
2757             gestureHub->InitDragDropEvent();
2758         }
2759     } else {
2760         gestureHub->RemoveDragEvent();
2761     }
2762     frameNode->SetDraggable(draggable);
2763 }
2764 
SetHoverEffect(FrameNode * frameNode,HoverEffectType hoverEffect)2765 void ViewAbstract::SetHoverEffect(FrameNode* frameNode, HoverEffectType hoverEffect)
2766 {
2767     CHECK_NULL_VOID(frameNode);
2768     auto eventHub = frameNode->GetOrCreateInputEventHub();
2769     CHECK_NULL_VOID(eventHub);
2770     eventHub->SetHoverEffect(hoverEffect);
2771 }
2772 
SetClickEffectLevel(FrameNode * frameNode,const ClickEffectLevel & level,float scaleValue)2773 void ViewAbstract::SetClickEffectLevel(FrameNode* frameNode, const ClickEffectLevel& level, float scaleValue)
2774 {
2775     ClickEffectInfo clickEffectInfo;
2776     clickEffectInfo.level = level;
2777     clickEffectInfo.scaleNumber = scaleValue;
2778     ACE_UPDATE_NODE_RENDER_CONTEXT(ClickEffectLevel, clickEffectInfo, frameNode);
2779 }
2780 
SetKeyboardShortcut(FrameNode * frameNode,const std::string & value,const std::vector<ModifierKey> & keys,std::function<void ()> && onKeyboardShortcutAction)2781 void ViewAbstract::SetKeyboardShortcut(FrameNode* frameNode, const std::string& value,
2782     const std::vector<ModifierKey>& keys, std::function<void()>&& onKeyboardShortcutAction)
2783 {
2784     auto pipeline = PipelineContext::GetCurrentContext();
2785     CHECK_NULL_VOID(pipeline);
2786     auto eventManager = pipeline->GetEventManager();
2787     CHECK_NULL_VOID(eventManager);
2788     auto eventHub = frameNode->GetEventHub<EventHub>();
2789     CHECK_NULL_VOID(eventHub);
2790     CHECK_NULL_VOID(frameNode);
2791     auto frameNodeRef = AceType::Claim<FrameNode>(frameNode);
2792     if (value.empty() || (keys.empty() && value.length() == 1)) {
2793         eventHub->SetKeyboardShortcut("", 0, nullptr);
2794         return;
2795     }
2796     auto key = eventManager->GetKeyboardShortcutKeys(keys);
2797     if ((key == 0 && value.length() == 1) || (key == 0 && !keys.empty() && value.length() > 1)) {
2798         return;
2799     }
2800     if (eventManager->IsSameKeyboardShortcutNode(value, key)) {
2801         return;
2802     }
2803     eventHub->SetKeyboardShortcut(value, key, onKeyboardShortcutAction);
2804     eventManager->AddKeyboardShortcutNode(WeakPtr<NG::FrameNode>(frameNodeRef));
2805 }
2806 
SetOnFocus(FrameNode * frameNode,OnFocusFunc && onFocusCallback)2807 void ViewAbstract::SetOnFocus(FrameNode* frameNode, OnFocusFunc &&onFocusCallback)
2808 {
2809     CHECK_NULL_VOID(frameNode);
2810     auto focusHub = frameNode->GetOrCreateFocusHub();
2811     focusHub->SetOnFocusCallback(std::move(onFocusCallback));
2812 }
2813 
SetOnBlur(FrameNode * frameNode,OnBlurFunc && onBlurCallback)2814 void ViewAbstract::SetOnBlur(FrameNode* frameNode, OnBlurFunc &&onBlurCallback)
2815 {
2816     CHECK_NULL_VOID(frameNode);
2817     auto focusHub = frameNode->GetOrCreateFocusHub();
2818     focusHub->SetOnBlurCallback(std::move(onBlurCallback));
2819 }
2820 
2821 } // namespace OHOS::Ace::NG
2822