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_SLIDER_SLIDER_TIP_MODIFIER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SLIDER_SLIDER_TIP_MODIFIER_H 18 19 #include "core/components_ng/base/modifier.h" 20 #include "core/components_ng/render/drawing.h" 21 #include "core/components_ng/render/paragraph.h" 22 23 namespace OHOS::Ace::NG { 24 class SliderTipModifier : public OverlayModifier { 25 DECLARE_ACE_TYPE(SliderTipModifier, OverlayModifier); 26 27 public: 28 SliderTipModifier(); 29 ~SliderTipModifier() override = default; 30 31 void PaintTip(DrawingContext& context); 32 void PaintBubble(DrawingContext& context); 33 onDraw(DrawingContext & context)34 void onDraw(DrawingContext& context) override 35 { 36 if (tipFlag_->Get()) { 37 PaintTip(context); 38 } 39 } 40 SetParagraph(const RefPtr<NG::Paragraph> & paragraph)41 void SetParagraph(const RefPtr<NG::Paragraph>& paragraph) 42 { 43 paragraph_ = paragraph; 44 } 45 SetDirection(const Axis & axis)46 void SetDirection(const Axis& axis) 47 { 48 axis_ = axis; 49 } 50 SetTipColor(const Color & color)51 void SetTipColor(const Color& color) 52 { 53 tipColor_ = color; 54 } 55 SetTipFlag(bool flag)56 void SetTipFlag(bool flag) 57 { 58 if (tipFlag_) { 59 tipFlag_->Set(flag); 60 } 61 } 62 SetContentOffset(OffsetF contentOffset)63 void SetContentOffset(OffsetF contentOffset) 64 { 65 if (contentOffset_) { 66 contentOffset_->Set(contentOffset); 67 } 68 } 69 SetBubbleSize(SizeF bubbleSize)70 void SetBubbleSize(SizeF bubbleSize) 71 { 72 if (bubbleSize_) { 73 bubbleSize_->Set(bubbleSize); 74 } 75 } 76 SetBubbleOffset(OffsetF bubbleOffset)77 void SetBubbleOffset(OffsetF bubbleOffset) 78 { 79 if (bubbleOffset_) { 80 bubbleOffset_->Set(bubbleOffset); 81 } 82 } 83 SetTextOffset(OffsetF textOffset)84 void SetTextOffset(OffsetF textOffset) 85 { 86 if (textOffset_) { 87 textOffset_->Set(textOffset); 88 } 89 } 90 91 private: 92 RefPtr<PropertyBool> tipFlag_; 93 RefPtr<PropertyOffsetF> contentOffset_; 94 RefPtr<PropertySizeF> bubbleSize_; 95 RefPtr<PropertyOffsetF> bubbleOffset_; 96 RefPtr<PropertyOffsetF> textOffset_; 97 RefPtr<NG::Paragraph> paragraph_; 98 Axis axis_ = Axis::HORIZONTAL; 99 Color tipColor_ = Color::BLACK; 100 ACE_DISALLOW_COPY_AND_MOVE(SliderTipModifier); 101 }; 102 } // namespace OHOS::Ace::NG 103 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SLIDER_TIP_MODIFIER_H 104