1 /* 2 * Copyright (c) 2021-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_SCROLL_SCROLL_CONTROLLER_BASE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_CONTROLLER_BASE_H 18 19 #include "base/geometry/axis.h" 20 #include "base/geometry/dimension.h" 21 #include "base/geometry/offset.h" 22 #include "base/memory/ace_type.h" 23 #include "core/animation/curve.h" 24 #include "core/components/common/layout/constants.h" 25 #include "core/event/ace_events.h" 26 27 namespace OHOS::Ace { 28 29 constexpr uint32_t POSITION_MIDDLE = 0; 30 constexpr uint32_t POSITION_TOP = 1 << 0; 31 constexpr uint32_t POSITION_BOTTOM = 1 << 1; 32 33 enum class ScrollEvent : size_t { 34 SCROLL_TOP = 0, 35 SCROLL_BOTTOM, 36 SCROLL_TOUCHUP, 37 SCROLL_END, 38 SCROLL_POSITION, 39 SCROLL_EDGE, 40 SCROLL_LEFT, 41 SCROLL_RIGHT, 42 UNKNOWN, 43 }; 44 45 enum class ScrollEdgeType : size_t { 46 SCROLL_TOP = 0, 47 SCROLL_BOTTOM, 48 SCROLL_LEFT, 49 SCROLL_RIGHT, 50 SCROLL_NONE, 51 }; 52 53 enum class ScrollAlign { 54 START = 0, 55 CENTER, 56 END, 57 AUTO, 58 NONE, 59 }; 60 61 class ACE_EXPORT ScrollControllerBase : public AceType { 62 DECLARE_ACE_TYPE(ScrollControllerBase, AceType); 63 64 public: 65 ScrollControllerBase() = default; 66 ~ScrollControllerBase() override = default; 67 68 virtual void JumpTo(int32_t index, bool smooth = false, ScrollAlign align = ScrollAlign::NONE, 69 int32_t source = 3) {} 70 GetScrollDirection()71 virtual Axis GetScrollDirection() const 72 { 73 return Axis::NONE; 74 } 75 AnimateTo(const Dimension & position,float duration,const RefPtr<Curve> & curve,bool smooth)76 virtual bool AnimateTo(const Dimension& position, float duration, const RefPtr<Curve>& curve, bool smooth) 77 { 78 return true; 79 } ScrollBy(double pixelX,double pixelY,bool smooth)80 virtual void ScrollBy(double pixelX, double pixelY, bool smooth) {} ScrollToEdge(ScrollEdgeType scrollEdgeType,bool smooth)81 virtual void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) {} ScrollPage(bool reverse,bool smooth)82 virtual void ScrollPage(bool reverse, bool smooth) {} GetCurrentOffset()83 virtual Offset GetCurrentOffset() const 84 { 85 return Offset(); 86 } IsAtEnd()87 virtual bool IsAtEnd() const 88 { 89 return true; 90 } 91 }; 92 } // namespace OHOS::Ace 93 94 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_CONTROLLER_BASE_H 95