flexbox

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flexbox is the flexbox-style layout solver of the Tango self-drawn UI: Row/Column with Grow/Shrink/Basis, Gap, Padding, Margin, Align, Justify and Wrap, plus Stack (children overlap) and absolute positioning for overlays. Sizes are measured on both axes: leaves expose a Measure callback that receives the available width and height (text wraps to the width it is given).

Deliberate difference from Viva's solver: an item with Grow > 0 and no explicit Basis is distributed from a basis of 0 (CSS `flex: 1`) on both axes, so equal Grow factors give equal sizes even in a Column.

The solver is internal: the public API is the opaque layout.Option and its constructors in package ui/layout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(s *Style, opts ...layout.Option)

Apply runs opts on s.

func Solve

func Solve(root *Node, w, h float32)

Solve lays out root to exactly w×h.

func SolveAt

func SolveAt(root *Node, w, h float32, fw, fh bool) geom.Size

SolveAt lays out root in a box of up to w×h, sizing it to content on axes not forced (used for overlays). Returns the chosen size.

Types

type Node

type Node struct {
	Style
	Children []*Node
	// Measure returns the content size of a leaf given the available inner
	// width and height (either may be +Inf).
	Measure func(maxW, maxH float32) geom.Size
	Ref     any

	Rect    geom.Rect // output: border box relative to parent
	Content geom.Size // output: size of laid-out content incl. padding
	// contains filtered or unexported fields
}

Node is a layout tree node. Callers fill Style/Children/Measure, call Solve, then read Rect (relative to the parent's border box) and Content.

type Pos

type Pos = flexstyle.Pos

Pos holds absolute offsets; layout.Unset (NaN) means unset.

type Style

Style is the layout input of a node (see flexstyle.Style).

Directories

Path Synopsis
Package flexstyle holds the layout input of a node, shared by the public option constructors (package ui/layout) and the solver (package ui/internal/flexbox).
Package flexstyle holds the layout input of a node, shared by the public option constructors (package ui/layout) and the solver (package ui/internal/flexbox).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL