• 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_STACK_RENDER_STACK_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_STACK_RENDER_STACK_H
18 
19 #include "core/components/common/layout/constants.h"
20 #include "core/components/common/properties/alignment.h"
21 #include "core/components/positioned/render_positioned.h"
22 #include "core/pipeline/base/render_node.h"
23 
24 namespace OHOS::Ace {
25 
26 class ACE_EXPORT RenderStack : public RenderNode {
27     DECLARE_ACE_TYPE(RenderStack, RenderNode);
28 
29 public:
30     static RefPtr<RenderNode> Create();
31 
32     void Update(const RefPtr<Component>& component) override;
33 
34     void PerformLayout() override;
35 
GetOverflowFlag()36     Overflow GetOverflowFlag() const
37     {
38         return overflow_;
39     }
40 
IsChildOverflow()41     bool IsChildOverflow() const
42     {
43         return isChildOverflow_;
44     }
45 
SetStackFit(StackFit fit)46     void SetStackFit(StackFit fit)
47     {
48         fit_ = fit;
49     }
50 
SetMainStackSize(MainStackSize mainStackSize)51     void SetMainStackSize(MainStackSize mainStackSize)
52     {
53         mainStackSize_ = mainStackSize;
54     }
55 
GetAlignment()56     const Alignment& GetAlignment() const
57     {
58         return align_;
59     }
60 
GetStackFit()61     StackFit GetStackFit() const
62     {
63         return fit_;
64     }
65 
GetOverflow()66     Overflow GetOverflow() const
67     {
68         return overflow_;
69     }
70 
71     void OnAttachContext() override;
72 
73 protected:
74     LayoutParam MakeNonPositionedInnerLayoutParam(const RefPtr<RenderNode>& firstChild) const;
75     LayoutParam MakePositionedInnerLayoutParam(
76         const RefPtr<RenderPositioned>& item, const RefPtr<RenderNode>& firstChild) const;
77 
78     Offset GetNonPositionedChildOffset(const Size& childSize);
79     Offset GetPositionedChildOffset(const RefPtr<RenderPositioned>& item);
80 
81     virtual void DetermineStackSize(bool hasNonPositioned);
SetChildrenStatus()82     virtual void SetChildrenStatus() {}
83 private:
84     Alignment align_;
85     StackFit fit_ = StackFit::KEEP;
86     Overflow overflow_ = Overflow::OBSERVABLE;
87     bool isChildOverflow_ = false;
88     MainStackSize mainStackSize_ = MainStackSize::NORMAL;
89 };
90 
91 } // namespace OHOS::Ace
92 
93 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_STACK_RENDER_STACK_H
94