geomancy-layout
Geometry and matrix manipulation
| Stackage Nightly 2026-12-05: | 0.2.1 |
| Latest on Hackage: | 0.2.1 |
geomancy-layout-0.2.1@sha256:beedced4742ccf93f395e10e7d33822841ce83d16e5c2d1b4f5620bb9fc85389,2045Module documentation for 0.2.1
geomancy-layout
Layout primitives using geomancy vectors.
Geomancy.Layout- box cutting and stacking.Geomancy.Layout.Box- size/position and top/right/bottom/left boxes and manipulation.Geomancy.Layout.Alignment- distribute size leftovers proportionally.Geomancy.Layout.View- SwiftUI-like containers.
Changes
0.2.1
Midlines
A view can report a midline, the line its content sits on, measured from its top. Toolkits pick that line for their leaves. Text would use the middle of the capitals on its first line. An icon would use the middle of its face.
GuidedFun and guidedFun make leaves that report one with their size. LayoutView has reportedMidline for other payloads, and it defaults to none. suspendGuided and decorated return the midline along with the size. suspend keeps its type.
Padding, frames, offsets and spans carry their content’s midline. Overlays and backgrounds carry their primary’s. Columns, z-stacks and grids take the first one among their children.
A middle-aligned row lines up the midlines of its children. A child without one puts the middle of its box on the line. The row grows above and below the line to fit them all, and reports that line as its own midline. Padding or decoration below text no longer pulls the text off its neighbours’ line. A row with no midlines centres its children as before. Top- and bottom-aligned rows ignore midlines.
A middle-aligned grid lines up the cells of each row the same way. SwiftUI’s grid rows align on the same guides as its stacks. A row grows to fit its line, and the grid reports its first row’s line as its midline. A cell spanning several rows still centres its box. SwiftUI grids can’t span rows and offer no rule for it.
Grid
Tracks ask every cell for its size, including cells that measured as fixed. A cell that reports more than it measured, like a middle-aligned row, stays inside its track instead of spilling into the next one. A grid can now report more height than it measured, the same way a middle-aligned row can.
0.2.0
Layout follows SwiftUI more closely. Where SwiftUI is silent, it picks the least surprising option.
Stacks
HStack and VStack got spacing and align. hstack and vstack take both. hstack_ and vstack_ keep the old look.
Stacks share space more fairly. They hold back room for the children still waiting, never offer a child less than its minimum, and give parent-sized children what the others leave. Their cross axis spans their widest child. Their size never goes negative or drifts from where the children end up.
Negative spacing overlaps children, as in SwiftUI.
Spacers
A spacer expands only along its stack’s axis, as in SwiftUI. Outside a row or column it still fills both ways. A row with a spacer no longer swallows its column’s height.
Clearance
A view can ask to keep space from its stack neighbours on each edge, through the new clearance field of ViewSize. A stack puts the larger of its spacing and its children’s requests between them. Neighbouring requests collapse instead of adding up. Containers pass on the requests of their outer children. Padding counts toward them.
Frames and aspect ratio
FlexibleFrame follows SwiftUI’s flexible frame. Its constraints moved to a new FrameBounds record, where a missing bound means “no constraint” rather than “take the parent’s size”. between, widthWithin, heightWithin, fillWidth, fillHeight and filling build bounds. A frame that fills now measures as flexible instead of parent-sized.
AspectRatio letterboxes its content. It offers the child the largest box with its ratio that the child can grow into. It reports the smallest box with that ratio around the child’s answer. A ratio without a positive, finite quotient does nothing.
Padding adds its insets to both ends of its measured range.
Layers
Overlay and ZStack got an align field. They place each layer at the size it reports, as in SwiftUI. The new Background works like Overlay but paints its secondary behind the primary.
Traversal runs back to front, in paint order. Backgrounds come before their primary and overlays after it. ZStack layers keep their order. Painting in foldMap order is now correct.
Grid
New Grid container, like SwiftUI’s. Columns are as wide as their widest cell and rows as tall as their tallest. Cells that would stretch forever fill their slot without widening it. A column or row made only of them takes what is left.
span_ lets a cell span columns and rows, like an HTML table cell. Cells fill row by row around earlier spans. A spanning cell gets its room before open tracks take the rest. It grows the covered tracks that can still grow first.
Upgrading
Code that builds HStack, VStack, ZStack, Overlay or ViewSize directly needs the new fields. FlexibleFrame takes FrameBounds. A parent_ pin becomes filling. A range_ frame becomes between, which takes the offered size instead of hugging its child.
0.1.1
- Added
Geomancy.Layout.View- an experimental SwiftUI-like propose-report-place protocol.
0.1
Initial import.
Extracted from keid-core.