grid

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Content    [][]btn.Option
	Defaults   btn.Option
	XGap, YGap float64
}

A Generator defines the variables used to create grids from optional arguments

func (*Generator) Generate

func (g *Generator) Generate() Grid

Generate creates a Grid from a Generator

type Grid

type Grid [][]btn.Btn

A Grid is a 2D slice of buttons

func New

func New(opts ...Option) Grid

New creates a grid of buttons from a set of options

type Option

type Option func(Generator) Generator

An Option modifies a generator prior to grid generation

func Content

func Content(content [][]btn.Option) Option

Content sets the button option to create for each button at x,y coordinates on this grid. This should not be used with Width and Height. Options set here act like And() when used with Defaults.

func ContentAt

func ContentAt(x, y int, opts ...btn.Option) Option

ContentAt sets the button uption to create for a button at a given x,y coordinate on this grid. If the grid has already had content defined by Width, Height, or Content, and the x,y value given would not fall on the defined grid, the grids dimensions will be expanded so that it will. Negative x or y values will result in this option having no effect. ContentAt will overwrite options set by Content. It acts like And() when used with Defaults.

func Defaults

func Defaults(defaults btn.Option) Option

Defaults sets the starting option used to create buttons in this grid.

func Height

func Height(h int) Option

Height sets the number of buttons vertically that this grid will make.

func Width

func Width(w int) Option

Width sets the number of buttons horizontally that this grid will make.

func XGap

func XGap(gap float64) Option

XGap sets the gap between buttons horizontally on this grid.

func YGap

func YGap(gap float64) Option

YGap sets the gap between buttons vertically on this grid.

Jump to

Keyboard shortcuts

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