Expand description
Layout property types: Insets, HAnchor, VAnchor, WidgetBase.
These types mirror the C# agg-sharp BorderDouble, HAnchor, VAnchor,
and the per-widget layout fields that every GuiWidget carried.
§Design
Every concrete widget embeds a WidgetBase and delegates the five
layout-property getters on the Widget trait to
it. The parent layout container reads those getters when placing children.
All values are stored in logical (device-independent) units.
WidgetBase::scaled_margin multiplies by the global
device_scale factor to produce
physical pixel values for use inside layout algorithms.
§Margin vs padding
- Margin lives on the child and is read by the parent during layout. It is space outside the widget’s bounds.
- Padding is the parent container’s internal inset — space between its
own border and its children. Containers store padding directly (e.g.
FlexColumn::inner_padding); individual leaf widgets do not have padding.
§Margin semantics
Margins are additive, not collapsed. When child A has
margin.bottom = 4 and child B has margin.top = 6, the gap between them
is gap + 4 + 6 = 10 + gap, not max(4, 6) = 6. This matches the
original C# agg-sharp behaviour.
Structs§
- HAnchor
- Horizontal anchor flags — how a widget sizes and positions itself horizontally within the slot assigned by its parent.
- Insets
- Per-side inset values (logical units).
- VAnchor
- Vertical anchor flags — how a widget sizes and positions itself vertically within the slot assigned by its parent.
- Widget
Base - Stores the five universal layout properties that every widget carries.
Functions§
- resolve_
fit_ or_ stretch - Given a natural (fit) size and a stretch (fill) size for one axis, resolve
the
MIN_FIT_OR_STRETCHorMAX_FIT_OR_STRETCHanchor to a concrete size.