1 /*
2  * Copyright 2020 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.compose.ui.platform
18 
19 import androidx.compose.ui.internal.JvmDefaultWithCompatibility
20 import androidx.compose.ui.unit.DpSize
21 import androidx.compose.ui.unit.dp
22 
23 /** Contains methods to standard constants used in the UI for timeouts, sizes, and distances. */
24 @JvmDefaultWithCompatibility
25 interface ViewConfiguration {
26     /** The duration before a press turns into a long press. */
27     val longPressTimeoutMillis: Long
28 
29     /**
30      * The duration between the first tap's up event and the second tap's down event for an
31      * interaction to be considered a double-tap.
32      */
33     val doubleTapTimeoutMillis: Long
34 
35     /**
36      * The minimum duration between the first tap's up event and the second tap's down event for an
37      * interaction to be considered a double-tap.
38      */
39     val doubleTapMinTimeMillis: Long
40 
41     /** Distance in pixels a touch can wander before we think the user is scrolling. */
42     val touchSlop: Float
43 
44     /** Distance in pixels a stylus touch can wander before we think the user is handwriting. */
45     val handwritingSlop: Float
46         get() = 2f
47 
48     /**
49      * The minimum touch target size. If layout has reduced the pointer input bounds below this, the
50      * touch target will be expanded evenly around the layout to ensure that it is at least this
51      * big.
52      */
53     val minimumTouchTargetSize: DpSize
54         get() = DpSize(48.dp, 48.dp)
55 
56     /**
57      * The maximum velocity a fling have at any given time. This value should be in pixels/second.
58      */
59     val maximumFlingVelocity: Float
60         get() = Float.MAX_VALUE
61 
62     /**
63      * Margin in pixels around text line bounds where stylus handwriting gestures should be
64      * supported.
65      */
66     val handwritingGestureLineMargin: Float
67         get() = 16f
68 }
69