ui

package
v0.0.0-...-6b99c35 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Em equals letter height divided by 2

View Source
var MinInputWidth = float64(font.CharWidth) * 24 * config.UIScaling

Minimum width for input elements, such as buttons and input fields

Functions

func DrawButtonBackground

func DrawButtonBackground(screen *ebiten.Image, hover bool, x, y, w, h float64)

func DrawInputBackground

func DrawInputBackground(screen *ebiten.Image, focused bool, x, y, w, h float64)

func DrawNeutralTooltip

func DrawNeutralTooltip(screen *ebiten.Image, x, y, w, h float64)

Draws a tooltip with neutral (gray) background color

func DrawTextTooltip

func DrawTextTooltip(screen *ebiten.Image, cursorX, cursorY int, preferredSide TooltipSide, text string)

Renders a tooltip at specified coordinates, with a specified side relative to the cursor. Or, if no preferredSide is specified, an optimal side will be picked.

func DrawTooltipBackground

func DrawTooltipBackground(screen *ebiten.Image, x, y, w, h float64)

func ImmediateDraw

func ImmediateDraw(screen *ebiten.Image, child Component)

A simple wrapper that initializes the screen component and immediately draws it

Types

type AvailableCraftsList

type AvailableCraftsList struct {
	*StackComponent
	// contains filtered or unexported fields
}

func NewAvailableCraftsList

func NewAvailableCraftsList(availableCrafts []types.Craft, selectedCraft int) *AvailableCraftsList

func (AvailableCraftsList) Align

func (b AvailableCraftsList) Align(alignment ComponentAlignment) *baseComponent

func (AvailableCraftsList) Alignment

func (b AvailableCraftsList) Alignment() ComponentAlignment

func (AvailableCraftsList) HasCustomStyles

func (b AvailableCraftsList) HasCustomStyles() bool

func (AvailableCraftsList) ID

func (b AvailableCraftsList) ID() uint64

func (*AvailableCraftsList) SetAvailableCrafts

func (craftList *AvailableCraftsList) SetAvailableCrafts(availableCrafts []types.Craft)

Update the list of available crafts. Also updates the UI

func (AvailableCraftsList) SetParent

func (b AvailableCraftsList) SetParent(parent Component)

func (*AvailableCraftsList) SetSelectedCraft

func (craftList *AvailableCraftsList) SetSelectedCraft(selectedCraft int)

func (AvailableCraftsList) Style

func (b AvailableCraftsList) Style() *ComponentStyle

type BackgroundColorComponent

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

func Background

func Background(clr color.Color, child Component) *BackgroundColorComponent

Similar to BackgroundColor, but takes the same space occupied by the child, essentially drawing background "behind" the child component.

func BackgroundColor

func BackgroundColor(clr color.Color, child Component) *BackgroundColorComponent

func BackgroundColorAlpha

func BackgroundColorAlpha(clr color.Color, alpha uint8, child Component) *BackgroundColorComponent

Same as BackgroundColor, but draws a background with alpha value. Useful for modal dialogs

func (*BackgroundColorComponent) Align

func (b *BackgroundColorComponent) Align(alignment ComponentAlignment) *baseComponent

func (*BackgroundColorComponent) Alignment

func (b *BackgroundColorComponent) Alignment() ComponentAlignment

func (*BackgroundColorComponent) CapacityForChild

func (b *BackgroundColorComponent) CapacityForChild(_ Component) (float64, float64)

func (*BackgroundColorComponent) Children

func (b *BackgroundColorComponent) Children() []Component

func (*BackgroundColorComponent) ComputedSize

func (b *BackgroundColorComponent) ComputedSize() (float64, float64)

func (*BackgroundColorComponent) Draw

func (b *BackgroundColorComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*BackgroundColorComponent) HasCustomStyles

func (b *BackgroundColorComponent) HasCustomStyles() bool

func (*BackgroundColorComponent) ID

func (b *BackgroundColorComponent) ID() uint64

func (*BackgroundColorComponent) MaxCapacityForChild

func (b *BackgroundColorComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*BackgroundColorComponent) MaxSize

func (b *BackgroundColorComponent) MaxSize() (float64, float64)

func (*BackgroundColorComponent) SetParent

func (b *BackgroundColorComponent) SetParent(parent Component)

func (*BackgroundColorComponent) Style

