layouts

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGrid added in v0.4.0

func NewGrid(columns ...bool) func(rows ...bool) *Grid

NewGrid creates a new grid layout. Rows and columns are specified as slices of booleans, where true means a row or column will expand and false means it will contract. Boxes are laid out left to right, then top to bottom. Boxes that go beyond the lengh of rows will be laid out according to columns, but they will not expand vertically.

If you aren't sure how to use this constructor, here is an example:

         X0     X1    X2     Y0    Y1    Y2
NewGrid(true, false, true)(false, true, true)

Types

type Column

type Column []bool

Column arranges boxes in a column. Boxes that share an index with a true value will expand, and others will contract.

func (Column) Arrange

func (column Column) Arrange(hints tomo.LayoutHints, boxes tomo.BoxArranger)

func (Column) MinimumSize

func (column Column) MinimumSize(hints tomo.LayoutHints, boxes tomo.BoxQuerier) image.Point

func (Column) RecommendedHeight added in v0.18.0

func (column Column) RecommendedHeight(hints tomo.LayoutHints, boxes tomo.BoxQuerier, width int) int

func (Column) RecommendedWidth added in v0.18.0

func (column Column) RecommendedWidth(hints tomo.LayoutHints, boxes tomo.BoxQuerier, height int) int

type Contract added in v0.12.0

type Contract bool

Contract is a layout that arranges boxes in a simple row or column according to their minimum sizes.

const ContractHorizontal Contract = false

ContractHorizontal is a horizontal contracted layout.

const ContractVertical Contract = true

ContractVertical is a vertical contracted layout.

func (Contract) Arrange added in v0.12.0

func (contract Contract) Arrange(hints tomo.LayoutHints, boxes tomo.BoxArranger)

func (Contract) MinimumSize added in v0.12.0

func (contract Contract) MinimumSize(hints tomo.LayoutHints, boxes tomo.BoxQuerier) image.Point

func (Contract) RecommendedHeight added in v0.18.0

func (contract Contract) RecommendedHeight(hints tomo.LayoutHints, boxes tomo.BoxQuerier, width int) int

func (Contract) RecommendedWidth added in v0.18.0

func (contract Contract) RecommendedWidth(hints tomo.LayoutHints, boxes tomo.BoxQuerier, height int) int

type Flow added in v0.12.0

type Flow bool

Flow is a grid layout where the number of rows and columns changes depending on the size of the container. It is designed to be used with an overflowing container. If the container does not overflow in the correct direction, the layout will behave like Contract.

const FlowHorizontal Flow = false

FlowHorizontal is a horizontal flow layout.

const FlowVertical Flow = true

FlowVertical is a vertical flow layout.

func (Flow) Arrange added in v0.12.0

func (flow Flow) Arrange(hints tomo.LayoutHints, boxes tomo.BoxArranger)

func (Flow) MinimumSize added in v0.12.0

func (flow Flow) MinimumSize(hints tomo.LayoutHints, boxes tomo.BoxQuerier) image.Point

func (Flow) RecommendedHeight added in v0.18.0

func (flow Flow) RecommendedHeight(hints tomo.LayoutHints, boxes tomo.BoxQuerier, width int) int

func (Flow) RecommendedWidth added in v0.18.0

func (flow Flow) RecommendedWidth(hints tomo.LayoutHints, boxes tomo.BoxQuerier, height int) int

type Grid added in v0.4.0

type Grid struct {
	// contains filtered or unexported fields
}

Grid is a layout that arranges boxes in a grid formation with distinct rows and columns. It is great for creating forms.

func (*Grid) Arrange added in v0.4.0

func (this *Grid) Arrange(hints tomo.LayoutHints, boxes tomo.BoxArranger)

func (*Grid) MinimumSize added in v0.4.0

func (this *Grid) MinimumSize(hints tomo.LayoutHints, boxes tomo.BoxQuerier) image.Point

func (*Grid) RecommendedHeight added in v0.18.0

func (this *Grid) RecommendedHeight(hints tomo.LayoutHints, boxes tomo.BoxQuerier, width int) int

func (*Grid) RecommendedWidth added in v0.18.0

func (this *Grid) RecommendedWidth(hints tomo.LayoutHints, boxes tomo.BoxQuerier, height int) int

type Row

type Row []bool

Row arranges boxes in a row. Boxes that share an index with a true value will expand, and others will contract.

func (Row) Arrange

func (row Row) Arrange(hints tomo.LayoutHints, boxes tomo.BoxArranger)

func (Row) MinimumSize

func (row Row) MinimumSize(hints tomo.LayoutHints, boxes tomo.BoxQuerier) image.Point

func (Row) RecommendedHeight added in v0.18.0

func (row Row) RecommendedHeight(hints tomo.LayoutHints, boxes tomo.BoxQuerier, width int) int

func (Row) RecommendedWidth added in v0.18.0

func (row Row) RecommendedWidth(hints tomo.LayoutHints, boxes tomo.BoxQuerier, height int) int

Jump to

Keyboard shortcuts

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