1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.core.view;
18 
19 /**
20  * An interface that can be implemented by Views to provide scroll related APIs.
21  */
22 public interface ScrollingView {
23     /**
24      * <p>Compute the horizontal range that the horizontal scrollbar
25      * represents.</p>
26      *
27      * <p>The range is expressed in arbitrary units that must be the same as the
28      * units used by {@link #computeHorizontalScrollExtent()} and
29      * {@link #computeHorizontalScrollOffset()}.</p>
30      *
31      * <p>The default range is the drawing width of this view.</p>
32      *
33      * @return the total horizontal range represented by the horizontal
34      *         scrollbar
35      *
36      * @see #computeHorizontalScrollExtent()
37      * @see #computeHorizontalScrollOffset()
38      */
computeHorizontalScrollRange()39     int computeHorizontalScrollRange();
40 
41     /**
42      * <p>Compute the horizontal offset of the horizontal scrollbar's thumb
43      * within the horizontal range. This value is used to compute the position
44      * of the thumb within the scrollbar's track.</p>
45      *
46      * <p>The range is expressed in arbitrary units that must be the same as the
47      * units used by {@link #computeHorizontalScrollRange()} and
48      * {@link #computeHorizontalScrollExtent()}.</p>
49      *
50      * <p>The default offset is the scroll offset of this view.</p>
51      *
52      * @return the horizontal offset of the scrollbar's thumb
53      *
54      * @see #computeHorizontalScrollRange()
55      * @see #computeHorizontalScrollExtent()
56      */
computeHorizontalScrollOffset()57     int computeHorizontalScrollOffset();
58 
59     /**
60      * <p>Compute the horizontal extent of the horizontal scrollbar's thumb
61      * within the horizontal range. This value is used to compute the length
62      * of the thumb within the scrollbar's track.</p>
63      *
64      * <p>The range is expressed in arbitrary units that must be the same as the
65      * units used by {@link #computeHorizontalScrollRange()} and
66      * {@link #computeHorizontalScrollOffset()}.</p>
67      *
68      * <p>The default extent is the drawing width of this view.</p>
69      *
70      * @return the horizontal extent of the scrollbar's thumb
71      *
72      * @see #computeHorizontalScrollRange()
73      * @see #computeHorizontalScrollOffset()
74      */
computeHorizontalScrollExtent()75     int computeHorizontalScrollExtent();
76 
77     /**
78      * <p>Compute the vertical range that the vertical scrollbar represents.</p>
79      *
80      * <p>The range is expressed in arbitrary units that must be the same as the
81      * units used by {@link #computeVerticalScrollExtent()} and
82      * {@link #computeVerticalScrollOffset()}.</p>
83      *
84      * @return the total vertical range represented by the vertical scrollbar
85      *
86      * <p>The default range is the drawing height of this view.</p>
87      *
88      * @see #computeVerticalScrollExtent()
89      * @see #computeVerticalScrollOffset()
90      */
computeVerticalScrollRange()91     int computeVerticalScrollRange();
92 
93     /**
94      * <p>Compute the vertical offset of the vertical scrollbar's thumb
95      * within the horizontal range. This value is used to compute the position
96      * of the thumb within the scrollbar's track.</p>
97      *
98      * <p>The range is expressed in arbitrary units that must be the same as the
99      * units used by {@link #computeVerticalScrollRange()} and
100      * {@link #computeVerticalScrollExtent()}.</p>
101      *
102      * <p>The default offset is the scroll offset of this view.</p>
103      *
104      * @return the vertical offset of the scrollbar's thumb
105      *
106      * @see #computeVerticalScrollRange()
107      * @see #computeVerticalScrollExtent()
108      */
computeVerticalScrollOffset()109     int computeVerticalScrollOffset();
110 
111     /**
112      * <p>Compute the vertical extent of the vertical scrollbar's thumb
113      * within the vertical range. This value is used to compute the length
114      * of the thumb within the scrollbar's track.</p>
115      *
116      * <p>The range is expressed in arbitrary units that must be the same as the
117      * units used by {@link #computeVerticalScrollRange()} and
118      * {@link #computeVerticalScrollOffset()}.</p>
119      *
120      * <p>The default extent is the drawing height of this view.</p>
121      *
122      * @return the vertical extent of the scrollbar's thumb
123      *
124      * @see #computeVerticalScrollRange()
125      * @see #computeVerticalScrollOffset()
126      */
computeVerticalScrollExtent()127     int computeVerticalScrollExtent();
128 }
129