widget

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ScreenPadding is the padding from the outside to any content
	ScreenPadding = 32

	// ButtonHeight is the default height for buttons
	ButtonHeight = 64
)

Sizes

View Source
const (
	// ButtonFontSize is the default font size for buttons
	ButtonFontSize = 18

	// TitleFontSize is the default font size for titles
	TitleFontSize = 54

	// DebugFontSize is the default font size for smaller (debug) text
	DebugFontSize = 18
)

Font sizes

Variables

This section is empty.

Functions

func Rect

func Rect(x, y, w, h int) image.Rectangle

func TouchPositions

func TouchPositions() []image.Point

TouchPositions gets all currently active positions (mouse or touch)

Types

type Alignment

type Alignment uint8
const (
	AlignTop    Alignment = 1 << iota
	AlignRight  Alignment = 1 << iota
	AlignBottom Alignment = 1 << iota
	AlignLeft   Alignment = 1 << iota
)

type Button

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

Button is an abstract widget that can be pressed

func NewButton

func NewButton(x, y, w, h int) *Button

func (*Button) Draw

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

func (*Button) SetOnPressed

func (b *Button) SetOnPressed(pressed func(b *Button))

func (*Button) SetPosition

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

func (*Button) Size

func (b *Button) Size() image.Point

func (*Button) Update

func (b *Button) Update(*Ui)

type Image

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

Image is an image, or a sheet of multiple images

func NewImage

func NewImage(src *ebiten.Image, x, y, w, h int) *Image

func (*Image) Draw

func (i *Image) Draw(dst *ebiten.Image)

func (*Image) GetHeight

func (i *Image) GetHeight() int

func (*Image) GetPosition

func (i *Image) GetPosition() image.Point

func (*Image) GetWidth

func (i *Image) GetWidth() int

func (*Image) Rescale

func (i *Image) Rescale(x, y float64)

func (*Image) Resize

func (i *Image) Resize(w, h int)

func (*Image) ScaledSize

func (i *Image) ScaledSize() image.Point

func (*Image) SetImageType

func (i *Image) SetImageType(image res.UiImageType)

func (*Image) SetPosition

func (i *Image) SetPosition(x, y int)

func (*Image) SetSourceRect

func (i *Image) SetSourceRect(rect image.Rectangle)

func (*Image) SetWidth

func (i *Image) SetWidth(w int)

func (*Image) Size

func (i *Image) Size() image.Point

func (*Image) Update

func (i *Image) Update(*Ui)

type ImageButton

type ImageButton struct {
	*Button
	*Image
}

ImageButton is a button with an image

func NewImageButton

func NewImageButton(image *ebiten.Image, x, y, w, h int) *ImageButton

func (*ImageButton) Draw

func (i *ImageButton) Draw(dst *ebiten.Image)

func (*ImageButton) SetPosition

func (i *ImageButton) SetPosition(x, y int)

func (*ImageButton) Size

func (i *ImageButton) Size() image.Point

func (*ImageButton) Update

func (i *ImageButton) Update(ui *Ui)

type Label

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

func NewLabel

func NewLabel(fontFace font.Face, x, y int, text string, color color.Color) *Label

func (*Label) Draw

func (l *Label) Draw(dst *ebiten.Image)

func (*Label) GetPosition added in v0.4.2

func (l *Label) GetPosition() image.Point

func (*Label) SetPosition

func (l *Label) SetPosition(x, y int)

func (*Label) SetText

func (l *Label) SetText(text string)

func (*Label) Size

func (l *Label) Size() image.Point

func (*Label) Update

func (l *Label) Update(*Ui)

type NinePatch

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

NinePatch is a nine-patch image

func NewNinePatch

func NewNinePatch(image *ebiten.Image, x, y, w, h int) *NinePatch

func (*NinePatch) Draw

func (n *NinePatch) Draw(dst *ebiten.Image)