func (b *BackgroundColorComponent) Style() *ComponentStyle

func (*BackgroundColorComponent) Update

func (b *BackgroundColorComponent) Update() error

type BackgroundImageComponent

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

func StretchBackgroundImage

func StretchBackgroundImage(texture types.Texture, child Component) *BackgroundImageComponent

func TileBackgroundImage

func TileBackgroundImage(texture types.Texture, child Component) *BackgroundImageComponent

func (*BackgroundImageComponent) Align

func (b *BackgroundImageComponent) Align(alignment ComponentAlignment) *baseComponent

func (*BackgroundImageComponent) Alignment

func (b *BackgroundImageComponent) Alignment() ComponentAlignment

func (*BackgroundImageComponent) CapacityForChild

func (b *BackgroundImageComponent) CapacityForChild(_ Component) (float64, float64)

func (*BackgroundImageComponent) Children

func (b *BackgroundImageComponent) Children() []Component

func (*BackgroundImageComponent) ComputedSize

func (b *BackgroundImageComponent) ComputedSize() (float64, float64)

func (*BackgroundImageComponent) Draw

func (b *BackgroundImageComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*BackgroundImageComponent) HasCustomStyles

func (b *BackgroundImageComponent) HasCustomStyles() bool

func (*BackgroundImageComponent) ID

func (b *BackgroundImageComponent) ID() uint64

func (*BackgroundImageComponent) MaxCapacityForChild

func (b *BackgroundImageComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*BackgroundImageComponent) MaxSize

func (b *BackgroundImageComponent) MaxSize() (float64, float64)

func (*BackgroundImageComponent) SetParent

func (b *BackgroundImageComponent) SetParent(parent Component)

func (*BackgroundImageComponent) Style

func (b *BackgroundImageComponent) Style() *ComponentStyle

func (*BackgroundImageComponent) Update

func (b *BackgroundImageComponent) Update() error

type BackgroundImageRenderingMode

type BackgroundImageRenderingMode uint
const (
	BackgroundStretch BackgroundImageRenderingMode = iota
	BackgroundTile
)

type ButtonComponent

type ButtonComponent[T any] struct {
	// contains filtered or unexported fields
}

func Button

func Button[T any](callback chan T, value T, child Component) *ButtonComponent[T]

func (*ButtonComponent) Align

func (b *ButtonComponent) Align(alignment ComponentAlignment) *baseComponent

func (*ButtonComponent) Alignment

func (b *ButtonComponent) Alignment() ComponentAlignment

func (*ButtonComponent[T]) CapacityForChild

func (b *ButtonComponent[T]) CapacityForChild(_ Component) (float64, float64)

func (*ButtonComponent[T]) Children

func (b *ButtonComponent[T]) Children() []Component

func (*ButtonComponent[T]) ComputedSize

func (b *ButtonComponent[T]) ComputedSize() (float64, float64)

func (*ButtonComponent[T]) Draw

func (b *ButtonComponent[T]) Draw(screen *ebiten.Image, x, y float64) error

func (*ButtonComponent) HasCustomStyles

func (b *ButtonComponent) HasCustomStyles() bool

func (*ButtonComponent) ID

func (b *ButtonComponent) ID() uint64

func (*ButtonComponent[T]) IsPressed

func (b *ButtonComponent[T]) IsPressed() bool

func (*ButtonComponent[T]) MaxCapacityForChild

func (b *ButtonComponent[T]) MaxCapacityForChild(_ Component) (float64, float64)

func (*ButtonComponent[T]) MaxSize

func (b *ButtonComponent[T]) MaxSize() (float64, float64)

func (*ButtonComponent[T]) Press

func (b *ButtonComponent[T]) Press()

func (*ButtonComponent) SetParent

func (b *ButtonComponent) SetParent(parent Component)

func (*ButtonComponent) Style

func (b *ButtonComponent) Style() *ComponentStyle

func (*ButtonComponent[T]) Update

func (b *ButtonComponent[T]) Update() error

type ButtonView

type ButtonView interface {
	Component

	IsPressed() bool
	Press()
}

ButtonView is an interface for components that can be clicked

type CenterComponent

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

func Center

func Center(child Component) *CenterComponent

Center the component on both Vertical and Horizontal axis

func HCenter

func HCenter(child Component) *CenterComponent

func VCenter

func VCenter(child Component) *CenterComponent

