gui

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gui implements UI form elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	Label    string
	X, Y, Z  float32
	Dy       float32
	Sx, Sy   float32
	MaxWidth float32
	FocusHandler
	OnSelect     func()
	Color        sprites.Color
	Font         sprites.FontID
	Centered     bool
	DefaultFocus bool
	Style        ButtonStyle
}

Button is a (clickable) label.

func (*Button) Height

func (b *Button) Height() float32

func (*Button) Render

func (b *Button) Render(tb *sprites.Batch)

func (*Button) SetY

func (b *Button) SetY(y float32)

func (*Button) TextWidth added in v0.3.1

func (b *Button) TextWidth() float32

func (*Button) Update

func (b *Button) Update(cam *gfx.Camera, ictx *input.Context)

func (*Button) Width

func (b *Button) Width() float32

type ButtonStyle

type ButtonStyle uint8

ButtonStyle is a render style for a Button control.

const (
	// BtnBorder is outlined text. When the button is hovered, the border
	// changes from black to rainbow.
	BtnBorder ButtonStyle = iota
	// BtnShadow is text with a drop shadow. When the button is hovered,
	// the text color changes to yellow.
	BtnShadow
	// BtnNone is plain text. When the button is hovered, the text color
	// changes to yellow.
	BtnNone
	// BtnTribe is outlined text with a card tribe indicator background.
	// Color changes the color of the background rather than the text.
	BtnTribe
)

type Control

type Control interface {
	Update(cam *gfx.Camera, ictx *input.Context)
	Render(b *sprites.Batch)

	SetY(float32)
	Width() float32
	Height() float32
	HasFocus() bool
}

type FocusHandler added in v0.3.1

type FocusHandler struct {
	InputFocus      **FocusHandler
	InputFocusLeft  func()
	InputFocusRight func()
	InputFocusUp    func()
	InputFocusDown  func()
}

func (*FocusHandler) Focus added in v0.3.1

func (h *FocusHandler) Focus()

func (*FocusHandler) GetFocusHandler added in v0.3.1

func (h *FocusHandler) GetFocusHandler() *FocusHandler

func (*FocusHandler) HasFocus added in v0.3.1

func (h *FocusHandler) HasFocus() bool

type Focuser added in v0.3.1

type Focuser interface {
	GetFocusHandler() *FocusHandler
}

type Horizontal

type Horizontal struct {
	Controls []Control
}

func (*Horizontal) HasFocus

func (h *Horizontal) HasFocus() bool

func (*Horizontal) Height

func (h *Horizontal) Height() float32

func (*Horizontal) Render

func (h *Horizontal) Render(b *sprites.Batch)

func (*Horizontal) SetY

func (h *Horizontal) SetY(y float32)

func (*Horizontal) Update

func (h *Horizontal) Update(cam *gfx.Camera, ictx *input.Context)

func (*Horizontal) Width added in v0.3.1

func (h *Horizontal) Width() float32

type HoverTilt

type HoverTilt struct {
	X, Y       float32
	X0, Y0     float32
	X1, Y1     float32
	Dx, Dy     float32
	Scale      float32
	OffX, OffY float32
	Falloff    float32
	Divisor    float32
	Mins, Maxs gfx.Vector
	Hover      uint8
}

func (*HoverTilt) Render

func (h *HoverTilt) Render(cam *gfx.Camera, render func(*gfx.Camera))

func (*HoverTilt) SetFunHouse added in v0.3.15

func (h *HoverTilt) SetFunHouse(batch *sprites.Batch)

func (*HoverTilt) Update

func (h *HoverTilt) Update(cam *gfx.Camera, cursorX, cursorY float32)

type Number added in v0.3.1

type Number struct {
	Toggle   Toggle
	Prefix   string
	Suffix   string
	Value    int64
	Min      int64
	Max      int64
	Step     int64
	ValueInf bool
	PosInf   bool
	NegInf   bool
	OnChange func(i int64, inf bool)
}

func (*Number) Focus added in v0.3.3

func (n *Number) Focus()

func (*Number) GetFocusHandler added in v0.3.3

func (n *Number) GetFocusHandler() *FocusHandler

func (*Number) HasFocus added in v0.3.3

func (n *Number) HasFocus() bool

func (*Number) Height added in v0.3.3

func (n *Number) Height() float32

func (*Number) Render added in v0.3.1

