ui

package module
v0.0.0-...-c19e608 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 14 Imported by: 0

README

UI

Disclaimer: Please do not use, this might change drastically at anytime.

  • Library is not stable
  • Code is dirty
  • A lot of stuff is experimental

Documentation

Index

Constants

View Source
const (
	ShapeBox     = Shape(graphics.ShapeBox)
	ShapeEllipse = Shape(graphics.ShapeEllipse)
	ShapeRhombus = Shape(graphics.ShapeRhombus)
	ShapeOctogon = Shape(graphics.ShapeOctogon)
	ShapeNone    = Shape(graphics.ShapeNone)
)
View Source
const (
	ColorFillingVertical = ColorFilling(graphics.ColorFillingVertical)
	ColorFillingDistance = ColorFilling(graphics.ColorFillingDistance)
	ColorFillingNone     = ColorFilling(graphics.ColorFillingNone)
)

Variables

This section is empty.

Functions

func GetFS

func GetFS() fs.FS

func GetFontSize

func GetFontSize() float64

func GetFontSource

func GetFontSource() *text.GoTextFaceSource

func SetBlockOption

func SetBlockOption(option func(*Block))

func SetEventHandler

func SetEventHandler(ec EventHandler)

func SetFS

func SetFS(fsys fs.FS)

func SetFocusedItem

func SetFocusedItem(item Item)

func SetFontSize

func SetFontSize(size float64)

func SetFontSource

func SetFontSource(source *text.GoTextFaceSource)

func SetGridOption

func SetGridOption(option func(*Grid))

Types

type AlignMode

type AlignMode byte
const (
	AlignCenter AlignMode = iota
	AlignMin
	AlignMax
	AlignOffset
)

type Block

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

func NewBlock

func NewBlock() *Block

func (Block) AddDeco

func (ii Block) AddDeco(deco Decoration)

func (Block) Align

func (ii Block) Align() (AlignMode, AlignMode)

func (Block) Alpha

func (ii Block) Alpha() float64

func (*Block) BlockBase

func (b *Block) BlockBase() *Block

func (Block) Border

func (ii Block) Border() (float64, color.Color)

func (Block) ColorFilling

func (ii Block) ColorFilling() ColorFilling

func (*Block) Content

func (b *Block) Content() Content

func (Block) Data

func (ii Block) Data() any

func (Block) Decorations

func (ii Block) Decorations() []Decoration

func (Block) DoEvent

func (ii Block) DoEvent(event Event)

func (Block) EventHandler

func (ii Block) EventHandler() EventHandler

func (Block) Focused

func (ii Block) Focused() bool

func (Block) Hovered

func (ii Block) Hovered() bool

func (Block) HoveredTicks

func (ii Block) HoveredTicks() uint

func (Block) JustFocused

func (ii Block) JustFocused() bool

func (Block) JustPressed

func (ii Block) JustPressed() bool

func (Block) JustUnhovered

func (ii Block) JustUnhovered() bool

func (Block) LastCursor

func (ii Block) LastCursor() image.Point

func (Block) LastFullRegion

func (ii Block) LastFullRegion() image.Rectangle

func (Block) LastRegion

func (ii Block) LastRegion() image.Rectangle

func (Block) Margin

func (ii Block) Margin() (left, right, top, bottom float64)

func (Block) MaxSize

func (ii Block) MaxSize() (int, int)

func (Block) MinSize

func (ii Block) MinSize() (int, int)

func (Block) Padding

func (ii Block) Padding() (left, right, top, bottom int)

func (Block) Pressed

func (ii Block) Pressed() bool

func (Block) PressedTicks

func (ii Block) PressedTicks() uint

func (Block) PrimaryColor

func (ii Block) PrimaryColor() color.Color

func (Block) PrimaryColorOffset

func (ii Block) PrimaryColorOffset() float64

func (Block) Rounding

func (ii Block) Rounding() float64

func (Block) SecondaryColor

func (ii Block) SecondaryColor() color.Color

func (Block) SetAlign

func (ii Block) SetAlign(x, y AlignMode)

func (Block) SetAlignX

