ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogo() []image.Image

GetLogo returns the Pixie logo in multiple sizes

Types

type Box

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

Box is a rectangle which may have padding and/or a colored border, as well as a single Child

func NewBox

func NewBox(child Drawable) *Box

NewBox creates a Box containing the specified Child

func (*Box) Bounds

func (b *Box) Bounds() image.Rectangle

Bounds returnsa Rectangle indicating the visual boundaries of the Box

func (*Box) Child

func (b *Box) Child() Drawable

Child give access to a Box's child

func (*Box) Draw

func (b *Box) Draw(screen *ebiten.Image)

Draw renders a Box to a screen

func (*Box) PreferredSize

func (b *Box) PreferredSize() (int, int)

PreferredSize calculates the width and height of the box including the margin and padding

func (*Box) SetBorder

func (b *Box) SetBorder(c color.Color)

SetBorder changes the color of the border

func (*Box) SetMargin

func (b *Box) SetMargin(margin int)

SetMargin changes the margin around the Box

func (*Box) SetPadding

func (b *Box) SetPadding(padding int)

SetPadding changes the width of the Border

func (*Box) SetPosition

func (b *Box) SetPosition(x, y int)

SetPosition changes the XY corrdinate of the upper-left pixel of the Box

func (*Box) SetSize

func (b *Box) SetSize(sx, sy int)

SetSize changes the width and height of the Box

func (*Box) SetVisible

func (b *Box) SetVisible(visible bool)

SetVisible changes the visibility of the Box

func (*Box) Update

func (b *Box) Update() error

Update tells the child to update

type Button

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

Button is a square button for performing actions

func NewButton

func NewButton(img *model.Sprite, scale int, callback ButtonHandler) *Button

NewButton creates a new empty Sprite of the specified size, scale (multiplier), and ButtonHandler

func (*Button) Bounds

func (b *Button) Bounds() image.Rectangle

Bounds returns a rectangle indicating the visible boundaries of the Sprite

func (*Button) Draw

func (b *Button) Draw(screen *ebiten.Image)

Draw renders the Sprite to a screen

func (*Button) PreferredSize

func (b *Button) PreferredSize() (int, int)

PreferredSize calculates the desired width and height of the Sprite

func (*Button) SetPosition

func (b *Button) SetPosition(x, y int)

SetPosition changes the XY coordinate of the upper-left pixel

func (*Button) SetSize

func (b *Button) SetSize(sx, sy int)

SetSize changes the width and height of the Sprite

func (*Button) SetVisible

func (b *Button) SetVisible(visible bool)

SetVisible changes the visibility of the Sprite

func (*Button) Update

func (b *Button) Update() error

Update detects a mouse click inside a sprite, changing the color according to the button pressed

type ButtonHandler

type ButtonHandler func(btn ebiten.MouseButton)

ButtonHandler is a callback to be used when a mouse button is clicked

type Drawable

type Drawable interface {
	// Bounds returns a rectangle indicating the visible boundaries of the Drawable
	Bounds() image.Rectangle
	// Draw renders this Drawable to a screen
	Draw(screen *ebiten.Image)
	// SetPosition sets the XY coordinate of the upper-left pixel
	SetPosition(x, y int)
	// SetSize changes the width and height of the Drawable
	SetSize(sx, sy int)
	// PreferredSize calculates the desired width and height of the Drawable
	PreferredSize() (sx, sy int)
	// SetVisible changes the visible of the Drawable
	SetVisible(visible bool)
	// Update changes the internal state of the Drawable and/or its Children
	Update() error
}

Drawable is an object which can be rendered to a screen and may have its own state

type Grid

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

Grid is a 2D matrix of Drawables

func NewGrid

func NewGrid(rows, cols int) *Grid

NewGrid creates a Grid of the specified rows and columns

func (*Grid) Append

func (g *Grid) Append(child Drawable)

Append adds a Child to the Grid

func (*Grid) Bounds

func (g *Grid) Bounds() image.Rectangle

Bounds returns a rectangle indicating the boundaries of the Grid if completely filled

func (*Grid) Children

