ui

package module
v0.0.0-...-5e8e24f Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2017 License: MIT Imports: 13 Imported by: 1

README

About

GoDoc Travis-CI codecov.io

A game UI for golang with boilerplate to run with ebiten.

Example usage

package main

import "github.com/martinlindhe/gameui"

const (
    width, height = 320, 200
    fontName      = "_resources/font/open_dyslexic/OpenDyslexic3-Regular.ttf"
)

var (
    gui       = ui.New(width, height)
    font12, _ = ui.NewFont(fontName, 12, 72, ui.White)
)

func main() {
    // add a text element
    text := ui.NewText(font12).SetText("hello")
    text.Position = ui.Point{X: width/2 - text.GetWidth()/2, Y: height / 3}
    gui.AddComponent(text)

    if err := gui.Update(); err != nil {
        return err
    }

    // get a image.Image
    img := gui.Render()
}

Full example using ebiten:

go get github.com/martinlindhe/gameui
cd $GOPATH/src/github.com/martinlindhe/gameui
go run examples/tooltip/main.go

See the examples folder for more examples

License

Under MIT

Documentation

Index

Constants

View Source
const (
	Key0         = Key(ebiten.Key0)
	Key1         = Key(ebiten.Key1)
	Key2         = Key(ebiten.Key2)
	Key3         = Key(ebiten.Key3)
	Key4         = Key(ebiten.Key4)
	Key5         = Key(ebiten.Key5)
	Key6         = Key(ebiten.Key6)
	Key7         = Key(ebiten.Key7)
	Key8         = Key(ebiten.Key8)
	Key9         = Key(ebiten.Key9)
	KeyA         = Key(ebiten.KeyA)
	KeyB         = Key(ebiten.KeyB)
	KeyC         = Key(ebiten.KeyC)
	KeyD         = Key(ebiten.KeyD)
	KeyE         = Key(ebiten.KeyE)
	KeyF         = Key(ebiten.KeyF)
	KeyG         = Key(ebiten.KeyG)
	KeyH         = Key(ebiten.KeyH)
	KeyI         = Key(ebiten.KeyI)
	KeyJ         = Key(ebiten.KeyJ)
	KeyK         = Key(ebiten.KeyK)
	KeyL         = Key(ebiten.KeyL)
	KeyM         = Key(ebiten.KeyM)
	KeyN         = Key(ebiten.KeyN)
	KeyO         = Key(ebiten.KeyO)
	KeyP         = Key(ebiten.KeyP)
	KeyQ         = Key(ebiten.KeyQ)
	KeyR         = Key(ebiten.KeyR)
	KeyS         = Key(ebiten.KeyS)
	KeyT         = Key(ebiten.KeyT)
	KeyU         = Key(ebiten.KeyU)
	KeyV         = Key(ebiten.KeyV)
	KeyW         = Key(ebiten.KeyW)
	KeyX         = Key(ebiten.KeyX)
	KeyY         = Key(ebiten.KeyY)
	KeyZ         = Key(ebiten.KeyZ)
	KeyAlt       = Key(ebiten.KeyAlt)
	KeyBackspace = Key(ebiten.KeyBackspace)
	KeyCapsLock  = Key(ebiten.KeyCapsLock)
	KeyComma     = Key(ebiten.KeyComma)
	KeyControl   = Key(ebiten.KeyControl)
	KeyDelete    = Key(ebiten.KeyDelete)
	KeyDown      = Key(ebiten.KeyDown)
	KeyEnd       = Key(ebiten.KeyEnd)
	KeyEnter     = Key(ebiten.KeyEnter)
	KeyEscape    = Key(ebiten.KeyEscape)
	KeyF1        = Key(ebiten.KeyF1)
	KeyF2        = Key(ebiten.KeyF2)
	KeyF3        = Key(ebiten.KeyF3)
	KeyF4        = Key(ebiten.KeyF4)
	KeyF5        = Key(ebiten.KeyF5)
	KeyF6        = Key(ebiten.KeyF6)
	KeyF7        = Key(ebiten.KeyF7)
	KeyF8        = Key(ebiten.KeyF8)
	KeyF9        = Key(ebiten.KeyF9)
	KeyF10       = Key(ebiten.KeyF10)
	KeyF11       = Key(ebiten.KeyF11)
	KeyF12       = Key(ebiten.KeyF12)
	KeyHome      = Key(ebiten.KeyHome)
	KeyInsert    = Key(ebiten.KeyInsert)
	KeyLeft      = Key(ebiten.KeyLeft)
	KeyPageDown  = Key(ebiten.KeyPageDown)
	KeyPageUp    = Key(ebiten.KeyPageUp)
	KeyPeriod    = Key(ebiten.KeyPeriod)
	KeyRight     = Key(ebiten.KeyRight)
	KeyShift     = Key(ebiten.KeyShift)
	KeySpace     = Key(ebiten.KeySpace)
	KeyTab       = Key(ebiten.KeyTab)
	KeyUp        = Key(ebiten.KeyUp)
	KeyMax       = KeyUp
)