func (ii Block) SetAlignX(x AlignMode)

func (Block) SetAlignY

func (ii Block) SetAlignY(y AlignMode)

func (Block) SetBorderColor

func (ii Block) SetBorderColor(clr color.Color)

func (Block) SetBorderColorAlpha

func (ii Block) SetBorderColorAlpha(alpha float64)

func (Block) SetBorderWidth

func (ii Block) SetBorderWidth(width float64)

func (Block) SetColorAlpha

func (ii Block) SetColorAlpha(alpha float64)

func (Block) SetColorFilling

func (ii Block) SetColorFilling(filling ColorFilling)

func (Block) SetColorPrimary

func (ii Block) SetColorPrimary(clr color.Color)

func (Block) SetColorPrimaryOffset

func (ii Block) SetColorPrimaryOffset(offset float64)

func (Block) SetColorSecondary

func (ii Block) SetColorSecondary(clr color.Color)

func (*Block) SetContent

func (b *Block) SetContent(c Content)

func (Block) SetData

func (ii Block) SetData(data any)

func (Block) SetEventActionOptions

func (ii Block) SetEventActionOptions(opts EventOptions)

func (Block) SetEventHandler

func (ii Block) SetEventHandler(handler EventHandler)

func (Block) SetEventHandling

func (ii Block) SetEventHandling(handled bool)

func (Block) SetEventStyleOptions

func (ii Block) SetEventStyleOptions(opts EventOptions)

func (Block) SetFocusHandling

func (ii Block) SetFocusHandling(handled bool)

SetFocusHandling defines whether an item should take the focused state, therefore unfocusing the previously focused item.

func (Block) SetItemOptions

func (ii Block) SetItemOptions(opts ...ItemOption)

func (Block) SetMargin

func (ii Block) SetMargin(left, right, top, bottom float64)

func (Block) SetMarginBottom

func (ii Block) SetMarginBottom(pixels float64)

func (Block) SetMarginLeft

func (ii Block) SetMarginLeft(pixels float64)

func (Block) SetMarginRight

func (ii Block) SetMarginRight(pixels float64)

func (Block) SetMarginTop

func (ii Block) SetMarginTop(pixels float64)

func (Block) SetMaxHeight

func (ii Block) SetMaxHeight(height int)

func (Block) SetMaxWidth

func (ii Block) SetMaxWidth(width int)

func (Block) SetMinHeight

func (ii Block) SetMinHeight(height int)

func (Block) SetMinWidth

func (ii Block) SetMinWidth(width int)

func (Block) SetPadding

func (ii Block) SetPadding(left, right, top, bottom int)

func (Block) SetPaddingBottom

func (ii Block) SetPaddingBottom(pixels int)

func (Block) SetPaddingLeft

func (ii Block) SetPaddingLeft(pixels int)

func (Block) SetPaddingRight

func (ii Block) SetPaddingRight(pixels int)

func (Block) SetPaddingTop

func (ii Block) SetPaddingTop(pixels int)

func (Block) SetRounding

func (ii Block) SetRounding(factor float64)

func (Block) SetShape

func (ii Block) SetShape(shape Shape)

func (Block) SetSkipped

func (ii Block) SetSkipped(skipped bool)

func (Block) SetSourceOffset

func (ii Block) SetSourceOffset(offset image.Point)

func (Block) Shape

func (ii Block) Shape() Shape

func (Block) Skipped

func (ii Block) Skipped() bool

func (Block) SourceOffset

func (ii Block) SourceOffset() image.Point

func (*Block) WithOptions

func (b *Block) WithOptions(opts ...BlockOption) *Block

type BlockOption

type BlockOption = func(*Block)

func WithBlockContent

func WithBlockContent(c Content) BlockOption

type ColorFilling

type ColorFilling graphics.ColorFilling

type Content

type Content interface {
	Draw(dst *ebiten.Image)
}

type Decoration

type Decoration interface {
	Item

	Visible() bool
}

type Event

type Event byte
const (
	Default Event = iota
	Hover
	Unhover
	Press
	PressHover
	JustPress
	Release
	ReleaseHover
	EventMax
)

