Removal of Px usages part 6 of n
Relnote: "Replaced usage of Px class in various
compose classes as part of the large
refactoring effort to only rely on Dp
and primitive types for pixel parameters"
Bug: 156681014
Test: re-ran compose tests
Change-Id: I086f4744d1eb51f0f31356e36991c2a8d4433059
diff --git a/ui/ui-unit/api/0.1.0-dev14.txt b/ui/ui-unit/api/0.1.0-dev14.txt
index 2b523bc..14182cc 100644
--- a/ui/ui-unit/api/0.1.0-dev14.txt
+++ b/ui/ui-unit/api/0.1.0-dev14.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/api/current.txt b/ui/ui-unit/api/current.txt
index 2b523bc..14182cc 100644
--- a/ui/ui-unit/api/current.txt
+++ b/ui/ui-unit/api/current.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
index 2b523bc..14182cc 100644
--- a/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
+++ b/ui/ui-unit/api/public_plus_experimental_0.1.0-dev14.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/api/public_plus_experimental_current.txt b/ui/ui-unit/api/public_plus_experimental_current.txt
index 2b523bc..14182cc 100644
--- a/ui/ui-unit/api/public_plus_experimental_current.txt
+++ b/ui/ui-unit/api/public_plus_experimental_current.txt
@@ -460,11 +460,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/api/restricted_0.1.0-dev14.txt b/ui/ui-unit/api/restricted_0.1.0-dev14.txt
index 2addb31..cd7cfe1 100644
--- a/ui/ui-unit/api/restricted_0.1.0-dev14.txt
+++ b/ui/ui-unit/api/restricted_0.1.0-dev14.txt
@@ -464,11 +464,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/api/restricted_current.txt b/ui/ui-unit/api/restricted_current.txt
index 2addb31..cd7cfe1 100644
--- a/ui/ui-unit/api/restricted_current.txt
+++ b/ui/ui-unit/api/restricted_current.txt
@@ -464,11 +464,12 @@
}
@androidx.compose.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.Immutable public androidx.ui.unit.PxBounds copy-wHlpFhg(float left, float top, float right, float bottom);
+ method @androidx.compose.Immutable public androidx.ui.unit.PxBounds copy(float left, float top, float right, float bottom);
method public float getBottom();
method public float getLeft();
method public float getRight();
diff --git a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
index 5826d71..de88bb7 100644
--- a/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
+++ b/ui/ui-unit/src/commonMain/kotlin/androidx/ui/unit/Px.kt
@@ -501,15 +501,15 @@
* The horizontal aspect of the size in [Px].
*/
@Stable
- inline val width: Px
- get() = unpackFloat1(value).px
+ inline val width: Float
+ get() = unpackFloat1(value)
/**
* The vertical aspect of the size in [Px].
*/
@Stable
- inline val height: Px
- get() = unpackFloat2(value).px
+ inline val height: Float
+ get() = unpackFloat2(value)
/**
* Returns a PxSize scaled by multiplying [width] and [height] by [other]
@@ -559,13 +559,13 @@
* [PxSize] with zero values.
*/
@Stable
- val Zero = PxSize(0.px, 0.px)
+ val Zero = PxSize(0f, 0f)
/**
* Default value indicating no specified size
*/
@Stable
- val UnspecifiedSize = PxSize(Px.Infinity, Px.Infinity)
+ val UnspecifiedSize = PxSize(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
}
}
@@ -605,7 +605,7 @@
*/
@Stable
fun PxSize.center(): PxPosition {
- return PxPosition(width.value / 2f, height.value / 2f)
+ return PxPosition(width / 2f, height / 2f)
}
/**
@@ -714,43 +714,43 @@
PxPosition(lerp(start.x, stop.x, fraction), lerp(start.y, stop.y, fraction))
/**
- * A four dimensional bounds using [Px] for units
+ * A four dimensional bounds using pixels for units
*/
@Immutable
data class PxBounds(
- val left: Px,
- val top: Px,
- val right: Px,
- val bottom: Px
+ val left: Float,
+ val top: Float,
+ val right: Float,
+ val bottom: Float
)
@Stable
inline fun PxBounds(topLeft: PxPosition, size: PxSize) =
PxBounds(
- left = topLeft.x.px,
- top = topLeft.y.px,
- right = topLeft.x.px + size.width,
- bottom = topLeft.y.px + size.height
+ left = topLeft.x,
+ top = topLeft.y,
+ right = topLeft.x + size.width,
+ bottom = topLeft.y + size.height
)
/**
* A width of this PxBounds in [Px].
*/
@Stable
-inline val PxBounds.width: Px get() = right - left
+inline val PxBounds.width: Float get() = right - left
/**
* A height of this PxBounds in [Px].
*/
@Stable
-inline val PxBounds.height: Px get() = bottom - top
+inline val PxBounds.height: Float get() = bottom - top
/**
* Returns the [PxPosition] of the center of the [PxBounds].
*/
@Stable
inline fun PxBounds.center(): PxPosition {
- return PxPosition(left.value + width.value / 2f, top.value + height.value / 2f)
+ return PxPosition(left + width / 2f, top + height / 2f)
}
/**
@@ -767,7 +767,7 @@
*/
@Stable
fun PxSize.toBounds(): PxBounds {
- return PxBounds(0.px, 0.px, width, height)
+ return PxBounds(0f, 0f, width, height)
}
/**
@@ -776,10 +776,10 @@
@Stable
fun PxBounds.toRect(): Rect {
return Rect(
- left.value,
- top.value,
- right.value,
- bottom.value
+ left,
+ top,
+ right,
+ bottom
)
}
@@ -788,5 +788,5 @@
*/
@Stable
fun PxSize.toRect(): Rect {
- return Rect(0f, 0f, width.value, height.value)
+ return Rect(0f, 0f, width, height)
}
\ No newline at end of file
diff --git a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
index 9748b08..0a19eea 100644
--- a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
+++ b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/IntPxTest.kt
@@ -224,7 +224,7 @@
@Test
fun createSize() {
- assertEquals(PxSize(10.px, 20.px), PxSize(10.ipx, 20.ipx))
+ assertEquals(PxSize(10f, 20f), PxSize(10.ipx, 20.ipx))
}
@Test
diff --git a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
index ed228ad..9b5173d 100644
--- a/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
+++ b/ui/ui-unit/src/unitTest/kotlin/androidx/ui/unit/PxTest.kt
@@ -375,60 +375,60 @@
@Test
fun boundsWidth() {
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
- assertEquals(15.px, bounds.width)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
+ assertEquals(15f, bounds.width)
}
@Test
fun boundsHeight() {
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
- assertEquals(10.px, bounds.height)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
+ assertEquals(10f, bounds.height)
}
@Test
fun toSize() {
- val size = PxSize(15.px, 10.px)
- val bounds = PxBounds(10.px, 5.px, 25.px, 15.px)
+ val size = PxSize(15f, 10f)
+ val bounds = PxBounds(10f, 5f, 25f, 15f)
assertEquals(size, bounds.toSize())
}
@Test
fun toBounds() {
- val size = PxSize(15.px, 10.px)
- val bounds = PxBounds(0.px, 0.px, 15.px, 10.px)
+ val size = PxSize(15f, 10f)
+ val bounds = PxBounds(0f, 0f, 15f, 10f)
assertEquals(bounds, size.toBounds())
}
@Test
fun sizeTimesInt() {
- assertEquals(PxSize(10.px, 10.px), PxSize(2.5.px, 2.5.px) * 4)
- assertEquals(PxSize(10.px, 10.px), 4 * PxSize(2.5.px, 2.5.px))
+ assertEquals(PxSize(10f, 10f), PxSize(2.5f, 2.5f) * 4)
+ assertEquals(PxSize(10f, 10f), 4 * PxSize(2.5f, 2.5f))
}
@Test
fun sizeDivInt() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4)
}
@Test
fun sizeTimesFloat() {
- assertEquals(PxSize(10.px, 10.px), PxSize(4.px, 4.px) * 2.5f)
- assertEquals(PxSize(10.px, 10.px), 2.5f * PxSize(4.px, 4.px))
+ assertEquals(PxSize(10f, 10f), PxSize(4f, 4f) * 2.5f)
+ assertEquals(PxSize(10f, 10f), 2.5f * PxSize(4f, 4f))
}
@Test
fun sizeDivFloat() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4f)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4f)
}
@Test
fun sizeTimesDouble() {
- assertEquals(PxSize(10.px, 10.px), PxSize(4.px, 4.px) * 2.5)
- assertEquals(PxSize(10.px, 10.px), 2.5 * PxSize(4.px, 4.px))
+ assertEquals(PxSize(10f, 10f), PxSize(4f, 4f) * 2.5)
+ assertEquals(PxSize(10f, 10f), 2.5 * PxSize(4f, 4f))
}
@Test
fun sizeDivDouble() {
- assertEquals(PxSize(10.px, 10.px), PxSize(40.px, 40.px) / 4.0)
+ assertEquals(PxSize(10f, 10f), PxSize(40f, 40f) / 4.0)
}
}
\ No newline at end of file