widgets

package
v0.0.0-...-657eaca Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetProperties

func SetProperties(p *Properties)

Types

type Event

type Event uint8

I want to try and simplify event handling for widgets. Not sure this counts.

const (
	ButtonUp Event = iota
	ButtonDown
	ButtonLeft
	ButtonRight
	ButtonA
	ButtonB
	ButtonSelect
	ButtonStart
)

type Home

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

Home widget displaying our name and logo. Felt cute. Might delete later.

func NewHome

func NewHome(renderer *sdl.Renderer, size *sdl.Rect) *Home

func (*Home) ProcessEvent

func (h *Home) ProcessEvent(e Event) bool

func (Home) SetNext

func (w Home) SetNext(next Widget)

func (*Home) Texture

func (h *Home) Texture() *sdl.Texture
type Menu struct {
	// contains filtered or unexported fields
}

Menu widget displaying a list of potential choices, each of which should map to some kind of Action.

func NewMenu

func NewMenu(r *sdl.Renderer, s *sdl.Rect, choices []MenuChoice) *Menu
func (m *Menu) Confirm()
func (m *Menu) Down()
func (m *Menu) ProcessEvent(e Event) bool
func (w Menu) SetNext(next Widget)
func (m *Menu) Texture() *sdl.Texture
func (m *Menu) Up()
type MenuChoice struct {
	Text   string
	Action func()
}

MenuChoice groups a choice string with the corresponding action.

type Properties

type Properties struct {
	Font      *ttf.Font
	TitleFont *ttf.Font

	BgColor sdl.Color
	FgColor sdl.Color

	Zoom int // Zoom factor for the GameBoy display. Used for outlines, margins.
}

Properties stores useful configuration variables to be passed to all widgets at creation time.

type Widget

type Widget interface {
	ProcessEvent(Event) bool
	Texture() *sdl.Texture
}

Jump to

Keyboard shortcuts

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