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_PATTERN_SCROLLABLE_SCROLLABLE_PAINT_METHOD_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLLABLE_SCROLLABLE_PAINT_METHOD_H 18 19 #include "core/components_ng/pattern/scrollable/scrollable_paint_property.h" 20 #include "core/components_ng/render/node_paint_method.h" 21 22 namespace OHOS::Ace::NG { 23 class ACE_EXPORT ScrollablePaintMethod : public NodePaintMethod { 24 DECLARE_ACE_TYPE(ScrollablePaintMethod, NodePaintMethod) 25 public: 26 ScrollablePaintMethod() = default; 27 ScrollablePaintMethod(bool vertical, bool isReverse, bool isVerticalReverse = false) vertical_(vertical)28 : vertical_(vertical), isReverse_(isReverse), isVerticalReverse_(isVerticalReverse) 29 {} 30 ~ScrollablePaintMethod() override = default; 31 SetOverlayRenderContext(const RefPtr<RenderContext> & overlayRenderContext)32 void SetOverlayRenderContext(const RefPtr<RenderContext>& overlayRenderContext) 33 { 34 overlayRenderContext_ = overlayRenderContext; 35 } 36 37 void SetFadingInfo(bool isFadingTop, bool isFadingBottom, bool hasFadingEdge, float percentFading = 0.0f, 38 float startPercent = 0.0f, float endPercent = 1.0f) 39 { 40 isFadingTop_ = isFadingTop; 41 isFadingBottom_ = isFadingBottom; 42 hasFadingEdge_ = hasFadingEdge; 43 percentFading_ = percentFading; 44 startPercent_ = startPercent; 45 endPercent_ = endPercent; 46 } 47 48 protected: 49 void UpdateFadingGradient(const RefPtr<RenderContext>& renderContext); 50 51 /** 52 * @brief Try to set content clip to render context. 53 * 54 * @return true if content clip is set up 55 */ 56 bool TryContentClip(PaintWrapper* wrapper); 57 58 bool vertical_ = false; 59 bool isReverse_ = false; 60 bool isVerticalReverse_ = false; 61 62 private: 63 RefPtr<RenderContext> overlayRenderContext_; 64 bool isFadingTop_ = false; 65 bool isFadingBottom_ = false; 66 bool hasFadingEdge_ = false; 67 float percentFading_ = 0.0f; 68 float startPercent_ = 0.0f; 69 float endPercent_ = 1.0f; 70 }; 71 } // namespace OHOS::Ace::NG 72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLLABLE_SCROLLABLE_PAINT_METHOD_H 73