pigui

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pigui offers a minimal API for building GUIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DrawEvent

type DrawEvent struct {
	Element    *Element
	HasPointer bool

	Pressed bool
	// contains filtered or unexported fields
}

func (DrawEvent) StopPropagation

func (e DrawEvent) StopPropagation()

call it if you don't want the event to be propagated to children

type Element

type Element struct {
	pi.Area[int]

	OnDraw    func(DrawEvent)
	OnUpdate  func(UpdateEvent)
	OnPress   func(Event)
	OnRelease func(Event)
	OnTap     func(Event)
	// contains filtered or unexported fields
}

func Attach

func Attach(parent *Element, x, y, w, h int) *Element

Attach attaches a new element with the specified size to the parent.

It returns the newly created element.

func New

func New() *Element

New creates a new GUI root element with the current screen size.

To update and draw the element along with its children, add it to your game loop by calling Element.Update and Element.Draw.

func (*Element) Attach

func (e *Element) Attach(child *Element)

Attach re-attaches an existing element to the parent e.

func (*Element) Detach

func (e *Element) Detach(child *Element)

Detach detaches the specified child element from e.

func (*Element) Draw

func (e *Element) Draw()

Draw should be called from within pi.Draw or by any subscriber listening to piloop.EventDraw events

func (*Element) Update

func (e *Element) Update()

Update should be called from within pi.Update or by any subscriber listening to piloop.EventUpdate events

type Event

type Event struct {
	Element    *Element
	HasPointer bool
}

type UpdateEvent

type UpdateEvent struct {
	Element    *Element
	HasPointer bool
	// contains filtered or unexported fields
}

func (UpdateEvent) StopPropagation

func (e UpdateEvent) StopPropagation()

call it if you don't want the event to be propagated to children

Jump to

Keyboard shortcuts

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