btn

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx *scene.Context, opts ...Option) *entities.Entity

New creates a button with the given options and defaults for all variables not set.

Types

type Generator

type Generator struct {
	X, Y         float64
	W, H         float64
	TxtX, TxtY   float64
	Color        color.Color
	Color2       color.Color
	ProgressFunc func(x, y, w, h int) float64
	Mod          mod.Transform
	R            render.Modifiable
	R1           render.Modifiable
	R2           render.Modifiable
	RS           []render.Modifiable
	Cid          event.CallerID
	Font         *render.Font
	Layers       []int
	Text         string
	TextPtr      *string
	TextStringer fmt.Stringer
	Children     []Generator
	Bindings     []func(ctx *scene.Context, caller *entities.Entity) event.Binding
	Trigger      string
	Shape        shape.Shape
	Label        collision.Label
}

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

func (Generator) Generate

func (g Generator) Generate(ctx *scene.Context) *entities.Entity

Generate creates a Button from a generator.

type Option

type Option func(Generator) Generator

An Option is used to populate generator fields prior to generation of a button

func AddChildren

func AddChildren(cg ...Generator) Option

AddChildren adds a generator to create a child btn

func And

func And(opts ...Option) Option

And combines a variadic number of options

func AndMod

func AndMod(m mod.Transform) Option

AndMod combines the input modification with whatever existing modifications exist for the generator, as opposed to Mod which resets previous modifications.

func Binding

func Binding[Payload any](ev event.EventID[Payload], bnd event.Bindable[*entities.Entity, Payload]) Option

Binding appends a function to be called when a specific event is triggered.

func CID

func CID(c event.CallerID) Option

CID sets the starting CID of the button to be generated

func Clear

func Clear() Option

Clear resets the button to be empty

func Click

Click appends a function to be called when the button is clicked on.

func Color

func Color(c color.Color) Option

Color sets the colorboxes color for the button to be generated

func FitText

func FitText(buffer int) Option

FitText adjusts a btn's width, given it has text and font defined, to be large enough for the given text plus the provided buffer

func Font

func Font(f *render.Font) Option

Font sets the font for the text of the button to be generated

func Height

func Height(h float64) Option

Height sets the Height of the button to be generated

func Label

func Label(l collision.Label) Option

func Layers

func Layers(ls ...int) Option

Layers sets the layer of the button to be generated

func Mod

func Mod(m mod.Transform) Option

Mod sets the modifications to apply to the initial color box for the button to be generated

func Offset

func Offset(x, y float64) Option

Offset increments the position of the button to be generated

func Pos

func Pos(x, y float64) Option

Pos sets the position of the button to be generated

func Renderable

func Renderable(r render.Modifiable) Option

Renderable sets a renderable to use as a base image for the button. Not compatible with Color / Toggle.

func Text

func Text(s string) Option

Text sets the text of the button to be generated

func TextPtr

func TextPtr(s *string) Option

TextPtr sets the text of the button to be generated to a string pointer.

func TextStringer

func TextStringer(s fmt.Stringer) Option

TextStringer sets the text of the generated button to use a fmt.Stringer String call

func TxtOff

func TxtOff(x, y float64) Option

TxtOff sets the text offset of the button generator from the bottom left

func VGradient

func VGradient(c1, c2 color.Color) Option

VGradient creates a vertical color gradient for the btn

func Width

func Width(w float64) Option

Width sets the Width of the button to be generated

Directories

Path Synopsis
Package grid provides structures for aligning grids of buttons
Package grid provides structures for aligning grids of buttons

Jump to

Keyboard shortcuts

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