• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_SCROLL_SCROLL_FADE_PAINTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_FADE_PAINTER_H
18 
19 #include "base/geometry/offset.h"
20 #include "base/geometry/size.h"
21 #include "base/memory/ace_type.h"
22 #include "core/components/common/properties/color.h"
23 #include "core/pipeline/base/render_context.h"
24 
25 class SkCanvas;
26 
27 namespace OHOS::Ace {
28 
29 enum class OverScrollDirection {
30     UP = 0,
31     DOWN,
32     LEFT,
33     RIGHT,
34 };
35 
36 class ScrollFadePainter : public AceType {
37     DECLARE_ACE_TYPE(ScrollFadePainter, AceType);
38 
39 public:
40     static RefPtr<ScrollFadePainter> CreatePainter();
41 
42     virtual void PaintSide(RenderContext& context, const Size& size, const Offset& offset) = 0;
43 
GetColor()44     Color GetColor() const
45     {
46         return color_;
47     }
48 
SetColor(const Color & color)49     void SetColor(const Color& color)
50     {
51         color_ = color;
52     }
53 
GetOpacity()54     double GetOpacity() const
55     {
56         return opacity_;
57     }
58 
SetOpacity(double opacity)59     void SetOpacity(double opacity)
60     {
61         opacity_ = opacity;
62     }
63 
GetScaleFactor()64     double GetScaleFactor() const
65     {
66         return scaleFactor_;
67     }
68 
SetScaleFactor(double scaleFactor)69     void SetScaleFactor(double scaleFactor)
70     {
71         scaleFactor_ = scaleFactor;
72     }
73 
SetDirection(OverScrollDirection direction)74     void SetDirection(OverScrollDirection direction)
75     {
76         direction_ = direction;
77     }
78 
79 protected:
80     OverScrollDirection direction_ = OverScrollDirection::UP;
81     Color color_ = Color::GRAY;
82     double opacity_ = 0.0;
83     double scaleFactor_ = 0.0;
84 };
85 
86 } // namespace OHOS::Ace
87 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_FADE_PAINTER_H
88