Merge "STL added IntOffset <-> Int to SpaceVectorConverter" into main
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
index 59ac68b..501fbb0 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
@@ -132,11 +132,7 @@
var onFirstPointerDown: () -> Unit,
swipeDetector: SwipeDetector = DefaultSwipeDetector,
private val dispatcher: NestedScrollDispatcher,
-) :
- DelegatingNode(),
- PointerInputModifierNode,
- CompositionLocalConsumerModifierNode,
- SpaceVectorConverter {
+) : DelegatingNode(), PointerInputModifierNode, CompositionLocalConsumerModifierNode {
private val pointerTracker = delegate(SuspendingPointerInputModifierNode { pointerTracker() })
private val pointerInput = delegate(SuspendingPointerInputModifierNode { pointerInput() })
private val velocityTracker = VelocityTracker()
@@ -151,13 +147,13 @@
private var converter = SpaceVectorConverter(orientation)
- override fun Offset.toFloat(): Float = with(converter) { this@toFloat.toFloat() }
+ fun Offset.toFloat(): Float = with(converter) { this@toFloat.toFloat() }
- override fun Velocity.toFloat(): Float = with(converter) { this@toFloat.toFloat() }
+ fun Velocity.toFloat(): Float = with(converter) { this@toFloat.toFloat() }
- override fun Float.toOffset(): Offset = with(converter) { this@toOffset.toOffset() }
+ fun Float.toOffset(): Offset = with(converter) { this@toOffset.toOffset() }
- override fun Float.toVelocity(): Velocity = with(converter) { this@toVelocity.toVelocity() }
+ fun Float.toVelocity(): Velocity = with(converter) { this@toVelocity.toVelocity() }
var orientation: Orientation = orientation
set(value) {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
index f08a180..ca50e77 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
@@ -18,6 +18,7 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.Velocity
interface SpaceVectorConverter {
@@ -25,9 +26,13 @@
fun Velocity.toFloat(): Float
+ fun IntOffset.toInt(): Int
+
fun Float.toOffset(): Offset
fun Float.toVelocity(): Velocity
+
+ fun Int.toIntOffset(): IntOffset
}
fun SpaceVectorConverter(orientation: Orientation) =
@@ -36,24 +41,30 @@
Orientation.Vertical -> VerticalConverter
}
-private val HorizontalConverter =
- object : SpaceVectorConverter {
- override fun Offset.toFloat() = x
+private data object HorizontalConverter : SpaceVectorConverter {
+ override fun Offset.toFloat() = x
- override fun Velocity.toFloat() = x
+ override fun Velocity.toFloat() = x
- override fun Float.toOffset() = Offset(this, 0f)
+ override fun IntOffset.toInt() = x
- override fun Float.toVelocity() = Velocity(this, 0f)
- }
+ override fun Float.toOffset() = Offset(this, 0f)
-private val VerticalConverter =
- object : SpaceVectorConverter {
- override fun Offset.toFloat() = y
+ override fun Float.toVelocity() = Velocity(this, 0f)
- override fun Velocity.toFloat() = y
+ override fun Int.toIntOffset() = IntOffset(this, 0)
+}
- override fun Float.toOffset() = Offset(0f, this)
+private data object VerticalConverter : SpaceVectorConverter {
+ override fun Offset.toFloat() = y
- override fun Float.toVelocity() = Velocity(0f, this)
- }
+ override fun Velocity.toFloat() = y
+
+ override fun IntOffset.toInt() = y
+
+ override fun Float.toOffset() = Offset(0f, this)
+
+ override fun Float.toVelocity() = Velocity(0f, this)
+
+ override fun Int.toIntOffset() = IntOffset(0, this)
+}