Documentation ¶
Index ¶
- Constants
- Variables
- func CheckUI(ui *UI) bool
- func DecodeImage(r io.Reader) (image.Image, error)
- func DrawRect(img draw.Image, r image.Rectangle, col color.Color)
- func LoadTiles(imgFile string, tileWidth, tileHeight int) (res []image.Image)
- func OpenImage(filename string) (image.Image, error)
- func RequireImage(filename string) image.Image
- type Bar
- func (c *Bar) Click(mouse Point) bool
- func (bar *Bar) Draw(mx, my int) *image.RGBA
- func (c *Bar) GetBounds() image.Rectangle
- func (c *Bar) GetPosition() Point
- func (bar *Bar) GetValue() int
- func (c *Bar) Hide()
- func (c *Bar) Hover(b bool)
- func (bar *Bar) IncValue(i int) int
- func (c *Bar) IsClean() bool
- func (c *Bar) IsHidden() bool
- func (c *Bar) IsMouseOver() bool
- func (c *Bar) Move(x, y int)
- func (c *Bar) RemoveAllChildren()
- func (c *Bar) SetBackgroundColor(col color.Color)
- func (bar *Bar) SetBorderColor(c color.Color)
- func (bar *Bar) SetFillColor(c color.Color)
- func (bar *Bar) SetFillImage(img image.Image)
- func (c *Bar) SetPosition(pos Point)
- func (c *Bar) SetTooltip(s string)
- func (bar *Bar) SetValue(v int)
- func (c *Bar) SetVisibility(b bool)
- func (c *Bar) Show()
- func (c *Bar) Tooltip() *Button
- type Button
- func (c *Button) Click(mouse Point) bool
- func (btn *Button) Draw(mx, my int) *image.RGBA
- func (c *Button) GetBounds() image.Rectangle
- func (c *Button) GetPosition() Point
- func (c *Button) Hide()
- func (c *Button) Hover(b bool)
- func (c *Button) IsClean() bool
- func (c *Button) IsHidden() bool
- func (c *Button) IsMouseOver() bool
- func (c *Button) Move(x, y int)
- func (c *Button) RemoveAllChildren()
- func (c *Button) SetBackgroundColor(col color.Color)
- func (btn *Button) SetBorderColor(c color.Color)
- func (btn *Button) SetIcon(img image.Image)
- func (c *Button) SetPosition(pos Point)
- func (btn *Button) SetText(fnt *Font, s string) *Button
- func (c *Button) SetTooltip(s string)
- func (c *Button) SetVisibility(b bool)
- func (c *Button) Show()
- func (c *Button) Tooltip() *Button
- type Color
- type Component
- type Dimension
- type Font
- type GracefulExitError
- type Group
- func (grp *Group) AddChild(c Component)
- func (grp *Group) Click(mouse Point) bool
- func (grp *Group) Draw(mx, my int) *image.RGBA
- func (c *Group) GetBounds() image.Rectangle
- func (c *Group) GetPosition() Point
- func (c *Group) Hide()
- func (c *Group) Hover(b bool)
- func (c *Group) IsClean() bool
- func (c *Group) IsHidden() bool
- func (c *Group) IsMouseOver() bool
- func (c *Group) Move(x, y int)
- func (c *Group) RemoveAllChildren()
- func (c *Group) SetBackgroundColor(col color.Color)
- func (c *Group) SetPosition(pos Point)
- func (c *Group) SetTooltip(s string)
- func (c *Group) SetVisibility(b bool)
- func (c *Group) Show()
- func (c *Group) Tooltip() *Button
- type Icon
- func (c *Icon) Click(mouse Point) bool
- func (ico *Icon) Draw(mx, my int) *image.RGBA
- func (c *Icon) GetBounds() image.Rectangle
- func (c *Icon) GetPosition() Point
- func (c *Icon) Hide()
- func (c *Icon) Hover(b bool)
- func (c *Icon) IsClean() bool
- func (c *Icon) IsHidden() bool
- func (c *Icon) IsMouseOver() bool
- func (c *Icon) Move(x, y int)
- func (c *Icon) RemoveAllChildren()
- func (c *Icon) SetBackgroundColor(col color.Color)
- func (ico *Icon) SetIcon(img image.Image)
- func (c *Icon) SetPosition(pos Point)
- func (c *Icon) SetTooltip(s string)
- func (c *Icon) SetVisibility(b bool)
- func (c *Icon) Show()
- func (c *Icon) Tooltip() *Button
- type IconGroup
- func (grp *IconGroup) AddObject(o IconGroupObject)
- func (grp *IconGroup) Click(mouse Point) bool
- func (grp *IconGroup) Draw(mx, my int) *image.RGBA
- func (c *IconGroup) GetBounds() image.Rectangle
- func (c *IconGroup) GetPosition() Point
- func (c *IconGroup) Hide()
- func (c *IconGroup) Hover(b bool)
- func (c *IconGroup) IsClean() bool
- func (c *IconGroup) IsHidden() bool
- func (c *IconGroup) IsMouseOver() bool
- func (c *IconGroup) Move(x, y int)
- func (c *IconGroup) RemoveAllChildren()
- func (grp *IconGroup) RemoveAllObjects()
- func (grp *IconGroup) RemoveObjectByID(id uint64)
- func (c *IconGroup) SetBackgroundColor(col color.Color)
- func (grp *IconGroup) SetBorderColor(c color.Color)
- func (c *IconGroup) SetPosition(pos Point)
- func (c *IconGroup) SetTooltip(s string)
- func (c *IconGroup) SetVisibility(b bool)
- func (c *IconGroup) Show()
- func (c *IconGroup) Tooltip() *Button
- type IconGroupObject
- type Input
- type Key
- type Line
- type List
- func (lst *List) AddLine(l Line, fnt *Font, fnc func())
- func (lst *List) Click(mouse Point) bool
- func (lst *List) Draw(mx, my int) *image.RGBA
- func (c *List) GetBounds() image.Rectangle
- func (c *List) GetPosition() Point
- func (c *List) Hide()
- func (c *List) Hover(b bool)
- func (c *List) IsClean() bool
- func (c *List) IsHidden() bool
- func (c *List) IsMouseOver() bool
- func (c *List) Move(x, y int)
- func (c *List) RemoveAllChildren()
- func (c *List) SetBackgroundColor(col color.Color)
- func (c *List) SetPosition(pos Point)
- func (lst *List) SetRowHeight(n int)
- func (c *List) SetTooltip(s string)
- func (c *List) SetVisibility(b bool)
- func (c *List) Show()
- func (c *List) Tooltip() *Button
- type MouseButton
- type Point
- type Positioner
- type Text
- func (c *Text) Click(mouse Point) bool
- func (txt *Text) Draw(mx, my int) *image.RGBA
- func (c *Text) GetBounds() image.Rectangle
- func (txt *Text) GetHeight() int
- func (c *Text) GetPosition() Point
- func (txt *Text) GetText() string
- func (txt *Text) GetWidth() int
- func (c *Text) Hide()
- func (c *Text) Hover(b bool)
- func (c *Text) IsClean() bool
- func (c *Text) IsHidden() bool
- func (c *Text) IsMouseOver() bool
- func (c *Text) Move(x, y int)
- func (c *Text) RemoveAllChildren()
- func (c *Text) SetBackgroundColor(col color.Color)
- func (txt *Text) SetFont(font *Font)
- func (c *Text) SetPosition(pos Point)
- func (txt *Text) SetText(s string) *Text
- func (c *Text) SetTooltip(s string)
- func (c *Text) SetVisibility(b bool)
- func (c *Text) Show()
- func (c *Text) Tooltip() *Button
- type UI
- func (ui *UI) AddComponent(o Component)
- func (ui *UI) AddKeyFunc(key Key, fnc func() error)
- func (c *UI) Click(mouse Point) bool
- func (c *UI) GetBounds() image.Rectangle
- func (c *UI) GetPosition() Point
- func (c *UI) Hide()
- func (c *UI) Hover(b bool)
- func (ui *UI) IsClean() bool
- func (c *UI) IsHidden() bool
- func (c *UI) IsMouseOver() bool
- func (c *UI) Move(x, y int)
- func (c *UI) RemoveAllChildren()
- func (ui *UI) Render() image.Image
- func (c *UI) SetBackgroundColor(col color.Color)
- func (c *UI) SetPosition(pos Point)
- func (c *UI) SetTooltip(s string)
- func (c *UI) SetVisibility(b bool)
- func (ui *UI) SetWindowTitle(s string)
- func (c *UI) Show()
- func (c *UI) Tooltip() *Button
- func (ui *UI) Update() error
- type Window
- func (wnd *Window) AddChild(c Component)
- func (wnd *Window) Click(mouse Point) bool
- func (wnd *Window) Draw(mx, my int) *image.RGBA
- func (c *Window) GetBounds() image.Rectangle
- func (c *Window) GetPosition() Point
- func (c *Window) Hide()
- func (wnd *Window) HideCloseButton()
- func (wnd *Window) HideTitle()
- func (c *Window) Hover(b bool)
- func (c *Window) IsClean() bool
- func (c *Window) IsHidden() bool
- func (c *Window) IsMouseOver() bool
- func (c *Window) Move(x, y int)
- func (c *Window) RemoveAllChildren()
- func (c *Window) SetBackgroundColor(col color.Color)
- func (wnd *Window) SetBorderColor(col color.Color)
- func (c *Window) SetPosition(pos Point)
- func (wnd *Window) SetTitle(s string) *Window
- func (wnd *Window) SetTitleColor(col color.Color)
- func (c *Window) SetTooltip(s string)
- func (c *Window) SetVisibility(b bool)
- func (c *Window) Show()
- func (wnd *Window) TitlebarHeight() int
- func (c *Window) Tooltip() *Button
Constants ¶
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
const ( MouseButtonLeft = MouseButton(ebiten.MouseButtonLeft) MouseButtonRight = MouseButton(ebiten.MouseButtonRight) MouseButtonMiddle = MouseButton(ebiten.MouseButtonMiddle) )
MouseButtons
Variables ¶
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 ¶
CheckUI performs some sanity checks on the UI instance in order to detect programmatic errors returns true if checks passed
func DecodeImage ¶
DecodeImage reads an image from r
func OpenImage ¶
OpenImage loads an image from file. based on Open from disintegration/imaging https://github.com/disintegration/imaging/blob/master/helpers.go#L68
func RequireImage ¶
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 (*Bar) GetPosition ¶
func (c *Bar) GetPosition() Point
func (*Bar) IsMouseOver ¶
func (c *Bar) IsMouseOver() bool
func (*Bar) RemoveAllChildren ¶
func (c *Bar) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Bar) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Bar) SetBorderColor ¶
SetBorderColor sets the border color
func (*Bar) SetFillColor ¶
SetFillColor sets the fill color
func (*Bar) SetFillImage ¶
SetFillImage sets the fill image. If set, is used instead of fill color
func (*Bar) SetPosition ¶
func (c *Bar) SetPosition(pos Point)
func (*Bar) SetVisibility ¶
func (c *Bar) SetVisibility(b bool)
SetVisibility changes visibility of component
type Button ¶
type Button struct { Text *Text // contains filtered or unexported fields }
Button is a button (UI component)
func (*Button) GetPosition ¶
func (c *Button) GetPosition() Point
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) IsMouseOver ¶
func (c *Button) IsMouseOver() bool
func (*Button) RemoveAllChildren ¶
func (c *Button) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Button) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Button) SetBorderColor ¶
SetBorderColor sets the border color
func (*Button) SetPosition ¶
func (c *Button) SetPosition(pos Point)
func (*Button) SetVisibility ¶
func (c *Button) SetVisibility(b bool)
SetVisibility changes visibility of component
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
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 (*Group) GetPosition ¶
func (c *Group) GetPosition() Point
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) IsMouseOver ¶
func (c *Group) IsMouseOver() bool
func (*Group) RemoveAllChildren ¶
func (c *Group) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Group) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Group) SetPosition ¶
func (c *Group) SetPosition(pos Point)
func (*Group) SetVisibility ¶
func (c *Group) SetVisibility(b bool)
SetVisibility changes visibility of component
type Icon ¶
type Icon struct {
// contains filtered or unexported fields
}
Icon is a icon (UI component)
func (*Icon) GetPosition ¶
func (c *Icon) GetPosition() Point
func (*Icon) IsClean ¶
func (c *Icon) IsClean() bool
IsClean returns false if component needs redraw
func (*Icon) IsMouseOver ¶
func (c *Icon) IsMouseOver() bool
func (*Icon) RemoveAllChildren ¶
func (c *Icon) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Icon) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Icon) SetPosition ¶
func (c *Icon) SetPosition(pos Point)
func (*Icon) SetVisibility ¶
func (c *Icon) SetVisibility(b bool)
SetVisibility changes visibility of component
type IconGroup ¶
type IconGroup struct {
// contains filtered or unexported fields
}
IconGroup is a tile-hased grid display of object icons
func NewIconGroup ¶
NewIconGroup ...
func (*IconGroup) AddObject ¶
func (grp *IconGroup) AddObject(o IconGroupObject)
AddObject adds an object to display in the group
func (*IconGroup) GetPosition ¶
func (c *IconGroup) GetPosition() Point
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) IsMouseOver ¶
func (c *IconGroup) IsMouseOver() bool
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 ¶
RemoveObjectByID ...
func (*IconGroup) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*IconGroup) SetBorderColor ¶
SetBorderColor sets the border color
func (*IconGroup) SetPosition ¶
func (c *IconGroup) SetPosition(pos Point)
func (*IconGroup) SetVisibility ¶
func (c *IconGroup) SetVisibility(b bool)
SetVisibility changes visibility of component
type IconGroupObject ¶
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 ¶
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 ¶
WasPressed returns true if key was pressed (for ctrl, alt etc)
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 (*List) GetPosition ¶
func (c *List) GetPosition() Point
func (*List) IsClean ¶
func (c *List) IsClean() bool
IsClean returns false if component needs redraw
func (*List) IsMouseOver ¶
func (c *List) IsMouseOver() bool
func (*List) RemoveAllChildren ¶
func (c *List) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*List) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*List) SetPosition ¶
func (c *List) SetPosition(pos Point)
func (*List) SetRowHeight ¶
SetRowHeight sets the list row height
func (*List) SetVisibility ¶
func (c *List) SetVisibility(b bool)
SetVisibility changes visibility of component
type Positioner ¶
Positioner ...
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text is a line of text (UI component)
func (*Text) GetPosition ¶
func (c *Text) GetPosition() Point
func (*Text) IsClean ¶
func (c *Text) IsClean() bool
IsClean returns false if component needs redraw
func (*Text) IsMouseOver ¶
func (c *Text) IsMouseOver() bool
func (*Text) RemoveAllChildren ¶
func (c *Text) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Text) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Text) SetPosition ¶
func (c *Text) SetPosition(pos Point)
func (*Text) SetVisibility ¶
func (c *Text) SetVisibility(b bool)
SetVisibility changes visibility of component
type UI ¶
UI represents an instance of the UI
func (*UI) AddComponent ¶
AddComponent adds a component to the ui
func (*UI) AddKeyFunc ¶
AddKeyFunc registers a function to run on key press
func (*UI) GetPosition ¶
func (c *UI) GetPosition() Point
func (*UI) IsMouseOver ¶
func (c *UI) IsMouseOver() bool
func (*UI) RemoveAllChildren ¶
func (c *UI) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*UI) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*UI) SetPosition ¶
func (c *UI) SetPosition(pos Point)
func (*UI) SetVisibility ¶
func (c *UI) SetVisibility(b bool)
SetVisibility changes visibility of component
func (*UI) SetWindowTitle ¶
SetWindowTitle sets the title of the application window
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a window (UI component)
func (*Window) GetPosition ¶
func (c *Window) GetPosition() Point
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) IsMouseOver ¶
func (c *Window) IsMouseOver() bool
func (*Window) RemoveAllChildren ¶
func (c *Window) RemoveAllChildren()
RemoveAllChildren removes all children from the component
func (*Window) SetBackgroundColor ¶
SetBackgroundColor sets the background color
func (*Window) SetBorderColor ¶
SetBorderColor ...
func (*Window) SetPosition ¶
func (c *Window) SetPosition(pos Point)
func (*Window) SetVisibility ¶
func (c *Window) SetVisibility(b bool)
SetVisibility changes visibility of component