egui

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: Apache-2.0 Imports: 13 Imported by: 1

README

egui

Ebiten Graphical User Interface (and Framework)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrElementNameInvalid is returned when a element name has invalid characters or too short
	ErrElementNameInvalid = fmt.Errorf("element name invalid")
	// ErrElementAlreadyExists is returned when a element already exists
	ErrElementAlreadyExists = fmt.Errorf("element already exists")
	// ErrElementNotFound is returned when a element is not loaded into the UI
	ErrElementNotFound = fmt.Errorf("element not found")
	// ErrResourceNameInvalid is returned when a resource name has invalid characters or too short
	ErrResourceNameInvalid = fmt.Errorf("resource name invalid")
	// ErrResourceAlreadyExists is returned when a resource already exists
	ErrResourceAlreadyExists = fmt.Errorf("resource already exists")
	// ErrResourceNotFound is returned when a resource was not found
	ErrResourceNotFound = fmt.Errorf("resource not found")
	// ErrSceneNameInvalid is returned when a scene name has invalid characters or too short
	ErrSceneNameInvalid = fmt.Errorf("scene name invalid")
	// ErrSceneAlreadyExists is returned when a Scene already exists
	ErrSceneAlreadyExists = fmt.Errorf("scene already exists")
	// ErrSceneNotFound is returned when a scene is not loaded into the UI
	ErrSceneNotFound = fmt.Errorf("scene not found")
)

Functions

This section is empty.

Types

type Button

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

Button represents a UI Button element

func (*Button) AlignmentRead

func (e *Button) AlignmentRead() int

AlignmentRead returns the alignment style

func (*Button) AlignmentUpdate

func (e *Button) AlignmentUpdate(alignment int)

AlignmentUpdate changes the alignment of the element

func (*Button) EnabledRead

func (e *Button) EnabledRead() bool

EnabledRead returns true if a button is enabled

func (*Button) EnabledUpdate

func (e *Button) EnabledUpdate(isEnabled bool)

EnabledUpdate changes if a button is enabled

func (*Button) IsDestroyed

func (e *Button) IsDestroyed() bool

IsDestroyed returns true when the element is flagged for deletion

func (*Button) IsVisible

func (e *Button) IsVisible() bool

IsVisible returns true if mob is visible

func (*Button) LerpPosition

func (e *Button) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())

LerpPosition changes an element's position over duration

func (*Button) NameRead

func (e *Button) NameRead() string

NameRead returns a mob's name

func (*Button) RenderIndexRead

func (e *Button) RenderIndexRead() int64

RenderIndexRead returns the render index of element

func (*Button) RenderIndexUpdate

func (e *Button) RenderIndexUpdate(renderIndex int64)

RenderIndexUpdate sets the render index of element

func (*Button) SetOnPressFunction

func (e *Button) SetOnPressFunction(f func())

SetOnPressFunction lets you pass a function without the need of button handling

func (*Button) SetOnPressed

func (e *Button) SetOnPressed(f func(e *Button))

SetOnPressed sets a button state

func (*Button) SetShape

func (e *Button) SetShape(shape common.Rectangle)

SetShape sets an element's X/Y position as well as width/height

func (*Button) Shape

func (e *Button) Shape() *common.Rectangle

Shape returns an element's X/Y position as well as width/height

func (*Button) TextUpdate

func (e *Button) TextUpdate(text string)

TextUpdate changes the text on the button

func (*Button) VisibleRead

func (e *Button) VisibleRead() bool

VisibleRead returns true if a button is visible

func (*Button) VisibleUpdate

func (e *Button) VisibleUpdate(isVisible bool)

VisibleUpdate changes the visibility of a button

type Frame

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

Frame represents a UI Frame element

func (*Frame) AlignmentRead

func (e *Frame) AlignmentRead() int

AlignmentRead returns the alignment style

func (*Frame) AlignmentUpdate

func (e *Frame) AlignmentUpdate(alignment int)

AlignmentUpdate changes the alignment of the element

func (*Frame) EnabledRead

func (e *Frame) EnabledRead() bool

EnabledRead returns true if a Frame is enabled

func (*Frame) EnabledUpdate

func (e *Frame) EnabledUpdate(isEnabled bool)

EnabledUpdate changes if a Frame is enabled

func (*Frame) IsDestroyed

func (e *Frame) IsDestroyed() bool

IsDestroyed returns true when the element is flagged for deletion

func (*Frame) IsVisible

func (e *Frame) IsVisible() bool

IsVisible returns true if mob is visible

func (*Frame) LerpPosition

func (e *Frame) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())

LerpPosition changes an element's position over duration

func (*Frame) NameRead

func (e *Frame) NameRead() string

NameRead returns a mob's name

func (*Frame) RenderIndexRead

func (e *Frame) RenderIndexRead() int64

RenderIndexRead returns the render index of element

func (*Frame) RenderIndexUpdate

func (e *Frame) RenderIndexUpdate(renderIndex int64)

RenderIndexUpdate sets the render index of element

func (*Frame) SetOnPressFunction

func (e *Frame) SetOnPressFunction(f func())

SetOnPressFunction lets you pass a function without the need of Frame handling

func (*Frame) SetOnPressed

func (e *Frame) SetOnPressed(f func(e *Frame))

SetOnPressed sets a Frame state

func (*Frame) SetShape

func (e *Frame) SetShape(shape common.Rectangle)

SetShape sets an element's X/Y position as well as width/height

func (*Frame) Shape

func (e *Frame) Shape() *common.Rectangle

