gui

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Unlicense Imports: 43 Imported by: 0

Documentation

Overview

package gui implements the SeedHammer controller user interface.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("backup: data does not fit plate")
View Source
var ProgressImageGen = op.RegisterParameterizedImage(func(args op.ImageArguments, x, y int) color.RGBA64 {
	src := args.Refs[0].(image.RGBA64Image)
	progress := math.Float32frombits(args.Args[0])
	b := src.Bounds()
	c := b.Max.Add(b.Min).Div(2)
	d := image.Pt(x, y).Sub(c)
	angle := float32(math.Atan2(float64(d.X), float64(d.Y)))
	angle = math.Pi - angle
	if angle > 2*math.Pi*progress {
		return color.RGBA64{}
	}
	return src.RGBA64At(x, y)
})

Functions

func Run added in v1.3.2

func Run(pl Platform, version string) func(yield func() bool)

func ShowAddressesScreen added in v1.3.2

func ShowAddressesScreen(ctx *Context, ops op.Ctx, th *Colors, desc *bip380.Descriptor)

Types

type BoundedTag added in v1.3.6

type BoundedTag struct {
	Tag    op.Tag
	Bounds image.Rectangle
}

type Button added in v1.2.0

type Button int
const (
	None Button = iota
	Up
	Down
	Left
	Right
	Center
	Button1
	Button2
	Button3
	MaxButton
)

func (Button) String added in v1.3.0

func (b Button) String() string

type ButtonEvent added in v1.2.0

type ButtonEvent struct {
	Button  Button
	Pressed bool
}

func (ButtonEvent) Event added in v1.3.0

func (b ButtonEvent) Event() Event

type ButtonStyle

type ButtonStyle int
const (
	StyleNone ButtonStyle = iota
	StyleSecondary
	StylePrimary
)

type Choice added in v1.3.6

type Choice struct {
	Size image.Point
	W    op.CallOp
	// contains filtered or unexported fields
}

type ChoiceScreen

type ChoiceScreen struct {
	Title   string
	Lead    string
	Choices []string
	// contains filtered or unexported fields
}

func (*ChoiceScreen) Choose added in v1.3.0

func (s *ChoiceScreen) Choose(ctx *Context, ops op.Ctx, th *Colors) (int, bool)

func (*ChoiceScreen) Draw added in v1.3.0

func (s *ChoiceScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point)

type Clickable added in v1.3.6

type Clickable struct {
	Button     Button
	AltButton  Button
	Repeatable bool

	Pressed bool
	Entered bool
	// contains filtered or unexported fields
}

func (*Clickable) Clicked added in v1.3.6

func (c *Clickable) Clicked(ctx *Context) bool

func (*Clickable) For added in v1.3.6

func (c *Clickable) For(btns ...Button) *Clickable

func (*Clickable) Next added in v1.3.6

func (c *Clickable) Next(ctx *Context) (ClickableEvent, bool)

type ClickableEvent added in v1.3.6

type ClickableEvent struct {
	Clicked bool
}

type Colors

type Colors struct {
	Background color.NRGBA
	Text       color.NRGBA
	Primary    color.NRGBA
}

type ConfirmDelay

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

func (*ConfirmDelay) Progress

func (c *ConfirmDelay) Progress(ctx *Context) float32

func (*ConfirmDelay) Start

func (c *ConfirmDelay) Start(ctx *Context, delay time.Duration)

type ConfirmResult

type ConfirmResult int
const (
	ConfirmNone ConfirmResult = iota
	ConfirmNo
	ConfirmYes
)

type ConfirmWarningScreen

type ConfirmWarningScreen struct {
	Title string
	Body  string
	Icon  image.RGBA64Image
	// contains filtered or unexported fields
}

func (*ConfirmWarningScreen) Layout

func (s *ConfirmWarningScreen) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point) ConfirmResult

type Context

type Context struct {
	Platform      Platform
	Styles        Styles
	Wakeup        time.Time
	Done          bool
	FrameCallback func()

	// Global UI state.
	Version        string
	LastDescriptor *bip380.Descriptor

	Router EventRouter
	// contains filtered or unexported fields
}

func NewContext

func NewContext(pl Platform) *Context

func (*Context) Frame added in v1.2.0

func (c *Context) Frame()

func (*Context) Reset added in v1.2.0

func (c *Context) Reset()

func (*Context) Scan added in v1.3.6

func (c *Context) Scan() (scanResult, bool)

func (*Context) WakeupAt added in v1.2.0

func (c *Context) WakeupAt(t time.Time)

type DescriptorScreen

type DescriptorScreen struct {
	Descriptor *bip380.Descriptor
}

func (*DescriptorScreen) Confirm added in v1.3.0

func (s *DescriptorScreen) Confirm(ctx *Context, ops op.Ctx, th *Colors) (Plate, bool)

func (*DescriptorScreen) Draw added in v1.3.0

func (s *DescriptorScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point)

type EngraveScreen

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

func NewEngraveScreen

func NewEngraveScreen(ctx *Context, plate Plate) *EngraveScreen

func (*EngraveScreen) Engrave added in v1.3.0

func (s *EngraveScreen) Engrave(ctx *Context, ops op.Ctx, th *Colors) bool

type Engraver added in v1.3.0

type Engraver interface {
	stepper.Writer
	Close() error
	Stats() EngraverStats
}

type EngraverStats added in v1.4.0

type EngraverStats struct {
	StallSpeed       int
	XSpeed, YSpeed   int
	XLoad, YLoad     int
	XStalls, YStalls int
	Error            error
}

type ErrorScreen

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

func NewErrorScreen

func NewErrorScreen(err error) *ErrorScreen

