Documentation
¶
Overview ¶
Package layout holds the layout options of the Tango self-drawn UI: Row/Column/Stack containers take Options built here (Grow, W, H, Pad, Gap, Align, Justify, Abs ...), and Box.Style applies more. The layout solver itself (flexbox-style: Grow/Shrink/Basis, Gap, Padding, Margin, Align, Justify, Wrap, Stack and absolute positioning) is internal.
API tiers: only the symbols listed in api/stable/ui_layout.txt are covered by the compatibility promise of docs/release.md ("API 稳定性"); every other exported symbol is Experimental and may change in any 0.x release. The API reference on the documentation site marks the experimental symbols.
Index ¶
- Variables
- type Align
- type Direction
- type Justify
- type Option
- func Abs(left, top, right, bottom float32) Option
- func AlignItems(a Align) Option
- func Basis(v float32) Option
- func Between() Option
- func Center() Option
- func Dir(d Direction) Option
- func End() Option
- func Fill() Option
- func Gap(v float32) Option
- func GapXY(main, lines float32) Option
- func Grow(g float32) Option
- func H(v float32) Option
- func JustifyContent(j Justify) Option
- func Margin(in geom.Insets) Option
- func MaxH(v float32) Option
- func MaxW(v float32) Option
- func Middle() Option
- func MinH(v float32) Option
- func MinW(v float32) Option
- func NoStretch() Option
- func Pad(v float32) Option
- func PadSE(v, start, end float32) Option
- func PadVH(v, h float32) Option
- func Padding(in geom.Insets) Option
- func Physical() Option
- func ScrollX() Option
- func ScrollY() Option
- func Self(a Align) Option
- func Shrink(v float32) Option
- func Size(w, h float32) Option
- func Stretch() Option
- func W(v float32) Option
- func WrapItems() Option
Constants ¶
This section is empty.
Variables ¶
var Unset = float32(math.NaN())
Unset marks an unused edge of Abs. It is a variable only because Go has no NaN constant: treat it as a constant and never assign to it.
Functions ¶
This section is empty.
Types ¶
type Align ¶
type Align uint8
Align positions items on the cross axis.
Append-only: never reorder or insert; the zero value stays AlignAuto.
type Direction ¶
type Direction uint8
Direction is the main axis of a container.
Append-only: never reorder or insert; the zero value stays Column.
type Justify ¶
type Justify uint8
Justify distributes free space on the main axis.
Append-only: never reorder or insert; the zero value stays JustifyStart.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option sets one aspect of a node's layout. It is opaque: build it with the functions of this package and pass it to containers (ui.Row, ui.Column, ui.Div ...) or Box.Style. The zero Option does nothing.
func Fill ¶
func Fill() Option
Fill makes the node grow on the main axis and stretch on the cross axis.
func JustifyContent ¶
JustifyContent sets main-axis distribution.
func Middle ¶
func Middle() Option
Middle centers children on the cross axis (vertical centering in rows).
func NoStretch ¶
func NoStretch() Option
NoStretch keeps the node's own cross size where the alignment would stretch it; it is then placed at the start of the cross axis.
func PadSE ¶
PadSE sets vertical padding v and inline start/end padding. Left/Right of geom.Insets are the start/end sides (they swap physically in RTL boxes).
func Physical ¶
func Physical() Option
Physical keeps the node at its physical (LTR) position inside an RTL parent: its x is not mirrored. Use it for things pinned to a physical edge regardless of reading direction. It does not affect the node's own children; those follow the node's RTL flag.