func (*CenterComponent) Align

func (b *CenterComponent) Align(alignment ComponentAlignment) *baseComponent

func (*CenterComponent) Alignment

func (b *CenterComponent) Alignment() ComponentAlignment

func (*CenterComponent) CapacityForChild

func (c *CenterComponent) CapacityForChild(_ Component) (float64, float64)

func (*CenterComponent) Children

func (c *CenterComponent) Children() []Component

func (*CenterComponent) ComputedSize

func (c *CenterComponent) ComputedSize() (w, h float64)

func (*CenterComponent) Draw

func (c *CenterComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*CenterComponent) HasCustomStyles

func (b *CenterComponent) HasCustomStyles() bool

func (*CenterComponent) ID

func (b *CenterComponent) ID() uint64

func (*CenterComponent) MaxCapacityForChild

func (c *CenterComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*CenterComponent) MaxSize

func (c *CenterComponent) MaxSize() (float64, float64)

func (*CenterComponent) SetParent

func (b *CenterComponent) SetParent(parent Component)

func (*CenterComponent) Style

func (b *CenterComponent) Style() *ComponentStyle

func (*CenterComponent) Update

func (c *CenterComponent) Update() error

type CompassComponent

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

func NewCompassComponent

func NewCompassComponent() *CompassComponent

func (*CompassComponent) Align

func (b *CompassComponent) Align(alignment ComponentAlignment) *baseComponent

func (*CompassComponent) Alignment

func (b *CompassComponent) Alignment() ComponentAlignment

func (*CompassComponent) CapacityForChild

func (compass *CompassComponent) CapacityForChild(_ Component) (float64, float64)

func (*CompassComponent) Children

func (compass *CompassComponent) Children() []Component

func (*CompassComponent) ComputedSize

func (compass *CompassComponent) ComputedSize() (float64, float64)

func (*CompassComponent) Draw

func (compass *CompassComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*CompassComponent) HasCustomStyles

func (b *CompassComponent) HasCustomStyles() bool

func (*CompassComponent) ID

func (b *CompassComponent) ID() uint64

func (*CompassComponent) MaxCapacityForChild

func (compass *CompassComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*CompassComponent) MaxSize

func (compass *CompassComponent) MaxSize() (float64, float64)

func (*CompassComponent) SetParent

func (b *CompassComponent) SetParent(parent Component)

func (*CompassComponent) Style

func (b *CompassComponent) Style() *ComponentStyle

func (*CompassComponent) Update

func (compass *CompassComponent) Update() error

type Component

type Component interface {
	SetParent(parent Component)
	Children() []Component

	// Alignment of the child inside the parent container
	Alignment() ComponentAlignment
	// MaxSize returns maximum space that the component could theoretically occupy
	MaxSize() (float64, float64)
	// Returns actual size of the component
	ComputedSize() (float64, float64)
	// Returns available space that the child could take in its parent, considering the parent's current size.
	CapacityForChild(child Component) (float64, float64)
	// Returns practical maximum space, that the child could take in its parent
	// For most component's this is the same as CapacityForChild
	MaxCapacityForChild(child Component) (float64, float64)

	// Update is pretty much useless,
	// because for many widgets to update, we need to know their size,
	// and their size can't be calculated without access to graphics.
	// So, instead, all those operations are done in Draw() function.
	// But, things not dependent on graphics can be done there
	Update() error
	Draw(screen *ebiten.Image, x, y float64) error

	// ID returns unique identifier of the component, so it can be compared to others
	ID() uint64

	Style() *ComponentStyle
	HasCustomStyles() bool
}

Component is the base interface for all components

type ComponentAlignment

type ComponentAlignment int

Used to hint the parent container how the component should be aligned inside it

const (
	AlignNone ComponentAlignment = iota
	AlignStart
	AlignCenter
	AlignEnd
)

type ComponentStyle

type ComponentStyle struct {
	Modified bool

	TextColor  color.Color
	TextShadow bool
	TextSize   float64
}

type CraftDescription

type CraftDescription struct {
	*StyledComponent
	// contains filtered or unexported fields
}

func NewCraftDescription

func NewCraftDescription() *CraftDescription

func (CraftDescription) Align

func (b CraftDescription) Align(alignment ComponentAlignment) *baseComponent

func (CraftDescription) Alignment

