• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_CHECKBOXGROUP_CHECKBOXGROUP_PAINT_METHOD_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_CHECKBOXGROUP_CHECKBOXGROUP_PAINT_METHOD_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/utils/macros.h"
21 #include "core/components_ng/pattern/radio/radio_paint_method.h"
22 #include "core/components_ng/render/canvas.h"
23 #include "core/components_ng/render/drawing.h"
24 #include "core/components_ng/render/node_paint_method.h"
25 
26 namespace OHOS::Ace::NG {
27 
28 class CheckBoxGroupPaintMethod : public NodePaintMethod {
DECLARE_ACE_TYPE(CheckBoxGroupPaintMethod,NodePaintMethod)29     DECLARE_ACE_TYPE(CheckBoxGroupPaintMethod, NodePaintMethod)
30 
31 public:
32     CheckBoxGroupPaintMethod(bool enabled, bool isTouch, bool isHover, float shapeScale, UIStatus uiStatus)
33         : enabled_(enabled), isTouch_(isTouch), isHover_(isHover), shapeScale_(shapeScale), uiStatus_(uiStatus) {};
34 
35     ~CheckBoxGroupPaintMethod() override = default;
36 
37     CanvasDrawFunction GetContentDrawFunction(PaintWrapper* paintWrapper) override;
38 
SetHotZoneOffset(OffsetF & hotZoneOffset)39     void SetHotZoneOffset(OffsetF& hotZoneOffset)
40     {
41         hotZoneOffset_ = hotZoneOffset;
42     }
43 
SetHotZoneSize(SizeF & hotZoneSize)44     void SetHotZoneSize(SizeF& hotZoneSize)
45     {
46         hotZoneSize_ = hotZoneSize;
47     }
48 
49 private:
50     void InitializeParam();
51     void PaintCheckBox(RSCanvas& canvas, PaintWrapper* paintWrapper) const;
52     void DrawUnselected(RSCanvas& canvas, const OffsetF& origin, RSPen& pen, SizeF& paintSize) const;
53     void DrawActiveBorder(RSCanvas& canvas, const OffsetF& paintOffset, RSBrush& brush, const SizeF& paintSize) const;
54     void DrawUnselectedBorder(
55         RSCanvas& canvas, const OffsetF& paintOffset, RSBrush& brush, const SizeF& paintSize) const;
56     void DrawPart(RSCanvas& canvas, const OffsetF& origin, RSPen& pen, const SizeF& paintSize) const;
57     void DrawTouchBoard(RSCanvas& canvas, const SizeF& contentSize, const OffsetF& offset) const;
58     void DrawHoverBoard(RSCanvas& canvas, const SizeF& contentSize, const OffsetF& offset) const;
59     void DrawAnimationOffToOn(RSCanvas& canvas, const OffsetF& origin, RSPen& pen, const SizeF& paintSize) const;
60     void DrawAnimationOnToOff(RSCanvas& canvas, const OffsetF& origin, RSPen& pen, const SizeF& paintSize) const;
61 
62     float borderWidth_ = 0.0f;
63     float borderRadius_ = 0.0f;
64     float checkStroke_ = 0.0f;
65     Color pointColor_;
66     Color activeColor_;
67     Color inactiveColor_;
68     Color shadowColor_;
69     Color clickEffectColor_;
70     Color hoverColor_;
71     Color inactivePointColor_;
72     Dimension hoverRadius_;
73     Dimension hotZoneHorizontalPadding_;
74     Dimension hotZoneVerticalPadding_;
75     Dimension shadowWidth_;
76 
77     bool enabled_ = true;
78     bool isTouch_ = false;
79     bool isHover_ = false;
80     float shapeScale_ = 1.0f;
81     UIStatus uiStatus_ = UIStatus::UNSELECTED;
82     OffsetF hotZoneOffset_;
83     SizeF hotZoneSize_;
84 };
85 } // namespace OHOS::Ace::NG
86 
87 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PAINTS_CHECKBOXGROUP_CHECKBOXGROUP_PAINT_METHOD_H
88