Documentation
¶
Overview ¶
Package ui provides interactive user-interface components.
Button is a clickable element with Normal/Hovered/Pressed states. Dialog presents a modal overlay with a title, contextual text, and selectable options, each with a callback. Both components handle their own input processing and rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button struct {
// Label is the display text for this button.
Label string
// ShortcutLabel is the text shown in brackets before the label (e.g., "1", "ESC").
ShortcutLabel string
// X is the left edge of the button in screen pixels.
X float64
// Y is the top edge of the button in screen pixels.
Y float64
// Width is the button width in screen pixels.
Width float64
// Height is the button height in screen pixels.
Height float64
// State is the current visual state of the button.
State ButtonState
// contains filtered or unexported fields
}
Button represents a clickable UI button with text, a keyboard shortcut label, and hover/press states.
type ButtonState ¶
type ButtonState int
ButtonState represents the visual state of a button.
const ( // ButtonStateNone is the default uninitialized button state. ButtonStateNone ButtonState = iota // ButtonStateNormal is the default button state. ButtonStateNormal // ButtonStateHovered is when the mouse cursor is over the button. ButtonStateHovered // ButtonStatePressed is when the button is being clicked. ButtonStatePressed )
type Dialog ¶
type Dialog struct {
// Title is displayed at the top of the dialog.
Title string
// Context is optional text displayed between the title and options.
Context string
// Options is the list of selectable options.
Options []DialogOption
// OnCancel is called when the dialog is dismissed with ESC.
OnCancel func()
// SelectedIndex is the currently highlighted option (for keyboard navigation).
SelectedIndex int
// contains filtered or unexported fields
}
Dialog is a modal UI overlay with a title, optional context text, and selectable options.
func NewDialog ¶
func NewDialog(title string, options []DialogOption, onCancel func()) *Dialog
NewDialog creates a dialog with the given title, options, and cancel callback.
func (*Dialog) SetScreenSize ¶
SetScreenSize updates the screen dimensions used for centering the dialog.
type DialogOption ¶
type DialogOption struct {
// Label is the display text for this option.
Label string
// Detail is optional secondary text shown to the right (e.g., a price or cooldown).
Detail string
// OnSelect is called when this option is selected.
OnSelect func()
}
DialogOption represents a selectable option in the dialog.