1 /* 2 * Copyright (c) 2021-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 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 #ifndef USE_ROSEN_DRAWING 26 class SkCanvas; 27 #endif 28 29 namespace OHOS::Ace { 30 31 enum class OverScrollDirection { 32 UP = 0, 33 DOWN, 34 LEFT, 35 RIGHT, 36 }; 37 38 class ScrollFadePainter : public AceType { 39 DECLARE_ACE_TYPE(ScrollFadePainter, AceType); 40 41 public: 42 static RefPtr<ScrollFadePainter> CreatePainter(); 43 44 virtual void PaintSide(RenderContext& context, const Size& size, const Offset& offset) = 0; 45 GetColor()46 Color GetColor() const 47 { 48 return color_; 49 } 50 SetColor(const Color & color)51 void SetColor(const Color& color) 52 { 53 color_ = color; 54 } 55 GetOpacity()56 double GetOpacity() const 57 { 58 return opacity_; 59 } 60 SetOpacity(double opacity)61 void SetOpacity(double opacity) 62 { 63 opacity_ = opacity; 64 } 65 GetScaleFactor()66 double GetScaleFactor() const 67 { 68 return scaleFactor_; 69 } 70 SetScaleFactor(double scaleFactor)71 void SetScaleFactor(double scaleFactor) 72 { 73 scaleFactor_ = scaleFactor; 74 } 75 SetDirection(OverScrollDirection direction)76 void SetDirection(OverScrollDirection direction) 77 { 78 direction_ = direction; 79 } 80 81 protected: 82 OverScrollDirection direction_ = OverScrollDirection::UP; 83 Color color_ = Color::GRAY; 84 double opacity_ = 0.0; 85 double scaleFactor_ = 0.0; 86 }; 87 88 } // namespace OHOS::Ace 89 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_FADE_PAINTER_H 90