Documentation
¶
Index ¶
- type App
- func (a *App) AddFocusable(widgets ...Widget)
- func (a *App) Backend() gfxdisplay.Backend
- func (a *App) ClearFocusables()
- func (a *App) CloseMenu()
- func (a *App) Configure(fn func(*App))
- func (a *App) FindElement(id string) *ui.Element
- func (a *App) Focus(widget Widget)
- func (a *App) FocusNext()
- func (a *App) FocusPrevious()
- func (a *App) Input() gfxinput.Handler
- func (a *App) LoadFile(path string, handler interface{}) error
- func (a *App) LoadString(source string, handler interface{}) error
- func (a *App) OpenMenu(menuID string, x, y int) bool
- func (a *App) Quit()
- func (a *App) Redraw()
- func (a *App) RegisterClientShortcut(shortcutID, windowID uint32, key gfxinput.Key, ch rune, ...) error
- func (a *App) RegisterGlobalShortcut(shortcutID uint32, key gfxinput.Key, ch rune, modifiers gfxinput.Modifiers, ...) error
- func (a *App) RegisterShortcut(shortcutID, windowID, scope uint32, key gfxinput.Key, ch rune, ...) error
- func (a *App) RequestFrame()
- func (a *App) Root() Widget
- func (a *App) Run() error
- func (a *App) SetBackground(c color.NRGBA)
- func (a *App) SetDebugDamage(enabled bool)
- func (a *App) SetDebugFlashColor(c color.NRGBA)
- func (a *App) SetDebugFlashFrames(frames int)
- func (a *App) SetFPS(fps int)
- func (a *App) SetOptions(opts Options)
- func (a *App) SetRoot(widget Widget)
- func (a *App) SetTitle(title string)
- func (a *App) Size() (width, height int)
- func (a *App) UIRoot() *ui.Element
- func (a *App) UnregisterShortcut(shortcutID uint32) error
- type Options
- type Widget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
OnQuit func()
OnEscape func() // If set, called on Escape instead of quitting.
OnEvent func(ev gfxinput.Event) bool
// contains filtered or unexported fields
}
App represents the main application with a single root widget that fills the entire screen.
func (*App) AddFocusable ¶
AddFocusable registers a widget for keyboard focus (tab navigation). These are typically interactive leaf widgets (buttons, text inputs) that live somewhere inside the root widget tree.
func (*App) Backend ¶
func (a *App) Backend() gfxdisplay.Backend
Backend returns the display backend.
func (*App) ClearFocusables ¶
func (a *App) ClearFocusables()
ClearFocusables removes all registered focusable widgets.
func (*App) CloseMenu ¶
func (a *App) CloseMenu()
CloseMenu closes the currently open popup menu, if any.
func (*App) FindElement ¶
FindElement searches the loaded declarative tree by id.
func (*App) FocusNext ¶
func (a *App) FocusNext()
FocusNext moves focus to the next focusable widget.
func (*App) FocusPrevious ¶
func (a *App) FocusPrevious()
FocusPrevious moves focus to the previous focusable widget.
func (*App) LoadString ¶
LoadString loads UI from a string source.
func (*App) OpenMenu ¶
OpenMenu opens a popup menu at window-local coordinates (x, y) using the menu definition found by menuID in the current UI tree.
func (*App) RegisterClientShortcut ¶
func (a *App) RegisterClientShortcut(shortcutID, windowID uint32, key gfxinput.Key, ch rune, modifiers gfxinput.Modifiers, handler func(gfxinput.Event)) error
RegisterClientShortcut registers a shortcut scoped to this client. Pass windowID=0 to match any window from this client.
func (*App) RegisterGlobalShortcut ¶
func (a *App) RegisterGlobalShortcut(shortcutID uint32, key gfxinput.Key, ch rune, modifiers gfxinput.Modifiers, handler func(gfxinput.Event)) error
RegisterGlobalShortcut registers a global shortcut callback.
func (*App) RegisterShortcut ¶
func (a *App) RegisterShortcut(shortcutID, windowID, scope uint32, key gfxinput.Key, ch rune, modifiers gfxinput.Modifiers, handler func(gfxinput.Event)) error
RegisterShortcut registers a compositor shortcut callback. If key is gfxinput.KeyNone, ch must be a printable rune.
func (*App) RequestFrame ¶
func (a *App) RequestFrame()
RequestFrame schedules a render pass without forcing a full-screen redraw.
func (*App) Run ¶
Run starts the main application loop. The root widget is resized to fill the entire framebuffer.
func (*App) SetBackground ¶
SetBackground sets the background color.
func (*App) SetDebugDamage ¶
SetDebugDamage enables or disables the damage flash overlay. When enabled, repainted regions flash red and fade out over several frames, similar to Android's "Show surface updates" developer option.
func (*App) SetDebugFlashColor ¶
SetDebugFlashColor sets the flash overlay color (default semi-transparent red).
func (*App) SetDebugFlashFrames ¶
SetDebugFlashFrames sets how many frames each flash persists (default 6).
func (*App) SetOptions ¶
SetOptions configures app startup options on this instance.
func (*App) SetRoot ¶
SetRoot sets the single root widget. It will be resized to fill the entire screen when Run() is called.
func (*App) UnregisterShortcut ¶
UnregisterShortcut removes a previously registered shortcut callback.
type Options ¶
type Options struct {
Title string // Window title.
Width int // Window width; 0 = default (800).
Height int // Window height; 0 = default (600).
Backend gfxdisplay.Backend // Display backend (required).
Input gfxinput.Handler // Input handler (required).
FPS int // Target FPS; 0 = default (60).
Background color.NRGBA // Background color.
BackgroundSet bool // When true, use Background even if it is transparent (0 alpha).
}
Options configures a new application.
type Widget ¶
type Widget interface {
Draw(buf *core.Buffer)
Bounds() image.Rectangle
SetBounds(r image.Rectangle)
MinSize() image.Point
HandleEvent(ev gfxinput.Event) bool
SetFocused(focused bool)
IsFocused() bool
IsDirty() bool
MarkClean()
SetVisible(visible bool)
IsVisible() bool
}
Widget is the rendering/input contract expected by app.App.