Expand description
Constraint-based layout engine for the Fission UI framework.
This crate takes a flat list of LayoutInputNodes (produced from the
fission-ir intermediate representation) and computes the
absolute position and size of every node on screen. It implements:
- Box layout – constrained containers with padding, min/max, and aspect ratio.
- Flexbox – single-axis distribution with grow, shrink, wrap, alignment, and justification.
- CSS Grid – two-dimensional track-based layout with
fr,%, and fixed sizing. - Scroll containers – clipped viewports with infinite content axes.
- Absolute positioning –
top/left/right/bottomoffsets. - ZStack – overlapping children.
- Flyout anchoring – popups positioned relative to an anchor node.
The engine is pure computation with no platform dependencies. Give it nodes and
a viewport size, and it returns a LayoutSnapshot mapping every
NodeId to a LayoutRect.
§Example
use fission_layout::*;
use fission_ir::{NodeId, LayoutOp};
let mut engine = LayoutEngine::new();
let root_id = NodeId::explicit("root");
// ... build LayoutInputNode list ...
// let snapshot = engine.compute_layout(&nodes, root_id, viewport, &|_| 0.0).unwrap();Structs§
- BoxConstraints
- Minimum and maximum width/height bounds passed from parent to child during layout.
- Layout
Engine - The constraint-based layout solver.
- Layout
Input Node - A flattened representation of a layout node, ready for the layout engine.
- Layout
Node Geometry - The computed geometry of a single layout node.
- Layout
Point - A 2D point in layout coordinate space.
- Layout
Rect - An axis-aligned rectangle: an origin point plus a size.
- Layout
Size - A 2D size in layout coordinate space.
- Layout
Snapshot - The complete output of a layout pass.
- Line
Metric - Per-line metrics returned by text measurement.
Enums§
- Flex
Direction - The primary axis direction for a flex or scroll container.
- Grid
Placement - Where a grid item is placed within its grid container.
- Grid
Track - A track sizing function for CSS Grid-style columns or rows.
- Layout
Op - A layout operation that sizes and positions a node and its children.
Traits§
- Scroll
Data Source - A source of scroll offsets for scroll containers.
- Text
Measurer - A platform-provided text measurement backend.
Type Aliases§
- Layout
Unit - The scalar type used for all layout measurements.