Skip to main content

Crate cranpose_ui_layout

Crate cranpose_ui_layout 

Source
Expand description

§Cranpose UI Layout

cranpose-ui-layout defines measurement, placement, alignment and arrangement contracts for Cranpose widgets. Custom layout authors use Constraints, Measurable, MeasureScope and Placeable. App developers usually use Column, Row, Box and Layout from cranpose.

§Adjust child constraints

Constraints use logical pixels. A custom measure policy can deflate parent bounds before a child measure call:

use cranpose_ui_layout::Constraints;

let parent = Constraints::loose(320.0, 480.0);
let child = parent.deflate(16.0, 12.0);
let (width, height) = child.constrain(400.0, 40.0);
assert_eq!((width, height), (304.0, 40.0));

The feature set is empty. See the Constraints API, the layout guide and the crate source.

Modules§

prelude

Structs§

Alignment
Alignment across both axes used for positioning content within a box.
AlignmentLines
Text baselines measured down from a layout’s top edge.
Constraints
Constraints used during layout measurement.
FlexParentData
Parent data for flex layouts (Row/Column weights and alignment).
LayoutModifierMeasureResult
Result of a layout modifier measurement operation.
MeasureResult
Result of a measurement operation.
Measurement
The size and explicit alignment lines produced by a measure policy.
ParentData
Layout metadata supplied by a child for its direct parent.
Placeable
Result of running a measurement pass for a single child.
Placement
Placement information for a measured child.

Enums§

Axis
Represents the primary axis of flex layout (Row or Column).
HorizontalAlignment
Alignment along the horizontal axis.
IntrinsicSize
Specifies how to size a component based on its intrinsic measurements.
LinearArrangement
Arrangement strategy matching Jetpack Compose’s linear arrangements.
VerticalAlignment
Alignment along the vertical axis.

Traits§

Arrangement
Trait implemented by arrangement strategies that distribute children on an axis.
AxisAlignment
An alignment along one axis, which places a block at a bias of the space left beside it.
Measurable
Object capable of measuring a layout child and exposing intrinsic sizes.
MeasurePolicy
Policy responsible for measuring and placing children.
MeasureScope
Scope for measurement operations.
PlaceTarget
What a node-backed Placeable tells when its parent places it.

Functions§

bias_offset
Compose’s BiasAlignment: the offset that puts child at bias of available (-1 the start, 0 the middle, 1 the end), on a whole device pixel of density as Kotlin’s roundToInt rounds it, and before the start when the child is the larger.
ceil_to_px
A length moved up onto the next whole device pixel, as Compose sizes text: a layout’s size is its paragraph’s, ceiled, so it never clips.
round_to_px
A length moved onto the whole device pixel Compose would give it.