Keys

View Source
const (
	MouseButtonLeft   = MouseButton(ebiten.MouseButtonLeft)
	MouseButtonRight  = MouseButton(ebiten.MouseButtonRight)
	MouseButtonMiddle = MouseButton(ebiten.MouseButtonMiddle)
)

MouseButtons

Variables

View Source
var (
	Black       = color.Black
	White       = color.White
	Red         = color.RGBA{255, 0, 0, 255}
	Green       = color.RGBA{0, 255, 0, 255}
	Blue        = color.RGBA{0, 0, 255, 255}
	Yellow      = color.RGBA{255, 255, 0, 255}
	Purple      = color.RGBA{255, 0, 255, 255}
	Brown       = color.RGBA{139, 69, 19, 255}
	Orange      = color.RGBA{255, 165, 0, 255}
	Pink        = color.RGBA{255, 105, 180, 255}
	DarkGrey    = color.RGBA{169, 169, 169, 255}
	LightGrey   = color.RGBA{211, 211, 211, 255}
	Transparent = color.Transparent
	Opaque      = color.Opaque
)

...

Functions

func CheckUI

func CheckUI(ui *UI) bool

CheckUI performs some sanity checks on the UI instance in order to detect programmatic errors returns true if checks passed

func DecodeImage

func DecodeImage(r io.Reader) (image.Image, error)

DecodeImage reads an image from r

func DrawRect

func DrawRect(img draw.Image, r image.Rectangle, col color.Color)

DrawRect ...

func LoadTiles

func LoadTiles(imgFile string, tileWidth, tileHeight int) (res []image.Image)

LoadTiles ...

func OpenImage

func OpenImage(filename string) (image.Image, error)

OpenImage loads an image from file. based on Open from disintegration/imaging https://github.com/disintegration/imaging/blob/master/helpers.go#L68

func RequireImage

func RequireImage(filename string) image.Image

RequireImage loads an image or exits if not successful

Types

type Bar

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

Bar is a progress bar (UI component)

func NewBar

func NewBar(width, height int) *Bar

NewBar creates a new Bar

func (*Bar) Click

func (c *Bar) Click(mouse Point) bool

Click returns true if click was handled

func (*Bar) Draw

func (bar *Bar) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*Bar) GetBounds

func (c *Bar) GetBounds() image.Rectangle

func (*Bar) GetPosition

func (c *Bar) GetPosition() Point

func (*Bar) GetValue

func (bar *Bar) GetValue() int

GetValue returns the value (0-100, percent)

func (*Bar) Hide

func (c *Bar) Hide()

Hide makes component hidden

func (*Bar) Hover

func (c *Bar) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Bar) IncValue

func (bar *Bar) IncValue(i int) int

IncValue increases value by `i` up to 100 and returns the new value

func (*Bar) IsClean

func (c *Bar) IsClean() bool

IsClean returns false if component needs redraw

func (*Bar) IsHidden

func (c *Bar) IsHidden() bool

func (*Bar) IsMouseOver

func (c *Bar) IsMouseOver() bool

func (*Bar) Move

func (c *Bar) Move(x, y int)

func (*Bar) RemoveAllChildren

func (c *Bar) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Bar) SetBackgroundColor

func (c *Bar) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Bar) SetBorderColor

func (bar *Bar) SetBorderColor(c color.Color)

SetBorderColor sets the border color

func (*Bar) SetFillColor

func (bar *Bar) SetFillColor(c color.Color)

SetFillColor sets the fill color

func (*Bar) SetFillImage

func (bar *Bar) SetFillImage(img image.Image)

SetFillImage sets the fill image. If set, is used instead of fill color

func (*Bar) SetPosition

func (c *Bar) SetPosition(pos Point)

func (*Bar) SetTooltip

func (c *Bar) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Bar) SetValue

func (bar *Bar) SetValue(v int)

