layout

package
v0.0.0-...-69d9917 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT, Unlicense Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reverse

func Reverse(shouldReverse bool, items ...layout.FlexChild) []layout.FlexChild

Reverse the order of the provided flex children if the boolean is true.

Types

type Background

type Background color.NRGBA

Background lays out a widget over a colored background.

func (Background) Layout

type C

type C = layout.Context

type D

type D = layout.Dimensions

type GutterStyle

type GutterStyle struct {
	LeftWidth  unit.Dp
	RightWidth unit.Dp
	layout.Alignment
}

GutterStyle configures a gutter on either side of a horizontal row of content. Both sides can optionally display a widget atop the gutter space.

func Gutter

func Gutter() GutterStyle

Gutter returns a GutterStyle with a narrow left gutter and a wide right gutter.

func (GutterStyle) Layout

func (g GutterStyle) Layout(gtx layout.Context, left, center, right layout.Widget) layout.Dimensions

Layout the gutter with the left and right widgets laid out atop the gutter areas and the center widget in the remaining space in between. Left or right may be provided as nil to indicate that nothing should be displayed in the gutter.

type Rounded

type Rounded unit.Dp

Rounded lays out a widget with rounded corners.

func (Rounded) Layout

func (r Rounded) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions

type Row

type Row struct {
	// Margin between rows.
	Margin VerticalMarginStyle
	// InternalMargin between internal rows.
	// Leave unset if you want to control spacing between RowChild individually.
	InternalMargin VerticalMarginStyle
	// Gutter handles the left-right gutters of the row that provides padding and
	// can contain other widgets.
	Gutter GutterStyle
	// Direction of widgets within this row.
	// Typically, non-local widgets are aligned W, and local widgets aligned E.
	Direction layout.Direction
}

Row lays out a central widget with gutters either side. The central widget can be arbitrarily aligned and gutters can have supplimentary widgets stacked atop them.

func (Row) Layout

func (r Row) Layout(gtx C, w ...RowChild) D

Layout the Row with any number of internal rows.

type RowChild

type RowChild struct {
	Left    layout.Widget
	Content layout.Widget
	Right   layout.Widget
	Unified bool
}

RowChild specifies a content widget and two gutter widgets either side. RowChild is used to layout composite rows made up of any number of interal rows.

func ContentRow

func ContentRow(w layout.Widget) RowChild

ContentRow returns a RowChild that lays out a content with no gutter widgets.

func FullRow

func FullRow(l, w, r layout.Widget) RowChild

FullRow returns a RowChild that lays out content with optional gutter widgets either side.

func UnifiedRow

func UnifiedRow(w layout.Widget) RowChild

UnifiedRow ignores gutters, taking up all available space.

type VerticalMarginStyle

type VerticalMarginStyle struct {
	Size unit.Dp
}

VerticalMarginStyle provides a simple API for insetting a widget equally on its top and bottom edges. Consistently wrapping chat elements in a single VerticalMarginStyle as their outermost layout type will ensure that they are spaced evenly and no part of their content crowds that of the message above and below.

func VerticalMargin

func VerticalMargin() VerticalMarginStyle

VerticalMargin configures a vertical margin with a sensible default margin.

func (VerticalMarginStyle) Layout

Layout the provided widget within the margin and return their combined dimensions.

Jump to

Keyboard shortcuts

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