func (b CraftDescription) Alignment() ComponentAlignment

func (CraftDescription) HasCustomStyles

func (b CraftDescription) HasCustomStyles() bool

func (CraftDescription) ID

func (b CraftDescription) ID() uint64

func (*CraftDescription) SetCraft

func (craftDescription *CraftDescription) SetCraft(craft types.Craft)

func (CraftDescription) SetParent

func (b CraftDescription) SetParent(parent Component)

func (CraftDescription) Style

func (b CraftDescription) Style() *ComponentStyle

type FocusView

type FocusView interface {
	Component

	SetFocused(focus bool)
	Focused() bool
}

FocusView is an interface for components that can be focused

type FormComponent

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

a simple wrapper around basic components, to simplify creation of prompts

func Form

func Form(submitButtonTitle string, formData chan []string, prompts ...FormPrompt) *FormComponent

When compose button is pressed, form data will be sent through `formData` channel, in the proper order

func (*FormComponent) Align

func (b *FormComponent) Align(alignment ComponentAlignment) *baseComponent

func (*FormComponent) Alignment

func (b *FormComponent) Alignment() ComponentAlignment

func (*FormComponent) CapacityForChild

func (f *FormComponent) CapacityForChild(_ Component) (float64, float64)

func (*FormComponent) Children

func (f *FormComponent) Children() []Component

func (*FormComponent) ComputedSize

func (f *FormComponent) ComputedSize() (float64, float64)

func (*FormComponent) Draw

func (f *FormComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*FormComponent) HasCustomStyles

func (b *FormComponent) HasCustomStyles() bool

func (*FormComponent) ID

func (b *FormComponent) ID() uint64

func (*FormComponent) MaxCapacityForChild

func (f *FormComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*FormComponent) MaxSize

func (f *FormComponent) MaxSize() (float64, float64)

func (*FormComponent) SetParent

func (b *FormComponent) SetParent(parent Component)

func (*FormComponent) Style

func (b *FormComponent) Style() *ComponentStyle

func (*FormComponent) Update

func (f *FormComponent) Update() error

type FormPrompt

type FormPrompt struct {
	Title string
	// contains filtered or unexported fields
}

type ImageComponent

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

func Image

func Image(image *ebiten.Image) *ImageComponent

Scaling is enabled by default

func (*ImageComponent) Align

func (b *ImageComponent) Align(alignment ComponentAlignment) *baseComponent

func (*ImageComponent) Alignment

func (b *ImageComponent) Alignment() ComponentAlignment

func (*ImageComponent) CapacityForChild

func (image *ImageComponent) CapacityForChild(_ Component) (float64, float64)

func (*ImageComponent) Children

func (image *ImageComponent) Children() []Component

func (*ImageComponent) ComputedSize

func (image *ImageComponent) ComputedSize() (float64, float64)

func (*ImageComponent) DisableScaling

func (image *ImageComponent) DisableScaling() *ImageComponent

func (*ImageComponent) Draw

func (image *ImageComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*ImageComponent) HasCustomStyles

func (b *ImageComponent) HasCustomStyles() bool

func (*ImageComponent) ID

func (b *ImageComponent) ID() uint64

func (*ImageComponent) MaxCapacityForChild

func (image *ImageComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*ImageComponent) MaxSize

func (image *ImageComponent) MaxSize() (float64, float64)

func (*ImageComponent) SetParent

func (b *ImageComponent) SetParent(parent Component)

func (*ImageComponent) Style

func (b *ImageComponent) Style() *ComponentStyle

func (*ImageComponent) Update

func (image *ImageComponent) Update() error

type InputComponent

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

func Input

func Input(handler func(string), enterKey ebiten.Key, initialFocus bool) *InputComponent

func (*InputComponent) Align

func (b *InputComponent) Align(alignment ComponentAlignment) *baseComponent

func (*InputComponent) Alignment

func (b *InputComponent) Alignment() ComponentAlignment

func (*InputComponent) CapacityForChild

func (i *InputComponent) CapacityForChild(_ Component) (float64, float64)

func (*InputComponent) Children

func (i *InputComponent) Children() []Component

func (*InputComponent) ComputedSize

func (i *InputComponent) ComputedSize() (float64, float64)

func (*InputComponent) Draw

func (i *InputComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*InputComponent) Focused

func (b *InputComponent) Focused() bool

