Skip to main content

Crate fission_layout

Crate fission_layout 

Source
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 positioningtop/left/right/bottom offsets.
  • 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.
LayoutEngine
The constraint-based layout solver.
LayoutInputNode
A flattened representation of a layout node, ready for the layout engine.
LayoutNodeGeometry
The computed geometry of a single layout node.
LayoutPoint
A 2D point in layout coordinate space.
LayoutRect
An axis-aligned rectangle: an origin point plus a size.
LayoutSize
A 2D size in layout coordinate space.
LayoutSnapshot
The complete output of a layout pass.
LineMetric
Per-line metrics returned by text measurement.

Enums§

FlexDirection
The primary axis direction for a flex or scroll container.
GridPlacement
Where a grid item is placed within its grid container.
GridTrack
A track sizing function for CSS Grid-style columns or rows.
LayoutOp
A layout operation that sizes and positions a node and its children.

Traits§

ScrollDataSource
A source of scroll offsets for scroll containers.
TextMeasurer
A platform-provided text measurement backend.

Type Aliases§

LayoutUnit
The scalar type used for all layout measurements.