Expand description
frus-layout — frus’s layout engine.
It turns a tree of styled nodes into positioned rectangles, in absolute
coordinates, ready for frus-gpu to draw.
The implementation rests on taffy for flexbox, but
taffy is entirely hidden behind frus’s own API, so it can be replaced later
without breaking anything public.
Structs§
- Layout
- A layout tree.
Tis user data attached to the nodes — a colour, say — handed back with each computed rectangle. - Overflowing
- A box whose children do not fit inside it, and by how much.
- Rect
- An axis-aligned rectangle, in logical pixels.
- Size
- A 2D size (width × height).
- Style
- A layout node’s style.
Enums§
- Align
- How children are aligned on the cross axis.
- Align
Content - How a wrapping container’s lines are distributed on the cross axis.
- Dimension
- The dimension of one axis, width or height.
- Flex
Direction - The main-axis direction of a flex container.
- Justify
- How children are distributed along the main axis.
- Side
- The edge a box’s content ran past.
Type Aliases§
- Measure
Fn - A constrained measurement for a leaf whose size depends on the space
offered — wrapping text, custom-painted content. It receives the maximum
width and height (
None= unconstrained) and returns the content’s size. Taffy calls it during layout, including for intrinsic sizes (min-content gives a width ofSome(0.0), max-content givesNone). The lifetime is what lets a measurement borrow: a text’s closure owns everything it needs and is'static, but acrate::Layoutbuilt for a widget tree can hold a closure that borrows the tree, which is how a box whose content is built from the space offered gets measured at all. - NodeId
- An opaque identifier for a layout node.