Documentation
¶
Overview ¶
Package segment solves one-dimensional stretchable segment layout.
Build a partial order of "segment A lies wholly before segment B", then propagate positions in topological order using actual measured extents rather than declared ones.
The engine uses it vertically, for floating elements: a floating element sits below whatever lies above it, and how far below is its declared gap to the nearest predecessor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout is a solved partial order, reusable across measurements.
func New ¶
New builds the layout.
deps maps each segment to the segments it depends on -- those that must be placed first. It must be acyclic and hold an entry for every segment.
func (*Layout) Solve ¶
Solve returns each segment's actual start, given its actual extent.
A segment with no dependencies keeps its declared start. One with dependencies begins after the last of them ends, plus its gap -- and the gap applies only when the segment has an extent of its own, so a collapsed segment neither occupies space nor reserves any.