SetValue accepts a value between 0-100

func (*Bar) SetVisibility

func (c *Bar) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Bar) Show

func (c *Bar) Show()

Show makes component visible

func (*Bar) Tooltip

func (c *Bar) Tooltip() *Button

Tooltip returns the current tooltip

type Button

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

Button is a button (UI component)

func NewButton

func NewButton(width, height int) *Button

NewButton ...

func (*Button) Click

func (c *Button) Click(mouse Point) bool

Click returns true if click was handled

func (*Button) Draw

func (btn *Button) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*Button) GetBounds

func (c *Button) GetBounds() image.Rectangle

func (*Button) GetPosition

func (c *Button) GetPosition() Point

func (*Button) Hide

func (c *Button) Hide()

Hide makes component hidden

func (*Button) Hover

func (c *Button) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Button) IsClean

func (c *Button) IsClean() bool

IsClean returns false if component needs redraw

func (*Button) IsHidden

func (c *Button) IsHidden() bool

func (*Button) IsMouseOver

func (c *Button) IsMouseOver() bool

func (*Button) Move

func (c *Button) Move(x, y int)

func (*Button) RemoveAllChildren

func (c *Button) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Button) SetBackgroundColor

func (c *Button) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Button) SetBorderColor

func (btn *Button) SetBorderColor(c color.Color)

SetBorderColor sets the border color

func (*Button) SetIcon

func (btn *Button) SetIcon(img image.Image)

SetIcon a image to show on button, instead of text

func (*Button) SetPosition

func (c *Button) SetPosition(pos Point)

func (*Button) SetText

func (btn *Button) SetText(fnt *Font, s string) *Button

SetText sets the button text

func (*Button) SetTooltip

func (c *Button) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Button) SetVisibility

func (c *Button) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Button) Show

func (c *Button) Show()

Show makes component visible

func (*Button) Tooltip

func (c *Button) Tooltip() *Button

Tooltip returns the current tooltip

type Color

type Color color.Color

Color ...

type Component

type Component interface {
	Draw(mx, my int) *image.RGBA // returns nil if no image is drawn
	GetBounds() image.Rectangle
	Hover(bool)
	Move(int, int)
	IsClean() bool
	IsHidden() bool
	Click(Point) bool
	IsMouseOver() bool
	Tooltip() *Button
}

Component represents any type of UI component

type Dimension

type Dimension struct {
	Width, Height int
}

Dimension represents a size in 2D space

type Font

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

Font is a font resource

func NewFont

func NewFont(fontName string, size float64, dpi float64, col color.Color) (*Font, error)

NewFont prepares a new font resource for use

func (*Font) Print

func (fnt *Font) Print(text string) (*image.RGBA, error)

Print draws text using the font

type GracefulExitError

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

GracefulExitError is used to signal a graceful shutdown

func (GracefulExitError) Error

func (e GracefulExitError) Error() string

type Group

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

Group is a container of more components, similar to a transparent Window

func NewGroup

func NewGroup(width, height int) *Group

NewGroup creates a new Group

func (*Group) AddChild

func (grp *Group) AddChild(c Component)

AddChild adds a child to the group

func (*Group) Click

func (grp *Group) Click(mouse Point) bool

Click pass click to window child components

func (*Group) Draw

func (grp *Group) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*Group) GetBounds

func (c *Group) GetBounds() image.Rectangle

func (*Group) GetPosition

func (c *Group) GetPosition() Point

func (*Group) Hide

func (c *Group) Hide()

Hide makes component hidden

func (*Group) Hover

func (c *Group) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Group) IsClean

func (c *Group) IsClean() bool

IsClean returns false if component needs redraw

func (*Group) IsHidden

func (c *Group) IsHidden() bool

func (*Group) IsMouseOver

func (c *Group) IsMouseOver() bool

func (*Group) Move

func (c *Group) Move(x, y int)

func (*Group) RemoveAllChildren

func (c *Group) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Group) SetBackgroundColor

func (c *Group) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Group) SetPosition

func (c *Group) SetPosition(pos Point)

func (*Group) SetTooltip

func (c *Group) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Group) SetVisibility

func (c *Group) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Group) Show

func (c *Group) Show()

Show makes component visible

func (*Group) Tooltip

func (c *Group) Tooltip() *Button

Tooltip returns the current tooltip

type Icon

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

Icon is a icon (UI component)

func NewIcon

func NewIcon(img image.Image) *Icon

NewIcon creates a new icon

