• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_V2_GRID_LAYOUT_GRIDCOL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRIDCOL_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/memory/referenced.h"
21 #include "core/components_v2/grid_layout/grid_col_element.h"
22 #include "core/components_v2/grid_layout/grid_container_util_class.h"
23 #include "core/components_v2/grid_layout/render_grid_col.h"
24 #include "core/pipeline/base/sole_child_component.h"
25 
26 namespace OHOS::Ace::V2 {
27 
28 class ACE_EXPORT GridColComponent : public SoleChildComponent {
29     DECLARE_ACE_TYPE(GridColComponent, SoleChildComponent);
30 
31 public:
SetSpan(const RefPtr<GridContainerSize> & span)32     void SetSpan(const RefPtr<GridContainerSize>& span)
33     {
34         span_ = span;
35     }
36 
SetOffset(const RefPtr<GridContainerSize> & offset)37     void SetOffset(const RefPtr<GridContainerSize>& offset)
38     {
39         offset_ = offset;
40     }
41 
SetOrder(const RefPtr<GridContainerSize> & order)42     void SetOrder(const RefPtr<GridContainerSize>& order)
43     {
44         order_ = order;
45     }
46 
GetSpan()47     RefPtr<GridContainerSize> GetSpan() const
48     {
49         return span_;
50     }
51 
GetSpan(GridSizeType sizeType)52     int32_t GetSpan(GridSizeType sizeType) const
53     {
54         LOGI("GetSpan %{public}d", span_->sm);
55         switch (sizeType) {
56             case GridSizeType::XS:
57                 return span_->xs;
58                 break;
59             case GridSizeType::SM:
60                 return span_->sm;
61                 break;
62             case GridSizeType::MD:
63                 return span_->md;
64                 break;
65             case GridSizeType::LG:
66                 return span_->lg;
67                 break;
68             case GridSizeType::XL:
69                 return span_->xl;
70                 break;
71             case GridSizeType::XXL:
72                 return span_->xxl;
73                 break;
74             default:
75                 return span_->xs;
76         }
77     }
78 
GetOffset()79     RefPtr<GridContainerSize> GetOffset() const
80     {
81         return offset_;
82     }
83 
GetOffset(GridSizeType sizeType)84     int32_t GetOffset(GridSizeType sizeType) const
85     {
86         switch (sizeType) {
87             case GridSizeType::XS:
88                 return offset_->xs;
89                 break;
90             case GridSizeType::SM:
91                 return offset_->sm;
92                 break;
93             case GridSizeType::MD:
94                 return offset_->md;
95                 break;
96             case GridSizeType::LG:
97                 return offset_->lg;
98                 break;
99             case GridSizeType::XL:
100                 return offset_->xl;
101                 break;
102             case GridSizeType::XXL:
103                 return offset_->xxl;
104                 break;
105             default:
106                 return offset_->xs;
107         }
108     }
109 
GetOrder()110     RefPtr<GridContainerSize> GetOrder() const
111     {
112         return order_;
113     }
114 
GetOrder(GridSizeType sizeType)115     int32_t GetOrder(GridSizeType sizeType) const
116     {
117         switch (sizeType) {
118             case GridSizeType::XS:
119                 return order_->xs;
120                 break;
121             case GridSizeType::SM:
122                 return order_->sm;
123                 break;
124             case GridSizeType::MD:
125                 return order_->md;
126                 break;
127             case GridSizeType::LG:
128                 return order_->lg;
129                 break;
130             case GridSizeType::XL:
131                 return order_->xl;
132                 break;
133             case GridSizeType::XXL:
134                 return order_->xxl;
135                 break;
136             default:
137                 return order_->xs;
138         }
139     }
140 
141     RefPtr<Element> CreateElement() override;
142 
143     RefPtr<RenderNode> CreateRenderNode() override;
144 
145 private:
146     RefPtr<GridContainerSize> span_ = AceType::MakeRefPtr<GridContainerSize>(1);
147     RefPtr<GridContainerSize> offset_ = AceType::MakeRefPtr<GridContainerSize>(0);
148     RefPtr<GridContainerSize> order_ = AceType::MakeRefPtr<GridContainerSize>(0);
149 };
150 
151 } // namespace OHOS::Ace::V2
152 #endif