func (*InputComponent) HasCustomStyles

func (b *InputComponent) HasCustomStyles() bool

func (*InputComponent) ID

func (b *InputComponent) ID() uint64

func (*InputComponent) Input

func (i *InputComponent) Input() string

func (*InputComponent) MaxCapacityForChild

func (i *InputComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*InputComponent) MaxSize

func (i *InputComponent) MaxSize() (float64, float64)

func (*InputComponent) SetFocused

func (b *InputComponent) SetFocused(focused bool)

func (*InputComponent) SetInput

func (i *InputComponent) SetInput(input string)

func (*InputComponent) SetParent

func (b *InputComponent) SetParent(parent Component)

func (*InputComponent) Style

func (b *InputComponent) Style() *ComponentStyle

func (*InputComponent) Update

func (i *InputComponent) Update() error

func (*InputComponent) WithMaxInputLength

func (i *InputComponent) WithMaxInputLength(length int) *InputComponent

Sets maximum input length

type InputView

type InputView interface {
	FocusView

	Input() string
	SetInput(input string)
}

InputView is an interface for components that accept keyboard input

type ItemSlotComponent

type ItemSlotComponent struct {
	*TooltipComponent
	// contains filtered or unexported fields
}

func ItemSlot

func ItemSlot(slot *types.ItemSlot) *ItemSlotComponent

func (ItemSlotComponent) Align

func (b ItemSlotComponent) Align(alignment ComponentAlignment) *baseComponent

func (ItemSlotComponent) Alignment

func (b ItemSlotComponent) Alignment() ComponentAlignment

func (*ItemSlotComponent) Draw

func (slot *ItemSlotComponent) Draw(screen *ebiten.Image, x, y float64) error

func (ItemSlotComponent) HasCustomStyles

func (b ItemSlotComponent) HasCustomStyles() bool

func (ItemSlotComponent) ID

func (b ItemSlotComponent) ID() uint64

func (ItemSlotComponent) SetParent

func (b ItemSlotComponent) SetParent(parent Component)

func (ItemSlotComponent) Style

func (b ItemSlotComponent) Style() *ComponentStyle

func (*ItemSlotComponent) Update

func (slot *ItemSlotComponent) Update() error

type LabelComponent

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

func ColoredLabel

func ColoredLabel(s string, color color.Color) *LabelComponent

func CustomLabel

func CustomLabel(s string, color color.Color, scaling float64) *LabelComponent

func Label

func Label(s string) *LabelComponent

func LabelF

func LabelF(format string, a ...any) *LabelComponent

func (*LabelComponent) Align

func (b *LabelComponent) Align(alignment ComponentAlignment) *baseComponent

func (*LabelComponent) Alignment

func (b *LabelComponent) Alignment() ComponentAlignment

func (*LabelComponent) CapacityForChild

func (l *LabelComponent) CapacityForChild(_ Component) (float64, float64)

func (*LabelComponent) Children

func (l *LabelComponent) Children() []Component

func (*LabelComponent) ComputedSize

func (l *LabelComponent) ComputedSize() (float64, float64)

func (*LabelComponent) Draw

func (l *LabelComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*LabelComponent) HasCustomStyles

func (b *LabelComponent) HasCustomStyles() bool

func (*LabelComponent) ID

func (b *LabelComponent) ID() uint64

func (*LabelComponent) MaxCapacityForChild

func (l *LabelComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*LabelComponent) MaxSize

func (l *LabelComponent) MaxSize() (float64, float64)

func (*LabelComponent) SetParent

func (b *LabelComponent) SetParent(parent Component)

func (*LabelComponent) SetText

func (l *LabelComponent) SetText(text string)

func (*LabelComponent) Style

func (b *LabelComponent) Style() *ComponentStyle

func (*LabelComponent) Text

func (l *LabelComponent) Text() string

func (*LabelComponent) Update

func (l *LabelComponent) Update() error

func (*LabelComponent) WithTextColor

func (l *LabelComponent) WithTextColor(newColor color.Color) *LabelComponent

func (*LabelComponent) WithTextSize

func (l *LabelComponent) WithTextSize(size float64) *LabelComponent

func (*LabelComponent) WithoutTextShadow

func (l *LabelComponent) WithoutTextShadow() *LabelComponent

type OverlayComponent

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

func Overlay

