Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Paper/llms.txt
Use this file to discover all available pages before exploring further.
UnitValue is the fundamental measurement type used throughout Prowl.Paper’s layout engine. Rather than forcing a single unit mode, every UnitValue is a composite of four independent components — Px, Pct, Grow, and AutoFactor — evaluated together as Px + (Pct/100 × parent) + Grow × remainderShare + AutoFactor × contentSize. This design lets you express natural combinations such as “50% of the parent minus 8 pixels” (Percentage(50, -8)) or “fill remaining space with a 10px floor” (Stretch(1) + Pixels(10)) without needing separate union types.
Unit types at a glance
| Type | Factory | Components set | Resolves using |
|---|---|---|---|
| Pixels | UnitValue.Pixels(v) | Px = v | Fixed pixel value |
| Percentage | UnitValue.Percentage(v, offset) | Pct = v, Px = offset | Fraction of parent size |
| Stretch | UnitValue.Stretch(f) | Grow = f | Share of leftover space |
| Auto | UnitValue.Auto | AutoFactor = 1 | Element’s content size |
Struct fields
Raw pixel offset. Contributes a fixed amount to the resolved size regardless of parent or content dimensions.
Percentage of the parent container’s corresponding dimension, expressed in the range 0–100. A value of
50 means 50% of the parent.Stretch (flex-grow) factor. After all fixed and percentage sizes are subtracted from the available space, the remainder is distributed among siblings weighted by their
Grow values.Content-size multiplier.
1.0 means “use the full intrinsic content size”; 0.0 means content is ignored. The sentinel value UnitValue.Auto sets this to 1 with all other components at 0.Constructor
Factory methods
UnitValue.Pixels(float value)
Creates a pure pixel value with no percentage, stretch, or auto component.
UnitValue.Percentage(float value, float offset = 0f)
Creates a percentage of the parent, with an optional pixel offset baked in. The offset is stored in Px so arithmetic remains clean.
UnitValue.Stretch(float factor = 1f)
Creates a stretch unit that claims a proportional share of the remaining space after fixed/percentage elements are placed. Siblings with higher factors get proportionally more space.
Pre-allocated constants
| Constant | Equivalent | Notes |
|---|---|---|
UnitValue.Auto | new UnitValue(0,0,0,1) | Sizes to content |
UnitValue.ZeroPixels | new UnitValue(0,0,0,0) | Explicit zero |
UnitValue.StretchOne | new UnitValue(0,0,1,0) | Stretch(1) without allocation |
Predicate properties
All predicates are read-only and examine the raw component values:| Property | Returns true when… |
|---|---|
HasGrow | Grow > 0 — participates in stretch distribution |
HasAuto | AutoFactor > 0 — has a content-size contribution |
IsFixed | Grow == 0 && AutoFactor == 0 — resolves without stretch or content measurement |
IsAuto | Exactly the Auto sentinel (Px=0, Pct=0, Grow=0, AutoFactor=1) |
IsStretch | Purely a stretch factor — no Px, Pct, or AutoFactor |
IsPixels | Purely a pixel value — no Pct, Grow, or AutoFactor |
IsPercentage | Carries a Pct component with no Grow or AutoFactor |
IsFixed returns true for percentage values because they resolve to a definite length once the parent size is known, without participating in stretch competition or content measurement.Arithmetic operators
UnitValue arithmetic combines components element-wise, making compound values natural to express:
| Operator | Description |
|---|---|
a + b | Component-wise addition |
a - b | Component-wise subtraction |
-a | Negate all components |
a * scalar | Scale all components by a float |
scalar * a | Commutative scalar multiply |
a / scalar | Divide all components by a float |
Interpolation
UnitValue.Lerp(UnitValue a, UnitValue b, float t)
Linearly interpolates each component independently. t is clamped to [0, 1]. Because components are interpolated separately, mixing unit types produces intermediate values that are meaningful — for example, Lerp(Pixels(0), Auto, 0.5f) yields {AutoFactor: 0.5}, which contributes half the content size.
Implicit conversions
Bothint and float implicitly convert to UnitValue as pixel values, so you can pass numeric literals directly to any layout API:
Comparison and equality
UnitValue implements IEquatable<UnitValue>. Two values are equal when all four components are identical:
== / != operators delegate to Equals(UnitValue other), which compares Px, Pct, Grow, and AutoFactor as floats.
ToString()
Returns a human-readable string listing only the non-zero components, joined with +: