Documentation
¶
Overview ¶
Package layout is Nimbus Native's flexbox engine, in pure Go so the same layout runs on iOS, Android and (later) the web.
It follows the CSS Flexbox algorithm with Nimbus Native's defaults: column direction, flex-shrink 0, no automatic minimum size, every node a flex container. Results are in points (iOS) / dp (Android); hosts round to pixels. conformance_test.go checks it against Chromium's own layout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Align ¶
type Align uint8
Align positions children on the cross axis. On AlignSelf, AlignAuto means "use the parent's AlignItems"; on AlignItems it means Stretch.
type Edges ¶
type Edges struct{ Left, Top, Right, Bottom float32 }
Edges are per-side lengths in points.
type MeasureFunc ¶
MeasureFunc sizes a leaf (text, an image, a native control) within the space offered. A width or height whose mode is Undefined is not a limit.
type Node ¶
type Node struct {
Style Style
Measure MeasureFunc
Children []*Node
// Results. X and Y are the border box's offset from the parent's border
// box; W and H its size. ContentW and ContentH are the extent of the
// children (padding included) — a scroll view's content size.
X, Y, W, H float32
ContentW, ContentH float32
// contains filtered or unexported fields
}
Node is one box in the layout tree. Set Style, Children and, for leaves, Measure; call Calculate on the root; read the results.
type Style ¶
type Style struct {
Direction Direction
Justify Justify
AlignItems Align
AlignSelf Align
Grow float32
Shrink float32
Basis Value
Width, Height Value
MinWidth, MinHeight Value
MaxWidth, MaxHeight Value
Padding Edges
Margin Edges
Border Edges
Gap float32 // between children on the main axis
Position Position
Left, Top, Right, Bottom Value // insets; Auto means unset
// Hidden removes the node from layout (display: none).
Hidden bool
// Scroll lays children out unconstrained along the main axis, as the
// content of a scroll view. The node's own size is unaffected.
Scroll bool
}
Style is everything that affects a node's layout. The zero Style is an auto-sized column that stretches its children.