1 /* 2 * Copyright (c) 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_MODIFIER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIVIDER_DIVIDER_MODIFIER_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/components/common/properties/color.h" 21 #include "core/components_ng/base/modifier.h" 22 #include "core/components_ng/property/property.h" 23 #include "core/components_ng/render/animation_utils.h" 24 #include "core/components_ng/render/drawing_forward.h" 25 26 namespace OHOS::Ace::NG { 27 class DividerModifier : public ContentModifier { 28 DECLARE_ACE_TYPE(DividerModifier, ContentModifier); 29 public: 30 DividerModifier(); 31 ~DividerModifier() override = default; 32 void PaintDivider(DrawingContext& context) const; 33 void onDraw(DrawingContext& context) override; 34 SetColor(LinearColor color)35 void SetColor(LinearColor color) 36 { 37 color_->Set(color); 38 } 39 SetStrokeWidth(float strokeWidth)40 void SetStrokeWidth(float strokeWidth) 41 { 42 strokeWidth_->Set(strokeWidth); 43 } 44 SetDividerLength(float dividerLength)45 void SetDividerLength(float dividerLength) 46 { 47 dividerLength_->Set(dividerLength); 48 } 49 SetLineCap(LineCap lineCap)50 void SetLineCap(LineCap lineCap) 51 { 52 lineCap_->Set(static_cast<int>(lineCap)); 53 } 54 SetVertical(bool vertical)55 void SetVertical(bool vertical) 56 { 57 vertical_->Set(vertical); 58 } 59 SetOffset(OffsetF offset)60 void SetOffset(OffsetF offset) 61 { 62 offset_->Set(offset); 63 } 64 SetStrokeWidthLimitation(bool limite)65 void SetStrokeWidthLimitation(bool limite) 66 { 67 strokeWidthLimitation_->Set(limite); 68 } 69 70 private: 71 RefPtr<AnimatablePropertyFloat> strokeWidth_; 72 RefPtr<AnimatablePropertyColor> color_; 73 RefPtr<PropertyFloat> dividerLength_; 74 RefPtr<PropertyInt> lineCap_; 75 RefPtr<PropertyBool> vertical_; 76 RefPtr<PropertyOffsetF> offset_; 77 RefPtr<PropertyBool> strokeWidthLimitation_; 78 79 ACE_DISALLOW_COPY_AND_MOVE(DividerModifier); 80 }; 81 } // namespace OHOS::Ace::NG 82 83 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_DIVIDER_DIVIDER_MODIFIER_H 84