Merge "Removal of PxBounds" into androidx-master-dev
diff --git a/ui/ui-animation/api/current.txt b/ui/ui-animation/api/current.txt
index efb240d..ec7c6bb 100644
--- a/ui/ui-animation/api/current.txt
+++ b/ui/ui-animation/api/current.txt
@@ -88,7 +88,7 @@
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Size,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Size.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Bounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.Bounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Offset.Companion);
- method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
+ method @Deprecated public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntOffset.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntSize,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntSize.Companion);
}
@@ -117,7 +117,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Offset animate(androidx.compose.ui.geometry.Offset target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Offset> animSpec = remember({
return <init>(Offset(PxVisibilityThreshold, PxVisibilityThreshold))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit>? endListener = null);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Rect animate(androidx.compose.ui.geometry.Rect target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Rect> animSpec = remember({
+ return <init>(Rect.VectorConverter.invoke(PxVisibilityThreshold4D))
+}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Rect,kotlin.Unit>? endListener = null);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
return <init>(PxBounds.VectorConverter.invoke(PxVisibilityThreshold4D))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.PxBounds,kotlin.Unit>? endListener = null);
method @androidx.compose.runtime.Composable public static int animate(int target, androidx.compose.animation.core.AnimationSpec<java.lang.Integer> animSpec = remember({
diff --git a/ui/ui-animation/api/public_plus_experimental_current.txt b/ui/ui-animation/api/public_plus_experimental_current.txt
index efb240d..ec7c6bb 100644
--- a/ui/ui-animation/api/public_plus_experimental_current.txt
+++ b/ui/ui-animation/api/public_plus_experimental_current.txt
@@ -88,7 +88,7 @@
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Size,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Size.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Bounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.Bounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Offset.Companion);
- method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
+ method @Deprecated public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntOffset.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntSize,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntSize.Companion);
}
@@ -117,7 +117,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Offset animate(androidx.compose.ui.geometry.Offset target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Offset> animSpec = remember({
return <init>(Offset(PxVisibilityThreshold, PxVisibilityThreshold))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit>? endListener = null);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Rect animate(androidx.compose.ui.geometry.Rect target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Rect> animSpec = remember({
+ return <init>(Rect.VectorConverter.invoke(PxVisibilityThreshold4D))
+}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Rect,kotlin.Unit>? endListener = null);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
return <init>(PxBounds.VectorConverter.invoke(PxVisibilityThreshold4D))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.PxBounds,kotlin.Unit>? endListener = null);
method @androidx.compose.runtime.Composable public static int animate(int target, androidx.compose.animation.core.AnimationSpec<java.lang.Integer> animSpec = remember({
diff --git a/ui/ui-animation/api/restricted_current.txt b/ui/ui-animation/api/restricted_current.txt
index efb240d..ec7c6bb 100644
--- a/ui/ui-animation/api/restricted_current.txt
+++ b/ui/ui-animation/api/restricted_current.txt
@@ -88,7 +88,7 @@
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Size,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Size.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Bounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.Bounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.geometry.Offset.Companion);
- method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
+ method @Deprecated public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.PxBounds,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.unit.PxBounds.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntOffset.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.IntSize,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.IntSize.Companion);
}
@@ -117,7 +117,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Offset animate(androidx.compose.ui.geometry.Offset target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Offset> animSpec = remember({
return <init>(Offset(PxVisibilityThreshold, PxVisibilityThreshold))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Offset,kotlin.Unit>? endListener = null);
- method @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
+ method @androidx.compose.runtime.Composable public static androidx.compose.ui.geometry.Rect animate(androidx.compose.ui.geometry.Rect target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.geometry.Rect> animSpec = remember({
+ return <init>(Rect.VectorConverter.invoke(PxVisibilityThreshold4D))
+}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.geometry.Rect,kotlin.Unit>? endListener = null);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.ui.unit.PxBounds animate(androidx.compose.ui.unit.PxBounds target, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.PxBounds> animSpec = remember({
return <init>(PxBounds.VectorConverter.invoke(PxVisibilityThreshold4D))
}), kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.PxBounds,kotlin.Unit>? endListener = null);
method @androidx.compose.runtime.Composable public static int animate(int target, androidx.compose.animation.core.AnimationSpec<java.lang.Integer> animSpec = remember({
diff --git a/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/compose/animation/SingleValueAnimationTest.kt b/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/compose/animation/SingleValueAnimationTest.kt
index 0d2eb83..28feb86 100644
--- a/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/compose/animation/SingleValueAnimationTest.kt
+++ b/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/compose/animation/SingleValueAnimationTest.kt
@@ -29,6 +29,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.lerp
@@ -171,6 +172,66 @@
}
@Test
+ fun animate4DRectTest() {
+ val startVal = AnimationVector(30f, -76f, 280f, 35f)
+ val endVal = AnimationVector(-42f, 89f, 77f, 100f)
+
+ var vectorValue = startVal
+ var boundsValue = Bounds.VectorConverter.convertFromVector(startVal)
+ var pxBoundsValue = Rect.VectorConverter.convertFromVector(startVal)
+
+ fun <V> tween(): TweenSpec<V> =
+ TweenSpec(
+ easing = LinearOutSlowInEasing,
+ durationMillis = 100
+ )
+
+ val children: @Composable() (Boolean) -> Unit = { enabled ->
+ vectorValue = animate(
+ if (enabled) endVal else startVal,
+ tween()
+ )
+
+ boundsValue = animate(
+ if (enabled)
+ Bounds.VectorConverter.convertFromVector(endVal)
+ else
+ Bounds.VectorConverter.convertFromVector(startVal),
+ tween()
+ )
+
+ pxBoundsValue = animate(
+ if (enabled)
+ Rect.VectorConverter.convertFromVector(endVal)
+ else
+ Rect.VectorConverter.convertFromVector(startVal),
+ tween()
+ )
+ }
+
+ val verify: () -> Unit = {
+ for (i in 0..100 step 50) {
+ val fraction = LinearOutSlowInEasing.invoke(i / 100f)
+ val expect = AnimationVector(
+ lerp(startVal.v1, endVal.v1, fraction),
+ lerp(startVal.v2, endVal.v2, fraction),
+ lerp(startVal.v3, endVal.v3, fraction),
+ lerp(startVal.v4, endVal.v4, fraction)
+ )
+
+ assertEquals(expect, vectorValue)
+ assertEquals(Bounds.VectorConverter.convertFromVector(expect), boundsValue)
+ assertEquals(Rect.VectorConverter.convertFromVector(expect), pxBoundsValue)
+ composeTestRule.clockTestRule.advanceClock(50)
+ waitForIdle()
+ }
+ }
+
+ animateTest(children, verify)
+ }
+
+ @Suppress("DEPRECATION")
+ @Test
fun animate4DTest() {
val startVal = AnimationVector(30f, -76f, 280f, 35f)
val endVal = AnimationVector(-42f, 89f, 77f, 100f)
diff --git a/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt
index de10e34..1952ca6 100644
--- a/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt
+++ b/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt
@@ -177,6 +177,7 @@
/**
* A type converter that converts a [PxBounds] to a [AnimationVector4D], and vice versa.
*/
+@Suppress("DEPRECATION")
private val PxBoundsToVector: TwoWayConverter<PxBounds, AnimationVector4D> =
TwoWayConverter(
convertToVector = {
@@ -299,6 +300,9 @@
/**
* A type converter that converts a [PxBounds] to a [AnimationVector4D], and vice versa.
*/
+@Deprecated("Use Rect and RectToVectorConverter instead",
+ ReplaceWith("Rect.VectorConverter"))
+@Suppress("DEPRECATION")
val PxBounds.Companion.VectorConverter: TwoWayConverter<PxBounds, AnimationVector4D>
get() = PxBoundsToVector
@@ -306,6 +310,7 @@
* A type converter that converts a [PxBounds] to a [AnimationVector4D], and vice versa.
*/
@Deprecated("", ReplaceWith("PxBounds.VectorConverter"))
+@Suppress("DEPRECATION")
val PxBoundsToVectorConverter: TwoWayConverter<PxBounds, AnimationVector4D> =
PxBounds.VectorConverter
diff --git a/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
index 865bc17..3f5e20e 100644
--- a/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
+++ b/ui/ui-animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
@@ -28,6 +28,7 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.AnimationClockAmbient
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Bounds
@@ -283,6 +284,38 @@
}
/**
+ * Fire-and-forget animation [Composable] for [Rect]. Once such an animation is created, it will
+ * be positionally memoized, like other @[Composable]s. To trigger the animation, or alter the
+ * course of the animation, simply supply a different [target] to the [Composable].
+ *
+ * Note, [animate] is for simple animations that cannot be canceled. For cancellable animations
+ * see [animatedValue].
+ *
+ * val bounds : Rect = animate(
+ * if (enabled) Rect(0f, 0f, 100f, 100f) else Rect(8f, 8f, 80f, 80f))
+ *
+ * @param target Target value of the animation
+ * @param animSpec The animation that will be used to change the value through time. Physics
+ * animation will be used by default.
+ * @param endListener An optional end listener to get notified when the animation is finished.
+ */
+@Composable
+fun animate(
+ target: Rect,
+ animSpec: AnimationSpec<Rect> = remember {
+ SpringSpec(
+ visibilityThreshold =
+ Rect.VectorConverter.convertFromVector(PxVisibilityThreshold4D)
+ )
+ },
+ endListener: ((Rect) -> Unit)? = null
+): Rect {
+ return animate(
+ target, Rect.VectorConverter, animSpec, endListener = endListener
+ )
+}
+
+/**
* Fire-and-forget animation [Composable] for [PxBounds]. Once such an animation is created, it will
* be positionally memoized, like other @[Composable]s. To trigger the animation, or alter the
* course of the animation, simply supply a different [target] to the [Composable].
@@ -298,6 +331,11 @@
* animation will be used by default.
* @param endListener An optional end listener to get notified when the animation is finished.
*/
+@Deprecated("Consider usage of Rect instead",
+ ReplaceWith("animate(target: Rect, animSpec: AnimationSpec<Rect>, " +
+ "endListener: ((Rect) -> " +
+ "Unit)?", "androidx.compose.animation.animation"))
+@Suppress("DEPRECATION")
@Composable
fun animate(
target: PxBounds,
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index ff46d30..b1c5894 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -1630,7 +1630,7 @@
}
public interface LayoutCoordinates {
- method public androidx.compose.ui.unit.PxBounds childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
+ method public androidx.compose.ui.geometry.Rect childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
method public androidx.compose.ui.geometry.Offset childToLocal(androidx.compose.ui.layout.LayoutCoordinates child, androidx.compose.ui.geometry.Offset childLocal);
method public operator int get(androidx.compose.ui.AlignmentLine line);
method public androidx.compose.ui.layout.LayoutCoordinates? getParentCoordinates();
@@ -1647,9 +1647,9 @@
}
public final class LayoutCoordinatesKt {
- method public static androidx.compose.ui.unit.PxBounds getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getGlobalPosition(androidx.compose.ui.layout.LayoutCoordinates);
method public static androidx.compose.ui.geometry.Offset getPositionInParent(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getPositionInRoot(androidx.compose.ui.layout.LayoutCoordinates);
@@ -2332,11 +2332,11 @@
public final class SemanticsNode {
method public int getAlignmentLinePosition(androidx.compose.ui.AlignmentLine line);
- method public androidx.compose.ui.unit.PxBounds getBoundsInRoot();
+ method public androidx.compose.ui.geometry.Rect getBoundsInRoot();
method public java.util.List<androidx.compose.ui.semantics.SemanticsNode> getChildren();
method public androidx.compose.ui.node.LayoutNode getComponentNode();
method public androidx.compose.ui.semantics.SemanticsConfiguration getConfig();
- method public androidx.compose.ui.unit.PxBounds getGlobalBounds();
+ method public androidx.compose.ui.geometry.Rect getGlobalBounds();
method public androidx.compose.ui.geometry.Offset getGlobalPosition();
method public int getId();
method public boolean getMergingEnabled();
@@ -2344,11 +2344,11 @@
method public androidx.compose.ui.geometry.Offset getPositionInRoot();
method public androidx.compose.ui.unit.IntSize getSize();
method public boolean isRoot();
- property public final androidx.compose.ui.unit.PxBounds boundsInRoot;
+ property public final androidx.compose.ui.geometry.Rect boundsInRoot;
property public final java.util.List<androidx.compose.ui.semantics.SemanticsNode> children;
property public final androidx.compose.ui.node.LayoutNode componentNode;
property public final androidx.compose.ui.semantics.SemanticsConfiguration config;
- property public final androidx.compose.ui.unit.PxBounds globalBounds;
+ property public final androidx.compose.ui.geometry.Rect globalBounds;
property public final androidx.compose.ui.geometry.Offset globalPosition;
property public final int id;
property public final boolean isRoot;
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index ff46d30..b1c5894 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -1630,7 +1630,7 @@
}
public interface LayoutCoordinates {
- method public androidx.compose.ui.unit.PxBounds childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
+ method public androidx.compose.ui.geometry.Rect childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
method public androidx.compose.ui.geometry.Offset childToLocal(androidx.compose.ui.layout.LayoutCoordinates child, androidx.compose.ui.geometry.Offset childLocal);
method public operator int get(androidx.compose.ui.AlignmentLine line);
method public androidx.compose.ui.layout.LayoutCoordinates? getParentCoordinates();
@@ -1647,9 +1647,9 @@
}
public final class LayoutCoordinatesKt {
- method public static androidx.compose.ui.unit.PxBounds getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getGlobalPosition(androidx.compose.ui.layout.LayoutCoordinates);
method public static androidx.compose.ui.geometry.Offset getPositionInParent(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getPositionInRoot(androidx.compose.ui.layout.LayoutCoordinates);
@@ -2332,11 +2332,11 @@
public final class SemanticsNode {
method public int getAlignmentLinePosition(androidx.compose.ui.AlignmentLine line);
- method public androidx.compose.ui.unit.PxBounds getBoundsInRoot();
+ method public androidx.compose.ui.geometry.Rect getBoundsInRoot();
method public java.util.List<androidx.compose.ui.semantics.SemanticsNode> getChildren();
method public androidx.compose.ui.node.LayoutNode getComponentNode();
method public androidx.compose.ui.semantics.SemanticsConfiguration getConfig();
- method public androidx.compose.ui.unit.PxBounds getGlobalBounds();
+ method public androidx.compose.ui.geometry.Rect getGlobalBounds();
method public androidx.compose.ui.geometry.Offset getGlobalPosition();
method public int getId();
method public boolean getMergingEnabled();
@@ -2344,11 +2344,11 @@
method public androidx.compose.ui.geometry.Offset getPositionInRoot();
method public androidx.compose.ui.unit.IntSize getSize();
method public boolean isRoot();
- property public final androidx.compose.ui.unit.PxBounds boundsInRoot;
+ property public final androidx.compose.ui.geometry.Rect boundsInRoot;
property public final java.util.List<androidx.compose.ui.semantics.SemanticsNode> children;
property public final androidx.compose.ui.node.LayoutNode componentNode;
property public final androidx.compose.ui.semantics.SemanticsConfiguration config;
- property public final androidx.compose.ui.unit.PxBounds globalBounds;
+ property public final androidx.compose.ui.geometry.Rect globalBounds;
property public final androidx.compose.ui.geometry.Offset globalPosition;
property public final int id;
property public final boolean isRoot;
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index baf2819..6a90cc3 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -1676,7 +1676,7 @@
}
public interface LayoutCoordinates {
- method public androidx.compose.ui.unit.PxBounds childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
+ method public androidx.compose.ui.geometry.Rect childBoundingBox(androidx.compose.ui.layout.LayoutCoordinates child);
method public androidx.compose.ui.geometry.Offset childToLocal(androidx.compose.ui.layout.LayoutCoordinates child, androidx.compose.ui.geometry.Offset childLocal);
method public operator int get(androidx.compose.ui.AlignmentLine line);
method public androidx.compose.ui.layout.LayoutCoordinates? getParentCoordinates();
@@ -1693,9 +1693,9 @@
}
public final class LayoutCoordinatesKt {
- method public static androidx.compose.ui.unit.PxBounds getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
- method public static androidx.compose.ui.unit.PxBounds getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInParent(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getBoundsInRoot(androidx.compose.ui.layout.LayoutCoordinates);
+ method public static androidx.compose.ui.geometry.Rect getGlobalBounds(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getGlobalPosition(androidx.compose.ui.layout.LayoutCoordinates);
method public static androidx.compose.ui.geometry.Offset getPositionInParent(androidx.compose.ui.layout.LayoutCoordinates);
method public static inline androidx.compose.ui.geometry.Offset getPositionInRoot(androidx.compose.ui.layout.LayoutCoordinates);
@@ -2406,11 +2406,11 @@
public final class SemanticsNode {
method public int getAlignmentLinePosition(androidx.compose.ui.AlignmentLine line);
- method public androidx.compose.ui.unit.PxBounds getBoundsInRoot();
+ method public androidx.compose.ui.geometry.Rect getBoundsInRoot();
method public java.util.List<androidx.compose.ui.semantics.SemanticsNode> getChildren();
method public androidx.compose.ui.node.LayoutNode getComponentNode();
method public androidx.compose.ui.semantics.SemanticsConfiguration getConfig();
- method public androidx.compose.ui.unit.PxBounds getGlobalBounds();
+ method public androidx.compose.ui.geometry.Rect getGlobalBounds();
method public androidx.compose.ui.geometry.Offset getGlobalPosition();
method public int getId();
method public boolean getMergingEnabled();
@@ -2418,11 +2418,11 @@
method public androidx.compose.ui.geometry.Offset getPositionInRoot();
method public androidx.compose.ui.unit.IntSize getSize();
method public boolean isRoot();
- property public final androidx.compose.ui.unit.PxBounds boundsInRoot;
+ property public final androidx.compose.ui.geometry.Rect boundsInRoot;
property public final java.util.List<androidx.compose.ui.semantics.SemanticsNode> children;
property public final androidx.compose.ui.node.LayoutNode componentNode;
property public final androidx.compose.ui.semantics.SemanticsConfiguration config;
- property public final androidx.compose.ui.unit.PxBounds globalBounds;
+ property public final androidx.compose.ui.geometry.Rect globalBounds;
property public final androidx.compose.ui.geometry.Offset globalPosition;
property public final int id;
property public final boolean isRoot;
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawLayerTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawLayerTest.kt
index 7a5fb5c3..6dfe2f7 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawLayerTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawLayerTest.kt
@@ -26,16 +26,14 @@
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.drawLayer
import androidx.compose.ui.onPositioned
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.layout.globalBounds
import androidx.compose.ui.layout.globalPosition
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
-import androidx.compose.ui.unit.height
-import androidx.compose.ui.unit.width
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
@@ -84,7 +82,7 @@
activity.runOnUiThread {
assertEquals(Offset(10f, 10f), layoutCoordinates.positionInRoot)
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(10f, 10f, 40f, 40f), bounds)
+ assertEquals(Rect(10f, 10f, 40f, 40f), bounds)
val global = layoutCoordinates.globalBounds
val position = layoutCoordinates.globalPosition
assertEquals(position.x, global.left)
@@ -111,7 +109,7 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(5f, 0f, 25f, 30f), bounds)
+ assertEquals(Rect(5f, 0f, 25f, 30f), bounds)
assertEquals(Offset(5f, 0f), layoutCoordinates.positionInRoot)
}
}
@@ -133,7 +131,7 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(0f, 10f, 30f, 20f), bounds)
+ assertEquals(Rect(0f, 10f, 30f, 20f), bounds)
assertEquals(Offset(30f, 10f), layoutCoordinates.positionInRoot)
}
}
@@ -156,7 +154,7 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(20f, 10f, 30f, 20f), bounds)
+ assertEquals(Rect(20f, 10f, 30f, 20f), bounds)
assertEquals(Offset(30f, 10f), layoutCoordinates.positionInRoot)
}
}
@@ -179,7 +177,7 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(15f, 18f, 25f, 28f), bounds)
+ assertEquals(Rect(15f, 18f, 25f, 28f), bounds)
assertEquals(Offset(15f, 18f), layoutCoordinates.positionInRoot)
}
}
@@ -203,7 +201,7 @@
assertTrue(positionLatch.await(1, TimeUnit.SECONDS))
activity.runOnUiThread {
val bounds = layoutCoordinates.boundsInRoot
- assertEquals(PxBounds(10f, 10f, 20f, 20f), bounds)
+ assertEquals(Rect(10f, 10f, 20f, 20f), bounds)
// Positions aren't clipped
assertEquals(Offset(5f, 10f), layoutCoordinates.positionInRoot)
}
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/HitPathTrackerTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/HitPathTrackerTest.kt
index dcca79a..0b3046f 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/HitPathTrackerTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/HitPathTrackerTest.kt
@@ -28,8 +28,8 @@
import androidx.compose.ui.platform.consumePositionChange
import androidx.compose.ui.platform.positionChange
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.unit.milliseconds
import androidx.compose.ui.platform.CustomEvent
import androidx.compose.ui.platform.CustomEventDispatcher
@@ -3354,7 +3354,7 @@
TODO("not implemented")
}
- override fun childBoundingBox(child: LayoutCoordinates): PxBounds {
+ override fun childBoundingBox(child: LayoutCoordinates): Rect {
TODO("not implemented")
}
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnPositionedTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnPositionedTest.kt
index 8835052..c72fb2f 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnPositionedTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnPositionedTest.kt
@@ -39,6 +39,7 @@
import androidx.compose.ui.SimpleRow
import androidx.compose.ui.Wrap
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.onChildPositioned
import androidx.compose.ui.onPositioned
import androidx.compose.ui.platform.DensityAmbient
@@ -46,7 +47,6 @@
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.unit.Constraints
-import androidx.compose.ui.unit.PxBounds
import androidx.test.filters.SmallTest
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -302,14 +302,14 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
rule.runOnUiThread {
- assertEquals(PxBounds(5f, 5f, 15f, 15f), coordinates!!.boundsInParent)
+ assertEquals(Rect(5f, 5f, 15f, 15f), coordinates!!.boundsInParent)
var root = coordinates!!
while (root.parentCoordinates != null) {
root = root.parentCoordinates!!
}
- assertEquals(PxBounds(0f, 0f, 20f, 20f), root.boundsInParent)
+ assertEquals(Rect(0f, 0f, 20f, 20f), root.boundsInParent)
}
}
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RootNodeLayoutTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RootNodeLayoutTest.kt
index 45ff1be..57f9310 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RootNodeLayoutTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RootNodeLayoutTest.kt
@@ -26,8 +26,8 @@
import androidx.compose.ui.onPositioned
import androidx.compose.ui.test.TestActivity
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.platform.setContent
-import androidx.compose.ui.unit.PxBounds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNotNull
@@ -92,7 +92,8 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
assertNotNull(coordinates)
- assertEquals(PxBounds(left = 0f, top = 0f, right = 10f, bottom = 10f),
+ assertEquals(
+ Rect(left = 0f, top = 0f, right = 10f, bottom = 10f),
coordinates!!.boundsInRoot)
}
diff --git a/ui/ui-core/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt b/ui/ui-core/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt
index d65a391..b5b47db 100644
--- a/ui/ui-core/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt
+++ b/ui/ui-core/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeViewAccessibilityDelegateCompat.kt
@@ -52,7 +52,6 @@
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.length
-import androidx.compose.ui.unit.toRect
import androidx.compose.ui.util.fastForEach
internal class AndroidComposeViewAccessibilityDelegateCompat(val view: AndroidComposeView) :
@@ -682,7 +681,7 @@
private fun toScreenCoords(textNode: SemanticsNode, bounds: Rect): Rect? {
val screenBounds = bounds.shift(textNode.globalPosition)
- val globalBounds = textNode.globalBounds.toRect()
+ val globalBounds = textNode.globalBounds
if (screenBounds.overlaps(globalBounds)) {
return screenBounds.intersect(globalBounds)
}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutCoordinates.kt b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutCoordinates.kt
index a6894b1..6f1ae4e 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutCoordinates.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutCoordinates.kt
@@ -18,8 +18,8 @@
import androidx.compose.ui.AlignmentLine
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.PxBounds
/**
* A holder of the measured bounds for the layout (MeasureBox).
@@ -69,7 +69,7 @@
/**
* Returns the child bounding box, discarding clipped rectangles, in local coordinates.
*/
- fun childBoundingBox(child: LayoutCoordinates): PxBounds
+ fun childBoundingBox(child: LayoutCoordinates): Rect
/**
* Returns the position of an [alignment line][AlignmentLine],
@@ -91,7 +91,7 @@
/**
* The boundaries of this layout inside the root composable.
*/
-val LayoutCoordinates.boundsInRoot: PxBounds
+val LayoutCoordinates.boundsInRoot: Rect
get() {
return findRoot(this).childBoundingBox(this)
}
@@ -108,19 +108,19 @@
* done with respect to the parent. For the root, the bounds is positioned at (0, 0) and sized
* to the size of the root.
*/
-val LayoutCoordinates.boundsInParent: PxBounds
+val LayoutCoordinates.boundsInParent: Rect
get() = parentCoordinates?.childBoundingBox(this)
- ?: PxBounds(0f, 0f, size.width.toFloat(), size.height.toFloat())
+ ?: Rect(0f, 0f, size.width.toFloat(), size.height.toFloat())
/**
* The global boundaries of this layout inside.
*/
-val LayoutCoordinates.globalBounds: PxBounds
+val LayoutCoordinates.globalBounds: Rect
get() {
val root = findRoot(this)
val rootPosition = root.localToGlobal(Offset.Zero)
val bounds = root.childBoundingBox(this)
- return PxBounds(
+ return Rect(
left = bounds.left + rootPosition.x,
top = bounds.top + rootPosition.y,
right = bounds.right + rootPosition.x,
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt
index 603c382..914fd26 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt
@@ -33,7 +33,6 @@
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.unit.minus
import androidx.compose.ui.unit.plus
import androidx.compose.ui.unit.toOffset
@@ -255,11 +254,11 @@
bounds.bottom += y
}
- override fun childBoundingBox(child: LayoutCoordinates): PxBounds {
+ override fun childBoundingBox(child: LayoutCoordinates): Rect {
check(isAttached) { ExpectAttachedLayoutCoordinates }
check(child.isAttached) { "Child $child is not attached!" }
- val bounds = rectCache ?: NativeRectF().also { rectCache = it }
- bounds.set(
+ val rectF = rectCache ?: NativeRectF().also { rectCache = it }
+ rectF.set(
0f,
0f,
child.size.width.toFloat(),
@@ -267,7 +266,7 @@
)
var wrapper = child as LayoutNodeWrapper
while (wrapper !== this) {
- wrapper.rectInParent(bounds)
+ wrapper.rectInParent(rectF)
val parent = wrapper.wrappedBy
check(parent != null) {
@@ -275,11 +274,11 @@
}
wrapper = parent
}
- return PxBounds(
- left = bounds.left,
- top = bounds.top,
- right = bounds.right,
- bottom = bounds.bottom
+ return Rect(
+ left = rectF.left,
+ top = rectF.top,
+ right = rectF.right,
+ bottom = rectF.bottom
)
}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsNode.kt b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsNode.kt
index b302e56..5ee596d 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsNode.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/compose/ui/semantics/SemanticsNode.kt
@@ -18,6 +18,7 @@
import androidx.compose.ui.AlignmentLine
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.layout.globalBounds
import androidx.compose.ui.layout.globalPosition
@@ -27,7 +28,6 @@
import androidx.compose.ui.node.LayoutNodeWrapper
import androidx.compose.ui.node.findClosestParentNode
import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.util.fastForEach
/**
@@ -83,9 +83,9 @@
/**
* The bounding box for this node relative to the root of this Compose hierarchy, with
* clipping applied. To get the bounds with no clipping applied, use
- * PxBounds([positionInRoot], [size].toSize())
+ * Rect([positionInRoot], [size].toSize())
*/
- val boundsInRoot: PxBounds
+ val boundsInRoot: Rect
get() {
return componentNode.coordinates.boundsInRoot
}
@@ -103,7 +103,7 @@
* The bounding box for this node relative to the screen, with clipping applied. To get the
* bounds with no clipping applied, use PxBounds([globalPosition], [size].toSize())
*/
- val globalBounds: PxBounds
+ val globalBounds: Rect
get() {
return componentNode.coordinates.globalBounds
}
diff --git a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
index 8e1c954..dd3e07a 100644
--- a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
+++ b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
@@ -46,6 +46,7 @@
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.compositeOver
@@ -56,12 +57,8 @@
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.PxBounds
-import androidx.compose.ui.unit.center
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.height
import androidx.compose.ui.unit.sp
-import androidx.compose.ui.unit.width
import androidx.test.filters.FlakyTest
import androidx.test.filters.MediumTest
import androidx.test.filters.SdkSuppress
@@ -553,7 +550,7 @@
assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
- assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
+ assertWithinOnePixel(buttonBounds.center, contentBounds.center)
}
}
@@ -611,8 +608,8 @@
@Test
fun weightModifierOnButton() {
- var item1Bounds = PxBounds(0f, 0f, 0f, 0f)
- var buttonBounds = PxBounds(0f, 0f, 0f, 0f)
+ var item1Bounds = Rect(0f, 0f, 0f, 0f)
+ var buttonBounds = Rect(0f, 0f, 0f, 0f)
composeTestRule.setMaterialContent {
Column {
Spacer(Modifier.size(10.dp).weight(1f).onPositioned {
@@ -635,9 +632,9 @@
@Test
fun buttonContentIsRow() {
- var buttonBounds = PxBounds(0f, 0f, 0f, 0f)
- var item1Bounds = PxBounds(0f, 0f, 0f, 0f)
- var item2Bounds = PxBounds(0f, 0f, 0f, 0f)
+ var buttonBounds = Rect(0f, 0f, 0f, 0f)
+ var item1Bounds = Rect(0f, 0f, 0f, 0f)
+ var item2Bounds = Rect(0f, 0f, 0f, 0f)
composeTestRule.setMaterialContent {
Button(onClick = {}, modifier = Modifier.onPositioned {
buttonBounds = it.boundsInRoot
@@ -651,10 +648,10 @@
}
}
- assertThat(item1Bounds.center().y).isWithin(1f).of(buttonBounds.center().y)
- assertThat(item2Bounds.center().y).isWithin(1f).of(buttonBounds.center().y)
- assertThat(item1Bounds.right).isWithin(1f).of(buttonBounds.center().x)
- assertThat(item2Bounds.left).isWithin(1f).of(buttonBounds.center().x)
+ assertThat(item1Bounds.center.y).isWithin(1f).of(buttonBounds.center.y)
+ assertThat(item2Bounds.center.y).isWithin(1f).of(buttonBounds.center.y)
+ assertThat(item1Bounds.right).isWithin(1f).of(buttonBounds.center.x)
+ assertThat(item2Bounds.left).isWithin(1f).of(buttonBounds.center.x)
}
private fun assertLeftPaddingIs(
diff --git a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
index 3e01705..9488365 100644
--- a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
+++ b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
@@ -37,6 +37,7 @@
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
+import androidx.compose.ui.geometry.Rect
import androidx.ui.test.assertHeightIsEqualTo
import androidx.ui.test.assertIsEnabled
import androidx.ui.test.assertShape
@@ -48,11 +49,7 @@
import androidx.ui.test.onNodeWithTag
import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdle
-import androidx.compose.ui.unit.PxBounds
-import androidx.compose.ui.unit.center
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.height
-import androidx.compose.ui.unit.width
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -144,8 +141,8 @@
@Test
fun fab_weightModifier() {
- var item1Bounds = PxBounds(0f, 0f, 0f, 0f)
- var buttonBounds = PxBounds(0f, 0f, 0f, 0f)
+ var item1Bounds = Rect(0f, 0f, 0f, 0f)
+ var buttonBounds = Rect(0f, 0f, 0f, 0f)
composeTestRule.setMaterialContent {
Column {
Spacer(Modifier.size(10.dp).weight(1f).onPositioned {
@@ -256,7 +253,7 @@
assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
- assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
+ assertWithinOnePixel(buttonBounds.center, contentBounds.center)
}
}
@@ -287,7 +284,7 @@
assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
- assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
+ assertWithinOnePixel(buttonBounds.center, contentBounds.center)
}
}
@@ -325,12 +322,12 @@
assertThat(iconBounds.width).isEqualTo(10.dp.toIntPx().toFloat())
assertThat(iconBounds.height).isEqualTo(10.dp.toIntPx().toFloat())
- assertWithinOnePixel(buttonBounds.center().y, iconBounds.center().y)
- assertWithinOnePixel(buttonBounds.center().y, textBounds.center().y)
+ assertWithinOnePixel(buttonBounds.center.y, iconBounds.center.y)
+ assertWithinOnePixel(buttonBounds.center.y, textBounds.center.y)
val halfPadding = 6.dp.toIntPx().toFloat()
assertWithinOnePixel(
- iconBounds.center().x + iconBounds.width / 2 + halfPadding,
- textBounds.center().x - textBounds.width / 2 - halfPadding
+ iconBounds.center.x + iconBounds.width / 2 + halfPadding,
+ textBounds.center.x - textBounds.width / 2 - halfPadding
)
}
}
diff --git a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
index dc0b5d7..9315a70 100644
--- a/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
@@ -552,7 +552,7 @@
}
}
runOnIdle {
- assertThat(geometry.bottomBarBounds?.toSize()).isEqualTo(bottomBarSize.toSize())
+ assertThat(geometry.bottomBarBounds?.size).isEqualTo(bottomBarSize.toSize())
assertThat(geometry.bottomBarBounds?.width).isNotEqualTo(0f)
}
}
diff --git a/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt b/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
index 380bd45..f067792 100644
--- a/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
@@ -42,10 +42,7 @@
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.height
-import androidx.compose.ui.unit.width
import kotlin.math.sqrt
/**
@@ -202,7 +199,7 @@
*/
private data class BottomAppBarCutoutShape(
val cutoutShape: Shape,
- val fabBounds: PxBounds
+ val fabBounds: Rect
) : Shape {
override fun createOutline(size: Size, density: Density): Outline {
diff --git a/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt b/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
index 5d6d112..2cb742e 100644
--- a/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
+++ b/ui/ui-material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
@@ -36,6 +36,7 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
@@ -43,10 +44,7 @@
import androidx.compose.ui.onPositioned
import androidx.compose.ui.platform.DensityAmbient
import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.height
-import androidx.compose.ui.unit.toSize
import androidx.compose.ui.zIndex
/**
@@ -75,21 +73,21 @@
* parameter in scaffold is not set
*/
val topBarSize: Size?
- get() = scaffoldGeometry.topBarBounds?.toSize()
+ get() = scaffoldGeometry.topBarBounds?.size
/**
* Get current size of the bottomBar in [Scaffold], if known. `null` if this unknown or
* bottomBar parameter in scaffold is not set
*/
val bottomBarSize: Size?
- get() = scaffoldGeometry.bottomBarBounds?.toSize()
+ get() = scaffoldGeometry.bottomBarBounds?.size
/**
* Get current size of the floatingActionButton in [Scaffold], if known. `null` if this unknown
* or floatingActionButton parameter in scaffold is not set
*/
val floatingActionButtonSize: Size?
- get() = scaffoldGeometry.fabBounds?.toSize()
+ get() = scaffoldGeometry.fabBounds?.size
internal val scaffoldGeometry = ScaffoldGeometry()
}
@@ -110,9 +108,9 @@
@Stable
internal class ScaffoldGeometry {
- var topBarBounds by mutableStateOf<PxBounds?>(null, structuralEqualityPolicy())
- var bottomBarBounds by mutableStateOf<PxBounds?>(null, structuralEqualityPolicy())
- var fabBounds by mutableStateOf<PxBounds?>(null, structuralEqualityPolicy())
+ var topBarBounds by mutableStateOf<Rect?>(null, structuralEqualityPolicy())
+ var bottomBarBounds by mutableStateOf<Rect?>(null, structuralEqualityPolicy())
+ var fabBounds by mutableStateOf<Rect?>(null, structuralEqualityPolicy())
var isFabDocked by mutableStateOf(false)
}
@@ -368,7 +366,7 @@
@Composable
private fun BoundsAwareScaffoldSlot(
modifier: Modifier,
- onBoundsKnown: (PxBounds?) -> Unit,
+ onBoundsKnown: (Rect?) -> Unit,
slotContent: @Composable () -> Unit
) {
onDispose {
diff --git a/ui/ui-test/src/androidMain/kotlin/androidx/ui/test/AndroidAssertions.kt b/ui/ui-test/src/androidMain/kotlin/androidx/ui/test/AndroidAssertions.kt
index 208cff7..b28b5e3 100644
--- a/ui/ui-test/src/androidMain/kotlin/androidx/ui/test/AndroidAssertions.kt
+++ b/ui/ui-test/src/androidMain/kotlin/androidx/ui/test/AndroidAssertions.kt
@@ -24,9 +24,6 @@
import androidx.compose.ui.node.findClosestParentNode
import androidx.compose.ui.platform.AndroidOwner
import androidx.compose.ui.semantics.SemanticsNode
-import androidx.compose.ui.unit.height
-import androidx.compose.ui.unit.toRect
-import androidx.compose.ui.unit.width
@OptIn(ExperimentalLayoutNodeApi::class)
internal actual fun SemanticsNodeInteraction.checkIsDisplayed(): Boolean {
@@ -65,7 +62,7 @@
composeView.getLocationInWindow(it)
Offset(it[0].toFloat(), it[1].toFloat())
}
- return boundsInRoot.toRect().shift(rootLocationInWindow)
+ return boundsInRoot.shift(rootLocationInWindow)
}
@OptIn(ExperimentalLayoutNodeApi::class)
diff --git a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/BoundsAssertions.kt b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/BoundsAssertions.kt
index c18ef02..9462726 100644
--- a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/BoundsAssertions.kt
+++ b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/BoundsAssertions.kt
@@ -17,14 +17,12 @@
package androidx.ui.test
import androidx.compose.ui.AlignmentLine
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.unit.Bounds
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.PxBounds
-import androidx.compose.ui.unit.height
import androidx.compose.ui.unit.toSize
-import androidx.compose.ui.unit.width
import kotlin.math.absoluteValue
private const val floatTolerance = 0.5f
@@ -215,9 +213,9 @@
}
}
-internal val SemanticsNode.unclippedBoundsInRoot: PxBounds
+internal val SemanticsNode.unclippedBoundsInRoot: Rect
get() {
- return PxBounds(positionInRoot, size.toSize())
+ return Rect(positionInRoot, size.toSize())
}
internal expect fun <R> SemanticsNodeInteraction.withDensity(
@@ -225,7 +223,7 @@
): R
internal expect fun SemanticsNodeInteraction.withUnclippedBoundsInRoot(
- assertion: Density.(PxBounds) -> Unit
+ assertion: Density.(Rect) -> Unit
): SemanticsNodeInteraction
private fun Density.isAtLeastOrThrow(
diff --git a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/Output.kt b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/Output.kt
index 82328c5..40d0074 100644
--- a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/Output.kt
+++ b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/Output.kt
@@ -16,12 +16,12 @@
package androidx.ui.test
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.semantics.SemanticsConfiguration
import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.semantics.SemanticsProperties
import androidx.compose.ui.util.annotation.IntRange
import androidx.compose.ui.text.AnnotatedString
-import androidx.compose.ui.unit.PxBounds
import androidx.compose.ui.unit.toSize
internal expect fun printToLog(tag: String, message: String)
@@ -156,7 +156,7 @@
sb.append("$nestingIndent |-")
}
sb.append("Node #$id at ")
- sb.append(pxBoundsToShortString(unclippedGlobalBounds))
+ sb.append(rectToShortString(unclippedGlobalBounds))
if (config.contains(SemanticsProperties.TestTag)) {
sb.append(", Tag: '")
@@ -203,13 +203,13 @@
}
}
-private val SemanticsNode.unclippedGlobalBounds: PxBounds
+private val SemanticsNode.unclippedGlobalBounds: Rect
get() {
- return PxBounds(globalPosition, size.toSize())
+ return Rect(globalPosition, size.toSize())
}
-private fun pxBoundsToShortString(bounds: PxBounds): String {
- return "(${bounds.left}, ${bounds.top}, ${bounds.right}, ${bounds.bottom})px"
+private fun rectToShortString(rect: Rect): String {
+ return "(${rect.left}, ${rect.top}, ${rect.right}, ${rect.bottom})px"
}
private fun StringBuilder.appendConfigInfo(config: SemanticsConfiguration, indent: String = "") {
diff --git a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/SemanticsNodeInteraction.kt b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/SemanticsNodeInteraction.kt
index cc434fa..2a5c49b 100644
--- a/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/SemanticsNodeInteraction.kt
+++ b/ui/ui-test/src/commonMain/kotlin/androidx/ui/test/SemanticsNodeInteraction.kt
@@ -16,10 +16,10 @@
package androidx.ui.test
+import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.node.ExperimentalLayoutNodeApi
import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.unit.Density
-import androidx.compose.ui.unit.PxBounds
internal expect fun getAllSemanticsNodes(mergingEnabled: Boolean): List<SemanticsNode>
@@ -223,7 +223,7 @@
}
internal actual fun SemanticsNodeInteraction.withUnclippedBoundsInRoot(
- assertion: Density.(PxBounds) -> Unit
+ assertion: Density.(Rect) -> Unit
): SemanticsNodeInteraction {
val node = fetchSemanticsNode("Failed to retrieve bounds of the node.")
@OptIn(ExperimentalLayoutNodeApi::class)
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
index 9b52095..fee4ef2 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
@@ -40,7 +40,6 @@
import androidx.lifecycle.ViewTreeViewModelStoreOwner
import androidx.compose.ui.platform.AnimationClockAmbient
import androidx.compose.ui.platform.setContent
-import androidx.compose.ui.graphics.toAndroidRect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.FontLoaderAmbient
@@ -51,8 +50,6 @@
import androidx.ui.tooling.asTree
import androidx.ui.tooling.preview.animation.PreviewAnimationClock
import androidx.compose.ui.unit.IntBounds
-import androidx.compose.ui.unit.PxBounds
-import androidx.compose.ui.unit.toRect
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
@@ -291,13 +288,13 @@
.forEach {
if (it.hasBounds()) {
canvas?.apply {
- val pxBounds = PxBounds(
- it.bounds.left.toFloat(),
- it.bounds.top.toFloat(),
- it.bounds.right.toFloat(),
- it.bounds.bottom.toFloat()
+ val pxBounds = android.graphics.Rect(
+ it.bounds.left,
+ it.bounds.top,
+ it.bounds.right,
+ it.bounds.bottom
)
- drawRect(pxBounds.toRect().toAndroidRect(), debugBoundsPaint)
+ drawRect(pxBounds, debugBoundsPaint)
}
}
}
diff --git a/ui/ui-unit/api/current.txt b/ui/ui-unit/api/current.txt
index 1765e67..090bc94 100644
--- a/ui/ui-unit/api/current.txt
+++ b/ui/ui-unit/api/current.txt
@@ -360,21 +360,21 @@
public static final class Position.Companion {
}
- @androidx.compose.runtime.Immutable public final class PxBounds {
- ctor public PxBounds(float left, float top, float right, float bottom);
- method public float component1();
- method public float component2();
- method public float component3();
- method public float component4();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
- method public float getBottom();
- method public float getLeft();
- method public float getRight();
- method public float getTop();
- field public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
+ @Deprecated @androidx.compose.runtime.Immutable public final class PxBounds {
+ ctor @Deprecated public PxBounds(float left, float top, float right, float bottom);
+ method @Deprecated public float component1();
+ method @Deprecated public float component2();
+ method @Deprecated public float component3();
+ method @Deprecated public float component4();
+ method @Deprecated @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
+ method @Deprecated public float getBottom();
+ method @Deprecated public float getLeft();
+ method @Deprecated public float getRight();
+ method @Deprecated public float getTop();
+ field @Deprecated public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
}
- public static final class PxBounds.Companion {
+ @Deprecated public static final class PxBounds.Companion {
}
@androidx.compose.runtime.Immutable public final inline class PxCubed implements java.lang.Comparable<androidx.compose.ui.unit.PxCubed> {
@@ -412,15 +412,15 @@
}
public final class PxKt {
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Offset center-uvyYCjk(long);
- method public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
- method public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.IntOffset round(androidx.compose.ui.geometry.Offset);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
- method @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
}
@androidx.compose.runtime.Immutable public final inline class PxSquared implements java.lang.Comparable<androidx.compose.ui.unit.PxSquared> {
diff --git a/ui/ui-unit/api/public_plus_experimental_current.txt b/ui/ui-unit/api/public_plus_experimental_current.txt
index 1765e67..090bc94 100644
--- a/ui/ui-unit/api/public_plus_experimental_current.txt
+++ b/ui/ui-unit/api/public_plus_experimental_current.txt
@@ -360,21 +360,21 @@
public static final class Position.Companion {
}
- @androidx.compose.runtime.Immutable public final class PxBounds {
- ctor public PxBounds(float left, float top, float right, float bottom);
- method public float component1();
- method public float component2();
- method public float component3();
- method public float component4();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
- method public float getBottom();
- method public float getLeft();
- method public float getRight();
- method public float getTop();
- field public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
+ @Deprecated @androidx.compose.runtime.Immutable public final class PxBounds {
+ ctor @Deprecated public PxBounds(float left, float top, float right, float bottom);
+ method @Deprecated public float component1();
+ method @Deprecated public float component2();
+ method @Deprecated public float component3();
+ method @Deprecated public float component4();
+ method @Deprecated @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
+ method @Deprecated public float getBottom();
+ method @Deprecated public float getLeft();
+ method @Deprecated public float getRight();
+ method @Deprecated public float getTop();
+ field @Deprecated public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
}
- public static final class PxBounds.Companion {
+ @Deprecated public static final class PxBounds.Companion {
}
@androidx.compose.runtime.Immutable public final inline class PxCubed implements java.lang.Comparable<androidx.compose.ui.unit.PxCubed> {
@@ -412,15 +412,15 @@
}
public final class PxKt {
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Offset center-uvyYCjk(long);
- method public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
- method public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.IntOffset round(androidx.compose.ui.geometry.Offset);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
- method @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
}
@androidx.compose.runtime.Immutable public final inline class PxSquared implements java.lang.Comparable<androidx.compose.ui.unit.PxSquared> {
diff --git a/ui/ui-unit/api/restricted_current.txt b/ui/ui-unit/api/restricted_current.txt
index b95ef79..3b6d91d 100644
--- a/ui/ui-unit/api/restricted_current.txt
+++ b/ui/ui-unit/api/restricted_current.txt
@@ -360,21 +360,21 @@
public static final class Position.Companion {
}
- @androidx.compose.runtime.Immutable public final class PxBounds {
- ctor public PxBounds(float left, float top, float right, float bottom);
- method public float component1();
- method public float component2();
- method public float component3();
- method public float component4();
- method @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
- method public float getBottom();
- method public float getLeft();
- method public float getRight();
- method public float getTop();
- field public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
+ @Deprecated @androidx.compose.runtime.Immutable public final class PxBounds {
+ ctor @Deprecated public PxBounds(float left, float top, float right, float bottom);
+ method @Deprecated public float component1();
+ method @Deprecated public float component2();
+ method @Deprecated public float component3();
+ method @Deprecated public float component4();
+ method @Deprecated @androidx.compose.runtime.Immutable public androidx.compose.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
+ method @Deprecated public float getBottom();
+ method @Deprecated public float getLeft();
+ method @Deprecated public float getRight();
+ method @Deprecated public float getTop();
+ field @Deprecated public static final androidx.compose.ui.unit.PxBounds.Companion Companion;
}
- public static final class PxBounds.Companion {
+ @Deprecated public static final class PxBounds.Companion {
}
@androidx.compose.runtime.Immutable public final inline class PxCubed implements java.lang.Comparable<androidx.compose.ui.unit.PxCubed> {
@@ -412,15 +412,15 @@
}
public final class PxKt {
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
- method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.PxBounds PxBounds-MrV732k(androidx.compose.ui.geometry.Offset topLeft, long size);
+ method @Deprecated @androidx.compose.runtime.Stable public static inline androidx.compose.ui.geometry.Offset center(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Offset center-uvyYCjk(long);
- method public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
- method public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getHeight(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated public static inline float getWidth(androidx.compose.ui.unit.PxBounds);
method @androidx.compose.runtime.Stable public static inline androidx.compose.ui.unit.IntOffset round(androidx.compose.ui.geometry.Offset);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
- method @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.unit.PxBounds toBounds-uvyYCjk(long);
+ method @Deprecated @androidx.compose.runtime.Stable public static androidx.compose.ui.geometry.Rect toRect(androidx.compose.ui.unit.PxBounds);
+ method @Deprecated @androidx.compose.runtime.Stable public static long toSize(androidx.compose.ui.unit.PxBounds);
}
@androidx.compose.runtime.Immutable public final inline class PxSquared implements java.lang.Comparable<androidx.compose.ui.unit.PxSquared> {
diff --git a/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Px.kt b/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Px.kt
index b0b3ba8b..82ba112 100644
--- a/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Px.kt
+++ b/ui/ui-unit/src/commonMain/kotlin/androidx/compose/ui/unit/Px.kt
@@ -225,6 +225,9 @@
/**
* A four dimensional bounds using pixels for units
*/
+@Deprecated("Use Rect instead",
+ ReplaceWith("Rect(left, top, right, bottom)",
+ "androidx.compose.ui.geometry"))
@Immutable
data class PxBounds(
val left: Float,
@@ -235,6 +238,9 @@
companion object
}
+@Deprecated("Use Rect instead",
+ ReplaceWith("Rect(topleft, size)", "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
inline fun PxBounds(topLeft: Offset, size: Size) =
PxBounds(
@@ -247,18 +253,27 @@
/**
* A width of this PxBounds in pixels.
*/
+@Deprecated("Use Rect.width instead", ReplaceWith("Rect.width",
+ "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
inline val PxBounds.width: Float get() = right - left
/**
* A height of this PxBounds in pixels.
*/
+@Deprecated("use Rect.height instead", ReplaceWith("Rect.height",
+ "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
inline val PxBounds.height: Float get() = bottom - top
/**
* Returns the [Offset] of the center of the [PxBounds].
*/
+@Deprecated("Use Rect.center instead", ReplaceWith("Rect.center",
+ "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
inline fun PxBounds.center(): Offset {
return Offset((left + right) / 2f, (top + bottom) / 2f)
@@ -267,6 +282,9 @@
/**
* Convert a [PxBounds] to a [Size].
*/
+@Deprecated("Use Rect.size instead", ReplaceWith("Rect.size",
+ "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
fun PxBounds.toSize(): Size {
return Size(width, height)
@@ -276,6 +294,9 @@
* Convert a [Size] to a [PxBounds]. The left and top are 0.px and the right and bottom
* are the width and height, respectively.
*/
+@Deprecated("Use toRect() instead",
+ ReplaceWith("Size.toRect()", "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
fun Size.toBounds(): PxBounds {
return PxBounds(0f, 0f, width, height)
@@ -284,6 +305,9 @@
/**
* Convert a [PxBounds] to a [Rect].
*/
+@Deprecated("Use Rect instead of PxBounds", ReplaceWith("Rect(left, top, right, bottom)",
+ "androidx.compose.ui.geometry"))
+@Suppress("DEPRECATION")
@Stable
fun PxBounds.toRect(): Rect {
return Rect(
diff --git a/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/PxTest.kt b/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/PxTest.kt
index b1b0613..e3272a3 100644
--- a/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/PxTest.kt
+++ b/ui/ui-unit/src/test/kotlin/androidx/compose/ui/unit/PxTest.kt
@@ -105,18 +105,21 @@
}
@Test
+ @Suppress("DEPRECATION")
fun boundsWidth() {
val bounds = PxBounds(10f, 5f, 25f, 15f)
assertEquals(15f, bounds.width)
}
@Test
+ @Suppress("DEPRECATION")
fun boundsHeight() {
val bounds = PxBounds(10f, 5f, 25f, 15f)
assertEquals(10f, bounds.height)
}
@Test
+ @Suppress("DEPRECATION")
fun toBounds() {
val size = Size(15f, 10f)
val bounds = PxBounds(0f, 0f, 15f, 10f)
@@ -124,6 +127,7 @@
}
@Test
+ @Suppress("DEPRECATION")
fun toSize() {
val size = Size(15f, 10f)
val bounds = PxBounds(10f, 5f, 25f, 15f)