outlay

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Unlicense Imports: 13 Imported by: 0

README

outlay

Go Reference

This package provides extra layouts for gio.

State

This package has no stable API, and should always be locked to a particular commit with go modules.

Layouts

Grid

This layout allows placement of many items in a grid with to several different strategies for wrapping across lines. For examples, run:

Radial

The radial layout allows you to lay out a set of widgets along an arc. The width and oritentation of the arc are configurable to allow for everything from a hand of cards to a full circle of widgets.

Known issues:

  • The radial layout does not currently return correct dimensions for itself, which breaks most attempts to use it as part of a larger layout.

Documentation

Overview

Package outlay provides extra layouts for gio.

Index

Constants

This section is empty.

Variables

View Source
var (
	Horizontal   = _l.Horizontal
	Vertical     = _l.Vertical
	Start        = _l.Start
	End          = _l.End
	Middle       = _l.Middle
	Baseline     = _l.Baseline
	SpaceSides   = _l.SpaceSides
	SpaceStart   = _l.SpaceStart
	SpaceEvenly  = _l.SpaceEvenly
	SpaceAround  = _l.SpaceAround
	SpaceBetween = _l.SpaceBetween
	SpaceEnd     = _l.SpaceEnd
)
View Source
var (
	Exact = _l.Exact
	Pt    = _i.Pt
)

Functions

This section is empty.

Types

type Alignment

type Alignment = _l.Alignment

type Animation

type Animation struct {
	time.Duration
	StartTime time.Time
}

Animation holds state for an Animation between two states that is not invertible.

func (*Animation) Animating

func (n *Animation) Animating(g Gx) bool

func (*Animation) Progress

func (n *Animation) Progress(g Gx) float32

Progress returns the current progress through the animation as a value in the range [0,1]

func (*Animation) SetDuration

func (n *Animation) SetDuration(d time.Duration)

func (*Animation) Start

func (n *Animation) Start(now time.Time)

type Axis

type Axis = _l.Axis

type AxisPosition

type AxisPosition struct {
	// First and last are the indicies of the first and last visible
	// cell on the axis.
	First, Last int
	// Offset is the pixel offset from the beginning of the first cell to
	// the first visible pixel.
	Offset int
	// OffsetAbs is the estimated absolute position of the first visible
	// pixel within the entire axis, mesaured in pixels.
	OffsetAbs int
	// Length is the estimated total size of the axis, measured in pixels.
	Length int
}

AxisPosition describes the position of a viewport on a given axis.

type Cell

type Cell func(gtx Gx, row, col int) Dim

Cell is the layout function for a grid cell, with row,col parameters.

type Constraints

type Constraints = _l.Constraints

type Dim

type Dim = _l.Dimensions

type Dimensioner

type Dimensioner func(axis Axis, index, constraint int) int

Dimensioner is a function that provides the dimensions (in pixels) of an element on a given axis. The constraint parameter provides the size of the visible portion of the axis for applications that want it.

type Dp

type Dp = _u.Dp

type Fan

type Fan struct {
	Animation

	// The width, in radians, of the full arc that items should occupy.
	// If zero, math.Pi/2 will be used (1/4 of a full circle).
	WidthRadians float32

	// The offset, in radians, above the X axis to apply before rendering the
	// arc. This can be used with a value of Pi/4 to center an arc of width
	// Pi/2. If zero, math.Pi/4 will be used (1/8 of a full circle). To get the
	// equivalent of specifying zero, specify a value of 2*math.Pi.
	OffsetRadians float32

	// The radius of the hollow circle at the center of the fan. Leave nil to
	// use the default heuristic of half the width of the widest item.
	HollowRadius *Dp
	// contains filtered or unexported fields
}

func (*Fan) Layout

func (f *Fan) Layout(g Gx, items ...FanItem) Dim

type FanItem

type FanItem struct {
	W       Widget
	Elevate bool
}

func Item

func Item(elevate bool, w Widget) FanItem

type Flex

type Flex struct {
	// Axis is the main axis, either Horizontal or Vertical.
	Axis Axis
	// Spacing controls the distribution of space left after
	//
	Spacing Spacing
	// Alignment is the alignment in the cross axis.
	Alignment Alignment
	// WeightSum is the sum of weights used for the weighted
	// size of Flexed children. If WeightSum is zero, the sum
	// of all Flexed weights is used.
	WeightSum float32
}

