1 /* 2 * Copyright (c) 2023-2024 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_SCROLL_GRID_SCROLL_WITH_OPTIONS_LAYOUT_ALGORITHM_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_SCROLL_GRID_SCROLL_WITH_OPTIONS_LAYOUT_ALGORITHM_H 18 19 #include "core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.h" 20 21 namespace OHOS::Ace::NG { 22 class ACE_EXPORT GridScrollWithOptionsLayoutAlgorithm : public GridScrollLayoutAlgorithm { 23 DECLARE_ACE_TYPE(GridScrollWithOptionsLayoutAlgorithm, GridScrollLayoutAlgorithm); 24 25 public: GridScrollWithOptionsLayoutAlgorithm(GridLayoutInfo gridLayoutInfo,uint32_t crossCount,uint32_t mainCount)26 GridScrollWithOptionsLayoutAlgorithm(GridLayoutInfo gridLayoutInfo, uint32_t crossCount, uint32_t mainCount) 27 : GridScrollLayoutAlgorithm(gridLayoutInfo, crossCount, mainCount) {}; 28 ~GridScrollWithOptionsLayoutAlgorithm() override = default; 29 30 private: 31 void SkipLargeOffset(float mainSize, LayoutWrapper* layoutWrapper) override; 32 void SkipIrregularLines(LayoutWrapper* layoutWrapper, bool forward) override; 33 34 void LargeItemLineHeight(const RefPtr<LayoutWrapper>& itemWrapper, bool& hasNormalItem) override; 35 36 void GetTargetIndexInfoWithBenchMark( 37 LayoutWrapper* layoutWrapper, bool isTargetBackward, int32_t targetIndex) override; 38 39 void AdjustRowColSpan( 40 const RefPtr<LayoutWrapper>& itemLayoutWrapper, LayoutWrapper* layoutWrapper, int32_t itemIndex) override; 41 42 std::pair<int32_t, int32_t> GetCrossStartAndSpan(LayoutWrapper* layoutWrapper, int32_t itemIndex); 43 44 std::pair<int32_t, int32_t> GetCrossStartAndSpanWithUserFunction( 45 int32_t itemIndex, const GridLayoutOptions& options, int32_t firstIrregularIndex); 46 UpdateRealGridItemPositionInfo(const RefPtr<LayoutWrapper> & itemLayoutWrapper,int32_t mainIndex,int32_t crossIndex)47 void UpdateRealGridItemPositionInfo( 48 const RefPtr<LayoutWrapper>& itemLayoutWrapper, int32_t mainIndex, int32_t crossIndex) override 49 {} 50 UpdateMainLineOnReload(int32_t startIdx)51 void UpdateMainLineOnReload(int32_t startIdx) override 52 { 53 /* With irregular items, mainLineIndex can't be determined by simple calculation. */ 54 } 55 FillOneLineForwardWithoutUpdatingStartIndex(float crossSize,float mainSize,LayoutWrapper * layoutWrapper)56 void FillOneLineForwardWithoutUpdatingStartIndex( 57 float crossSize, float mainSize, LayoutWrapper* layoutWrapper) override 58 {} 59 ACE_DISALLOW_COPY_AND_MOVE(GridScrollWithOptionsLayoutAlgorithm); 60 }; 61 } // namespace OHOS::Ace::NG 62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_SCROLL_GRID_SCROLL_WITH_OPTIONS_LAYOUT_ALGORITHM_H 63