• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_ROOT_RENDER_ROOT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_ROOT_RENDER_ROOT_H
18 
19 #include "core/animation/animator.h"
20 #include "core/pipeline/base/render_node.h"
21 
22 namespace OHOS::Ace {
23 
24 class RenderRoot : public RenderNode {
25     DECLARE_ACE_TYPE(RenderRoot, RenderNode);
26 
27 public:
28     ~RenderRoot() override = default;
29 
30     static RefPtr<RenderNode> Create();
31 
32     void Update(const RefPtr<Component>& component) override;
33     void PerformLayout() override;
34 
35     // Set the design size directly proportional to the real physical pixels.
SetScale(float scale)36     void SetScale(float scale)
37     {
38         scale_ = scale;
39     }
40 
GetScale()41     float GetScale() const
42     {
43         return scale_;
44     }
45 
46     virtual void DumpLayerTree();
47 
IsRepaintBoundary()48     bool IsRepaintBoundary() const override
49     {
50         return true;
51     }
52 
SetReset(bool reset)53     void SetReset(bool reset)
54     {
55         isReset_ = reset;
56     }
57 
58     void AnimateToShow(int32_t duration);
59 
60     void AnimateToHide(int32_t duration);
61 
62     void SetBgColor(const Color& color);
63 
64     void SetDefaultBgColor(bool isTransparent = false);
65 
NotifyOnShow()66     void NotifyOnShow() const
67     {
68         for (const auto& child : GetChildren()) {
69             child->OnAppShow();
70         }
71     }
72 
NotifyOnHide()73     void NotifyOnHide() const
74     {
75         for (const auto& child : GetChildren()) {
76             child->OnAppHide();
77         }
78     }
79 
80 protected:
81     RenderRoot();
82 
83     float scale_ = 1.0f;
84     Color bgColor_ = Color::WHITE;
85     bool forceColor_ = false;
86     bool isBgColorInit_ = false;
87     bool isReset_ = false;
88     RefPtr<Animator> controller_;
89     bool isContextMenu_ = false;
90 };
91 
92 } // namespace OHOS::Ace
93 
94 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_ROOT_RENDER_ROOT_H
95