Expand description
Integral layout, the way Compose does it.
Cranpose’s layout is continuous: Constraints
is four f32, a child is placed at an f32 offset, and nothing in
cranpose-ui-layout rounds. Compose’s is integral — Dp.roundToPx() turns
every padding, minimum size and spacing into an Int before anything is
measured, and Placeable.placeAt takes an IntOffset.
That difference is not cosmetic. Half a pixel of drift moves a line of
text’s antialiasing onto the next row, and it puts a soft edge everywhere
the Compose build draws a crisp one. A widget that must draw a crisp edge
therefore rounds its own sizes and offsets through Density rather than
trusting the ambient float arithmetic. The Wear widgets do this throughout;
the rest of the library does not, which is where a soft edge still comes
from.
One length unit runs through all of it: a Cranpose layout point is a dp.
Density converts to and from device pixels and does the rounding on
the pixel side, which is the only side where rounding means anything.
Structs§
- Density
- The device pixel grid a layout measures against: how many device pixels a layout point is worth, and how the platform converts a text size.
- Density
Measure Scope - The production
cranpose_ui_layout::MeasureScope: a grid captured at composition time, carried through measurement.
Functions§
- Provide
Density - Runs
contentondensity. - density
- The device pixel grid in force here.
- local_
density - The
CompositionLocalcarrying the device pixel grid.