Flex lays out child elements along an axis, according to alignment, weights, and the configured system locale. It differs from gioui.org/Flex by flipping the visual order of its children in RTL locales.

func (Flex) Layout

func (f Flex) Layout(gtx Gx, children ...FlexChild) Dim

Layout a list of children. The position of the children are determined by the specified order, but Rigid children are laid out before Flexed children. If the locale of the gtx specifies a horizontal, RTL language, the children will be allocated space in the order that they are provided, but will be displayed in the inverse order to match RTL conventions.

type FlexChild

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

FlexChild is the descriptor for a Flex child.

func Flexed

func Flexed(weight float32, widget Widget) FlexChild

Flexed returns a Flex child forced to take up weight fraction of the space left over from Rigid children. The fraction is weight divided by either the weight sum of all Flexed children or the Flex WeightSum if non-zero.

func Rigid

func Rigid(widget Widget) FlexChild

Rigid returns a Flex child with a maximal constraint of the remaining space.

type Flow

type Flow struct {
	Num       int
	Axis      Axis
	Alignment Alignment
	// contains filtered or unexported fields
}

Flow lays out at most Num elements along the main axis. The number of cross axis elements depend on the total number of elements.

func (*Flow) Layout

func (g *Flow) Layout(gtx Gx, num int, el FlowElement) Dim

type FlowElement

type FlowElement func(gtx Gx, i int) Dim

FlowElement lays out the ith element of a Grid.

type FlowWrap

type FlowWrap struct {
	Axis      Axis
	Alignment Alignment
}

FlowWrap lays out as many elements as possible along the main axis before wrapping to the cross axis.

func (FlowWrap) Layout

func (g FlowWrap) Layout(gtx Gx, num int, el FlowElement) Dim

type Grid

type Grid struct {
	Vertical   AxisPosition
	Horizontal AxisPosition
	Vscroll    gesture.Scroll
	Hscroll    gesture.Scroll
	// LockedRows is a quantity of rows (starting from row 0) to lock to
	// the top of the grid's viewport. These rows will not be included in
	// the indicies provided in the Vertical AxisPosition field.
	LockedRows int
}

Grid provides a scrollable two dimensional viewport that efficiently lays out only content visible or nearly visible within the current viewport.

func (*Grid) Layout

func (g *Grid) Layout(gtx Gx, rows, cols int, dimensioner Dimensioner, cellFunc Cell) Dim

Layout the Grid.

func (*Grid) Update

func (g *Grid) Update(gtx Gx, rows, cols int, dim Dimensioner)

type Gx

type Gx = _l.Context

type Inset

type Inset struct {
	Top, Bottom unit.Dp
	// Start and End refer to the visual start and end of the widget
	// and surrounding area. In LTR locales, Start is left and End is
	// right. In RTL locales the inverse in true.
	Start, End unit.Dp
}

Inset adds space around a widget by decreasing its maximum constraints. The minimum constraints will be adjusted to ensure they do not exceed the maximum. Inset respects the system locale provided at layout time, and will swap start/end insets for RTL text. This differs from gioui.org/Inset, which never swaps the sides contextually.

func UniformInset

func UniformInset(v unit.Dp) Inset

UniformInset returns an Inset with a single inset applied to all edges.

func (Inset) Layout

func (in Inset) Layout(gtx Gx, w Widget) Dim

Layout a widget.

type List

type List = _l.List

type Point

type Point = _i.Point

type RigidRows

type RigidRows struct {
	Axis         Axis
	Alignment    Alignment
	Spacing      Spacing
	CrossSpacing Spacing
	CrossAlign   Alignment
}

RigidRows lays out a sequence of rigid widgets along Axis until it runs out of out space. It then makes a new row/column on the cross axis and fills that with widgets until it runs out there, repeating this process until all widgets are placed.

func (RigidRows) Layout

func (m RigidRows) Layout(g Gx, children ...Widget) Dim

Layout children in rows/columns.

type Sp

type Sp = _u.Sp

type Spacing

type Spacing = _l.Spacing

type Widget

type Widget = _l.Widget

Jump to

Keyboard shortcuts

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