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