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