ui

package
v0.0.0-...-9a45f89 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAllAnimations

func ClearAllAnimations()

ClearAllAnimations clear all animations

func Color

func Color(s string) color.Color

Color return color

func ColorCode

func ColorCode(c color.Color) string

ColorCode show RGBA color as HTML color code. e.g. White -> #ffffffff

func Draw

func Draw(screen *ebiten.Image)

func RegisterFont

func RegisterFont(fontType FontType, f *truetype.Font)

RegisterFont register font

func Update

func Update() error

Update ui

Types

type Align

type Align int

Align is Horizontal Align

const (
	Left Align = iota
	Center
	Right
)

Align

type Animation

type Animation struct {
	IsLoop   bool
	Duration int
	Delay    int
	Ease     EasingFunc
	OnStart  AnimationFunc
	OnAnime  AnimationFunc
	OnEnd    AnimationFunc
}

Animation is animation

type AnimationFunc

type AnimationFunc func(el Element, t float64)

AnimationFunc is animate function for animation

type Box

type Box struct {
	Rect  image.Rectangle
	Color color.Color

	Image *ebiten.Image

	Parent   Element
	Children []Element
	Self     Element
	// contains filtered or unexported fields
}

Box is simple box

func NewBox

func NewBox(w, h int, c color.Color) *Box

NewBox make new Box

func NewRoot

func NewRoot(w, h int, c color.Color) *Box

func (*Box) Add

func (b *Box) Add(x, y int, child Element)

Add append child element to element

func (*Box) Clear

func (b *Box) Clear()

Clear clear children

func (*Box) Dirty

func (b *Box) Dirty()

Dirty set element isDirty

func (*Box) Hide

func (b *Box) Hide()

Hide element

func (*Box) Id

func (b *Box) Id() int

Id retruns id

func (*Box) IsVisible

func (b *Box) IsVisible() bool

IsVisible return visiblity

func (*Box) Move

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

Move move element. (x, y) is relative position from parent.

func (*Box) Position

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

Position return relative position from parent element

func (*Box) Reflesh

func (b *Box) Reflesh()

Reflesh updates internal *ebiten.Image

func (*Box) Resize

func (b *Box) Resize(w, h int)

Resize resize element

func (*Box) SetAnimation

func (b *Box) SetAnimation(a Animation)

SetAnimation set animation

func (*Box) SetBackgroundColor

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

SetBackgroundColor set background color

func (*Box) SetDrawImageOptions

func (b *Box) SetDrawImageOptions(op *ebiten.DrawImageOptions)

SetDrawImageOptions set DrawImageOptions

func (*Box) SetFocus

func (b *Box) SetFocus()

SetFocus set focus to element

func (Box) SetKeyCallback

func (k Box) SetKeyCallback(key ebiten.Key, cb Callback)

SetKeyCallback set callback function for key. set nil means delete.

func (Box) SetMouseCallback

func (cs Box) SetMouseCallback(e MouseEvent, c Callback)

SetMouseCallback set callback function to element. When set nil, it means delete

func (*Box) Show

func (b *Box) Show()

Show element

func (*Box) Size

func (b *Box) Size() (w, h int)

Size get size of element

func (*Box) StopAnimation

func (b *Box) StopAnimation()

StopAnimation stop animation

func (*Box) String

func (b *Box) String() string

String for fmt.Stringer

type Callback

type Callback func(el Element)

Callback is callback function on event

type EasingFunc

type EasingFunc func(t float64) float64

EasingFunc is easing function for animation

type Element

type Element interface {
	Id() int

	Show()
	Hide()
	IsVisible() bool

	Reflesh()
	Dirty()

	Move(x, y int)
	Position() (x, y int)
	Resize(w, h int)
	Size() (w, h int)
	SetDrawImageOptions(op *ebiten.DrawImageOptions)
	SetBackgroundColor(c color.Color)
	SetAnimation(anime Animation)
	StopAnimation()

	Add(x, y int, el Element)
	Clear()

	SetMouseCallback(e MouseEvent, c Callback)

	SetKeyCallback(key ebiten.Key, cb Callback)

	SetFocus()

	String() string
	// contains filtered or unexported methods
}

Element is ebiten UI element

type FontSize

type FontSize int

FontSize is font size

type FontType

type FontType int

FontType is font type

type Image

type Image struct {
	*Box
	Source image.Image
}

Image is simple box

func NewImage

func NewImage(w, h int, srcImg image.Image) *Image

NewImage make new *ui.Image

func (*Image) Reflesh

func (i *Image) Reflesh()

Reflesh updates internal *ebiten.Image

