1 /* 2 * Copyright (c) 2022-2023 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_PATTERNS_DIVIDER_DIVIDER_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIVIDER_DIVIDER_PATTERN_H 18 19 #include "core/components_ng/pattern/divider/divider_layout_algorithm.h" 20 #include "core/components_ng/pattern/divider/divider_layout_property.h" 21 #include "core/components_ng/pattern/divider/divider_modifier.h" 22 #include "core/components_ng/pattern/divider/divider_paint_method.h" 23 #include "core/components_ng/pattern/divider/divider_render_property.h" 24 #include "core/components_ng/pattern/pattern.h" 25 26 namespace OHOS::Ace::NG { 27 class DividerPattern : public Pattern { 28 DECLARE_ACE_TYPE(DividerPattern, Pattern); 29 30 public: 31 DividerPattern() = default; 32 ~DividerPattern() override = default; 33 CreateNodePaintMethod()34 RefPtr<NodePaintMethod> CreateNodePaintMethod() override 35 { 36 if (!dividerModifier_) { 37 dividerModifier_ = AceType::MakeRefPtr<DividerModifier>(); 38 } 39 return MakeRefPtr<DividerPaintMethod>(constrainStrokeWidth_, dividerLength_, vertical_, dividerModifier_); 40 } 41 CreateLayoutProperty()42 RefPtr<LayoutProperty> CreateLayoutProperty() override 43 { 44 return MakeRefPtr<DividerLayoutProperty>(); 45 } 46 CreateLayoutAlgorithm()47 RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override 48 { 49 return MakeRefPtr<DividerLayoutAlgorithm>(); 50 } 51 CreatePaintProperty()52 RefPtr<PaintProperty> CreatePaintProperty() override 53 { 54 return MakeRefPtr<DividerRenderProperty>(); 55 } 56 GetFocusPattern()57 FocusPattern GetFocusPattern() const override 58 { 59 return { FocusType::NODE, false, FocusStyleType::OUTER_BORDER }; 60 } 61 62 private: 63 bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override; 64 float constrainStrokeWidth_ = 0; 65 float dividerLength_ = 0; 66 bool vertical_ = false; 67 RefPtr<DividerModifier> dividerModifier_; 68 ACE_DISALLOW_COPY_AND_MOVE(DividerPattern); 69 }; 70 } // namespace OHOS::Ace::NG 71 72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIVIDER_DIVIDER_PATTERN_H 73