Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt +5 −9 Original line number Diff line number Diff line Loading @@ -132,11 +132,7 @@ internal class MultiPointerDraggableNode( 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() Loading @@ -151,13 +147,13 @@ internal class MultiPointerDraggableNode( 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) { Loading packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt +25 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.compose.ui.util 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 { Loading @@ -25,9 +26,13 @@ interface SpaceVectorConverter { fun Velocity.toFloat(): Float fun IntOffset.toInt(): Int fun Float.toOffset(): Offset fun Float.toVelocity(): Velocity fun Int.toIntOffset(): IntOffset } fun SpaceVectorConverter(orientation: Orientation) = Loading @@ -36,24 +41,30 @@ fun SpaceVectorConverter(orientation: Orientation) = Orientation.Vertical -> VerticalConverter } private val HorizontalConverter = object : SpaceVectorConverter { private data object HorizontalConverter : SpaceVectorConverter { override fun Offset.toFloat() = x override fun Velocity.toFloat() = x override fun IntOffset.toInt() = x override fun Float.toOffset() = Offset(this, 0f) override fun Float.toVelocity() = Velocity(this, 0f) override fun Int.toIntOffset() = IntOffset(this, 0) } private val VerticalConverter = object : SpaceVectorConverter { private data object VerticalConverter : SpaceVectorConverter { override fun Offset.toFloat() = y 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) } Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt +5 −9 Original line number Diff line number Diff line Loading @@ -132,11 +132,7 @@ internal class MultiPointerDraggableNode( 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() Loading @@ -151,13 +147,13 @@ internal class MultiPointerDraggableNode( 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) { Loading
packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt +25 −14 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.compose.ui.util 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 { Loading @@ -25,9 +26,13 @@ interface SpaceVectorConverter { fun Velocity.toFloat(): Float fun IntOffset.toInt(): Int fun Float.toOffset(): Offset fun Float.toVelocity(): Velocity fun Int.toIntOffset(): IntOffset } fun SpaceVectorConverter(orientation: Orientation) = Loading @@ -36,24 +41,30 @@ fun SpaceVectorConverter(orientation: Orientation) = Orientation.Vertical -> VerticalConverter } private val HorizontalConverter = object : SpaceVectorConverter { private data object HorizontalConverter : SpaceVectorConverter { override fun Offset.toFloat() = x override fun Velocity.toFloat() = x override fun IntOffset.toInt() = x override fun Float.toOffset() = Offset(this, 0f) override fun Float.toVelocity() = Velocity(this, 0f) override fun Int.toIntOffset() = IntOffset(this, 0) } private val VerticalConverter = object : SpaceVectorConverter { private data object VerticalConverter : SpaceVectorConverter { override fun Offset.toFloat() = y 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) }