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_SCROLL_EFFECT_SCROLL_FADE_PAINTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLL_EFFECT_SCROLL_FADE_PAINTER_H
18 
19 #include "base/geometry/ng/offset_t.h"
20 #include "base/geometry/ng/size_t.h"
21 #include "base/memory/ace_type.h"
22 #include "core/components/common/properties/color.h"
23 #include "core/components_ng/render/drawing.h"
24 
25 namespace OHOS::Ace::NG {
26 enum class OverScrollDirection {
27     UP = 0,
28     DOWN,
29     LEFT,
30     RIGHT,
31 };
32 
33 class ScrollFadePainter : public AceType {
34     DECLARE_ACE_TYPE(ScrollFadePainter, AceType);
35 
36 public:
37     void PaintSide(RSCanvas& context, const SizeF& size, const OffsetF& offset);
38 
GetColor()39     Color GetColor() const
40     {
41         return color_;
42     }
43 
SetColor(const Color & color)44     void SetColor(const Color& color)
45     {
46         color_ = color;
47     }
48 
GetOpacity()49     float GetOpacity() const
50     {
51         return opacity_;
52     }
53 
SetOpacity(float opacity)54     void SetOpacity(float opacity)
55     {
56         opacity_ = opacity;
57     }
58 
GetScaleFactor()59     float GetScaleFactor() const
60     {
61         return scaleFactor_;
62     }
63 
SetScaleFactor(float scaleFactor)64     void SetScaleFactor(float scaleFactor)
65     {
66         scaleFactor_ = scaleFactor;
67     }
68 
SetDirection(OverScrollDirection direction)69     void SetDirection(OverScrollDirection direction)
70     {
71         direction_ = direction;
72     }
73 
GetDirection()74     OverScrollDirection GetDirection() const
75     {
76         return direction_;
77     }
78 
79 protected:
80     void Paint(RSCanvas& canvas, const SizeF& size, const OffsetF& offset);
81 
82     OverScrollDirection direction_ = OverScrollDirection::UP;
83     Color color_ = Color::GRAY;
84     float opacity_ = 0.0f;
85     float scaleFactor_ = 0.0f;
86 };
87 } // namespace OHOS::Ace::NG
88 
89 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SCROLL_EFFECT_SCROLL_FADE_PAINTER_H