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_PAINTS_CHECKBOX_CHECKBOX_PAINT_METHOD_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_CHECKBOX_CHECKBOX_PAINT_METHOD_H 18 19 #include "base/memory/ace_type.h" 20 #include "base/utils/macros.h" 21 #include "core/components_ng/pattern/checkbox/checkbox_modifier.h" 22 #include "core/components_ng/render/node_paint_method.h" 23 namespace OHOS::Ace::NG { 24 class CheckBoxPaintProperty; 25 constexpr float CHECKBOX_MARK_STROKEWIDTH_LIMIT_RATIO = 0.25f; 26 class CheckBoxPaintMethod : public NodePaintMethod { 27 DECLARE_ACE_TYPE(CheckBoxPaintMethod, NodePaintMethod) 28 29 public: 30 CheckBoxPaintMethod() = default; 31 32 ~CheckBoxPaintMethod() override = default; 33 34 RefPtr<Modifier> GetContentModifier(PaintWrapper* paintWrapper) override; 35 36 void UpdateCheckboxColors(const RefPtr<CheckBoxPaintProperty>& paintProperty); 37 38 void UpdateContentModifier(PaintWrapper* paintWrapper) override; 39 40 void SetModifierBoundsRect(const SizeF& size, const OffsetF& offset); 41 42 void SetHoverEffectType(const RefPtr<CheckBoxPaintProperty>& checkBoxPaintProperty); 43 SetHotZoneOffset(OffsetF & hotZoneOffset)44 void SetHotZoneOffset(OffsetF& hotZoneOffset) 45 { 46 hotZoneOffset_ = hotZoneOffset; 47 } 48 SetHotZoneSize(SizeF & hotZoneSize)49 void SetHotZoneSize(SizeF& hotZoneSize) 50 { 51 hotZoneSize_ = hotZoneSize; 52 } 53 SetEnabled(bool enabled)54 void SetEnabled(bool enabled) 55 { 56 enabled_ = enabled; 57 } 58 SetTotalScale(float totalScale)59 void SetTotalScale(float totalScale) 60 { 61 totalScale_ = totalScale; 62 } 63 SetPointScale(float pointScale)64 void SetPointScale(float pointScale) 65 { 66 pointScale_ = pointScale; 67 } 68 SetTouchHoverAnimationType(const TouchHoverAnimationType touchHoverType)69 void SetTouchHoverAnimationType(const TouchHoverAnimationType touchHoverType) 70 { 71 touchHoverType_ = touchHoverType; 72 } 73 SetCheckboxStyle(CheckBoxStyle checkBoxStyle)74 void SetCheckboxStyle(CheckBoxStyle checkBoxStyle) 75 { 76 checkBoxStyle_ = checkBoxStyle; 77 } 78 SetUseContentModifier(bool useContentModifier)79 void SetUseContentModifier(bool useContentModifier) 80 { 81 useContentModifier_ = useContentModifier; 82 } 83 SetHasBuilder(bool hasBuilder)84 void SetHasBuilder(bool hasBuilder) 85 { 86 hasBuilder_ = hasBuilder; 87 } 88 GetCheckBoxModifier()89 RefPtr<CheckBoxModifier> GetCheckBoxModifier() 90 { 91 return checkboxModifier_; 92 } 93 94 private: 95 bool enabled_ = true; 96 float totalScale_ = 1.0f; 97 float pointScale_ = 0.5f; 98 bool hasBuilder_ = false; 99 bool useContentModifier_ = false; 100 CheckBoxStyle checkBoxStyle_ = CheckBoxStyle::CIRCULAR_STYLE; 101 OffsetF hotZoneOffset_; 102 SizeF hotZoneSize_; 103 TouchHoverAnimationType touchHoverType_ = TouchHoverAnimationType::NONE; 104 105 RefPtr<CheckBoxModifier> checkboxModifier_; 106 }; 107 } // namespace OHOS::Ace::NG 108 109 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_CHECKBOX_CHECKBOX_PAINT_METHOD_H 110