Add modifiers for intrinsic sizing
The CL adds modifiers for sizing to intrinsic measurements, and
deprecates the existing components serving this purpose.
Relnote: Added modifiers for sizing to intrinsic measurements and deprecated the components serving this purpose.
Bug: 150137448
Bug: 143755052
Test: ran ui-layout tests
Change-Id: I8295d57e17ba8ca83ea170713fc57ea7baea52fb
diff --git a/ui/ui-layout/api/0.1.0-dev09.txt b/ui/ui-layout/api/0.1.0-dev09.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/0.1.0-dev09.txt
+++ b/ui/ui-layout/api/0.1.0-dev09.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/api/current.txt b/ui/ui-layout/api/current.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/current.txt
+++ b/ui/ui-layout/api/current.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev09.txt b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev09.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev09.txt
+++ b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev09.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/api/public_plus_experimental_current.txt b/ui/ui-layout/api/public_plus_experimental_current.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/public_plus_experimental_current.txt
+++ b/ui/ui-layout/api/public_plus_experimental_current.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/api/restricted_0.1.0-dev09.txt b/ui/ui-layout/api/restricted_0.1.0-dev09.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/restricted_0.1.0-dev09.txt
+++ b/ui/ui-layout/api/restricted_0.1.0-dev09.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/api/restricted_current.txt b/ui/ui-layout/api/restricted_current.txt
index b66344e..5ca9a9c 100644
--- a/ui/ui-layout/api/restricted_current.txt
+++ b/ui/ui-layout/api/restricted_current.txt
@@ -354,10 +354,17 @@
}
public final class IntrinsicKt {
- method public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
- method public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MaxIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicHeight(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method @Deprecated public static void MinIntrinsicWidth(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+ method public static androidx.ui.core.Modifier preferredHeight(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ method public static androidx.ui.core.Modifier preferredWidth(androidx.ui.core.Modifier, androidx.ui.layout.IntrinsicSize intrinsicSize);
+ }
+
+ public enum IntrinsicSize {
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Max;
+ enum_constant public static final androidx.ui.layout.IntrinsicSize Min;
}
public final class LayoutAlign {
diff --git a/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt b/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
index 31dbad0..7e5661a 100644
--- a/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
+++ b/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
@@ -23,132 +23,116 @@
import androidx.ui.foundation.Text
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
-import androidx.ui.layout.MaxIntrinsicHeight
-import androidx.ui.layout.MaxIntrinsicWidth
-import androidx.ui.layout.MinIntrinsicHeight
-import androidx.ui.layout.MinIntrinsicWidth
+import androidx.ui.layout.IntrinsicSize
import androidx.ui.layout.Row
import androidx.ui.layout.Stack
import androidx.ui.layout.aspectRatio
import androidx.ui.layout.fillMaxHeight
import androidx.ui.layout.fillMaxWidth
+import androidx.ui.layout.preferredHeight
import androidx.ui.layout.preferredSize
import androidx.ui.layout.preferredWidth
import androidx.ui.unit.dp
-/**
- * Builds a layout containing three [Box] having the same width as the widest one.
- *
- * Here [MinIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
- * whose minimum intrinsic width will correspond to the preferred width of the largest
- * [Box]. Then [MinIntrinsicWidth] will measure the [Column] with tight width, the same
- * as the premeasured minimum intrinsic width, which due to [LayoutWidth.Fill] will force
- * the [Box]'s to use the same width.
- */
@Sampled
@Composable
fun SameWidthBoxes() {
+ // Builds a layout containing three Box having the same width as the widest one.
+ //
+ // Here preferredWidth min intrinsic is adding a width premeasurement pass for the
+ // Column, whose minimum intrinsic width will correspond to the preferred width of the largest
+ // Box. Then preferredWidth min intrinsic will measure the Column with tight width, the
+ // same as the premeasured minimum intrinsic width, which due to fillMaxWidth will force
+ // the Box's to use the same width.
Stack {
- MinIntrinsicWidth {
- Column(Modifier.fillMaxHeight()) {
- Box(
- modifier = Modifier.fillMaxWidth().preferredSize(20.dp, 10.dp),
- backgroundColor = Color.Gray
- )
- Box(
- modifier = Modifier.fillMaxWidth().preferredSize(30.dp, 10.dp),
- backgroundColor = Color.Blue
- )
- Box(
- modifier = Modifier.fillMaxWidth().preferredSize(10.dp, 10.dp),
- backgroundColor = Color.Magenta
- )
- }
+ Column(Modifier.preferredWidth(IntrinsicSize.Min).fillMaxHeight()) {
+ Box(
+ modifier = Modifier.fillMaxWidth().preferredSize(20.dp, 10.dp),
+ backgroundColor = Color.Gray
+ )
+ Box(
+ modifier = Modifier.fillMaxWidth().preferredSize(30.dp, 10.dp),
+ backgroundColor = Color.Blue
+ )
+ Box(
+ modifier = Modifier.fillMaxWidth().preferredSize(10.dp, 10.dp),
+ backgroundColor = Color.Magenta
+ )
}
}
}
-/**
- * Builds a layout containing two pieces of text separated by a divider, where the divider
- * is sized according to the height of the longest text.
- *
- * Here [MinIntrinsicHeight] is adding a speculative height measurement pass for the [Row],
- * whose minimum intrinsic height will correspond to the height of the largest [Text]. Then
- * [MinIntrinsicHeight] will measure the [Row] with tight height, the same as the premeasured
- * minimum intrinsic height, which due to [LayoutHeight.Fill] will force the [Text]s and
- * the divider to use the same height.
- */
@Sampled
@Composable
fun MatchParentDividerForText() {
+ // Builds a layout containing two pieces of text separated by a divider, where the divider
+ // is sized according to the height of the longest text.
+ //
+ // Here preferredHeight min intrinsic is adding a height premeasurement pass for the Row,
+ // whose minimum intrinsic height will correspond to the height of the largest Text. Then
+ // preferredHeight min intrinsic will measure the Row with tight height, the same as the
+ // premeasured minimum intrinsic height, which due to fillMaxHeight will force the Texts and
+ // the divider to use the same height.
Stack {
- MinIntrinsicHeight {
- Row {
- Text(
- text = "This is a really short text",
- modifier = Modifier.weight(1f).fillMaxHeight()
- )
- Box(Modifier.preferredWidth(1.dp).fillMaxHeight(), backgroundColor = Color.Black)
- Text(
- text = "This is a much much much much much much much much much much" +
- " much much much much much much longer text",
- modifier = Modifier.weight(1f).fillMaxHeight()
- )
- }
+ Row(Modifier.preferredHeight(IntrinsicSize.Min)) {
+ Text(
+ text = "This is a really short text",
+ modifier = Modifier.weight(1f).fillMaxHeight()
+ )
+ Box(Modifier.preferredWidth(1.dp).fillMaxHeight(), backgroundColor = Color.Black)
+ Text(
+ text = "This is a much much much much much much much much much much" +
+ " much much much much much much longer text",
+ modifier = Modifier.weight(1f).fillMaxHeight()
+ )
}
}
}
-/**
- * Builds a layout containing three [Text] boxes having the same width as the widest one.
- *
- * Here [MaxIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
- * whose maximum intrinsic width will correspond to the preferred width of the largest
- * [Box]. Then [MaxIntrinsicWidth] will measure the [Column] with tight width, the same
- * as the premeasured maximum intrinsic width, which due to [LayoutWidth.Fill] modifiers will
- * force the [Box]s to use the same width.
- */
@Sampled
@Composable
fun SameWidthTextBoxes() {
+ // Builds a layout containing three Text boxes having the same width as the widest one.
+ //
+ // Here preferredWidth max intrinsic is adding a width premeasurement pass for the Column,
+ // whose maximum intrinsic width will correspond to the preferred width of the largest
+ // Box. Then preferredWidth max intrinsic will measure the Column with tight width, the
+ // same as the premeasured maximum intrinsic width, which due to fillMaxWidth modifiers will
+ // force the Boxs to use the same width.
+
Stack {
- MaxIntrinsicWidth {
- Column(Modifier.fillMaxHeight()) {
- Box(Modifier.fillMaxWidth(), backgroundColor = Color.Gray) {
- Text("Short text")
- }
- Box(Modifier.fillMaxWidth(), backgroundColor = Color.Blue) {
- Text("Extremely long text giving the width of its siblings")
- }
- Box(Modifier.fillMaxWidth(), backgroundColor = Color.Magenta) {
- Text("Medium length text")
- }
+ Column(Modifier.preferredWidth(IntrinsicSize.Max).fillMaxHeight()) {
+ Box(Modifier.fillMaxWidth(), backgroundColor = Color.Gray) {
+ Text("Short text")
+ }
+ Box(Modifier.fillMaxWidth(), backgroundColor = Color.Blue) {
+ Text("Extremely long text giving the width of its siblings")
+ }
+ Box(Modifier.fillMaxWidth(), backgroundColor = Color.Magenta) {
+ Text("Medium length text")
}
}
}
}
-/**
- * Builds a layout containing two [LayoutAspectRatio]s separated by a divider, where the divider
- * is sized according to the height of the taller [LayoutAspectRatio].
- *
- * Here [MaxIntrinsicHeight] is adding a speculative height measurement pass for the [Row], whose
- * maximum intrinsic height will correspond to the height of the taller [LayoutAspectRatio]. Then
- * [MaxIntrinsicHeight] will measure the [Row] with tight height, the same as the premeasured
- * maximum intrinsic height, which due to [LayoutHeight.Fill] modifier will force the
- * [LayoutAspectRatio]s and the divider to use the same height.
- */
@Sampled
@Composable
fun MatchParentDividerForAspectRatio() {
+ // Builds a layout containing two aspectRatios separated by a divider, where the divider
+ // is sized according to the height of the taller aspectRatio.
+ //
+ // Here preferredHeight max intrinsic is adding a height premeasurement pass for the
+ // Row, whose maximum intrinsic height will correspond to the height of the taller
+ // aspectRatio. Then preferredHeight max intrinsic will measure the Row with tight height,
+ // the same as the premeasured maximum intrinsic height, which due to fillMaxHeight modifier
+ // will force the aspectRatios and the divider to use the same height.
+ //
Stack {
- MaxIntrinsicHeight {
- Row {
- val modifier = Modifier.fillMaxHeight().weight(1f)
- Box(modifier.aspectRatio(2f), backgroundColor = Color.Gray)
- Box(Modifier.preferredWidth(1.dp).fillMaxHeight(), backgroundColor = Color.Black)
- Box(modifier.aspectRatio(1f), backgroundColor = Color.Blue)
- }
+ Row(Modifier.preferredHeight(IntrinsicSize.Max)) {
+ val modifier = Modifier.fillMaxHeight().weight(1f)
+ Box(modifier.aspectRatio(2f), backgroundColor = Color.Gray)
+ Box(Modifier.preferredWidth(1.dp).fillMaxHeight(), backgroundColor = Color.Black)
+ Box(modifier.aspectRatio(1f), backgroundColor = Color.Blue)
}
}
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
index 3d67011..b0d1000 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
@@ -17,6 +17,7 @@
package androidx.ui.layout.test
import androidx.compose.Composable
+import androidx.compose.emptyContent
import androidx.test.filters.SmallTest
import androidx.ui.core.Layout
import androidx.ui.core.LayoutCoordinates
@@ -24,11 +25,10 @@
import androidx.ui.core.Ref
import androidx.ui.core.onChildPositioned
import androidx.ui.layout.DpConstraints
-import androidx.ui.layout.MaxIntrinsicHeight
-import androidx.ui.layout.MaxIntrinsicWidth
-import androidx.ui.layout.MinIntrinsicHeight
-import androidx.ui.layout.MinIntrinsicWidth
import androidx.ui.layout.Stack
+import androidx.ui.layout.IntrinsicSize
+import androidx.ui.layout.preferredHeight
+import androidx.ui.layout.preferredWidth
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
@@ -58,16 +58,14 @@
positionedLatch.countDown()
}
) {
- MinIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
@@ -89,16 +87,14 @@
positionedLatch.countDown()
}
) {
- MinIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
- size = childSize,
- position = childPosition,
- positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
+ size = childSize,
+ position = childPosition,
+ positionedLatch = positionedLatch
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
@@ -120,16 +116,14 @@
positionedLatch.countDown()
}
) {
- MaxIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
- size = childSize,
- position = childPosition,
- positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
+ size = childSize,
+ position = childPosition,
+ positionedLatch = positionedLatch
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
@@ -151,16 +145,14 @@
positionedLatch.countDown()
}
) {
- MaxIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
@@ -185,16 +177,14 @@
positionedLatch.countDown()
}
) {
- MinIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
- size = childSize,
- position = childPosition,
- positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
+ size = childSize,
+ position = childPosition,
+ positionedLatch = positionedLatch
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -220,16 +210,14 @@
positionedLatch.countDown()
}
) {
- MinIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -253,16 +241,14 @@
}
) {
ConstrainedBox(DpConstraints(maxHeight = 35.dp)) {
- MinIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
- size = childSize,
- position = childPosition,
- positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
+ size = childSize,
+ position = childPosition,
+ positionedLatch = positionedLatch
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -286,16 +272,14 @@
}
) {
ConstrainedBox(DpConstraints(minHeight = 45.dp)) {
- MinIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -319,16 +303,14 @@
}
) {
ConstrainedBox(DpConstraints(maxWidth = 25.dp)) {
- MaxIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
- size = childSize,
- position = childPosition,
- positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
+ size = childSize,
+ position = childPosition,
+ positionedLatch = positionedLatch
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -352,16 +334,14 @@
}
) {
ConstrainedBox(DpConstraints(minWidth = 35.dp)) {
- MaxIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -385,16 +365,14 @@
}
) {
ConstrainedBox(DpConstraints(maxHeight = 55.dp)) {
- MaxIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -418,16 +396,14 @@
}
) {
ConstrainedBox(DpConstraints(minHeight = 65.dp)) {
- MaxIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp,
- Modifier.saveLayoutInfo(
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
- )
- ) {
- }
- }
+ ),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}
}
}
@@ -440,10 +416,10 @@
@Test
fun testMinIntrinsicWidth_intrinsicMeasurements() = with(density) {
- testIntrinsics(@Composable {
- MinIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp) { }
- }
+ testIntrinsics({
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Min), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(10.dp.toIntPx(), minIntrinsicWidth(0.ipx))
assertEquals(40.dp.toIntPx(), minIntrinsicHeight(0.ipx))
@@ -454,10 +430,11 @@
@Test
fun testMinIntrinsicHeight_intrinsicMeasurements() = with(density) {
- testIntrinsics(@Composable {
- MinIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp) { }
- }
+ testIntrinsics({
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Min),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(10.dp.toIntPx(), minIntrinsicWidth(0.ipx))
assertEquals(40.dp.toIntPx(), minIntrinsicHeight(0.ipx))
@@ -468,10 +445,10 @@
@Test
fun testMaxIntrinsicWidth_intrinsicMeasurements() = with(density) {
- testIntrinsics(@Composable {
- MaxIntrinsicWidth {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp) { }
- }
+ testIntrinsics({
+ FixedIntrinsicsBox(
+ Modifier.preferredWidth(IntrinsicSize.Max), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(30.dp.toIntPx(), minIntrinsicWidth(0.ipx))
assertEquals(40.dp.toIntPx(), minIntrinsicHeight(0.ipx))
@@ -482,10 +459,11 @@
@Test
fun testMaxIntrinsicHeight_intrinsicMeasurements() = with(density) {
- testIntrinsics(@Composable {
- MaxIntrinsicHeight {
- FixedIntrinsicsBox(10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp) { }
- }
+ testIntrinsics({
+ FixedIntrinsicsBox(
+ Modifier.preferredHeight(IntrinsicSize.Max),
+ 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ )
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(10.dp.toIntPx(), minIntrinsicWidth(0.ipx))
assertEquals(60.dp.toIntPx(), minIntrinsicHeight(0.ipx))
@@ -497,17 +475,16 @@
@Composable
private fun FixedIntrinsicsBox(
+ modifier: Modifier = Modifier.None,
minIntrinsicWidth: Dp,
width: Dp,
maxIntrinsicWidth: Dp,
minIntrinsicHeight: Dp,
height: Dp,
- maxIntrinsicHeight: Dp,
- modifier: Modifier = Modifier.None,
- children: @Composable() () -> Unit
+ maxIntrinsicHeight: Dp
) {
Layout(
- children,
+ emptyContent(),
minIntrinsicWidthMeasureBlock = { _, _, _ -> minIntrinsicWidth.toIntPx() },
minIntrinsicHeightMeasureBlock = { _, _, _ -> minIntrinsicHeight.toIntPx() },
maxIntrinsicWidthMeasureBlock = { _, _, _ -> maxIntrinsicWidth.toIntPx() },
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutDirectionModifierTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutDirectionModifierTest.kt
index 35387ba..41361d3 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutDirectionModifierTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutDirectionModifierTest.kt
@@ -23,7 +23,8 @@
import androidx.ui.core.LayoutDirectionAmbient
import androidx.ui.core.Modifier
import androidx.ui.core.Ref
-import androidx.ui.layout.MaxIntrinsicWidth
+import androidx.ui.layout.IntrinsicSize
+import androidx.ui.layout.preferredWidth
import androidx.ui.layout.rtl
import androidx.ui.unit.ipx
import org.junit.Assert.assertNotNull
@@ -69,21 +70,19 @@
val latch = CountDownLatch(1)
val layoutDirection = Ref<androidx.ui.core.LayoutDirection>()
val children = @Composable {
- MaxIntrinsicWidth {
- Layout(
- children = @Composable() {},
- modifier = Modifier.rtl,
- minIntrinsicWidthMeasureBlock = { _, _, _ -> 0.ipx },
- minIntrinsicHeightMeasureBlock = { _, _, _ -> 0.ipx },
- maxIntrinsicWidthMeasureBlock = { _, _, incomingLayoutDirection ->
- layoutDirection.value = incomingLayoutDirection
- latch.countDown()
- 0.ipx
- },
- maxIntrinsicHeightMeasureBlock = { _, _, _ -> 0.ipx }
- ) { _, _, _ ->
- layout(0.ipx, 0.ipx) {}
- }
+ Layout(
+ children = @Composable() {},
+ modifier = Modifier.preferredWidth(IntrinsicSize.Max).rtl,
+ minIntrinsicWidthMeasureBlock = { _, _, _ -> 0.ipx },
+ minIntrinsicHeightMeasureBlock = { _, _, _ -> 0.ipx },
+ maxIntrinsicWidthMeasureBlock = { _, _, incomingLayoutDirection ->
+ layoutDirection.value = incomingLayoutDirection
+ latch.countDown()
+ 0.ipx
+ },
+ maxIntrinsicHeightMeasureBlock = { _, _, _ -> 0.ipx }
+ ) { _, _, _ ->
+ layout(0.ipx, 0.ipx) {}
}
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
index a7d846b..35ac62135 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Intrinsic.kt
@@ -18,26 +18,173 @@
import androidx.compose.Composable
import androidx.ui.core.Constraints
+import androidx.ui.core.IntrinsicMeasurable
import androidx.ui.core.Layout
+import androidx.ui.core.LayoutDirection
+import androidx.ui.core.LayoutModifier2
+import androidx.ui.core.Measurable
+import androidx.ui.core.MeasureScope
+import androidx.ui.core.Modifier
import androidx.ui.core.enforce
+import androidx.ui.unit.Density
+import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.ipx
/**
+ * Declare the preferred width of the content to be the same as the min or max intrinsic width of
+ * the content. The incoming measurement [Constraints] may override this value, forcing the content
+ * to be either smaller or larger.
+ *
+ * See [preferredHeight] for options of sizing to intrinsic height.
+ * Also see [preferredWidth] and [preferredWidthIn] for other options to set the preferred width.
+ *
+ * Example usage for min intrinsic:
+ * @sample androidx.ui.layout.samples.SameWidthBoxes
+ *
+ * Example usage for max intrinsic:
+ * @sample androidx.ui.layout.samples.SameWidthTextBoxes
+ */
+fun Modifier.preferredWidth(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
+ IntrinsicSize.Min -> this + PreferredMinIntrinsicWidthModifier
+ IntrinsicSize.Max -> this + PreferredMaxIntrinsicWidthModifier
+}
+
+/**
+ * Declare the preferred height of the content to be the same as the min or max intrinsic height of
+ * the content. The incoming measurement [Constraints] may override this value, forcing the content
+ * to be either smaller or larger.
+ *
+ * See [preferredWidth] for other options of sizing to intrinsic width.
+ * Also see [preferredHeight] and [preferredHeightIn] for other options to set the preferred height.
+ *
+ * Example usage for min intrinsic:
+ * @sample androidx.ui.layout.samples.MatchParentDividerForText
+ *
+ * Example usage for max intrinsic:
+ * @sample androidx.ui.layout.samples.MatchParentDividerForAspectRatio
+ */
+fun Modifier.preferredHeight(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
+ IntrinsicSize.Min -> this + PreferredMinIntrinsicHeightModifier
+ IntrinsicSize.Max -> this + PreferredMaxIntrinsicHeightModifier
+}
+
+/**
+ * Intrinsic size used in [preferredWidth] or [preferredHeight] which can refer to width or height.
+ */
+enum class IntrinsicSize { Min, Max }
+
+private object PreferredMinIntrinsicWidthModifier : PreferredIntrinsicSizeModifier {
+ override fun calculateContentConstraints(
+ measurable: Measurable,
+ constraints: Constraints
+ ): Constraints {
+ val width = measurable.minIntrinsicWidth(constraints.maxHeight)
+ return Constraints.fixedWidth(width)
+ }
+
+ override fun Density.maxIntrinsicWidth(
+ measurable: IntrinsicMeasurable,
+ height: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.minIntrinsicWidth(height)
+}
+
+private object PreferredMinIntrinsicHeightModifier : PreferredIntrinsicSizeModifier {
+ override fun calculateContentConstraints(
+ measurable: Measurable,
+ constraints: Constraints
+ ): Constraints {
+ val height = measurable.minIntrinsicHeight(constraints.maxWidth)
+ return Constraints.fixedHeight(height)
+ }
+
+ override fun Density.maxIntrinsicHeight(
+ measurable: IntrinsicMeasurable,
+ width: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.minIntrinsicHeight(width)
+}
+
+private object PreferredMaxIntrinsicWidthModifier : PreferredIntrinsicSizeModifier {
+ override fun calculateContentConstraints(
+ measurable: Measurable,
+ constraints: Constraints
+ ): Constraints {
+ val width = measurable.maxIntrinsicWidth(constraints.maxHeight)
+ return Constraints.fixedWidth(width)
+ }
+
+ override fun Density.minIntrinsicWidth(
+ measurable: IntrinsicMeasurable,
+ height: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.maxIntrinsicWidth(height)
+}
+
+private object PreferredMaxIntrinsicHeightModifier : PreferredIntrinsicSizeModifier {
+ override fun calculateContentConstraints(
+ measurable: Measurable,
+ constraints: Constraints
+ ): Constraints {
+ val height = measurable.maxIntrinsicHeight(constraints.maxWidth)
+ return Constraints.fixedHeight(height)
+ }
+
+ override fun Density.minIntrinsicHeight(
+ measurable: IntrinsicMeasurable,
+ width: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.maxIntrinsicHeight(width)
+}
+
+private interface PreferredIntrinsicSizeModifier : LayoutModifier2 {
+ fun calculateContentConstraints(measurable: Measurable, constraints: Constraints): Constraints
+
+ override fun MeasureScope.measure(
+ measurable: Measurable,
+ constraints: Constraints,
+ layoutDirection: LayoutDirection
+ ): MeasureScope.LayoutResult {
+ val placeable = measurable.measure(
+ calculateContentConstraints(measurable, constraints).enforce(constraints)
+ )
+ return layout(placeable.width, placeable.height) {
+ placeable.place(IntPxPosition.Origin)
+ }
+ }
+
+ override fun Density.minIntrinsicWidth(
+ measurable: IntrinsicMeasurable,
+ height: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.minIntrinsicWidth(height)
+
+ override fun Density.minIntrinsicHeight(
+ measurable: IntrinsicMeasurable,
+ width: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.minIntrinsicHeight(width)
+
+ override fun Density.maxIntrinsicWidth(
+ measurable: IntrinsicMeasurable,
+ height: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.maxIntrinsicWidth(height)
+
+ override fun Density.maxIntrinsicHeight(
+ measurable: IntrinsicMeasurable,
+ width: IntPx,
+ layoutDirection: LayoutDirection
+ ) = measurable.maxIntrinsicHeight(width)
+}
+
+/**
* Layout composable that forces its child to be as wide as its min intrinsic width.
* If incoming constraints do not allow this, the closest possible width will be used.
- *
- * Example usage:
- *
- * @sample androidx.ui.layout.samples.SameWidthBoxes
- *
- * The sample builds a layout containing three [androidx.ui.foundation.Box] having the same width
- * as the widest one.
- *
- * Here [MinIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
- * whose minimum intrinsic width will correspond to the preferred width of the largest
- * [androidx.ui.foundation.Box]. Then [MinIntrinsicWidth] will measure the [Column] with tight
- * width, the same as the premeasured minimum intrinsic width.
*/
+@Deprecated("This component is deprecated. " +
+ "Please use the preferredWidth(IntrinsicSize.Min) modifier instead.")
@Composable
fun MinIntrinsicWidth(children: @Composable() () -> Unit) {
Layout(
@@ -69,20 +216,9 @@
/**
* Layout composable that forces its child to be as tall as its min intrinsic height.
* If incoming constraints do not allow this, the closest possible height will be used.
- *
- * Example usage:
- *
- * @sample androidx.ui.layout.samples.MatchParentDividerForText
- *
- * The sample builds a layout containing two pieces of text separated by a divider, where the
- * divider is sized according to the height of the longest text.
- *
- * Here [MinIntrinsicHeight] is adding a speculative height measurement pass for the [Row],
- * whose minimum intrinsic height will correspond to the height of the largest [Text]. Then
- * [MinIntrinsicHeight] will measure the [Row] with tight height, the same as the premeasured
- * minimum intrinsic height, which due to [LayoutHeight.Fill] will force the [Text]s and
- * the divider to use the same height.
*/
+@Deprecated("This component is deprecated. " +
+ "Please use the preferredHeight(IntrinsicSize.Min) modifier instead.")
@Composable
fun MinIntrinsicHeight(children: @Composable() () -> Unit) {
Layout(
@@ -114,20 +250,9 @@
/**
* Layout composable that forces its child to be as wide as its max intrinsic width.
* If incoming constraints do not allow this, the closest possible width will be used.
- *
- * Example usage:
- *
- * @sample androidx.ui.layout.samples.SameWidthTextBoxes
- *
- * The sample builds a layout containing three [Text] boxes having the same width as the widest one.
- *
- * Here [MaxIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
- * whose maximum intrinsic width will correspond to the preferred width of the largest
- * [androidx.ui.foundation.Box]. Then [MaxIntrinsicWidth] will measure the [Column] with tight
- * width, the same as the premeasured maximum intrinsic width, which due to [LayoutWidth.Fill]
- * will force the [androidx.ui.foundation.Box]s to use the same width.
- * The sample is a layout containing three composables having the same width as the widest one.
*/
+@Deprecated("This component is deprecated. " +
+ "Please use the preferredWidth(IntrinsicSize.Max) modifier instead.")
@Composable
fun MaxIntrinsicWidth(children: @Composable() () -> Unit) {
Layout(
@@ -159,20 +284,9 @@
/**
* Layout composable that forces its child to be as tall as its max intrinsic height.
* If incoming constraints do not allow this, the closest possible height will be used.
- *
- * Example usage:
- *
- * @sample androidx.ui.layout.samples.MatchParentDividerForAspectRatio
- *
- * The sample builds a layout containing two [LayoutAspectRatio]s separated by a divider, where the
- * divider is sized according to the height of the taller [LayoutAspectRatio].
- *
- * Here [MaxIntrinsicHeight] is adding a speculative height measurement pass for the [Row],
- * whose maximum intrinsic height will correspond to the height of the taller [AspectRatio]. Then
- * [MaxIntrinsicHeight] will measure the [Row] with tight height, the same as the premeasured
- * maximum intrinsic height, which due to [LayoutHeight.Fill] will force the [AspectRatio]s
- * and the divider to use the same height.
*/
+@Deprecated("This component is deprecated. " +
+ "Please use the preferredHeight(IntrinsicSize.Max) modifier instead.")
@Composable
fun MaxIntrinsicHeight(children: @Composable() () -> Unit) {
Layout(
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
index 2bc0b75..3541ba0 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Table.kt
@@ -199,9 +199,10 @@
/**
* Sizes the column to the width of the widest child in that column.
*
- * Note that in order to compute their preferred widths, the children will be measured with
- * infinite width constraints, which means that some of them may have infinite width. For a
- * wrap content behaviour that avoids this, use [MinIntrinsicWidth] or [MaxIntrinsicWidth].
+ * Note that, in order to compute their preferred widths, the children will be measured with
+ * infinite width constraints to prevent them from filling the available space. For a
+ * wrap content behaviour without infinite measurements, use [minIntrinsicWidth] or
+ * [maxIntrinsicWidth].
*/
object Wrap : Inflexible() {