func (*Icon) Click

func (c *Icon) Click(mouse Point) bool

Click returns true if click was handled

func (*Icon) Draw

func (ico *Icon) Draw(mx, my int) *image.RGBA

Draw ...

func (*Icon) GetBounds

func (c *Icon) GetBounds() image.Rectangle

func (*Icon) GetPosition

func (c *Icon) GetPosition() Point

func (*Icon) Hide

func (c *Icon) Hide()

Hide makes component hidden

func (*Icon) Hover

func (c *Icon) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Icon) IsClean

func (c *Icon) IsClean() bool

IsClean returns false if component needs redraw

func (*Icon) IsHidden

func (c *Icon) IsHidden() bool

func (*Icon) IsMouseOver

func (c *Icon) IsMouseOver() bool

func (*Icon) Move

func (c *Icon) Move(x, y int)

func (*Icon) RemoveAllChildren

func (c *Icon) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Icon) SetBackgroundColor

func (c *Icon) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Icon) SetIcon

func (ico *Icon) SetIcon(img image.Image)

SetIcon sets the icon

func (*Icon) SetPosition

func (c *Icon) SetPosition(pos Point)

func (*Icon) SetTooltip

func (c *Icon) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Icon) SetVisibility

func (c *Icon) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Icon) Show

func (c *Icon) Show()

Show makes component visible

func (*Icon) Tooltip

func (c *Icon) Tooltip() *Button

Tooltip returns the current tooltip

type IconGroup

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

IconGroup is a tile-hased grid display of object icons

func NewIconGroup

func NewIconGroup(columns, rows, iconWidth, iconHeight int) *IconGroup

NewIconGroup ...

func (*IconGroup) AddObject

func (grp *IconGroup) AddObject(o IconGroupObject)

AddObject adds an object to display in the group

func (*IconGroup) Click

func (grp *IconGroup) Click(mouse Point) bool

Click pass click to child icon (click has happened)

func (*IconGroup) Draw

func (grp *IconGroup) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*IconGroup) GetBounds

func (c *IconGroup) GetBounds() image.Rectangle

func (*IconGroup) GetPosition

func (c *IconGroup) GetPosition() Point

func (*IconGroup) Hide

func (c *IconGroup) Hide()

Hide makes component hidden

func (*IconGroup) Hover

func (c *IconGroup) Hover(b bool)

Hover sets the mouse hovering state for component

func (*IconGroup) IsClean

func (c *IconGroup) IsClean() bool

IsClean returns false if component needs redraw

func (*IconGroup) IsHidden

func (c *IconGroup) IsHidden() bool

func (*IconGroup) IsMouseOver

func (c *IconGroup) IsMouseOver() bool

func (*IconGroup) Move

func (c *IconGroup) Move(x, y int)

func (*IconGroup) RemoveAllChildren

func (c *IconGroup) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*IconGroup) RemoveAllObjects

func (grp *IconGroup) RemoveAllObjects()

RemoveAllObjects removes all displayed content

func (*IconGroup) RemoveObjectByID

func (grp *IconGroup) RemoveObjectByID(id uint64)

RemoveObjectByID ...

func (*IconGroup) SetBackgroundColor

func (c *IconGroup) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*IconGroup) SetBorderColor

func (grp *IconGroup) SetBorderColor(c color.Color)

SetBorderColor sets the border color

func (*IconGroup) SetPosition

func (c *IconGroup) SetPosition(pos Point)

func (*IconGroup) SetTooltip

func (c *IconGroup) SetTooltip(s string)

SetTooltip sets the tooltip

func (*IconGroup) SetVisibility

func (c *IconGroup) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*IconGroup) Show

func (c *IconGroup) Show()

Show makes component visible

func (*IconGroup) Tooltip

func (c *IconGroup) Tooltip() *Button

Tooltip returns the current tooltip

type IconGroupObject

type IconGroupObject interface {
	Name() string
	Icon() image.Image
	Click()
	ID() uint64
}

IconGroupObject is something that is contained in the icon group

type Input

type Input struct {
	X, Y int
	// contains filtered or unexported fields
}

Input ...

func (*Input) ConsumeStateForMouse

func (i *Input) ConsumeStateForMouse(mouse MouseButton)

ConsumeStateForMouse makes the mouse state been consumed, so click-thru doesn't happen

func (*Input) StateForKey

func (i *Input) StateForKey(key Key) bool

StateForKey returns true once when the key starts to be pressed