func (g *Grid) Children() []Drawable

Children provides access to a Grid's children

func (*Grid) Clear

func (g *Grid) Clear()

Clear removes all the children

func (*Grid) Draw

func (g *Grid) Draw(screen *ebiten.Image)

Draw renders the Grid to a screen

Children are drawn row by row, from left to right, until no more rows or children are available

func (*Grid) PreferredSize

func (g *Grid) PreferredSize() (int, int)

PreferredSize indicated the width and height of the Grid if completely filled

func (*Grid) SetPosition

func (g *Grid) SetPosition(x, y int)

SetPosition changes the XY coordinate of the upper-left pixel

Additionally, each child's position is modified, setting any extra children to invisible

func (*Grid) SetSize

func (g *Grid) SetSize(sx, sy int)

SetSize sets the width and heght of the Grid (NOT IMPLEMENTED)

func (*Grid) SetVisible

func (g *Grid) SetVisible(visible bool)

SetVisible changes the visibility of the Grid and its Children

func (*Grid) Update

func (g *Grid) Update() error

Update calls Update for each child, one at a time

type Rectangle

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

Rectangle is a colored box

func NewRectangle

func NewRectangle(sx, sy int) *Rectangle

NewRectangle creates a new Rectangle of the specified width and height

func (*Rectangle) Bounds

func (r *Rectangle) Bounds() image.Rectangle

Bounds returns a rectangle indicating the visible area of the Rectangle

func (*Rectangle) Draw

func (r *Rectangle) Draw(screen *ebiten.Image)

Draw renders the Rectangle to a screen

func (*Rectangle) PreferredSize

func (r *Rectangle) PreferredSize() (int, int)

PreferredSize calculates the desired width and height of the Rectangle

func (*Rectangle) SetColor

func (r *Rectangle) SetColor(c color.Color)

SetColor changes the color of the Rectangle

func (*Rectangle) SetPosition

func (r *Rectangle) SetPosition(x, y int)

SetPosition changes the XY coordinate of the upper-left pixel

func (*Rectangle) SetSize

func (r *Rectangle) SetSize(sx, sy int)

SetSize changes that width and height of the Rectangle

func (*Rectangle) SetVisible

func (r *Rectangle) SetVisible(visible bool)

SetVisible changes the visibility of the Rectangle

func (*Rectangle) Update

func (r *Rectangle) Update() error

Update updates the state of the Rectangle (NOT IMPLEMENTED)

type Selected

type Selected int

Selected indicated whether or not a UI element is selected and how it was selected

const (
	// UnSelected indicates no selection
	UnSelected Selected = iota
	// LeftSelect indicates a selection by left click
	LeftSelect
	// RightSelect indicates a selection by right click
	RightSelect
)

type Toolbar

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

Toolbar is a grid of toolbar icons for carrying out specific actions

func NewToolbar

func NewToolbar(x, y int) *Toolbar

NewToolbar creates an empty Toolbar

func (*Toolbar) Append

func (t *Toolbar) Append(b *Button)

Append adds a new Button to the Toolbar

func (*Toolbar) Bounds

func (t *Toolbar) Bounds() image.Rectangle

Bounds returns a rectangle indicating the visible boundaries of the Toolbar

func (*Toolbar) Draw

func (t *Toolbar) Draw(screen *ebiten.Image)

Draw renders the Toolbar to a screen

func (*Toolbar) PreferredSize

func (t *Toolbar) PreferredSize() (sx, sy int)

PreferredSize calculates the desired width and height of the Toolbar

func (*Toolbar) SetPosition

func (t *Toolbar) SetPosition(x, y int)

SetPosition changes the XY coordinate of the upper-left pixel

func (*Toolbar) SetSize

func (t *Toolbar) SetSize(sx, sy int)

SetSize changes the desired width and height

func (*Toolbar) SetVisible

func (t *Toolbar) SetVisible(visible bool)

SetVisible changes the visibility of the Toolbar

func (*Toolbar) Update

func (t *Toolbar) Update() error

Update checks if a toolbar button is pressed (NOT IMPLEMENTED)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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