type EventHandler

type EventHandler interface {
	State(item Item, is InputState) Event
}

func GetEventHandler

func GetEventHandler() EventHandler

type EventOptions

type EventOptions [EventMax]ItemOption

type Grid

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

func NewGrid

func NewGrid(columns, rows int) *Grid

func (*Grid) Add

func (g *Grid) Add(x, y, columns, rows int, item Item)

func (Grid) AddDeco

func (ii Grid) AddDeco(deco Decoration)

func (Grid) Align

func (ii Grid) Align() (AlignMode, AlignMode)

func (Grid) Alpha

func (ii Grid) Alpha() float64

func (Grid) Border

func (ii Grid) Border() (float64, color.Color)

func (Grid) ColorFilling

func (ii Grid) ColorFilling() ColorFilling

func (*Grid) Columns

func (g *Grid) Columns() int

func (Grid) Data

func (ii Grid) Data() any

func (Grid) Decorations

func (ii Grid) Decorations() []Decoration

func (*Grid) Dimensions

func (g *Grid) Dimensions() (int, int)

func (Grid) DoEvent

func (ii Grid) DoEvent(event Event)

func (Grid) EventHandler

func (ii Grid) EventHandler() EventHandler

func (Grid) Focused

func (ii Grid) Focused() bool

func (*Grid) ForEach

func (g *Grid) ForEach(fn func(i Item))

func (*Grid) GridBase

func (g *Grid) GridBase() *Grid

func (Grid) Hovered

func (ii Grid) Hovered() bool

func (Grid) HoveredTicks

func (ii Grid) HoveredTicks() uint

func (Grid) JustFocused

func (ii Grid) JustFocused() bool

func (Grid) JustPressed

func (ii Grid) JustPressed() bool

func (Grid) JustUnhovered

func (ii Grid) JustUnhovered() bool

func (Grid) LastCursor

func (ii Grid) LastCursor() image.Point

func (Grid) LastFullRegion

func (ii Grid) LastFullRegion() image.Rectangle

func (Grid) LastRegion

func (ii Grid) LastRegion() image.Rectangle

func (Grid) Margin

func (ii Grid) Margin() (left, right, top, bottom float64)

func (Grid) MaxSize

func (ii Grid) MaxSize() (int, int)

func (Grid) MinSize

func (ii Grid) MinSize() (int, int)

func (Grid) Padding

func (ii Grid) Padding() (left, right, top, bottom int)

func (Grid) Pressed

func (ii Grid) Pressed() bool

func (Grid) PressedTicks

func (ii Grid) PressedTicks() uint

func (Grid) PrimaryColor

func (ii Grid) PrimaryColor() color.Color

func (Grid) PrimaryColorOffset

func (ii Grid) PrimaryColorOffset() float64

func (Grid) Rounding

func (ii Grid) Rounding() float64

func (*Grid) Rows

func (g *Grid) Rows() int

func (Grid) SecondaryColor

func (ii Grid) SecondaryColor() color.Color

func (Grid) SetAlign

func (ii Grid) SetAlign(x, y AlignMode)

func (Grid) SetAlignX

func (ii Grid) SetAlignX(x AlignMode)

func (Grid) SetAlignY

func (ii Grid) SetAlignY(y AlignMode)

func (Grid) SetBorderColor

func (ii Grid) SetBorderColor(clr color.Color)

func (Grid) SetBorderColorAlpha

func (ii Grid) SetBorderColorAlpha(alpha float64)

func (Grid) SetBorderWidth

func (ii Grid) SetBorderWidth(width float64)

func (Grid) SetColorAlpha

func (ii Grid) SetColorAlpha(alpha float64)

func (Grid) SetColorFilling

func (ii Grid) SetColorFilling(filling ColorFilling)

func (Grid) SetColorPrimary

func (ii Grid) SetColorPrimary(clr color.Color)

func (Grid) SetColorPrimaryOffset

func (ii Grid) SetColorPrimaryOffset(offset float64)

func (Grid) SetColorSecondary