func (n *Number) Render(tb *sprites.Batch)

func (*Number) SetY added in v0.3.3

func (n *Number) SetY(y float32)

func (*Number) Update added in v0.3.1

func (n *Number) Update(cam *gfx.Camera, ictx *input.Context)

func (*Number) Width added in v0.3.3

func (n *Number) Width() float32

type Scroll

type Scroll struct {
	Control    Control
	Scroll     float32
	Target     float32
	HasTarget  bool
	StealFocus bool
	Size       float32
	Screen     float32
	Margin     float32
	Wheel      float32
	Momentum   float32
}

func (*Scroll) HasFocus

func (s *Scroll) HasFocus() bool

func (*Scroll) Height

func (s *Scroll) Height() float32

func (*Scroll) Render

func (s *Scroll) Render(b *sprites.Batch)

func (*Scroll) SetY

func (s *Scroll) SetY(y float32)

func (*Scroll) Update

func (s *Scroll) Update(cam *gfx.Camera, ictx *input.Context)

type Sprite added in v0.3.1

type Sprite struct {
	Sprite  *sprites.Sprite
	X, Y, Z float32
	Dy      float32
	Sx, Sy  float32
	FocusHandler
	OnSelect     func()
	Color        sprites.Color
	HoverColor   sprites.Color
	DefaultFocus bool
}

Sprite is a (clickable) icon.

func (*Sprite) Height added in v0.3.1

func (s *Sprite) Height() float32

func (*Sprite) Render added in v0.3.1

func (s *Sprite) Render(b *sprites.Batch)

func (*Sprite) SetY added in v0.3.1

func (s *Sprite) SetY(y float32)

func (*Sprite) Update added in v0.3.1

func (s *Sprite) Update(cam *gfx.Camera, ictx *input.Context)

func (*Sprite) Width added in v0.3.1

func (s *Sprite) Width() float32

type Text

type Text struct {
	Text        []rune
	Placeholder string
	FocusHandler
	OnChange func(*[]rune)
	X, Y, Z  float32
	Sx, Sy   float32
	MaxWidth float32
	Dy       float32
	AutoGrow bool
	Font     sprites.FontID
	Rows     int
}

func (*Text) Height

func (t *Text) Height() float32

func (*Text) Lines added in v0.3.1

func (t *Text) Lines() int

func (*Text) Render

func (t *Text) Render(b *sprites.Batch)

func (*Text) SetY

func (t *Text) SetY(y float32)

func (*Text) Update

func (t *Text) Update(cam *gfx.Camera, ictx *input.Context)

func (*Text) Width

func (t *Text) Width() float32

type Toggle

type Toggle struct {
	Button     Button
	OnChange   func(int, ToggleOption)
	Options    []ToggleOption
	Selected   int
	ForceArrow bool
}

func (*Toggle) Focus added in v0.3.3

func (t *Toggle) Focus()

func (*Toggle) GetFocusHandler added in v0.3.3

func (t *Toggle) GetFocusHandler() *FocusHandler

func (*Toggle) HasFocus added in v0.3.3

func (t *Toggle) HasFocus() bool

func (*Toggle) Height added in v0.3.3

func (t *Toggle) Height() float32

func (*Toggle) Render

func (t *Toggle) Render(tb *sprites.Batch)

func (*Toggle) SetY added in v0.3.3

func (t *Toggle) SetY(y float32)

func (*Toggle) Update

func (t *Toggle) Update(cam *gfx.Camera, ictx *input.Context)

func (*Toggle) Width added in v0.3.3

func (t *Toggle) Width() float32

type ToggleOption

type ToggleOption struct {
	Label string
}

type Vertical

type Vertical struct {
	Controls    []Control
	BaseY       float32
	Gap         float32
	AlwaysFocus bool
	// contains filtered or unexported fields
}

func (*Vertical) HasFocus

func (v *Vertical) HasFocus() bool

func (*Vertical) Height

func (v *Vertical) Height() float32

func (*Vertical) Render

func (v *Vertical) Render(b *sprites.Batch)

func (*Vertical) SetY

func (v *Vertical) SetY(y float32)

func (*Vertical) Update

func (v *Vertical) Update(cam *gfx.Camera, ictx *input.Context)

func (*Vertical) Width added in v0.3.1

func (v *Vertical) Width() float32

Jump to

Keyboard shortcuts

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