...

Package etk

Overview ▾

Package etk provides an Ebitengine tool kit for creating graphical user interfaces.

Index ▾

Variables
func Draw(screen *ebiten.Image) error
func Layout(outsideWidth, outsideHeight int)
func SetRoot(w Widget)
func Update() error
type Attributes
type Box
    func NewBox() *Box
    func (b *Box) AddChild(w ...Widget)
    func (b *Box) Children() []Widget
    func (b *Box) Rect() image.Rectangle
    func (b *Box) SetRect(r image.Rectangle)
type Button
    func NewButton(label string, onSelected func() error) *Button
    func (b *Button) Draw(screen *ebiten.Image) error
    func (b *Button) HandleKeyboard() (handled bool, err error)
    func (b *Button) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    func (b *Button) SetRect(r image.Rectangle)
type Flex
    func NewFlex() *Flex
    func (f *Flex) Draw(screen *ebiten.Image) error
    func (f *Flex) HandleKeyboard() (handled bool, err error)
    func (f *Flex) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    func (f *Flex) SetRect(r image.Rectangle)
    func (f *Flex) SetVertical(v bool)
type Input
    func NewInput(prefix string, text string, onSelected func(text string) (handled bool)) *Input
    func (i *Input) Clear()
    func (i *Input) Draw(screen *ebiten.Image) error
    func (i *Input) HandleKeyboard() (handled bool, err error)
    func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    func (i *Input) SetRect(r image.Rectangle)
    func (i *Input) Text() string
    func (i *Input) Write(p []byte) (n int, err error)
type Shortcuts
type Text
    func NewText(text string) *Text
    func (t *Text) Clear()
    func (t *Text) Draw(screen *ebiten.Image) error
    func (t *Text) HandleKeyboard() (handled bool, err error)
    func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    func (t *Text) SetRect(r image.Rectangle)
    func (t *Text) Text() string
    func (t *Text) Write(p []byte) (n int, err error)
type Widget
type Window
    func NewWindow() *Window
    func (w *Window) AddChild(wgt ...Widget)
    func (w *Window) AddChildWithLabel(wgt Widget, label string)
    func (w *Window) Draw(screen *ebiten.Image) error
    func (w *Window) HandleKeyboard() (handled bool, err error)
    func (w *Window) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    func (w *Window) SetRect(r image.Rectangle)

Package files

box.go button.go doc.go flex.go game.go input.go keybind.go style.go text.go widget.go window.go

Variables

var Bindings = &Shortcuts{
    ConfirmKeyboard: []ebiten.Key{ebiten.KeyEnter, ebiten.KeyKPEnter},
    ConfirmMouse:    []ebiten.MouseButton{ebiten.MouseButtonLeft},
    ConfirmGamepad:  []ebiten.GamepadButton{ebiten.GamepadButton0},
}
var Style = &Attributes{
    TextFont: defaultFont(),

    TextColorLight: color.RGBA{255, 255, 255, 255},
    TextColorDark:  color.RGBA{0, 0, 0, 255},

    TextBgColor: transparent,

    BorderColor: color.RGBA{0, 0, 0, 255},

    InputBgColor: color.RGBA{0, 128, 0, 255},

    ButtonBgColor:         color.RGBA{255, 255, 255, 255},
    ButtonBgColorDisabled: color.RGBA{110, 110, 110, 255},
}

func Draw

func Draw(screen *ebiten.Image) error

func Layout

func Layout(outsideWidth, outsideHeight int)

func SetRoot

func SetRoot(w Widget)

func Update

func Update() error

type Attributes

type Attributes struct {
    TextFont font.Face

    TextColorLight color.Color
    TextColorDark  color.Color

    TextBgColor color.Color

    BorderColor color.Color

    InputBgColor color.Color

    ButtonTextColor       color.Color
    ButtonBgColor         color.Color
    ButtonBgColorDisabled color.Color
}

type Box

type Box struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewBox

func NewBox() *Box

func (*Box) AddChild

func (b *Box) AddChild(w ...Widget)

func (*Box) Children

func (b *Box) Children() []Widget

func (*Box) Rect

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

func (*Box) SetRect

func (b *Box) SetRect(r image.Rectangle)

type Button

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

func NewButton

func NewButton(label string, onSelected func() error) *Button

func (*Button) Draw

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

func (*Button) HandleKeyboard

func (b *Button) HandleKeyboard() (handled bool, err error)

func (*Button) HandleMouse

func (b *Button) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*Button) SetRect

func (b *Button) SetRect(r image.Rectangle)

type Flex

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

func NewFlex

func NewFlex() *Flex

func (*Flex) Draw

func (f *Flex) Draw(screen *ebiten.Image) error

func (*Flex) HandleKeyboard

func (f *Flex) HandleKeyboard() (handled bool, err error)

func (*Flex) HandleMouse

func (f *Flex) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*Flex) SetRect

func (f *Flex) SetRect(r image.Rectangle)

func (*Flex) SetVertical

func (f *Flex) SetVertical(v bool)

type Input

type Input struct {
    *Box
    Field *messeji.InputField
}

func NewInput

func NewInput(prefix string, text string, onSelected func(text string) (handled bool)) *Input

func (*Input) Clear

func (i *Input) Clear()

Clear clears the field's buffer.

func (*Input) Draw

func (i *Input) Draw(screen *ebiten.Image) error

func (*Input) HandleKeyboard

func (i *Input) HandleKeyboard() (handled bool, err error)

func (*Input) HandleMouse

func (i *Input) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*Input) SetRect

func (i *Input) SetRect(r image.Rectangle)

func (*Input) Text

func (i *Input) Text() string

func (*Input) Write

func (i *Input) Write(p []byte) (n int, err error)

Write writes to the field's buffer.

type Shortcuts

type Shortcuts struct {
    ConfirmKeyboard []ebiten.Key
    ConfirmMouse    []ebiten.MouseButton
    ConfirmGamepad  []ebiten.GamepadButton
}

type Text

type Text struct {
    *Box
    Field *messeji.TextField
}

func NewText

func NewText(text string) *Text

func (*Text) Clear

func (t *Text) Clear()

Clear clears the field's buffer.

func (*Text) Draw

func (t *Text) Draw(screen *ebiten.Image) error

func (*Text) HandleKeyboard

func (t *Text) HandleKeyboard() (handled bool, err error)

func (*Text) HandleMouse

func (t *Text) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*Text) SetRect

func (t *Text) SetRect(r image.Rectangle)

func (*Text) Text

func (t *Text) Text() string

func (*Text) Write

func (t *Text) Write(p []byte) (n int, err error)

Write writes to the field's buffer.

type Widget

type Widget interface {
    Rect() image.Rectangle
    SetRect(r image.Rectangle)
    HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)
    HandleKeyboard() (handled bool, err error)
    Draw(screen *ebiten.Image) error
    Children() []Widget
}

type Window

Window displays and passes input to only one child widget at a time.

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

func NewWindow

func NewWindow() *Window

func (*Window) AddChild

func (w *Window) AddChild(wgt ...Widget)

func (*Window) AddChildWithLabel

func (w *Window) AddChildWithLabel(wgt Widget, label string)

func (*Window) Draw

func (w *Window) Draw(screen *ebiten.Image) error

func (*Window) HandleKeyboard

func (w *Window) HandleKeyboard() (handled bool, err error)

func (*Window) HandleMouse

func (w *Window) HandleMouse(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*Window) SetRect

func (w *Window) SetRect(r image.Rectangle)

Subdirectories

Name Synopsis
..
examples
flex
showcase