func (ii Grid) SetColorSecondary(clr color.Color)

func (Grid) SetData

func (ii Grid) SetData(data any)

func (Grid) SetEventActionOptions

func (ii Grid) SetEventActionOptions(opts EventOptions)

func (Grid) SetEventHandler

func (ii Grid) SetEventHandler(handler EventHandler)

func (Grid) SetEventHandling

func (ii Grid) SetEventHandling(handled bool)

func (Grid) SetEventStyleOptions

func (ii Grid) SetEventStyleOptions(opts EventOptions)

func (Grid) SetFocusHandling

func (ii Grid) SetFocusHandling(handled bool)

SetFocusHandling defines whether an item should take the focused state, therefore unfocusing the previously focused item.

func (Grid) SetItemOptions

func (ii Grid) SetItemOptions(opts ...ItemOption)

func (Grid) SetMargin

func (ii Grid) SetMargin(left, right, top, bottom float64)

func (Grid) SetMarginBottom

func (ii Grid) SetMarginBottom(pixels float64)

func (Grid) SetMarginLeft

func (ii Grid) SetMarginLeft(pixels float64)

func (Grid) SetMarginRight

func (ii Grid) SetMarginRight(pixels float64)

func (Grid) SetMarginTop

func (ii Grid) SetMarginTop(pixels float64)

func (Grid) SetMaxHeight

func (ii Grid) SetMaxHeight(height int)

func (Grid) SetMaxWidth

func (ii Grid) SetMaxWidth(width int)

func (Grid) SetMinHeight

func (ii Grid) SetMinHeight(height int)

func (Grid) SetMinWidth

func (ii Grid) SetMinWidth(width int)

func (Grid) SetPadding

func (ii Grid) SetPadding(left, right, top, bottom int)

func (Grid) SetPaddingBottom

func (ii Grid) SetPaddingBottom(pixels int)

func (Grid) SetPaddingLeft

func (ii Grid) SetPaddingLeft(pixels int)

func (Grid) SetPaddingRight

func (ii Grid) SetPaddingRight(pixels int)

func (Grid) SetPaddingTop

func (ii Grid) SetPaddingTop(pixels int)

func (Grid) SetRounding

func (ii Grid) SetRounding(factor float64)

func (Grid) SetShape

func (ii Grid) SetShape(shape Shape)

func (Grid) SetSkipped

func (ii Grid) SetSkipped(skipped bool)

func (Grid) SetSourceOffset

func (ii Grid) SetSourceOffset(offset image.Point)

func (Grid) Shape

func (ii Grid) Shape() Shape

func (Grid) Skipped

func (ii Grid) Skipped() bool

func (Grid) SourceOffset

func (ii Grid) SourceOffset() image.Point

func (*Grid) WithOptions

func (g *Grid) WithOptions(opts ...GridOption) *Grid

type GridOption

type GridOption = func(*Grid)

type InputState

type InputState interface {
	Cursor() image.Point
	MouseWheel() (float64, float64)

	KeyPressDuration(ebiten.Key) int
	MouseButtonPressDuration(ebiten.MouseButton) int
	GamepadButtonPressDuration(ebiten.GamepadID, ebiten.GamepadButton) int
	StandardGamepadButtonPressDuration(ebiten.GamepadID, ebiten.StandardGamepadButton) int
	TouchPressDuration(ebiten.TouchID) int

	KeyJustReleased(ebiten.Key) bool
	MouseButtonJustReleased(ebiten.MouseButton) bool
	GamepadButtonJustReleased(ebiten.GamepadID, ebiten.GamepadButton) bool
	StandardGamepadButtonJustReleased(ebiten.GamepadID, ebiten.StandardGamepadButton) bool
	TouchJustReleased(ebiten.TouchID) bool

	DroppedFiles() fs.FS
}

func GetInputState

func GetInputState() InputState

type Item