func (*Image) SetImage

func (i *Image) SetImage(image image.Image)

SetImage set new source Image

func (Image) SetKeyCallback

func (k Image) SetKeyCallback(key ebiten.Key, cb Callback)

SetKeyCallback set callback function for key. set nil means delete.

func (Image) SetMouseCallback

func (cs Image) SetMouseCallback(e MouseEvent, c Callback)

SetMouseCallback set callback function to element. When set nil, it means delete

func (*Image) String

func (i *Image) String() string

String for fmt.Stringer interface

type Imager

type Imager interface {
	SetImage(srcImage image.Image)
	Source() (srcImage image.Image)
}

Imager has internal image source as image.Image

type Label

type Label struct {
	*Box

	FontType
	FontSize
	FontColor color.Color
	Align
	// contains filtered or unexported fields
}

Label is simple box

func NewLabel

func NewLabel(w, h int, text string, fontType FontType, fontSize FontSize, align Align, color, bgColor color.Color) *Label

NewLabel makes new *Label

func (*Label) Reflesh

func (l *Label) Reflesh()

Reflesh updates internal *ebiten.Image

func (Label) SetKeyCallback

func (k Label) SetKeyCallback(key ebiten.Key, cb Callback)

SetKeyCallback set callback function for key. set nil means delete.

func (Label) SetMouseCallback

func (cs Label) SetMouseCallback(e MouseEvent, c Callback)

SetMouseCallback set callback function to element. When set nil, it means delete

func (*Label) SetText

func (l *Label) SetText(s string)

SetText for ui.Texter interface

func (*Label) String

func (l *Label) String() string

String for fmt.Stringer interface

func (*Label) Text

func (l *Label) Text() string

Text for ui.Texter interface

type MouseEvent

type MouseEvent int

MouseEvent is type of all UI event

const (
	LeftDown MouseEvent = iota
	RightDown
	MiddleDown
	LeftUp
	RightUp
	MiddleUp
	LeftClick
	RightClick
	MiddleClick
	LeftDoubleClick
	RightDoubleClick
	MiddleDoubleClick
	MouseOn
	MouseOver
	MouseOut
	MouseIn
	MouseEnter
	MouseLeave
)

mouseEvents

func (MouseEvent) String

func (et MouseEvent) String() string

String() for fmt.Stringer interface

type Ninepatch

type Ninepatch struct {
	*Box
	Source      image.Image
	ContentArea image.Rectangle
}

Ninepatch is nine-patch image

func NewNinepatch

func NewNinepatch(w, h int, srcImg image.Image, contentArea image.Rectangle) *Ninepatch

NewNinepatch make new *ui.Ninepatch

func (*Ninepatch) Reflesh

func (n *Ninepatch) Reflesh()

Reflesh updates internal *ebiten.Image

func (Ninepatch) SetKeyCallback

func (k Ninepatch) SetKeyCallback(key ebiten.Key, cb Callback)

SetKeyCallback set callback function for key. set nil means delete.

func (Ninepatch) SetMouseCallback

func (cs Ninepatch) SetMouseCallback(e MouseEvent, c Callback)

SetMouseCallback set callback function to element. When set nil, it means delete

func (*Ninepatch) String

func (n *Ninepatch) String() string

String for fmt.Stringer interface

type RichLabel

type RichLabel struct {
	*Label
	LineHeight int
	VerticalAlign
}

RichLabel is rich label

func NewRichLabel

func NewRichLabel(w, h, lineHeight int, text string, fontType FontType, fontSize FontSize, align Align, valign VerticalAlign, color, bgColor color.Color) *RichLabel

NewRichLabel makes new *RichLabel

func (*RichLabel) Reflesh

func (l *RichLabel) Reflesh()

Reflesh updates internal *ebiten.Image

func (RichLabel) SetKeyCallback

func (k RichLabel) SetKeyCallback(key ebiten.Key, cb Callback)

SetKeyCallback set callback function for key. set nil means delete.

func (RichLabel) SetMouseCallback

func (cs RichLabel) SetMouseCallback(e MouseEvent, c Callback)

SetMouseCallback set callback function to element. When set nil, it means delete

func (*RichLabel) String

func (l *RichLabel) String() string

String for fmt.Stringer interface

type Texter

type Texter interface {
	SetText(text string)
	Text() (text string)
}

Texter has internal text as string

type VerticalAlign

type VerticalAlign int

VerticalAlign is Vertical Align

const (
	Top VerticalAlign = iota
	Middle
	Bottom
)

VerticalAlign

Jump to

Keyboard shortcuts

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