func (*Input) StateForMouse

func (i *Input) StateForMouse(mouse MouseButton) bool

StateForMouse ...

func (*Input) WasPressed

func (i *Input) WasPressed(key Key) bool

WasPressed returns true if key was pressed (for ctrl, alt etc)

type Key

type Key int

A Key represents a keyboard key.

type Line

type Line interface {
	Text() string
}

Line defines the interface for lines of text usable with the List object

type List

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

List holds a number of rows of text, each is clickable (UI component)

func NewList

func NewList(width, height int) *List

NewList ...

func (*List) AddLine

func (lst *List) AddLine(l Line, fnt *Font, fnc func())

AddLine ...

func (*List) Click

func (lst *List) Click(mouse Point) bool

Click pass click to window child components

func (*List) Draw

func (lst *List) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*List) GetBounds

func (c *List) GetBounds() image.Rectangle

func (*List) GetPosition

func (c *List) GetPosition() Point

func (*List) Hide

func (c *List) Hide()

Hide makes component hidden

func (*List) Hover

func (c *List) Hover(b bool)

Hover sets the mouse hovering state for component

func (*List) IsClean

func (c *List) IsClean() bool

IsClean returns false if component needs redraw

func (*List) IsHidden

func (c *List) IsHidden() bool

func (*List) IsMouseOver

func (c *List) IsMouseOver() bool

func (*List) Move

func (c *List) Move(x, y int)

func (*List) RemoveAllChildren

func (c *List) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*List) SetBackgroundColor

func (c *List) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*List) SetPosition

func (c *List) SetPosition(pos Point)

func (*List) SetRowHeight

func (lst *List) SetRowHeight(n int)

SetRowHeight sets the list row height

func (*List) SetTooltip

func (c *List) SetTooltip(s string)

SetTooltip sets the tooltip

func (*List) SetVisibility

func (c *List) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*List) Show

func (c *List) Show()

Show makes component visible

func (*List) Tooltip

func (c *List) Tooltip() *Button

Tooltip returns the current tooltip

type MouseButton

type MouseButton int

A MouseButton represents a mouse button.

type Point

type Point image.Point

Point is a absolute position

func (*Point) In

func (p *Point) In(rect image.Rectangle) bool

In returns true if `p` is inside of `rect`

type Positioner

type Positioner interface {
	GetPosition() Point
	SetPosition(Point)
}

Positioner ...

type Text

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

Text is a line of text (UI component)

func NewText

func NewText(font *Font) *Text

NewText creates a new Text instance

func (*Text) Click

func (c *Text) Click(mouse Point) bool

Click returns true if click was handled

func (*Text) Draw

func (txt *Text) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*Text) GetBounds

func (c *Text) GetBounds() image.Rectangle

func (*Text) GetHeight

func (txt *Text) GetHeight() int

GetHeight returns the rendered height in pixel

func (*Text) GetPosition

func (c *Text) GetPosition() Point

func (*Text) GetText

func (txt *Text) GetText() string

GetText returns the text

func (*Text) GetWidth

func (txt *Text) GetWidth() int

GetWidth returns the rendered width in pixel

func (*Text) Hide

func (c *Text) Hide()

Hide makes component hidden

func (*Text) Hover

func (c *Text) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Text) IsClean

func (c *Text) IsClean() bool

IsClean returns false if component needs redraw

func (*Text) IsHidden

func (c *Text) IsHidden() bool

func (*Text) IsMouseOver

func (c *Text) IsMouseOver() bool

func (*Text) Move

func (c *Text) Move(x, y int)

func (*Text) RemoveAllChildren

func (c *Text) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Text) SetBackgroundColor

func (c *Text) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Text) SetFont

func (txt *Text) SetFont(font *Font)

SetFont sets the font to use

func (*Text) SetPosition

func (c *Text) SetPosition(pos Point)

func (*Text) SetText

func (txt *Text) SetText(s string) *Text

SetText sets the text

func (*Text) SetTooltip

func (c *Text) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Text) SetVisibility

func (c *Text) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Text) Show

func (c *Text) Show()

Show makes component visible

func (*Text) Tooltip

func (c *Text) Tooltip() *Button

Tooltip returns the current tooltip

type UI

type UI struct {
	WindowTitle string
	Input       Input
	// contains filtered or unexported fields
}

UI represents an instance of the UI

func New

func New(width, height int) *UI

New creates a new UI instance

func (*UI) AddComponent

func (ui *UI) AddComponent(o Component)