type Item interface {
	SetItemOptions(opts ...ItemOption)

	// State
	Pressed() bool
	PressedTicks() uint
	JustPressed() bool
	Hovered() bool
	HoveredTicks() uint
	JustUnhovered() bool
	Focused() bool
	JustFocused() bool

	Skipped() bool
	SetSkipped(skipped bool)

	// Style options
	SetShape(shape Shape)
	SetRounding(factor float64)
	SetMinWidth(width int)
	SetMinHeight(height int)
	SetMaxWidth(width int)
	SetMaxHeight(height int)
	SetAlign(x, y AlignMode)
	SetAlignX(x AlignMode)
	SetAlignY(y AlignMode)
	SetMargin(left, right, top, bottom float64)
	SetMarginLeft(pixels float64)
	SetMarginRight(pixels float64)
	SetMarginTop(pixels float64)
	SetMarginBottom(pixels float64)
	SetPadding(left, right, top, bottom int)
	SetPaddingLeft(pixels int)
	SetPaddingRight(pixels int)
	SetPaddingTop(pixels int)
	SetPaddingBottom(pixels int)
	SetBorderWidth(width float64)
	SetBorderColor(clr color.Color)
	SetBorderColorAlpha(alpha float64)
	SetColorPrimary(clr color.Color)
	SetColorSecondary(clr color.Color)
	SetColorPrimaryOffset(offset float64)
	SetColorAlpha(alpha float64)
	SetColorFilling(filling ColorFilling)
	// Getters
	Shape() Shape
	Rounding() float64
	MinSize() (int, int)
	MaxSize() (int, int)
	Align() (AlignMode, AlignMode)
	Margin() (left, right, top, bottom float64)
	Padding() (left, right, top, bottom int)
	Border() (float64, color.Color)
	PrimaryColor() color.Color
	SecondaryColor() color.Color
	PrimaryColorOffset() float64
	Alpha() float64
	ColorFilling() ColorFilling

	// Event
	SetFocusHandling(handled bool)
	SetEventHandling(handled bool)
	SetEventHandler(handler EventHandler)
	EventHandler() EventHandler
	SetEventStyleOptions(EventOptions)
	SetEventActionOptions(EventOptions)
	DoEvent(event Event)

	// Class attributes
	Classes() []string
	SetClasses(classes ...string)
	AddClasses(classes ...string)

	// Decorations
	Decorations() []Decoration
	AddDeco(deco Decoration)

	// User data
	Data() any
	SetData(data any)
	// contains filtered or unexported methods
}

func FocusedItem

func FocusedItem() Item

type ItemOption

type ItemOption func(Item)

func WithCustomStyleFunc

func WithCustomStyleFunc[T Item](fn func(T, InputState)) ItemOption

WithCustomStyleFunc specifies a function to define the style of an item based on events. The function fn will replace the default function. This function is called every tick, and will always called before the update function.

func WithCustomUpdateFunc

func WithCustomUpdateFunc[T Item](fn func(T, InputState)) ItemOption

WithCustomUpdateFunc specifies a function to be called every tick for logic handling. The function fn will replace the default function. This function can also be used to edit the style of components and will overwrite any changes made by the func provided by WithStyleFunc, since it executes after.

func WithData

func WithData(data any) ItemOption

type Layout

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

Layout represents a surface (or window) acting as a grid, container for child UI items A Layout cannot exist without a grid

func NewLayout

func NewLayout(columns, rows int, unit image.Rectangle) *Layout

func NewLayoutFromGrid

func NewLayoutFromGrid(grid *Grid, unit image.Rectangle) *Layout

func (*Layout) Dimensions

func (l *Layout) Dimensions() (int, int)

func (*Layout) Draw

func (l *Layout) Draw(screen *ebiten.Image)

func (*Layout) Grid

func (l *Layout) Grid() *Grid

func (*Layout) SetDimensions

func (l *Layout) SetDimensions(width, height int)

func (*Layout) SetUnit

func (l *Layout) SetUnit(unit image.Rectangle)

func (*Layout) Unit

func (l *Layout) Unit() image.Rectangle

func (*Layout) Update

func (l *Layout) Update(offset image.Point, is InputState)

func (*Layout) WithGrid

func (l *Layout) WithGrid(g *Grid) *Layout

type Shape

type Shape graphics.Shape

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

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