func Overlay(children ...Component) *OverlayComponent

func (*OverlayComponent) Align

func (b *OverlayComponent) Align(alignment ComponentAlignment) *baseComponent

func (*OverlayComponent) Alignment

func (b *OverlayComponent) Alignment() ComponentAlignment

func (*OverlayComponent) CapacityForChild

func (overlay *OverlayComponent) CapacityForChild(_ Component) (float64, float64)

func (*OverlayComponent) Children

func (overlay *OverlayComponent) Children() []Component

func (*OverlayComponent) ComputedSize

func (overlay *OverlayComponent) ComputedSize() (float64, float64)

func (*OverlayComponent) Draw

func (overlay *OverlayComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*OverlayComponent) HasCustomStyles

func (b *OverlayComponent) HasCustomStyles() bool

func (*OverlayComponent) ID

func (b *OverlayComponent) ID() uint64

func (*OverlayComponent) MaxCapacityForChild

func (overlay *OverlayComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*OverlayComponent) MaxSize

func (overlay *OverlayComponent) MaxSize() (float64, float64)

func (*OverlayComponent) SetParent

func (b *OverlayComponent) SetParent(parent Component)

func (*OverlayComponent) Style

func (b *OverlayComponent) Style() *ComponentStyle

func (*OverlayComponent) Update

func (overlay *OverlayComponent) Update() error

type PaddingComponent

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

func Padding

func Padding(amount float64, child Component) *PaddingComponent

Adds padding on all sides

func PaddingX

func PaddingX(amount float64, child Component) *PaddingComponent

func PaddingXY

func PaddingXY(amountX, amountY float64, child Component) *PaddingComponent

func PaddingY

func PaddingY(amount float64, child Component) *PaddingComponent

func (*PaddingComponent) Align

func (b *PaddingComponent) Align(alignment ComponentAlignment) *baseComponent

func (*PaddingComponent) Alignment

func (b *PaddingComponent) Alignment() ComponentAlignment

func (*PaddingComponent) CapacityForChild

func (p *PaddingComponent) CapacityForChild(_ Component) (float64, float64)

func (*PaddingComponent) Children

func (p *PaddingComponent) Children() []Component

func (*PaddingComponent) ComputedSize

func (p *PaddingComponent) ComputedSize() (float64, float64)

func (*PaddingComponent) Draw

func (p *PaddingComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*PaddingComponent) HasCustomStyles

func (b *PaddingComponent) HasCustomStyles() bool

func (*PaddingComponent) ID

func (b *PaddingComponent) ID() uint64

func (*PaddingComponent) MaxCapacityForChild

func (p *PaddingComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*PaddingComponent) MaxSize

func (p *PaddingComponent) MaxSize() (float64, float64)

func (*PaddingComponent) SetParent

func (b *PaddingComponent) SetParent(parent Component)

func (*PaddingComponent) Style

func (b *PaddingComponent) Style() *ComponentStyle

func (*PaddingComponent) Update

func (p *PaddingComponent) Update() error

type Position

type Position int
const (
	PositionTopLeft Position = iota
	PositionTop
	PositionTopRight
	PositionLeft
	PositionCenter
	PositionRight
	PositionBottomLeft
	PositionBottom
	PositionBottomRight
)

type PositionComponent

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

func PositionSelf

func PositionSelf(position Position, child Component) *PositionComponent

Position the component absolutely within the container

func (*PositionComponent) Align

func (b *PositionComponent) Align(alignment ComponentAlignment) *baseComponent

func (*PositionComponent) Alignment

func (b *PositionComponent) Alignment() ComponentAlignment

func (*PositionComponent) CapacityForChild

func (position *PositionComponent) CapacityForChild(_ Component) (float64, float64)

func (*PositionComponent) Children

func (position *PositionComponent) Children() []Component

func (*PositionComponent) ComputedSize

func (position *PositionComponent) ComputedSize() (float64, float64)

func (*PositionComponent) Draw

func (position *PositionComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*PositionComponent) HasCustomStyles

func (b *PositionComponent) HasCustomStyles() bool

func (*PositionComponent) ID

func (b *PositionComponent) ID() uint64

func (*PositionComponent) MaxCapacityForChild

func (position *PositionComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*PositionComponent) MaxSize

func (position *PositionComponent) MaxSize() (float64, float64)

func (*PositionComponent) SetParent

