Update API surface of DpConstraints
Bug: 147804373
Test: ran demos and ui-layout tests
Change-Id: I712a00f632efb6045cd31eddc54ac6229110b5fc
diff --git a/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt b/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
index 79aa819..742e588 100644
--- a/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
+++ b/ui/ui-core/src/test/java/androidx/ui/core/ConstraintsTest.kt
@@ -39,14 +39,14 @@
val constraints = Constraints(0.ipx, 1.ipx, 2.ipx, 3.ipx)
constraints.assertEquals(0.ipx, 1.ipx, 2.ipx, 3.ipx)
- val tightConstraintsForWidth = Constraints.fixedWidth(5.ipx)
- tightConstraintsForWidth.assertEquals(5.ipx, 5.ipx, IntPx.Zero, IntPx.Infinity)
+ val fixedWidth = Constraints.fixedWidth(5.ipx)
+ fixedWidth.assertEquals(5.ipx, 5.ipx, IntPx.Zero, IntPx.Infinity)
- val tightConstraintsForHeight = Constraints.fixedHeight(5.ipx)
- tightConstraintsForHeight.assertEquals(IntPx.Zero, IntPx.Infinity, 5.ipx, 5.ipx)
+ val fixedHeight = Constraints.fixedHeight(5.ipx)
+ fixedHeight.assertEquals(IntPx.Zero, IntPx.Infinity, 5.ipx, 5.ipx)
- val tightConstraints = Constraints.fixed(5.ipx, 7.ipx)
- tightConstraints.assertEquals(5.ipx, 5.ipx, 7.ipx, 7.ipx)
+ val fixed = Constraints.fixed(5.ipx, 7.ipx)
+ fixed.assertEquals(5.ipx, 5.ipx, 7.ipx, 7.ipx)
}
@Test
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ColoredRectTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ColoredRectTest.kt
index 693ea7b..caf4c76 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ColoredRectTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ColoredRectTest.kt
@@ -55,7 +55,7 @@
val height = 71.dp
composeTestRule
.setContentAndCollectSizes(
- parentConstraints = DpConstraints.tightConstraints(
+ parentConstraints = DpConstraints.fixed(
width,
height
)
diff --git a/ui/ui-layout/api/0.1.0-dev04.txt b/ui/ui-layout/api/0.1.0-dev04.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/0.1.0-dev04.txt
+++ b/ui/ui-layout/api/0.1.0-dev04.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/api/current.txt b/ui/ui-layout/api/current.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/current.txt
+++ b/ui/ui-layout/api/current.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev04.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/api/public_plus_experimental_current.txt b/ui/ui-layout/api/public_plus_experimental_current.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/public_plus_experimental_current.txt
+++ b/ui/ui-layout/api/public_plus_experimental_current.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/api/restricted_0.1.0-dev04.txt b/ui/ui-layout/api/restricted_0.1.0-dev04.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-layout/api/restricted_0.1.0-dev04.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/api/restricted_current.txt b/ui/ui-layout/api/restricted_current.txt
index 581a9dc..b53e481 100644
--- a/ui/ui-layout/api/restricted_current.txt
+++ b/ui/ui-layout/api/restricted_current.txt
@@ -81,9 +81,9 @@
}
public static final class DpConstraints.Companion {
- method public androidx.ui.layout.DpConstraints tightConstraints(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForHeight(androidx.ui.unit.Dp height);
- method public androidx.ui.layout.DpConstraints tightConstraintsForWidth(androidx.ui.unit.Dp width);
+ method public androidx.ui.layout.DpConstraints fixed(androidx.ui.unit.Dp width, androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedHeight(androidx.ui.unit.Dp height);
+ method public androidx.ui.layout.DpConstraints fixedWidth(androidx.ui.unit.Dp width);
}
public final class DpConstraintsKt {
@@ -92,17 +92,11 @@
method public static androidx.ui.layout.DpConstraints enforce(androidx.ui.layout.DpConstraints, androidx.ui.layout.DpConstraints otherConstraints);
method public static boolean getHasBoundedHeight(androidx.ui.layout.DpConstraints);
method public static boolean getHasBoundedWidth(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightHeight(androidx.ui.layout.DpConstraints);
- method public static boolean getHasTightWidth(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedHeight(androidx.ui.layout.DpConstraints);
+ method public static boolean getHasFixedWidth(androidx.ui.layout.DpConstraints);
method public static boolean getSatisfiable(androidx.ui.layout.DpConstraints);
- method public static boolean isTight(androidx.ui.layout.DpConstraints);
method public static boolean isZero(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints looseMin(androidx.ui.layout.DpConstraints);
method public static androidx.ui.layout.DpConstraints offset(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp horizontal = 0.dp, androidx.ui.unit.Dp vertical = 0.dp);
- method public static androidx.ui.layout.DpConstraints tightMax(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints tightMin(androidx.ui.layout.DpConstraints);
- method public static androidx.ui.layout.DpConstraints withTight(androidx.ui.layout.DpConstraints, androidx.ui.unit.Dp? width = null, androidx.ui.unit.Dp? height = null);
}
public final class EdgeInsets {
diff --git a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/AspectRatioSample.kt b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/AspectRatioSample.kt
index 13a5d76..2dad8ed 100644
--- a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/AspectRatioSample.kt
+++ b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/AspectRatioSample.kt
@@ -28,7 +28,7 @@
@Sampled
@Composable
fun SimpleAspectRatio() {
- Container(constraints = DpConstraints.tightConstraintsForWidth(100.dp)) {
+ Container(constraints = DpConstraints.fixedWidth(100.dp)) {
ColoredRect(color = Color.Gray, modifier = LayoutAspectRatio(2f))
}
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
index 531d7d2..335763d 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
@@ -122,7 +122,7 @@
val childWidth = childWidthDp.toIntPx()
val childHeightDp = 30.dp
val childHeight = childHeightDp.toIntPx()
- val childConstraints = DpConstraints.tightConstraints(childWidthDp, childHeightDp)
+ val childConstraints = DpConstraints.fixed(childWidthDp, childHeightDp)
val positionedLatch = CountDownLatch(4)
val containerSize = Ref<PxSize>()
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
index 669bef2..5ac8eb4 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
@@ -2395,7 +2395,7 @@
show {
Center {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)
+ constraints = DpConstraints.fixed(sizeDp, sizeDp)
) {
Row {
OnChildPositioned( coordinates ->
@@ -2424,7 +2424,7 @@
show {
Center {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)
+ constraints = DpConstraints.fixed(sizeDp, sizeDp)
) {
Column {
OnChildPositioned( coordinates ->
@@ -2449,17 +2449,17 @@
testIntrinsics(@Composable {
Row {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Row(LayoutWidth.Fill) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Row {
Container(LayoutAspectRatio(2f) + LayoutGravity.Top) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp),
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp),
LayoutGravity.Center) { }
}
}, @Composable {
@@ -2468,43 +2468,43 @@
LayoutAspectRatio(2f) + LayoutGravity.RelativeToSiblings(FirstBaseline)
) { }
ConstrainedBox(
- DpConstraints.tightConstraints(50.dp, 40.dp),
+ DpConstraints.fixed(50.dp, 40.dp),
LayoutGravity.RelativeToSiblings { it.width }
) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.Begin) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.Center) {
Container(LayoutGravity.Center + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp),
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp),
LayoutGravity.Center) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.End) {
Container(LayoutGravity.Bottom + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp),
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp),
LayoutGravity.Bottom) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.SpaceAround) {
Container(LayoutHeight.Fill + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp),
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp),
LayoutHeight.Fill
) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.SpaceBetween) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Row(LayoutWidth.Fill, arrangement = Arrangement.SpaceEvenly) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
// Min width.
@@ -2530,99 +2530,99 @@
fun testRow_withFlexibleChildren_hasCorrectIntrinsicMeasurements() = withDensity(density) {
testIntrinsics(@Composable {
Row {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 40.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(2f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp)) { }
}
}, @Composable {
Row {
ConstrainedBox(
- DpConstraints.tightConstraints(20.dp, 30.dp),
+ DpConstraints.fixed(20.dp, 30.dp),
LayoutFlexible(3f) + LayoutGravity.Top
) { }
ConstrainedBox(
- DpConstraints.tightConstraints(30.dp, 40.dp),
+ DpConstraints.fixed(30.dp, 40.dp),
LayoutFlexible(2f) + LayoutGravity.Center
) { }
Container(LayoutAspectRatio(2f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp),
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp),
LayoutGravity.Bottom) { }
}
}, @Composable {
Row(arrangement = Arrangement.Begin) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 40.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(2f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp)) { }
}
}, @Composable {
Row(arrangement = Arrangement.Center) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutFlexible(3f) + LayoutGravity.Center
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ constraints = DpConstraints.fixed(30.dp, 40.dp),
modifier = LayoutFlexible(2f) + LayoutGravity.Center
) { }
Container(
LayoutAspectRatio(2f) + LayoutFlexible(2f) + LayoutGravity.Center
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutGravity.Center
) { }
}
}, @Composable {
Row(arrangement = Arrangement.End) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutFlexible(3f) + LayoutGravity.Bottom
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ constraints = DpConstraints.fixed(30.dp, 40.dp),
modifier = LayoutFlexible(2f) + LayoutGravity.Bottom
) { }
Container(
LayoutAspectRatio(2f) + LayoutFlexible(2f) + LayoutGravity.Bottom
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutGravity.Bottom
) { }
}
}, @Composable {
Row(arrangement = Arrangement.SpaceAround) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutFlexible(3f) + LayoutHeight.Fill
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ constraints = DpConstraints.fixed(30.dp, 40.dp),
modifier = LayoutFlexible(2f) + LayoutHeight.Fill
) { }
Container(
LayoutAspectRatio(2f) + LayoutFlexible(2f) + LayoutHeight.Fill
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ constraints = DpConstraints.fixed(20.dp, 30.dp),
modifier = LayoutHeight.Fill
) { }
}
}, @Composable {
Row(arrangement = Arrangement.SpaceBetween) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 40.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(2f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp)) { }
}
}, @Composable {
Row(arrangement = Arrangement.SpaceEvenly) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 40.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(2f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(20.dp, 30.dp)) { }
}
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
// Min width.
@@ -2677,57 +2677,57 @@
testIntrinsics(@Composable {
Column {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Column {
Container(LayoutAspectRatio(2f) + LayoutGravity.Start) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), LayoutGravity.End) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp), LayoutGravity.End) { }
}
}, @Composable {
Column {
Container(LayoutAspectRatio(2f) + LayoutGravity.RelativeToSiblings { 0.ipx }) { }
ConstrainedBox(
- DpConstraints.tightConstraints(50.dp, 40.dp),
+ DpConstraints.fixed(50.dp, 40.dp),
LayoutGravity.RelativeToSiblings(TestVerticalLine)
) { }
}
}, @Composable {
Column(LayoutHeight.Fill) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.Begin) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.Center) {
Container(LayoutGravity.Center + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.End) {
Container(LayoutGravity.End + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), LayoutGravity.End) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp), LayoutGravity.End) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.SpaceAround) {
Container(LayoutWidth.Fill + LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp),
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp),
LayoutWidth.Fill
) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.SpaceBetween) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}, @Composable {
Column(LayoutHeight.Fill, arrangement = Arrangement.SpaceEvenly) {
Container(LayoutAspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(50.dp, 40.dp)) { }
}
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
// Min width.
@@ -2753,98 +2753,98 @@
fun testColumn_withFlexibleChildren_hasCorrectIntrinsicMeasurements() = withDensity(density) {
testIntrinsics(@Composable {
Column {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(40.dp, 30.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(0.5f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp)) { }
}
}, @Composable {
Column {
ConstrainedBox(
- DpConstraints.tightConstraints(30.dp, 20.dp),
+ DpConstraints.fixed(30.dp, 20.dp),
LayoutFlexible(3f) + LayoutGravity.Start
) { }
ConstrainedBox(
- DpConstraints.tightConstraints(40.dp, 30.dp),
+ DpConstraints.fixed(40.dp, 30.dp),
LayoutFlexible(2f) + LayoutGravity.Center
) { }
Container(LayoutAspectRatio(0.5f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), LayoutGravity.End) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp), LayoutGravity.End) { }
}
}, @Composable {
Column(arrangement = Arrangement.Begin) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(40.dp, 30.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(0.5f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp)) { }
}
}, @Composable {
Column(arrangement = Arrangement.Center) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutFlexible(3f) + LayoutGravity.Center
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ constraints = DpConstraints.fixed(40.dp, 30.dp),
modifier = LayoutFlexible(2f) + LayoutGravity.Center
) { }
Container(
LayoutAspectRatio(0.5f) + LayoutFlexible(2f) + LayoutGravity.Center
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutGravity.Center
) { }
}
}, @Composable {
Column(arrangement = Arrangement.End) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutFlexible(3f) + LayoutGravity.End
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ constraints = DpConstraints.fixed(40.dp, 30.dp),
modifier = LayoutFlexible(2f) + LayoutGravity.End
) { }
Container(
LayoutAspectRatio(0.5f) + LayoutFlexible(2f) + LayoutGravity.End
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutGravity.End
) { }
}
}, @Composable {
Column(arrangement = Arrangement.SpaceAround) {
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutFlexible(3f) + LayoutWidth.Fill
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ constraints = DpConstraints.fixed(40.dp, 30.dp),
modifier = LayoutFlexible(2f) + LayoutWidth.Fill
) { }
Container(
LayoutAspectRatio(0.5f) + LayoutFlexible(2f) + LayoutWidth.Fill
) { }
ConstrainedBox(
- constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ constraints = DpConstraints.fixed(30.dp, 20.dp),
modifier = LayoutWidth.Fill
) { }
}
}, @Composable {
Column(arrangement = Arrangement.SpaceBetween) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(40.dp, 30.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(0.5f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp)) { }
}
}, @Composable {
Column(arrangement = Arrangement.SpaceEvenly) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), LayoutFlexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), LayoutFlexible(2f)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp), LayoutFlexible(3f)) { }
+ ConstrainedBox(DpConstraints.fixed(40.dp, 30.dp), LayoutFlexible(2f)) { }
Container(LayoutAspectRatio(0.5f) + LayoutFlexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ ConstrainedBox(DpConstraints.fixed(30.dp, 20.dp)) { }
}
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
// Min width.
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
index 4fed663..2dfa834 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
@@ -180,7 +180,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
val children = @Composable {
Container {
OnPositioned( coordinates ->
@@ -225,7 +225,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
val children = @Composable {
Container {
OnPositioned( coordinates ->
@@ -277,7 +277,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
paddingContainer {
Container {
OnPositioned( coordinates ->
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
index 840fff8..8f625fa 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
@@ -135,7 +135,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
val children = @Composable {
Container {
OnPositioned( coordinates ->
@@ -180,7 +180,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
val children = @Composable {
Container {
OnPositioned( coordinates ->
@@ -233,7 +233,7 @@
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
- ConstrainedBox(constraints = DpConstraints.tightConstraints(sizeDp, sizeDp)) {
+ ConstrainedBox(constraints = DpConstraints.fixed(sizeDp, sizeDp)) {
val children = @Composable {
Container {
OnPositioned( coordinates ->
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
index 866c7fa..757377f 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
@@ -308,11 +308,11 @@
Stack {
Container(LayoutGravity.TopLeft + LayoutAspectRatio(2f)) { }
ConstrainedBox(
- DpConstraints.tightConstraints(testWidth, testHeight),
+ DpConstraints.fixed(testWidth, testHeight),
LayoutGravity.BottomCenter
) { }
ConstrainedBox(
- DpConstraints.tightConstraints(200.dp, 200.dp),
+ DpConstraints.fixed(200.dp, 200.dp),
LayoutGravity.Stretch + LayoutPadding(10.dp)
) { }
}
@@ -342,7 +342,7 @@
Stack {
ConstrainedBox(
modifier = LayoutGravity.Stretch + LayoutPadding(10.dp),
- constraints = DpConstraints.tightConstraints(200.dp, 200.dp)
+ constraints = DpConstraints.fixed(200.dp, 200.dp)
) { }
}
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/DpConstraints.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/DpConstraints.kt
index 16787c6..5e3c284 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/DpConstraints.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/DpConstraints.kt
@@ -60,12 +60,12 @@
/**
* Creates constraints tight in both dimensions.
*/
- fun tightConstraints(width: Dp, height: Dp) = DpConstraints(width, width, height, height)
+ fun fixed(width: Dp, height: Dp) = DpConstraints(width, width, height, height)
/**
* Creates constraints with tight width and loose height.
*/
- fun tightConstraintsForWidth(width: Dp) = DpConstraints(
+ fun fixedWidth(width: Dp) = DpConstraints(
minWidth = width,
maxWidth = width,
minHeight = 0.dp,
@@ -75,7 +75,7 @@
/**
* Creates constraints with tight height and loose width.
*/
- fun tightConstraintsForHeight(height: Dp) = DpConstraints(
+ fun fixedHeight(height: Dp) = DpConstraints(
minWidth = 0.dp,
maxWidth = Dp.Infinity,
minHeight = height,
@@ -97,24 +97,18 @@
val DpConstraints.hasBoundedWidth get() = maxWidth.isFinite()
/**
- * Whether there is exactly one size that satisfies the constraints.
- * @see hasTightHeight
- * @see hasTightWidth
- */
-val DpConstraints.isTight get() = minWidth == maxWidth && minHeight == maxHeight
-
-/**
* Whether there is exactly one width value that satisfies the constraints.
*/
-val DpConstraints.hasTightWidth get() = maxWidth == minWidth
+val DpConstraints.hasFixedWidth get() = maxWidth == minWidth
/**
* Whether there is exactly one height value that satisfies the constraints.
*/
-val DpConstraints.hasTightHeight get() = maxHeight == minHeight
+val DpConstraints.hasFixedHeight get() = maxHeight == minHeight
/**
- * Whether there is exactly one height value that satisfies the constraints.
+ * Whether the area of a component respecting these constraints will definitely be 0.
+ * This is true when at least one of maxWidth and maxHeight are 0.
*/
val DpConstraints.isZero get() = maxWidth == 0.dp || maxHeight == 0.dp
@@ -134,40 +128,6 @@
)
/**
- * Returns a copy of the current instance, overriding the specified values to be tight.
- */
-fun DpConstraints.withTight(width: Dp? = null, height: Dp? = null) = DpConstraints(
- minWidth = width ?: this.minWidth,
- maxWidth = width ?: this.maxWidth,
- minHeight = height ?: this.minHeight,
- maxHeight = height ?: this.maxHeight
-)
-
-/**
- * Returns a copy of the current instance with no min constraints.
- */
-fun DpConstraints.looseMin() = this.copy(minWidth = 0.dp, minHeight = 0.dp)
-
-/**
- * Returns a copy of the current instance with no max constraints.
- */
-fun DpConstraints.looseMax() = this.copy(maxWidth = Dp.Infinity, maxHeight = Dp.Infinity)
-
-/**
- * Returns a copy of the current instance with the constraints tightened to their smallest size.
- */
-fun DpConstraints.tightMin() = this.withTight(width = minWidth, height = minHeight)
-
-/**
- * Returns a copy of the current instance with the constraints tightened to their largest size.
- * Note that if any of the constraints are unbounded, they will be left unchanged.
- */
-fun DpConstraints.tightMax() = this.copy(
- minWidth = if (hasBoundedWidth) maxWidth else minWidth,
- minHeight = if (hasBoundedHeight) maxHeight else minHeight
-)
-
-/**
* Returns the DpConstraints obtained by offsetting the current instance with the given values.
*/
fun DpConstraints.offset(horizontal: Dp = 0.dp, vertical: Dp = 0.dp) = DpConstraints(
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
index f29edde..1591537 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/SizeModifiers.kt
@@ -76,7 +76,7 @@
@Stable
data class LayoutWidth(val width: Dp)
// TODO: remove delegation here and implement inline
- : LayoutModifier by SizeModifier(DpConstraints.tightConstraintsForWidth(width)) {
+ : LayoutModifier by SizeModifier(DpConstraints.fixedWidth(width)) {
init {
require(width.isFinite()) { "width must be finite" }
require(width >= Dp.Hairline) { "width must be >= 0.dp" }
@@ -170,7 +170,7 @@
@Stable
data class LayoutHeight(val height: Dp)
// TODO: remove delegation here and implement inline
- : LayoutModifier by SizeModifier(DpConstraints.tightConstraintsForHeight(height)) {
+ : LayoutModifier by SizeModifier(DpConstraints.fixedHeight(height)) {
init {
require(height.isFinite()) { "height must be finite" }
require(height >= Dp.Hairline) { "height must be >= 0.dp" }
@@ -269,7 +269,7 @@
@Stable
data class LayoutSize(val width: Dp, val height: Dp)
// TODO: remove delegation here and implement inline
- : LayoutModifier by SizeModifier(DpConstraints.tightConstraints(width, height)) {
+ : LayoutModifier by SizeModifier(DpConstraints.fixed(width, height)) {
/**
* [Modifies][LayoutModifier] a Compose UI layout element to have a square size of [size].
diff --git a/ui/ui-layout/src/test/java/androidx/ui/layout/test/DpConstraintsTest.kt b/ui/ui-layout/src/test/java/androidx/ui/layout/test/DpConstraintsTest.kt
index 1e4c879..b3bd4d9 100644
--- a/ui/ui-layout/src/test/java/androidx/ui/layout/test/DpConstraintsTest.kt
+++ b/ui/ui-layout/src/test/java/androidx/ui/layout/test/DpConstraintsTest.kt
@@ -20,16 +20,10 @@
import androidx.ui.layout.enforce
import androidx.ui.layout.hasBoundedHeight
import androidx.ui.layout.hasBoundedWidth
-import androidx.ui.layout.hasTightHeight
-import androidx.ui.layout.hasTightWidth
-import androidx.ui.layout.isTight
+import androidx.ui.layout.hasFixedHeight
+import androidx.ui.layout.hasFixedWidth
import androidx.ui.layout.isZero
-import androidx.ui.layout.looseMax
-import androidx.ui.layout.looseMin
import androidx.ui.layout.offset
-import androidx.ui.layout.tightMax
-import androidx.ui.layout.tightMin
-import androidx.ui.layout.withTight
import androidx.ui.unit.Dp
import androidx.ui.unit.dp
import org.junit.Assert.assertFalse
@@ -50,13 +44,13 @@
val constraints = DpConstraints(0.dp, 1.dp, 2.dp, 3.dp)
constraints.assertEquals(0.dp, 1.dp, 2.dp, 3.dp)
- val tightDpConstraintsForWidth = DpConstraints.tightConstraintsForWidth(5.dp)
+ val tightDpConstraintsForWidth = DpConstraints.fixedWidth(5.dp)
tightDpConstraintsForWidth.assertEquals(5.dp, 5.dp, 0.dp, Dp.Infinity)
- val tightDpConstraintsForHeight = DpConstraints.tightConstraintsForHeight(5.dp)
+ val tightDpConstraintsForHeight = DpConstraints.fixedHeight(5.dp)
tightDpConstraintsForHeight.assertEquals(0.dp, Dp.Infinity, 5.dp, 5.dp)
- val tightDpConstraints = DpConstraints.tightConstraints(5.dp, 7.dp)
+ val tightDpConstraints = DpConstraints.fixed(5.dp, 7.dp)
tightDpConstraints.assertEquals(5.dp, 5.dp, 7.dp, 7.dp)
}
@@ -72,16 +66,14 @@
}
@Test
- fun hasTightDimensions() {
+ fun hasFixedDimensions() {
val untight = DpConstraints(3.dp, 4.dp, 8.dp, 9.dp)
- assertFalse(untight.hasTightWidth)
- assertFalse(untight.hasTightHeight)
- assertFalse(untight.isTight)
+ assertFalse(untight.hasFixedWidth)
+ assertFalse(untight.hasFixedHeight)
val tight = DpConstraints(3.dp, 3.dp, 5.dp, 5.dp)
- assertTrue(tight.hasTightWidth)
- assertTrue(tight.hasTightHeight)
- assertTrue(tight.isTight)
+ assertTrue(tight.hasFixedWidth)
+ assertTrue(tight.hasFixedHeight)
}
@Test
@@ -111,35 +103,6 @@
}
@Test
- fun withTight() {
- val constraints = DpConstraints(2.dp, 3.dp, 2.dp, 3.dp)
- constraints.withTight().assertEquals(2.dp, 3.dp, 2.dp, 3.dp)
- constraints.withTight(7.dp, 8.dp).assertEquals(7.dp, 7.dp, 8.dp, 8.dp)
- }
-
- @Test
- fun loose() {
- val bounded = DpConstraints(2.dp, 5.dp, 2.dp, 5.dp)
- bounded.looseMin().assertEquals(0.dp, 5.dp, 0.dp, 5.dp)
- bounded.looseMax().assertEquals(2.dp, Dp.Infinity, 2.dp, Dp.Infinity)
-
- val unbounded = DpConstraints(2.dp, Dp.Infinity, 2.dp, Dp.Infinity)
- unbounded.looseMin().assertEquals(0.dp, Dp.Infinity, 0.dp, Dp.Infinity)
- unbounded.looseMax().assertEquals(2.dp, Dp.Infinity, 2.dp, Dp.Infinity)
- }
-
- @Test
- fun tight() {
- val bounded = DpConstraints(2.dp, 5.dp, 2.dp, 5.dp)
- bounded.tightMin().assertEquals(2.dp, 2.dp, 2.dp, 2.dp)
- bounded.tightMax().assertEquals(5.dp, 5.dp, 5.dp, 5.dp)
-
- val unbounded = DpConstraints(2.dp, Dp.Infinity, 2.dp, Dp.Infinity)
- unbounded.tightMin().assertEquals(2.dp, 2.dp, 2.dp, 2.dp)
- unbounded.tightMax().assertEquals(2.dp, Dp.Infinity, 2.dp, Dp.Infinity)
- }
-
- @Test
fun offset() {
val constraints = DpConstraints(2.dp, 2.dp, 5.dp, 5.dp)
constraints.offset(horizontal = 2.dp, vertical = 3.dp).assertEquals(