1 /* 2 * Copyright (c) 2023 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_NG_PATTERN_GRID_GRID_LAYOUT_OPTIONS_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_LAYOUT_OPTIONS_H 18 19 namespace OHOS::Ace { 20 struct GridItemSize { 21 int32_t rows = 1; 22 int32_t columns = 1; 23 bool operator==(const GridItemSize& itemSize) const 24 { 25 return (rows == itemSize.rows) && (columns == itemSize.columns); 26 } GetCorssSizeGridItemSize27 int32_t GetCorssSize(Axis axis) const 28 { 29 return axis == Axis::VERTICAL ? columns : rows; 30 } 31 }; 32 33 using GetSizeByIndex = std::function<GridItemSize(int32_t)>; 34 35 struct GridLayoutOptions { 36 GridItemSize regularSize; 37 std::set<int32_t> irregularIndexes; 38 GetSizeByIndex getSizeByIndex; 39 bool operator==(const GridLayoutOptions& options) const 40 { 41 return (regularSize == options.regularSize) && (irregularIndexes == options.irregularIndexes) && 42 (!getSizeByIndex && !options.getSizeByIndex); 43 } 44 45 bool operator!=(const GridLayoutOptions& options) const 46 { 47 return !operator==(options); 48 } 49 }; 50 } // namespace OHOS::Ace 51 52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_LAYOUT_OPTIONS_H 53