func (b *PositionComponent) SetParent(parent Component)

func (*PositionComponent) Style

func (b *PositionComponent) Style() *ComponentStyle

func (*PositionComponent) Update

func (position *PositionComponent) Update() error

type ScreenComponent

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

ScreenComponent is the root component

func Screen

func Screen(child Component) *ScreenComponent

func (*ScreenComponent) Alignment

func (s *ScreenComponent) Alignment() ComponentAlignment

func (*ScreenComponent) CapacityForChild

func (s *ScreenComponent) CapacityForChild(_ Component) (float64, float64)

func (*ScreenComponent) Children

func (s *ScreenComponent) Children() []Component

func (*ScreenComponent) ComputedSize

func (s *ScreenComponent) ComputedSize() (float64, float64)

func (*ScreenComponent) Draw

func (s *ScreenComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*ScreenComponent) HasCustomStyles

func (s *ScreenComponent) HasCustomStyles() bool

func (*ScreenComponent) ID

func (s *ScreenComponent) ID() uint64

func (*ScreenComponent) MaxCapacityForChild

func (s *ScreenComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*ScreenComponent) MaxSize

func (s *ScreenComponent) MaxSize() (float64, float64)

func (*ScreenComponent) SetParent

func (s *ScreenComponent) SetParent(_ Component)

func (*ScreenComponent) Style

func (s *ScreenComponent) Style() *ComponentStyle

func (*ScreenComponent) Update

func (s *ScreenComponent) Update() error

type StackComponent

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

func HStack

func HStack(children ...Component) *StackComponent

func VStack

func VStack(children ...Component) *StackComponent

func (*StackComponent) AddChild

func (s *StackComponent) AddChild(child Component)

func (*StackComponent) Align

func (b *StackComponent) Align(alignment ComponentAlignment) *baseComponent

func (*StackComponent) AlignChildren

func (s *StackComponent) AlignChildren(alignment ComponentAlignment) *StackComponent

func (*StackComponent) Alignment

func (b *StackComponent) Alignment() ComponentAlignment

func (*StackComponent) CapacityForChild

func (s *StackComponent) CapacityForChild(child Component) (float64, float64)

func (*StackComponent) Children

func (s *StackComponent) Children() []Component

func (*StackComponent) ComputedSize

func (s *StackComponent) ComputedSize() (w, h float64)

func (*StackComponent) Draw

func (s *StackComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*StackComponent) HasCustomStyles

func (b *StackComponent) HasCustomStyles() bool

func (*StackComponent) ID

func (b *StackComponent) ID() uint64

func (*StackComponent) MaxCapacityForChild

func (s *StackComponent) MaxCapacityForChild(child Component) (float64, float64)

func (*StackComponent) MaxSize

func (s *StackComponent) MaxSize() (float64, float64)

func (*StackComponent) ReplaceChild

func (s *StackComponent) ReplaceChild(oldChild Component, newChild Component)

func (*StackComponent) SetParent

func (b *StackComponent) SetParent(parent Component)

func (*StackComponent) Style

func (b *StackComponent) Style() *ComponentStyle

func (*StackComponent) Update

func (s *StackComponent) Update() error

func (*StackComponent) WithChildren

func (s *StackComponent) WithChildren(children ...Component) *StackComponent

func (*StackComponent) WithDirection

func (s *StackComponent) WithDirection(direction StackDirection) *StackComponent

func (*StackComponent) WithProportions

func (s *StackComponent) WithProportions(proportions ...float64) *StackComponent

func (*StackComponent) WithSpacing

func (s *StackComponent) WithSpacing(spacing float64) *StackComponent

type StackDirection

type StackDirection uint
const (
	VerticalStack StackDirection = iota
	HorizontalStack
)

type StackOptions

type StackOptions struct {
	Direction     StackDirection
	Spacing       float64            // spacing between each child
	Proportions   []float64          // how much % of the parent space will each child occupy
	AlignChildren ComponentAlignment // explicit alignment of all childrens
}

type StyledComponent

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

func Styled

func Styled(child Component) *StyledComponent

Apply custom styles to a child component

func (*StyledComponent) Align

func (b *StyledComponent) Align(alignment ComponentAlignment) *baseComponent

func (*StyledComponent) Alignment

func (b *StyledComponent) Alignment() ComponentAlignment

