ui

package
v0.0.0-...-8a8a644 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseElement

type BaseElement struct {
	X, Y          float64
	Width, Height float64
	Visible       bool
	Enabled       bool
	Children      []UIElement
	Parent        UIElement
}

func NewBaseElement

func NewBaseElement(x, y, width, height float64) *BaseElement

func (*BaseElement) AddChild

func (b *BaseElement) AddChild(child UIElement)

func (*BaseElement) Draw

func (b *BaseElement) Draw(screen *ebiten.Image)

func (*BaseElement) GetChildren

func (b *BaseElement) GetChildren() []UIElement

func (*BaseElement) GetPosition

func (b *BaseElement) GetPosition() (float64, float64)

func (*BaseElement) GetSize

func (b *BaseElement) GetSize() (float64, float64)

func (*BaseElement) HandleInput

func (b *BaseElement) HandleInput(input *InputState)

func (*BaseElement) IsEnabled

func (b *BaseElement) IsEnabled() bool

func (*BaseElement) IsMouseOver

func (b *BaseElement) IsMouseOver(mouseX, mouseY int) bool

func (*BaseElement) IsVisible

func (b *BaseElement) IsVisible() bool

func (*BaseElement) SetEnabled

func (b *BaseElement) SetEnabled(enabled bool)

func (*BaseElement) SetPosition

func (b *BaseElement) SetPosition(x, y float64)

func (*BaseElement) SetVisible

func (b *BaseElement) SetVisible(visible bool)

func (*BaseElement) Update

func (b *BaseElement) Update(input *InputState)

type Button

type Button struct {
	BaseElement
	Text                 string
	Font                 font.Face
	TextColor            color.Color
	BackgroundColor      color.Color
	HoverBackgroundColor color.Color
	OnClick              func()
	// contains filtered or unexported fields
}

func NewButton

func NewButton(x, y, width, height float64, txt string, fnt font.Face, onClick func()) *Button

func (*Button) Draw

func (btn *Button) Draw(screen *ebiten.Image)

func (*Button) HandleInput

func (btn *Button) HandleInput(input *InputState)

func (*Button) Update

func (btn *Button) Update(input *InputState)

type Container

type Container struct {
	BaseElement
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(x, y float64, op *ContainerOptions) *Container

func (*Container) AddChild

func (c *Container) AddChild(newChild UIElement)

AddChild places the children based on the config beside or below each other, with a defined gap between them

func (*Container) SetPosition

func (c *Container) SetPosition(x, y float64)

type ContainerDirection

type ContainerDirection string
const (
	Undefined ContainerDirection = "undefined"
	Row       ContainerDirection = "row"
	Col       ContainerDirection = "col"
)

type ContainerOptions

type ContainerOptions struct {
	Direction ContainerDirection
	Gap       float64
}

type Image

type Image struct {
	BaseElement
	// contains filtered or unexported fields
}

func NewImage

func NewImage(x, y float64, img *ebiten.Image) *Image

func (*Image) Draw

func (img *Image) Draw(screen *ebiten.Image)

func (*Image) Update

func (img *Image) Update(input *InputState)

type InputState

type InputState struct {
	MouseX, MouseY         int
	MouseButtonLeftPressed bool
}

type Label

type Label struct {
	BaseElement
	Text  string
	Font  font.Face
	Color color.Color
}

func NewLabel

func NewLabel(x, y float64, txt string, fnt font.Face, clr color.Color) *Label

func (*Label) Draw

func (lbl *Label) Draw(screen *ebiten.Image)

func (*Label) Update

func (lbl *Label) Update(input *InputState)

type UIElement

type UIElement interface {
	Update(input *InputState)
	Draw(screen *ebiten.Image)
	SetPosition(x, y float64)
	GetPosition() (x, y float64)
	GetSize() (width, height float64)
	SetVisible(visible bool)
	IsVisible() bool
	SetEnabled(enabled bool)
	IsEnabled() bool
	AddChild(child UIElement)
	HandleInput(input *InputState)
	GetChildren() []UIElement
}

type UIManager

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

func NewUIManager

func NewUIManager() *UIManager

func (*UIManager) AddElement

func (m *UIManager) AddElement(element UIElement)

func (*UIManager) ClearElements

func (m *UIManager) ClearElements()

func (*UIManager) Draw

func (m *UIManager) Draw(screen *ebiten.Image)

func (*UIManager) RemoveElement

func (m *UIManager) RemoveElement(element UIElement)

func (*UIManager) Update

func (m *UIManager) Update()

Jump to

Keyboard shortcuts

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