func (*NinePatch) Position

func (n *NinePatch) Position() image.Point

func (*NinePatch) Resize

func (n *NinePatch) Resize(w, h int)

func (*NinePatch) SetPosition

func (n *NinePatch) SetPosition(x, y int)

func (*NinePatch) SetSourceRect

func (n *NinePatch) SetSourceRect(rect image.Rectangle)

func (*NinePatch) SetTargetRect

func (n *NinePatch) SetTargetRect(rect image.Rectangle)

func (*NinePatch) Update

func (n *NinePatch) Update(*Ui)

type Overlay

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

func NewOverlay

func NewOverlay(font font.Face) *Overlay

func (*Overlay) Draw

func (o *Overlay) Draw(dst *ebiten.Image)

func (*Overlay) Update

func (o *Overlay) Update(*Ui)

type RepeatImage

type RepeatImage struct {
	*Image
	// contains filtered or unexported fields
}

func NewRepeatImage

func NewRepeatImage(src *ebiten.Image, x, y, w, h int) *RepeatImage

func (*RepeatImage) Draw

func (r *RepeatImage) Draw(dst *ebiten.Image)

func (*RepeatImage) SetSize

func (r *RepeatImage) SetSize(size image.Point)

func (*RepeatImage) Update

func (r *RepeatImage) Update(*Ui)

type StretchedButton

type StretchedButton struct {
	*TextButton
	// contains filtered or unexported fields
}

StretchedButton is a button that stretches horizontally across the screen

func NewStretchedButton

func NewStretchedButton(background *ebiten.Image, fontFace font.Face, x, y, w, h int,
	align Alignment, text string) *StretchedButton

func (*StretchedButton) Draw

func (s *StretchedButton) Draw(dst *ebiten.Image)

func (*StretchedButton) Update

func (s *StretchedButton) Update(ui *Ui)

type TextButton

type TextButton struct {
	*Button

	Text string
	// contains filtered or unexported fields
}

TextButton is a button with text

func NewTextButton

func NewTextButton(background *ebiten.Image, font font.Face, x, y, w, h int, text string) *TextButton

func (*TextButton) Draw

func (t *TextButton) Draw(dst *ebiten.Image)

func (*TextButton) Update

func (t *TextButton) Update(ui *Ui)

type Ui

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

func NewUi

func NewUi() (*Ui, error)

func (*Ui) AddDebugLabel added in v0.2.0

func (u *Ui) AddDebugLabel(x, y int, text string) *Label

func (*Ui) AddDebugOverlay

func (u *Ui) AddDebugOverlay() *Overlay

func (*Ui) AddImage

func (u *Ui) AddImage(src *ebiten.Image, x, y, w, h int) *Image

func (*Ui) AddImageButton

func (u *Ui) AddImageButton(image res.UiImageType, x, y, w, h int) *ImageButton

func (*Ui) AddLabel

func (u *Ui) AddLabel(x, y int, text string) *Label

func (*Ui) AddNinePatch

func (u *Ui) AddNinePatch(image res.UiImageType, x, y, w, h int) *NinePatch

func (*Ui) AddRepeatImage

func (u *Ui) AddRepeatImage(image res.UiImageType, x, y, w, h int) *RepeatImage

func (*Ui) AddStretchedButton

func (u *Ui) AddStretchedButton(y int, align Alignment, text string) *StretchedButton

func (*Ui) AddTextButton

func (u *Ui) AddTextButton(x, y, w, h int, text string) *TextButton

func (*Ui) AddTitle

func (u *Ui) AddTitle(x, y int, text string) *Label

func (*Ui) Draw

func (u *Ui) Draw(screen *ebiten.Image)

func (*Ui) Update

func (u *Ui) Update(screenSize image.Point)

type Widget

type Widget interface {
	Update(ui *Ui)
	Draw(dst *ebiten.Image)
}

Jump to

Keyboard shortcuts

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