• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_RENDER_ADAPTER_FOCUS_ANIMATION_MODIFIER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_RENDER_ADAPTER_FOCUS_ANIMATION_MODIFIER_H
18 
19 #include <tuple>
20 
21 #include "core/components_ng/base/modifier.h"
22 #include "core/components_ng/render/adapter/focus_modifier.h"
23 #include "core/components_ng/render/animation_utils.h"
24 
25 namespace OHOS::Ace::NG {
26 class FocusAnimationModifier : public FocusModifier, public OverlayModifier {
27 public:
28     FocusAnimationModifier();
29     ~FocusAnimationModifier() = default;
30 
31     void onDraw(DrawingContext& context) override;
32     void StartFocusAnimation();
33     void StopFocusAnimation();
34 
35 private:
36     void PaintFocusState(const RSRoundRect&, RSCanvas&, float);
37     void InitTrajectoryData(const RSRoundRect&);
38     float CalArcAngle(float, float);
39     float CalArcLen(float);
40     std::tuple<float, float> GetPosition(float);
41     float GetIncludeAngleOfVector(float, float, float, float, float, float);
42     void InitRoundRectTrajectory(const RSRoundRect&);
43     void InitCircleTrajectory(float);
44     void InitTrajectDataFunc();
45     std::tuple<float, float, float, std::vector<RSScalar>> GetRenderParams(float, float, float);
46     float GetSweepGradientRenderPos(float, float, float, float, float);
47     RefPtr<AnimatablePropertyFloat> focusProcessFloat_;
48     std::shared_ptr<AnimationUtils::Animation> focusAnimation_;
49     bool isRise_ = true;
50     bool animating_ = false;
51     float grith_ = 0.0f;
52     float longerSide_ = 0.0f;
53     float shorterSide_ = 0.0f;
54     std::map<int32_t, std::function<std::tuple<float, float>(float, float)>> trajectDataFunc_;
55     std::map<int32_t, float> trajectoryData_;
56     float topLeftX_ = 0.0f;
57     float topLeftY_ = 0.0f;
58     float topRightX_ = 0.0f;
59     float topRightY_ = 0.0f;
60     float bottomLeftX_ = 0.0f;
61     float bottomLeftY_ = 0.0f;
62     float bottomRightX_ = 0.0f;
63     float bottomRightY_ = 0.0f;
64     RSMatrix rsMatrix_;
65 };
66 } // namespace OHOS::Ace::NG
67 #endif