AddComponent adds a component to the ui

func (*UI) AddKeyFunc

func (ui *UI) AddKeyFunc(key Key, fnc func() error)

AddKeyFunc registers a function to run on key press

func (*UI) Click

func (c *UI) Click(mouse Point) bool

Click returns true if click was handled

func (*UI) GetBounds

func (c *UI) GetBounds() image.Rectangle

func (*UI) GetPosition

func (c *UI) GetPosition() Point

func (*UI) Hide

func (c *UI) Hide()

Hide makes component hidden

func (*UI) Hover

func (c *UI) Hover(b bool)

Hover sets the mouse hovering state for component

func (*UI) IsClean

func (ui *UI) IsClean() bool

IsClean returns true if all UI components are clean

func (*UI) IsHidden

func (c *UI) IsHidden() bool

func (*UI) IsMouseOver

func (c *UI) IsMouseOver() bool

func (*UI) Move

func (c *UI) Move(x, y int)

func (*UI) RemoveAllChildren

func (c *UI) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*UI) Render

func (ui *UI) Render() image.Image

Render returns a fresh frame of the GUI. mx, my is absolute mouse position

func (*UI) SetBackgroundColor

func (c *UI) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*UI) SetPosition

func (c *UI) SetPosition(pos Point)

func (*UI) SetTooltip

func (c *UI) SetTooltip(s string)

SetTooltip sets the tooltip

func (*UI) SetVisibility

func (c *UI) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*UI) SetWindowTitle

func (ui *UI) SetWindowTitle(s string)

SetWindowTitle sets the title of the application window

func (*UI) Show

func (c *UI) Show()

Show makes component visible

func (*UI) Tooltip

func (c *UI) Tooltip() *Button

Tooltip returns the current tooltip

func (*UI) Update

func (ui *UI) Update() error

Update is called on every frame from the ebiten.Run update callback

type Window

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

Window is a window (UI component)

func NewWindow

func NewWindow(width, height int, titleText string) *Window

NewWindow creates a new window with height of `height` + height of title bar

func (*Window) AddChild

func (wnd *Window) AddChild(c Component)

AddChild adds a child to the window

func (*Window) Click

func (wnd *Window) Click(mouse Point) bool

Click pass click to window child components

func (*Window) Draw

func (wnd *Window) Draw(mx, my int) *image.RGBA

Draw redraws internal buffer

func (*Window) GetBounds

func (c *Window) GetBounds() image.Rectangle

func (*Window) GetPosition

func (c *Window) GetPosition() Point

func (*Window) Hide

func (c *Window) Hide()

Hide makes component hidden

func (*Window) HideCloseButton

func (wnd *Window) HideCloseButton()

HideCloseButton ...

func (*Window) HideTitle

func (wnd *Window) HideTitle()

HideTitle ...

func (*Window) Hover

func (c *Window) Hover(b bool)

Hover sets the mouse hovering state for component

func (*Window) IsClean

func (c *Window) IsClean() bool

IsClean returns false if component needs redraw

func (*Window) IsHidden

func (c *Window) IsHidden() bool

func (*Window) IsMouseOver

func (c *Window) IsMouseOver() bool

func (*Window) Move

func (c *Window) Move(x, y int)

func (*Window) RemoveAllChildren

func (c *Window) RemoveAllChildren()

RemoveAllChildren removes all children from the component

func (*Window) SetBackgroundColor

func (c *Window) SetBackgroundColor(col color.Color)

SetBackgroundColor sets the background color

func (*Window) SetBorderColor

func (wnd *Window) SetBorderColor(col color.Color)

SetBorderColor ...

func (*Window) SetPosition

func (c *Window) SetPosition(pos Point)

func (*Window) SetTitle

func (wnd *Window) SetTitle(s string) *Window

SetTitle ...

func (*Window) SetTitleColor

func (wnd *Window) SetTitleColor(col color.Color)

SetTitleColor ...

func (*Window) SetTooltip

func (c *Window) SetTooltip(s string)

SetTooltip sets the tooltip

func (*Window) SetVisibility

func (c *Window) SetVisibility(b bool)

SetVisibility changes visibility of component

func (*Window) Show

func (c *Window) Show()

Show makes component visible

func (*Window) TitlebarHeight

func (wnd *Window) TitlebarHeight() int

TitlebarHeight ...

func (*Window) Tooltip

func (c *Window) Tooltip() *Button

Tooltip returns the current tooltip

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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