loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / RENDERING AND LAYOUT

Constraint

Values describe cells along the layout axis. Negative lengths and weights request zero. Percentages are clamped to 0…100; ratios are clamped to 0…1, and a nonpositive denominator requests zero. Fraction requests use the original axis length, not the remaining space.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let constraints: [Constraint] = [.min(3), .max(10), .percentage(25), .ratio(1, 4), .fill(2)]
_ = Layout(.horizontal, constraints).split(Rect(width: 80, height: 24))
Members on this page

Feature guides and release status

Constraint

Enumeration
enum Constraint

Conforms to: Swift.Equatable, Swift.Hashable, Swift.Sendable, Swift.SendableMetatype.

A fixed, relative, bounded, or weighted share of terminal cells.

Source · Layout.swift:39

min(_:)

Case
case min(Int)

A lower bound, with equal shares of excess space when there are no positive fills.

Source · Layout.swift:41

max(_:)

Case
case max(Int)

An upper bound; grows toward the limit after minimum and requested sizes are satisfied.

Source · Layout.swift:43

length(_:)

Case
case length(Int)

A requested cell count, clipped when higher-priority requests exhaust the area.

Source · Layout.swift:45

percentage(_:)

Case
case percentage(Int)

A requested percentage of the original axis length, clamped to 0...100.

Source · Layout.swift:47

ratio(_:_:)

Case
case ratio(Int, Int)

A requested fraction of the original axis length; a nonpositive denominator requests zero.

Source · Layout.swift:49

fill(_:)

Case
case fill(Int)

A proportional share of excess cells; nonpositive weights receive no cells.

Source · Layout.swift:51