Shape returns an element's X/Y position as well as width/height

func (*Frame) TextUpdate

func (e *Frame) TextUpdate(text string)

TextUpdate changes the text on the Frame

func (*Frame) VisibleRead

func (e *Frame) VisibleRead() bool

VisibleRead returns true if a Frame is visible

func (*Frame) VisibleUpdate

func (e *Frame) VisibleUpdate(isVisible bool)

VisibleUpdate changes the visibility of a Frame

type Interfacer

type Interfacer interface {
	//TargetPositionUpdate(tp *common.Vector, duration time.Duration)
	EnabledRead() bool
	EnabledUpdate(isEnabled bool)
	VisibleRead() bool
	VisibleUpdate(isVisible bool)

	IsVisible() bool

	NameRead() string
	RenderIndexRead() int64
	RenderIndexUpdate(renderIndex int64)
	IsDestroyed() bool
	// Shape returns the shape of an element
	Shape() *common.Rectangle
	// SetShape sets the shape of an element
	SetShape(shape common.Rectangle)
	LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
	TextUpdate(string)
	// contains filtered or unexported methods
}

Interfacer is a generic user interface wrapper

type Label

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

Label represents a UI label element

func (*Label) EnabledRead

func (e *Label) EnabledRead() bool

EnabledRead returns true if a button is enabled

func (*Label) EnabledUpdate

func (e *Label) EnabledUpdate(isEnabled bool)

EnabledUpdate changes if a button is enabled

func (*Label) IsDestroyed

func (e *Label) IsDestroyed() bool

IsDestroyed returns true when the element is flagged for deletion

func (*Label) IsVisible

func (e *Label) IsVisible() bool

IsVisible returns true if element should be shown

func (*Label) LerpColor

func (e *Label) LerpColor(endColor color.Color, duration time.Duration, isDestroyed bool, endFunc func())

LerpColor changes the label's color over duration

func (*Label) LerpPosition

func (e *Label) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())

LerpPosition changes an element's position over duration

func (*Label) NameRead

func (e *Label) NameRead() string

NameRead returns an element's name

func (*Label) RenderIndexRead

func (e *Label) RenderIndexRead() int64

RenderIndexRead returns the render index of element

func (*Label) RenderIndexUpdate

func (e *Label) RenderIndexUpdate(renderIndex int64)

RenderIndexUpdate sets the render index of element

func (*Label) SetOnPressFunction

func (e *Label) SetOnPressFunction(f func())

SetOnPressFunction lets you pass a function without the need of label handling

func (*Label) SetOnPressed

func (e *Label) SetOnPressed(f func(e *Label))

SetOnPressed sets a label state

func (*Label) SetShape

func (e *Label) SetShape(shape common.Rectangle)

SetShape sets an element's X/Y position as well as width/height

func (*Label) Shape

func (e *Label) Shape() *common.Rectangle

Shape returns an element's X/Y position as well as width/height

func (*Label) TextUpdate

func (e *Label) TextUpdate(text string)

TextUpdate changes the text on the label

func (*Label) VisibleRead

func (e *Label) VisibleRead() bool

VisibleRead returns true if a button is visible

func (*Label) VisibleUpdate

func (e *Label) VisibleUpdate(isVisible bool)

VisibleUpdate changes the visibility of a button

type Scene

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

Scene represents a layout of ui

func NewScene

func NewScene() (s *Scene)

NewScene initializes a new scene

func (*Scene) AddElement

func (s *Scene) AddElement(e Interfacer) error

AddElement adds an element to the scene list

func (*Scene) Element

func (s *Scene) Element(name string) (Interfacer, error)

Element returns an element based on name

func (*Scene) RemoveElement

func (s *Scene) RemoveElement(name string) error

RemoveElement flags an element to be removed next update

type UI

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

UI contains core game components

func NewUI

func NewUI(font font.Face, fontMHeight int, screenResolution image.Point) (*UI, error)

NewUI instantiates a new User Interface

func (*UI) AddResource

func (u *UI) AddResource(name string, img *ebiten.Image) error

AddResource adds an image resource to ui

func (*UI) AddScene

func (u *UI) AddScene(name string, scene *Scene) error

AddScene appends a new scene to the UI

func (*UI) CurrentScene

func (u *UI) CurrentScene() *Scene

CurrentScene returns the current scene

func (*UI) NewButton

func (u *UI) NewButton(name string, resourceName string, scene string, text string, shape *common.Rectangle, textColor color.Color) (*Button, error)

NewButton creates a new button instance

func (*UI) NewFrame

func (u *UI) NewFrame(name string, resourceName string, text string, shape *common.Rectangle) (e *Frame, err error)

NewFrame creates a new Frame instance

func (*UI) NewLabel

func (u *UI) NewLabel(name string, text string, shape common.Rectangle, color color.Color) (e *Label, err error)

NewLabel creates a new label instance

func (*UI) Resolution

func (u *UI) Resolution() image.Point

Resolution returns the resolution

func (*UI) Resource

func (u *UI) Resource(name string) (*ebiten.Image, error)

Resource returns named resource

func (*UI) Scene

func (u *UI) Scene(name string) (*Scene, error)

Scene gets a scene

func (*UI) SetCurrentScene

func (u *UI) SetCurrentScene(name string) error

SetCurrentScene sets current scene

func (*UI) SetResolution

func (u *UI) SetResolution(resolution image.Point)

SetResolution changes the resolution of the UI

func (*UI) Update

func (u *UI) Update(image *ebiten.Image) error

Update updates all UI elements

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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