layout

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpaceEnd     = layout.SpaceEnd
	SpaceStart   = layout.SpaceStart
	SpaceSides   = layout.SpaceSides
	SpaceAround  = layout.SpaceAround
	SpaceBetween = layout.SpaceBetween
	SpaceEvenly  = layout.SpaceEvenly
)
View Source
const (
	Start    = layout.Start
	End      = layout.End
	Middle   = layout.Middle
	Baseline = layout.Baseline
)
View Source
const (
	NW     = layout.NW
	N      = layout.N
	NE     = layout.NE
	E      = layout.E
	SE     = layout.SE
	S      = layout.S
	SW     = layout.SW
	W      = layout.W
	Center = layout.Center
)
View Source
const (
	Horizontal = layout.Horizontal
	Vertical   = layout.Vertical
)

Variables

View Source
var Exact = layout.Exact
View Source
var Expanded = layout.Expanded
View Source
var Flexed = layout.Flexed
View Source
var NewContext = layout.NewContext
View Source
var Rigid = layout.Rigid
View Source
var Stacked = layout.Stacked
View Source
var UniformInset = layout.UniformInset

Functions

func Cross

func Cross(a Axis, pt *image.Point) *int

func Main

func Main(a Axis, pt *image.Point) *int

func MiddleAligned added in v0.4.0

func MiddleAligned(gtx Context, w Widget) layout.Dimensions

func Overlay added in v0.4.0

func Overlay(gtx Context, w1 Widget, w2 Widget) layout.Dimensions

func RightAligned added in v0.4.0

func RightAligned(gtx Context, w Widget) layout.Dimensions

func Rigids added in v0.4.0

func Rigids(gtx Context, axis layout.Axis, ws ...Widget) layout.Dimensions

func WithCursor added in v0.4.0

func WithCursor(gtx Context, p pointer.Cursor, w Widget) layout.Dimensions

Types

type Alignment

type Alignment = layout.Alignment

type Axis

type Axis = layout.Axis

type Constraints

type Constraints = layout.Constraints

func Normalize

func Normalize(c Constraints) Constraints

type Context

type Context = layout.Context

type Dimensions

type Dimensions = layout.Dimensions

type Direction

type Direction = layout.Direction

type Flex

type Flex = layout.Flex

type FlexChild

type FlexChild = layout.FlexChild

type Inset

type Inset = layout.Inset

type List

type List struct {
	Axis Axis
	// ScrollToEnd instructs the list to stay scrolled to the far end position
	// once reached. A List with ScrollToEnd == true and Position.BeforeEnd ==
	// false draws its content with the last item at the bottom of the list
	// area.
	ScrollToEnd bool
	// Alignment is the cross axis alignment of list elements.
	Alignment Alignment

	// Position is updated during Layout. To save the list scroll position,
	// just save Position after Layout finishes. To scroll the list
	// programmatically, update Position (e.g. restore it from a saved value)
	// before calling Layout.
	Position Position
	// contains filtered or unexported fields
}

List displays a subsection of a potentially infinitely large underlying list. List accepts user input to scroll the subsection.

func (*List) Dragging added in v0.4.0

func (l *List) Dragging() bool

Dragging reports whether the List is being dragged.

func (*List) Layout added in v0.4.0

func (l *List) Layout(gtx Context, len int, w ListElement) Dimensions

Layout a List of len items, where each item is implicitly defined by the callback w. Layout can handle very large lists because it only calls w to fill its viewport and the distance scrolled, if any.

func (*List) ScrollBy added in v0.4.0

func (l *List) ScrollBy(num float32)

ScrollBy scrolls the list by a relative amount of items.

Fractional scrolling may be inaccurate for items of differing dimensions. This includes scrolling by integer amounts if the current l.Position.Offset is non-zero.

func (*List) ScrollTo added in v0.4.0

func (l *List) ScrollTo(n int)

ScrollTo scrolls to the specified item.

type ListElement

type ListElement = layout.ListElement

type PixelInset

type PixelInset struct {
	Top, Bottom, Left, Right int
}

PixelInset is like Inset, but using pixel coordinates instead of dp.

func (PixelInset) Layout

func (in PixelInset) Layout(gtx Context, w Widget) Dimensions

type Position

type Position struct {
	// BeforeEnd tracks whether the List position is before the very end. We
	// use "before end" instead of "at end" so that the zero value of a
	// Position struct is useful.
	//
	// When laying out a list, if ScrollToEnd is true and BeforeEnd is false,
	// then First and Offset are ignored, and the list is drawn with the last
	// item at the bottom. If ScrollToEnd is false then BeforeEnd is ignored.
	BeforeEnd bool
	// First is the index of the first visible child.
	First int
	// Offset is the distance in pixels from the leading edge to the child at index
	// First.
	Offset int
	// OffsetLast is the signed distance in pixels from the trailing edge to the
	// bottom edge of the child at index First+Count.
	OffsetLast int
	// Count is the number of visible children.
	Count int
	// Length is the estimated total size of all children, measured in pixels.
	Length int

	ForceEndAligned bool
}

Position is a List scroll offset represented as an offset from the top edge of a child element.

type SmallGrid

type SmallGrid struct {
	Grid          outlay.Grid
	RowPadding    int
	ColumnPadding int
}

func (SmallGrid) Layout

func (sg SmallGrid) Layout(gtx Context, rows, cols int, sizeEstimator outlay.Cell, cellFunc outlay.Cell) Dimensions

type Spacer

type Spacer = layout.Spacer

type Spacing

type Spacing = layout.Spacing

type Stack

type Stack = layout.Stack

type Widget

type Widget = layout.Widget

Jump to

Keyboard shortcuts

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