func (*ErrorScreen) Layout

func (s *ErrorScreen) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point) bool

type Event

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

func (Event) AsButton added in v1.3.0

func (e Event) AsButton() (ButtonEvent, bool)

func (Event) AsFrame added in v1.3.0

func (e Event) AsFrame() (FrameEvent, bool)

func (Event) AsPointer added in v1.3.6

func (e Event) AsPointer() (PointerEvent, bool)

func (Event) AsRune added in v1.3.6

func (e Event) AsRune() (RuneEvent, bool)

func (Event) String added in v1.4.0

func (e Event) String() string

type EventRouter added in v1.4.0

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

func (*EventRouter) Events added in v1.4.0

func (r *EventRouter) Events(o *op.Ops, evts ...Event)

func (*EventRouter) Next added in v1.4.0

func (r *EventRouter) Next(filters ...Filter) (Event, bool)

func (*EventRouter) Reset added in v1.4.0

func (r *EventRouter) Reset() bool

type Features added in v1.3.6

type Features int
const (
	FeatureSecureBoot Features = 1 << iota
)

func (Features) Has added in v1.3.6

func (f Features) Has(feat Features) bool

type Filter added in v1.3.6

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

func ButtonFilter added in v1.3.6

func ButtonFilter(b Button) Filter

func FrameFilter added in v1.3.6

func FrameFilter() Filter

func PointerFilter added in v1.3.6

func PointerFilter(t op.Tag) Filter

func RuneFilter added in v1.3.6

func RuneFilter() Filter

type FrameEvent added in v1.2.0

type FrameEvent struct {
	Error error
	Image image.Image
}

func (FrameEvent) Event added in v1.3.0

func (f FrameEvent) Event() Event

type InputTracker added in v1.3.0

type InputTracker struct {
	Pressed [MaxButton]bool
	// contains filtered or unexported fields
}

func (*InputTracker) Next added in v1.3.0

func (t *InputTracker) Next(c *Context, filters ...Filter) (Event, bool)

type Keyboard

type Keyboard struct {
	Fragment string
	// contains filtered or unexported fields
}

func NewKeyboard

func NewKeyboard(ctx *Context, alphabet string) *Keyboard

func (*Keyboard) Clear

func (k *Keyboard) Clear()

func (*Keyboard) Layout

func (k *Keyboard) Layout(ctx *Context, ops op.Ctx, th *Colors) image.Point

func (*Keyboard) Update added in v1.2.0

func (k *Keyboard) Update(ctx *Context) bool

func (*Keyboard) Valid

func (k *Keyboard) Valid(key keyboardKey) bool

type Knotter added in v1.4.0

type Knotter interface {
	Knot(k bspline.Knot) (completed uint, err error)
}

type MainScreen

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

func (*MainScreen) Flow added in v1.3.6

func (m *MainScreen) Flow(ctx *Context, ops op.Ctx)
type NavButton struct {
	Clickable *Clickable
	Style     ButtonStyle
	Icon      image.Image
	Progress  float32
}

type Plate added in v1.2.0

type Plate struct {
	Duration uint
	Spline   bspline.Curve
}

type PlateSize added in v1.4.0

type PlateSize int
const (
	SquarePlate PlateSize = iota
)

func (PlateSize) Dims added in v1.4.0

func (p PlateSize) Dims(mm int) bezier.Point

type Platform

type Platform interface {
	LockBoot() error
	AppendEvents(deadline time.Time, evts []Event) []Event
	Wakeup()
	Engraver(stall bool) (Engraver, error)
	NFCReader() io.Reader
	EngraverParams() engrave.Params
	DisplaySize() image.Point
	// Dirty begins a refresh of the content
	// specified by r.
	Dirty(r image.Rectangle) error
	// NextChunk returns the next chunk of the refresh.
	NextChunk() (draw.RGBA64Image, bool)
	Features() Features
	HardwareVersion() string
}

type PointerEvent added in v1.3.6

type PointerEvent struct {
	Pressed bool
	Entered bool
	Pos     image.Point
}

func (PointerEvent) Event added in v1.3.6

func (p PointerEvent) Event() Event

type ProgressImage

type ProgressImage struct {
	Progress float32
	Src      image.RGBA64Image
}

func (*ProgressImage) Add added in v1.3.2

func (p *ProgressImage) Add(ctx op.Ctx)

type QRDecoder added in v1.3.0

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

func (*QRDecoder) Progress added in v1.3.0

func (d *QRDecoder) Progress() int

type RuneEvent added in v1.3.6

type RuneEvent struct {
	Rune rune
}

func (RuneEvent) Event added in v1.3.6

func (r RuneEvent) Event() Event

type ScanEvent added in v1.3.6

type ScanEvent struct {
	Content any
}

type SeedScreen

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

func (*SeedScreen) Confirm added in v1.3.0

func (s *SeedScreen) Confirm(ctx *Context, ops op.Ctx, th *Colors, mnemonic bip39.Mnemonic) bool

func (*SeedScreen) Draw added in v1.3.0

func (s *SeedScreen) Draw(ctx *Context, ops op.Ctx, th *Colors, dims image.Point, mnemonic bip39.Mnemonic)

type Styles

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

func NewStyles

func NewStyles() Styles

type Warning added in v1.2.0

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

func (*Warning) Layout added in v1.2.0

func (w *Warning) Layout(ctx *Context, ops op.Ctx, th *Colors, dims image.Point, title, txt string) image.Point

Directories

Path Synopsis
Code generated by gui/assets/gen.go; DO NOT EDIT.
Code generated by gui/assets/gen.go; DO NOT EDIT.

Jump to

Keyboard shortcuts

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