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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_MASK_PROGRESS_MOON_PROGRESS_MODIFIER_H
16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_MASK_PROGRESS_MOON_PROGRESS_MODIFIER_H
17 
18 #include "core/components/common/properties/color.h"
19 #include "core/components_ng/base/modifier.h"
20 
21 namespace OHOS::Ace::NG {
22 class MoonProgressModifier : public OverlayModifier {
23 public:
24     MoonProgressModifier(const WeakPtr<FrameNode>& maskNode);
25     ~MoonProgressModifier() override = default;
26 
27     void onDraw(DrawingContext& context) override;
28 
29     void SetMaskColor(LinearColor color);
30     void SetValue(float value);
31     void SetMaxValue(float value);
32     float GetMaxValue();
33     void InitRatio();
34     void SetMoonAnimate(float value);
35     void StartPictureAnimate() const;
36     void StopPictureAnimate() const;
37 
38     void SetBigRadius();
39     void SetEnableBreathe(bool enableBreathe);
40 
41 private:
42     void CalculateSquareMoonPath(RSPath& path, const PointF& centerPt, const double& angle);
43     void PaintSquareMoon(RSCanvas& canvas);
44     void PaintSquareMoonShadow(RSCanvas& canvas, RSBrush& brush);
45     void RegisterVisibleChange();
46     void RemoveVisibleChange();
47 
48     // Animatable
49     RefPtr<AnimatablePropertyColor> maskColor_;
50     RefPtr<AnimatablePropertyFloat> ratio_;
51     RefPtr<AnimatablePropertyFloat> value_;
52     RefPtr<AnimatablePropertyFloat> opacity_;
53     // No animatable
54     RefPtr<PropertyFloat> maxValue_;
55     RefPtr<PropertyBool> enableBreathe_;
56     WeakPtr<FrameNode> maskNode_;
57     // Others
58     float bigRadius_ = .0f;
59     float smallRadius_ = .0f;
60     SizeF frameSize_;
61     bool animationEnd_ = false;
62     bool hideMask_ = false;
63     bool hasVisibleChangeRegister_ = false;
64 };
65 } // namespace OHOS::Ace::NG
66 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_MASK_PROGRESS_MOON_PROGRESS_MODIFIER_H
67