• 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_FLEX_FLEX_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_H
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "base/utils/macros.h"
23 #include "core/components/common/layout/constants.h"
24 
25 namespace OHOS::Ace {
26 
27 const std::vector<WrapAlignment> WRAP_TABLE = {
28     WrapAlignment::START,
29     WrapAlignment::START,
30     WrapAlignment::CENTER,
31     WrapAlignment::END,
32     WrapAlignment::STRETCH,
33     WrapAlignment::BASELINE,
34     WrapAlignment::SPACE_BETWEEN,
35     WrapAlignment::SPACE_AROUND,
36     WrapAlignment::SPACE_EVENLY,
37 };
38 
39 constexpr int32_t MAIN_ALIGN_MAX_VALUE = 8;
40 constexpr int32_t CROSS_ALIGN_MAX_VALUE = 5;
41 constexpr int32_t DIRECTION_MAX_VALUE = 3;
42 
43 class ACE_EXPORT FlexModel {
44 public:
45     static FlexModel* GetInstance();
46     virtual ~FlexModel() = default;
47 
48     virtual void CreateFlexRow() = 0;
49 
50     virtual void CreateWrap() = 0;
51 
52     virtual void SetDirection(FlexDirection direction) = 0;
53     virtual void SetWrapDirection(WrapDirection direction) = 0;
54 
55     virtual void SetMainAxisAlign(FlexAlign flexAlign) = 0;
56     virtual void SetWrapMainAlignment(WrapAlignment value) = 0;
57 
58     virtual void SetCrossAxisAlign(FlexAlign flexAlign) = 0;
59     virtual void SetWrapCrossAlignment(WrapAlignment value) = 0;
60 
61     virtual void SetAlignItems(int32_t value) = 0;
62     virtual void SetWrapAlignment(WrapAlignment value) = 0;
63 
64     virtual void SetHasHeight() = 0;
65     virtual void SetHasWidth() = 0;
66     virtual void SetFlexWidth() = 0;
67     virtual void SetFlexHeight() = 0;
68 
69     virtual void SetJustifyContent(int32_t value) = 0;
70 
71     virtual void SetAlignContent(int32_t value) = 0;
72 
73 private:
74     static std::unique_ptr<FlexModel> instance_;
75 };
76 
77 } // namespace OHOS::Ace
78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_H
79