• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ITEM_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_ITEM_MODEL_H
18 
19 #include <functional>
20 #include <memory>
21 #include <mutex>
22 
23 namespace OHOS::Ace {
24 
25 class GridItemModel {
26 public:
27     static GridItemModel* GetInstance();
28     virtual ~GridItemModel() = default;
29 
30     virtual void Create() = 0;
31     virtual void Create(std::function<void(int32_t)>&& deepRenderFunc, bool isLazy) = 0;
32     virtual void SetRowStart(int32_t value) = 0;
33     virtual void SetRowEnd(int32_t value) = 0;
34     virtual void SetColumnStart(int32_t value) = 0;
35     virtual void SetColumnEnd(int32_t value) = 0;
36     virtual void SetForceRebuild(bool value) = 0;
37     virtual void SetSelectable(bool value) = 0;
38     virtual void SetSelected(bool selected) = 0;
39     virtual void SetSelectChangeEvent(std::function<void(bool)>&& changeEvent) = 0;
40     virtual void SetOnSelect(std::function<void(bool)>&& onSelect) = 0;
41 
42 private:
43     static std::unique_ptr<GridItemModel> instance_;
44     static std::mutex mutex_;
45 };
46 
47 } // namespace OHOS::Ace
48 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_GRID_GRID_ITEM_MODEL_H
49