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_GRID_CONTAINER_UTIL_CLASS_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRID_CONTAINER_UTIL_CLASS_H 18 19 #include <utility> 20 21 #include "base/geometry/dimension.h" 22 #include "base/memory/ace_type.h" 23 #include "base/memory/referenced.h" 24 #include "core/components/common/layout/grid_container_info.h" 25 26 namespace OHOS::Ace::V2 { 27 28 constexpr int32_t DEFAULT_COLUMN_NUMBER = 12; 29 struct GridContainerSize : public Referenced { 30 GridContainerSize() = default; GridContainerSizeGridContainerSize31 explicit GridContainerSize(int32_t column) 32 { 33 xs = column; 34 sm = column; 35 md = column; 36 lg = column; 37 xl = column; 38 xxl = column; 39 }; 40 DEFINE_COPY_CONSTRUCTOR_AND_COPY_OPERATOR_AND_COMPARE_OPERATOR_WITH_PROPERTIES( 41 GridContainerSize, (xs)(sm)(md)(lg)(xl)(xxl)) 42 int32_t xs = DEFAULT_COLUMN_NUMBER; 43 int32_t sm = DEFAULT_COLUMN_NUMBER; 44 int32_t md = DEFAULT_COLUMN_NUMBER; 45 int32_t lg = DEFAULT_COLUMN_NUMBER; 46 int32_t xl = DEFAULT_COLUMN_NUMBER; 47 int32_t xxl = DEFAULT_COLUMN_NUMBER; 48 }; 49 50 enum class BreakPointsReference { 51 WindowSize, 52 ComponentSize, 53 }; 54 55 enum class GridRowDirection { 56 Row, 57 RowReverse, 58 }; 59 60 enum class GridSizeType { 61 XS = 0, 62 SM = 1, 63 MD = 2, 64 LG = 3, 65 XL = 4, 66 XXL = 5, 67 UNDEFINED = 6, 68 }; 69 70 struct GridSizeInfo : public Referenced { 71 std::vector<Dimension> sizeInfo { 72 Dimension(320, DimensionUnit::VP), 73 Dimension(600, DimensionUnit::VP), 74 Dimension(840, DimensionUnit::VP), 75 }; 76 ResetGridSizeInfo77 void Reset() 78 { 79 sizeInfo.clear(); 80 } 81 }; 82 83 class Gutter : public AceType { 84 DECLARE_ACE_TYPE(Gutter, AceType); 85 86 public: 87 Gutter() = default; 88 DEFINE_COPY_CONSTRUCTOR_AND_COPY_OPERATOR_AND_COMPARE_OPERATOR_WITH_PROPERTIES( 89 Gutter, (xXs)(yXs)(xSm)(ySm)(xMd)(yMd)(xLg)(yLg)(xXl)(yXl)(xXXl)(yXXl)) 90 explicit Gutter(Dimension dimension) 91 : xXs(dimension), yXs(dimension), xSm(dimension), ySm(dimension), xMd(dimension), yMd(dimension), 92 xLg(dimension), yLg(dimension), xXl(dimension), yXl(dimension), xXXl(dimension), yXXl(dimension) {}; Gutter(Dimension xDimension,Dimension yDimension)93 Gutter(Dimension xDimension, Dimension yDimension) 94 : xXs(xDimension), yXs(yDimension), xSm(xDimension), ySm(yDimension), xMd(xDimension), yMd(yDimension), 95 xLg(xDimension), yLg(yDimension), xXl(xDimension), yXl(yDimension), xXXl(xDimension), yXXl(yDimension) {}; 96 SetYGutter(Dimension yDimension)97 void SetYGutter(Dimension yDimension) 98 { 99 yXs = yDimension; 100 ySm = yDimension; 101 yMd = yDimension; 102 yLg = yDimension; 103 yXl = yDimension; 104 yXXl = yDimension; 105 } 106 SetXGutter(Dimension xDimension)107 void SetXGutter(Dimension xDimension) 108 { 109 xXs = xDimension; 110 xSm = xDimension; 111 xMd = xDimension; 112 xLg = xDimension; 113 xXl = xDimension; 114 xXXl = xDimension; 115 } 116 Dimension xXs; 117 Dimension yXs; 118 Dimension xSm; 119 Dimension ySm; 120 Dimension xMd; 121 Dimension yMd; 122 Dimension xLg; 123 Dimension yLg; 124 Dimension xXl; 125 Dimension yXl; 126 Dimension xXXl; 127 Dimension yXXl; 128 }; 129 130 class BreakPoints : public AceType { 131 DECLARE_ACE_TYPE(BreakPoints, AceType); 132 133 public: 134 BreakPoints() = default; 135 DEFINE_COPY_CONSTRUCTOR_AND_COPY_OPERATOR_AND_COMPARE_OPERATOR_WITH_PROPERTIES( 136 BreakPoints, (reference)(breakpoints)) 137 BreakPointsReference reference = BreakPointsReference::WindowSize; 138 std::vector<std::string> breakpoints { "320vp", "600vp", "840vp" }; 139 }; 140 141 } // namespace OHOS::Ace::V2 142 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_GRID_LAYOUT_GRID_CONTAINER_UTIL_CLASS_H