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_GRIDROW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRIDROW_H 18 19 #include <string> 20 #include <vector> 21 22 #include "base/geometry/dimension.h" 23 #include "base/memory/ace_type.h" 24 #include "base/utils/macros.h" 25 #include "base/utils/string_utils.h" 26 #include "core/common/window.h" 27 #include "core/components_v2/common/common_def.h" 28 #include "core/components_v2/grid_layout/grid_container_util_class.h" 29 #include "core/components_v2/grid_layout/grid_row_element.h" 30 #include "core/components_v2/grid_layout/render_grid_row.h" 31 #include "core/pipeline/base/component_group.h" 32 33 namespace OHOS::Ace::V2 { 34 35 using ColumnInfo = GridContainerSize; 36 37 class ACE_EXPORT GridRowComponent : public ComponentGroup { 38 DECLARE_ACE_TYPE(GridRowComponent, ComponentGroup); 39 40 public: GetTotalCol()41 const RefPtr<ColumnInfo>& GetTotalCol() const 42 { 43 return totalCol_; 44 } 45 SetTotalCol(const RefPtr<ColumnInfo> & cols)46 void SetTotalCol(const RefPtr<ColumnInfo>& cols) 47 { 48 totalCol_ = cols; 49 } 50 GetBreakPoints()51 const RefPtr<BreakPoints>& GetBreakPoints() const 52 { 53 return breakPoints_; 54 } 55 SetBreakPoints(const RefPtr<BreakPoints> & breakpoints)56 void SetBreakPoints(const RefPtr<BreakPoints>& breakpoints) 57 { 58 breakPoints_ = breakpoints; 59 } 60 GetGutter()61 const RefPtr<Gutter>& GetGutter() const 62 { 63 return gutter_; 64 } 65 SetGutter(const RefPtr<Gutter> & gutter)66 void SetGutter(const RefPtr<Gutter>& gutter) 67 { 68 gutter_ = gutter; 69 } 70 SetHasContainerHeight(bool hasContainerHeight)71 void SetHasContainerHeight(bool hasContainerHeight) 72 { 73 hasContainerHeight_ = hasContainerHeight; 74 } 75 HasContainerHeight()76 bool HasContainerHeight() 77 { 78 return hasContainerHeight_; 79 } 80 81 RefPtr<Element> CreateElement() override; 82 83 RefPtr<RenderNode> CreateRenderNode() override; 84 SetDirection(const GridRowDirection direction)85 void SetDirection(const GridRowDirection direction) 86 { 87 direction_ = direction; 88 } 89 GetDirection()90 GridRowDirection GetDirection() const 91 { 92 return direction_; 93 } 94 95 ACE_DEFINE_COMPONENT_EVENT(breakPointChange, void(std::string)); 96 FirebreakPointEvent(const std::string & sizeType)97 void FirebreakPointEvent(const std::string& sizeType) 98 { 99 if (eventbreakPointChange_) { 100 (*eventbreakPointChange_)(sizeType); 101 } 102 } 103 104 private: 105 RefPtr<ColumnInfo> totalCol_ = AceType::MakeRefPtr<ColumnInfo>(); 106 RefPtr<BreakPoints> breakPoints_ = AceType::MakeRefPtr<BreakPoints>(); 107 RefPtr<Gutter> gutter_ = AceType::MakeRefPtr<Gutter>(); 108 GridRowDirection direction_ = GridRowDirection::Row; 109 bool hasContainerHeight_ = false; 110 }; 111 112 } // namespace OHOS::Ace::V2 113 114 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRIDROW_H 115