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 class ACE_EXPORT ScrollControllerBase : public AceType { 54 DECLARE_ACE_TYPE(ScrollControllerBase, AceType); 55 56 public: 57 ScrollControllerBase() = default; 58 ~ScrollControllerBase() override = default; 59 60 virtual void JumpTo(int32_t index, int32_t source = 3) {} 61 GetScrollDirection()62 virtual Axis GetScrollDirection() const 63 { 64 return Axis::NONE; 65 } 66 AnimateTo(const Dimension & position,float duration,const RefPtr<Curve> & curve)67 virtual bool AnimateTo(const Dimension& position, float duration, const RefPtr<Curve>& curve) 68 { 69 return true; 70 } ScrollBy(double pixelX,double pixelY,bool smooth)71 virtual void ScrollBy(double pixelX, double pixelY, bool smooth) {} ScrollToEdge(ScrollEdgeType scrollEdgeType,bool smooth)72 virtual void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) {} ScrollPage(bool reverse,bool smooth)73 virtual void ScrollPage(bool reverse, bool smooth) {} GetCurrentOffset()74 virtual Offset GetCurrentOffset() const 75 { 76 return Offset(); 77 } 78 }; 79 } // namespace OHOS::Ace 80 81 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_CONTROLLER_BASE_H 82