avyos.dev/pkg/graphics/app
package app
Package Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 0 |
| Variables | 0 |
| Functions | 1 |
| Types | 2 |
Functions
func ApplyConfiguredDefaultFont() errorApplyConfiguredDefaultFont loads config/fonts.ini and sets Default/UI fonts. It always applies bitmap fallback first so rendering remains functional.
Types
App
type App struct {
OnQuit func()
OnEscape func() // If set, called on Escape instead of quitting.
OnEvent func(ev graphics.Event) bool
// contains filtered or unexported fields
}App represents the main application with a single root widget that fills the entire screen.
Functions
func New(opts Options) *AppNew creates a new application with the given options.
Methods
func (a *App) AddFocusable(widgets ...graphics.Widget)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 (a *App) Backend() graphics.BackendBackend returns the display backend.
func (a *App) ClearFocusables()ClearFocusables removes all registered focusable widgets.
func (a *App) Focus(widget graphics.Widget)Focus sets keyboard focus to a specific widget.
func (a *App) FocusNext()FocusNext moves focus to the next focusable widget.
func (a *App) FocusPrevious()FocusPrevious moves focus to the previous focusable widget.
func (a *App) Input() graphics.InputHandlerInput returns the input handler.
func (a *App) Quit()Quit stops the application.
func (a *App) Redraw()Redraw marks the entire screen for redraw.
func (a *App) RegisterShortcut(shortcutID, windowID, scope uint32, key graphics.Key, ch rune, modifiers graphics.Modifiers, handler func(graphics.Event)) errorRegisterShortcut registers a compositor shortcut callback. If key is graphics.KeyNone, ch must be a printable rune.
func (a *App) RequestFrame()RequestFrame schedules a render pass without forcing a full-screen redraw.
func (a *App) Root() graphics.WidgetRoot returns the current root widget.
func (a *App) Run() errorRun starts the main application loop. The root widget is resized to fill the entire framebuffer.
func (a *App) SetBackground(c graphics.Color)SetBackground sets the background color.
func (a *App) SetDebugDamage(enabled bool)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 (a *App) SetDebugFlashColor(c graphics.Color)SetDebugFlashColor sets the flash overlay color (default semi-transparent red).
func (a *App) SetDebugFlashFrames(frames int)SetDebugFlashFrames sets how many frames each flash persists (default 6).
func (a *App) SetFPS(fps int)SetFPS sets the target frames per second.
func (a *App) SetRoot(widget graphics.Widget)SetRoot sets the single root widget. It will be resized to fill the entire screen when Run() is called.
func (a *App) SetTitle(title string)SetTitle sets the application title (informational only).
func (a *App) Size() (width, height int)Size returns the screen size.
func (a *App) UnregisterShortcut(shortcutID uint32) errorUnregisterShortcut removes a previously registered shortcut callback.
Options
type Options struct {
Title string // Window title.
Width int // Window width; 0 = default (800).
Height int // Window height; 0 = default (600).
Backend graphics.Backend // Display backend (required).
Input graphics.InputHandler // Input handler (required).
FPS int // Target FPS; 0 = default (60).
Background graphics.Color // Background color.
BackgroundSet bool // When true, use Background even if it is transparent (0 alpha).
}Options configures a new application.