func (*StyledComponent) CapacityForChild

func (styled *StyledComponent) CapacityForChild(_ Component) (float64, float64)

func (*StyledComponent) Children

func (styled *StyledComponent) Children() []Component

func (*StyledComponent) ComputedSize

func (styled *StyledComponent) ComputedSize() (float64, float64)

func (*StyledComponent) Draw

func (styled *StyledComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*StyledComponent) HasCustomStyles

func (b *StyledComponent) HasCustomStyles() bool

func (*StyledComponent) ID

func (b *StyledComponent) ID() uint64

func (*StyledComponent) MaxCapacityForChild

func (styled *StyledComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*StyledComponent) MaxSize

func (styled *StyledComponent) MaxSize() (float64, float64)

func (*StyledComponent) SetParent

func (b *StyledComponent) SetParent(parent Component)

func (*StyledComponent) Style

func (b *StyledComponent) Style() *ComponentStyle

func (*StyledComponent) Update

func (styled *StyledComponent) Update() error

func (*StyledComponent) WithChild

func (styled *StyledComponent) WithChild(child Component) *StyledComponent

func (*StyledComponent) WithTextColor

func (styled *StyledComponent) WithTextColor(color color.Color) *StyledComponent

func (*StyledComponent) WithTextShadow

func (styled *StyledComponent) WithTextShadow(shadow bool) *StyledComponent

func (*StyledComponent) WithTextSize

func (styled *StyledComponent) WithTextSize(size float64) *StyledComponent

type TextView

type TextView interface {
	Component

	Text() string
	SetText(text string)
}

type TooltipComponent

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

func Tooltip

func Tooltip(child Component) *TooltipComponent

func (*TooltipComponent) Align

func (b *TooltipComponent) Align(alignment ComponentAlignment) *baseComponent

func (*TooltipComponent) Alignment

func (b *TooltipComponent) Alignment() ComponentAlignment

func (*TooltipComponent) CapacityForChild

func (tooltip *TooltipComponent) CapacityForChild(_ Component) (float64, float64)

func (*TooltipComponent) Children

func (tooltip *TooltipComponent) Children() []Component

func (*TooltipComponent) ComputedSize

func (tooltip *TooltipComponent) ComputedSize() (float64, float64)

func (*TooltipComponent) Draw

func (tooltip *TooltipComponent) Draw(screen *ebiten.Image, x, y float64) error

func (*TooltipComponent) HasCustomStyles

func (b *TooltipComponent) HasCustomStyles() bool

func (*TooltipComponent) ID

func (b *TooltipComponent) ID() uint64

func (*TooltipComponent) MaxCapacityForChild

func (tooltip *TooltipComponent) MaxCapacityForChild(_ Component) (float64, float64)

func (*TooltipComponent) MaxSize

func (tooltip *TooltipComponent) MaxSize() (float64, float64)

func (*TooltipComponent) SetParent

func (b *TooltipComponent) SetParent(parent Component)

func (*TooltipComponent) Style

func (b *TooltipComponent) Style() *ComponentStyle

func (*TooltipComponent) Update

func (tooltip *TooltipComponent) Update() error

func (*TooltipComponent) WithNeutralColor

func (tooltip *TooltipComponent) WithNeutralColor() *TooltipComponent

Uses an alternative tooltip texture made from neutral gray colors

type TooltipSide

type TooltipSide int

Which side of the cursor to prefer for displaying the tooltip. By default, the tooltip is displayed where it fits. If there are multiple sides it can fit on, we pick the direction with the most free pixels (pixels to the edge of the screen) in both axis. The default order is: BottomRight, BottomLeft, TopRight, TopLeft

const (
	None TooltipSide = iota
	BottomRight
	BottomLeft
	TopRight
	TopLeft
)

type TooltipTexture

type TooltipTexture struct {
	TopLeft  *ebiten.Image
	Top      *ebiten.Image
	TopRight *ebiten.Image

	Left   *ebiten.Image
	Center *ebiten.Image
	Right  *ebiten.Image

	BottomLeft  *ebiten.Image
	Bottom      *ebiten.Image
	BottomRight *ebiten.Image
}

func AssembleTooltipTexture

func AssembleTooltipTexture(texture *ebiten.Image) TooltipTexture

Divide the tooltip texture into sub-textures for rendering

Jump to

Keyboard shortcuts

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