• 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_CONTROLLER_INTERFACE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_CONTROLLER_INTERFACE_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/pipeline/base/render_node.h"
26 
27 namespace OHOS::Ace {
28 
29 enum class ScrollEdgeType : size_t {
30     SCROLL_TOP = 0,
31     SCROLL_BOTTOM,
32     SCROLL_LEFT,
33     SCROLL_RIGHT,
34     SCROLL_NONE,
35 };
36 
37 class ACE_EXPORT ScrollController : public AceType {
38     DECLARE_ACE_TYPE(ScrollController, AceType);
39 
40 public:
41     ScrollController() = default;
42     ~ScrollController() override = default;
43 
44     virtual void JumpTo(int32_t index, int32_t source = 3) {}
45 
GetScrollDirection()46     virtual Axis GetScrollDirection() const
47     {
48         return Axis::NONE;
49     }
50 
AnimateTo(const Dimension & position,float duration,const RefPtr<Curve> & curve)51     virtual bool AnimateTo(const Dimension& position, float duration, const RefPtr<Curve>& curve)
52     {
53         return true;
54     }
ScrollBy(double pixelX,double pixelY,bool smooth)55     virtual void ScrollBy(double pixelX, double pixelY, bool smooth) {}
ScrollToEdge(ScrollEdgeType scrollEdgeType,bool smooth)56     virtual void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) {}
ScrollPage(bool reverse,bool smooth)57     virtual void ScrollPage(bool reverse, bool smooth) {}
GetCurrentOffset()58     virtual Offset GetCurrentOffset() const
59     {
60         return Offset();
61     }
62 
SetScrollNode(const WeakPtr<RenderNode> & scroll)63     void SetScrollNode(const WeakPtr<RenderNode>& scroll)
64     {
65         scroll_ = scroll;
66     }
67 
68 protected:
69     WeakPtr<RenderNode> scroll_;
70 };
71 
72 } // namespace OHOS::Ace
73 
74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SCROLL_SCROLL_CONTROLLER_INTERFACE_H
75