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