• 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_PATTERNS_LOADING_PROGRESS_LOADING_PROGRESS_MODIFIER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LOADING_PROGRESS_LOADING_PROGRESS_MODIFIER_H
18 
19 #include "base/memory/ace_type.h"
20 #include "core/components/common/properties/color.h"
21 #include "core/components_ng/base/modifier.h"
22 #include "core/components_ng/pattern/loading_progress/loading_progress_base.h"
23 #include "core/components_ng/pattern/loading_progress/loading_progress_owner.h"
24 #include "core/components_ng/pattern/refresh/refresh_animation_state.h"
25 #include "core/components_ng/property/property.h"
26 #include "core/components_ng/render/animation_utils.h"
27 #include "core/components_ng/render/drawing.h"
28 
29 namespace OHOS::Ace::NG {
30 class LoadingProgressModifier : public ContentModifier {
31     DECLARE_ACE_TYPE(LoadingProgressModifier, ContentModifier);
32 
33 public:
34     LoadingProgressModifier(LoadingProgressOwner loadingProgressOwner = LoadingProgressOwner::SELF);
35     ~LoadingProgressModifier() override = default;
36     void onDraw(DrawingContext& context) override;
37     void DrawOrbit(DrawingContext& canvas, const CometParam& cometParam, float orbitRadius, float date);
38     void DrawRing(DrawingContext& canvas, const RingParam& ringParam);
39     void StartRecycle();
40     void StartRecycleRingAnimation();
41     void StartRecycleCometAnimation();
42     void StartCometTailAnimation();
43     void StartTransToRecycleAnimation();
SetColor(LinearColor color)44     void SetColor(LinearColor color)
45     {
46         if (color_) {
47             color_->Set(color);
48         }
49     }
50 
51     void DrawCustomStyle(DrawingContext& context);
52     void RefreshRecycle(DrawingContext& context, Color& color, float scale);
53     void ChangeRefreshFollowData(float refreshFollowRatio);
54     void ChangeFadeAwayData(float fadeAwayRatio);
55     float CorrectNormalize(float originData);
56 
GetOwner()57     LoadingProgressOwner GetOwner()
58     {
59         return loadingProgressOwner_;
60     }
61 
62 private:
63     float GetCurentCometOpacity(float baseOpacity, uint32_t index, uint32_t totalNumber);
64     float GetCurentCometAngle(float baseAngle, uint32_t index, uint32_t totalNumber);
65 
66     uint32_t GetCometNumber();
67     RefPtr<AnimatablePropertyFloat> date_;
68     RefPtr<AnimatablePropertyColor> color_;
69     RefPtr<AnimatablePropertyFloat> centerDeviation_;
70     RefPtr<AnimatablePropertyFloat> cometOpacity_;
71     RefPtr<AnimatablePropertyFloat> cometSizeScale_;
72     RefPtr<AnimatablePropertyFloat> cometTailLen_;
73     RefPtr<AnimatablePropertyFloat> sizeScale_;
74 
75     LoadingProgressOwner loadingProgressOwner_;
76     bool isLoading_ = false;
77     ACE_DISALLOW_COPY_AND_MOVE(LoadingProgressModifier);
78 };
79 } // namespace OHOS::Ace::NG
80 
81 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LOADING_PROGRESS_LOADING_PROGRESS_MODIFIER_H
82 
83