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_NG_PATTERN_GRID_GRID_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_MODEL_H 18 19 #include "base/geometry/axis.h" 20 #include "base/geometry/dimension.h" 21 #include "base/memory/referenced.h" 22 #include "core/components/common/layout/constants.h" 23 #include "core/components/common/properties/color.h" 24 #include "core/components/scroll_bar/scroll_bar_proxy.h" 25 #include "core/components_v2/grid/grid_position_controller.h" 26 #include "core/event/ace_events.h" 27 #include "core/gestures/gesture_info.h" 28 29 namespace OHOS::Ace { 30 31 class GridModel { 32 public: 33 static GridModel* GetInstance(); 34 virtual ~GridModel() = default; 35 36 virtual void Create( 37 const RefPtr<ScrollControllerBase>& positionController, const RefPtr<ScrollProxy>& scrollBarProxy) = 0; 38 virtual void Pop() = 0; 39 virtual void SetColumnsTemplate(const std::string& value) = 0; 40 virtual void SetRowsTemplate(const std::string& value) = 0; 41 virtual void SetColumnsGap(const Dimension& value) = 0; 42 virtual void SetRowsGap(const Dimension& value) = 0; 43 virtual void SetGridHeight(const Dimension& value) = 0; 44 virtual void SetScrollBarMode(int32_t value) = 0; 45 virtual void SetScrollBarColor(const std::string& value) = 0; 46 virtual void SetScrollBarWidth(const std::string& value) = 0; 47 virtual void SetCachedCount(int32_t value) = 0; 48 virtual void SetIsRTL(bool rightToLeft) = 0; 49 virtual void SetLayoutDirection(FlexDirection value) = 0; 50 virtual void SetMaxCount(int32_t value) = 0; 51 virtual void SetMinCount(int32_t value) = 0; 52 virtual void SetCellLength(int32_t value) = 0; 53 virtual void SetEditable(bool value) = 0; 54 virtual void SetMultiSelectable(bool value) = 0; 55 virtual void SetSupportAnimation(bool value) = 0; 56 virtual void SetSupportDragAnimation(bool value) = 0; 57 virtual void SetEdgeEffect(EdgeEffect edgeEffect) = 0; 58 virtual void SetOnScrollToIndex(std::function<void(const BaseEventInfo*)>&& value) = 0; 59 virtual void SetOnItemDragStart(std::function<void(const ItemDragInfo&, int32_t)>&& value) = 0; 60 virtual void SetOnItemDragEnter(std::function<void(const ItemDragInfo&)>&& value) = 0; 61 virtual void SetOnItemDragMove(std::function<void(const ItemDragInfo&, int32_t, int32_t)>&& value) = 0; 62 virtual void SetOnItemDragLeave(std::function<void(const ItemDragInfo&, int32_t)>&& value) = 0; 63 virtual void SetOnItemDrop(std::function<void(const ItemDragInfo&, int32_t, int32_t, bool)>&& value) = 0; 64 virtual RefPtr<ScrollControllerBase> CreatePositionController(); 65 virtual RefPtr<ScrollProxy> CreateScrollBarProxy(); 66 67 private: 68 static std::unique_ptr<GridModel> instance_; 69 }; 70 71 } // namespace OHOS::Ace 72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_MODEL_H 73