screens

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseScreen

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

BaseScreen provides common scroll and focus management for screens. Embed this in screen structs to get scroll position preservation and focus restoration after rebuilds.

func (*BaseScreen) ClearFocusButtons

func (b *BaseScreen) ClearFocusButtons()

ClearFocusButtons clears all registered focus buttons and navigation zones. Call this at the start of Build() before registering new buttons.

func (*BaseScreen) ClearPendingFocus

func (b *BaseScreen) ClearPendingFocus()

ClearPendingFocus clears the pending focus state.

func (*BaseScreen) EnsureFocusedVisible

func (b *BaseScreen) EnsureFocusedVisible(focused widget.Focuser, isScrollableButton func(*widget.Button) bool)

EnsureFocusedVisible scrolls the view to ensure the focused widget is visible. The isScrollableButton function should return true if the focused widget should trigger scrolling (e.g., game buttons but not toolbar buttons).

func (*BaseScreen) FindFocusInDirection

func (b *BaseScreen) FindFocusInDirection(current widget.Focuser, direction int) *widget.Button

FindFocusInDirection finds the next button in the specified direction using zone-based navigation. Falls back to spatial navigation if no zones defined. Returns nil if no suitable target found.

func (*BaseScreen) GetPendingFocusButton

func (b *BaseScreen) GetPendingFocusButton() *widget.Button

GetPendingFocusButton returns the button that should receive focus after rebuild. Returns nil if no pending focus or button not found.

func (*BaseScreen) InitBase

func (b *BaseScreen) InitBase()

InitBase initializes the base screen state. Call this in the screen's constructor.

func (*BaseScreen) RegisterFocusButton

func (b *BaseScreen) RegisterFocusButton(key string, btn *widget.Button)

RegisterFocusButton registers a button for focus restoration. Call this during Build() for each focusable button.

func (*BaseScreen) RegisterNavZone

func (b *BaseScreen) RegisterNavZone(name string, zoneType string, keys []string, columns int)

RegisterNavZone registers a navigation zone with ordered buttons. For grid zones, keys should be in row-major order (left-to-right, top-to-bottom). zoneType should be types.NavZoneHorizontal, types.NavZoneVertical, or types.NavZoneGrid. columns is only used for grid zones.

func (*BaseScreen) RestoreScrollPosition

func (b *BaseScreen) RestoreScrollPosition()

RestoreScrollPosition restores the saved scroll position. Call this after rebuilding the screen, once the scroll container is set.

func (*BaseScreen) SaveFocusState

func (b *BaseScreen) SaveFocusState(focused widget.Focuser)

SaveFocusState checks which registered focus button currently has focus and saves its key as pending focus. This preserves focus across rebuilds triggered by async operations (e.g., achievement loading). Does nothing if pendingFocus is already set (e.g., by OnEnter).

func (*BaseScreen) SaveScrollPosition

func (b *BaseScreen) SaveScrollPosition()

SaveScrollPosition saves the current scroll position. Call this before rebuilding the screen.

func (*BaseScreen) SetDefaultFocus

func (b *BaseScreen) SetDefaultFocus(key string)

SetDefaultFocus sets the pending focus only if no focus is currently pending. Use this in OnEnter() to set initial focus without overriding restored focus.

func (*BaseScreen) SetNavTransition

func (b *BaseScreen) SetNavTransition(fromZone string, direction int, toZone string, toIndex int)

SetNavTransition defines where to navigate when leaving a zone in a direction.

func (*BaseScreen) SetPendingFocus

func (b *BaseScreen) SetPendingFocus(key string)

SetPendingFocus sets the key of the button to focus after rebuild.

func (*BaseScreen) SetScrollWidgets

func (b *BaseScreen) SetScrollWidgets(scrollContainer *widget.ScrollContainer, vSlider *widget.Slider)

SetScrollWidgets stores references to the scroll widgets for position preservation. Call this during Build() after creating the scroll container.

type DetailScreen

type DetailScreen struct {
	BaseScreen // Embedded for focus restoration
	// contains filtered or unexported fields
}

DetailScreen displays game information and launch options

func NewDetailScreen

func NewDetailScreen(callback ScreenCallback, library *storage.Library, config *storage.Config, achievementManager *achievements.Manager) *DetailScreen

NewDetailScreen creates a new detail screen

func (*DetailScreen) Build

func (s *DetailScreen) Build() *widget.Container

Build creates the detail screen UI

func (*DetailScreen) OnEnter

func (s *DetailScreen) OnEnter()

OnEnter is called when entering the detail screen

func (*DetailScreen) SetGame

func (s *DetailScreen) SetGame(gameCRC string)

SetGame sets the game to display

type ErrorMode

type ErrorMode int

ErrorMode distinguishes between types of config errors

const (
	// ErrorModeCorrupted indicates the JSON file could not be parsed
	ErrorModeCorrupted ErrorMode = iota
	// ErrorModeInvalid indicates the JSON parsed but contains invalid values
	ErrorModeInvalid
)

type ErrorScreen

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

ErrorScreen displays startup errors for corrupted config/library files

func NewErrorScreen

func NewErrorScreen(callback ScreenCallback, filename, filepath string, onDelete func()) *ErrorScreen

NewErrorScreen creates a new error screen

func (*ErrorScreen) Build

func (s *ErrorScreen) Build() *widget.Container

Build creates the error screen UI

func (*ErrorScreen) OnEnter

func (s *ErrorScreen) OnEnter()

OnEnter is called when entering the error screen

func (*ErrorScreen) SetError

func (s *ErrorScreen) SetError(filename, filepath string)

SetError updates the error details (used when transitioning between errors)

func (*ErrorScreen) SetValidationError

func (s *ErrorScreen) SetValidationError(filename, filepath string, details []string, onReset func())

SetValidationError configures the screen for validation error display

type FocusManager

type FocusManager = types.FocusManager

Re-export interfaces from types package for backward compatibility

type FocusRestorer

type FocusRestorer = types.FocusRestorer

Re-export interfaces from types package for backward compatibility

type LibraryScreen

type LibraryScreen struct {
	BaseScreen // Embedded for focus restoration
	// contains filtered or unexported fields
}

LibraryScreen displays the game library

func NewLibraryScreen

func NewLibraryScreen(callback ScreenCallback, library *storage.Library, config *storage.Config) *LibraryScreen

NewLibraryScreen creates a new library screen

func (*LibraryScreen) Build

func (s *LibraryScreen) Build() *widget.Container

Build creates the library screen UI

func (*LibraryScreen) ClearArtworkCache

func (s *LibraryScreen) ClearArtworkCache()

ClearArtworkCache clears the cached artwork images. Should be called after library scan or when library locations change.

func (*LibraryScreen) EnsureFocusedVisible

func (s *LibraryScreen) EnsureFocusedVisible(focused widget.Focuser)

EnsureFocusedVisible scrolls the view to ensure the focused widget is visible This is called after gamepad navigation changes focus

func (*LibraryScreen) OnEnter

func (s *LibraryScreen) OnEnter()

OnEnter is called when entering the library screen

func (*LibraryScreen) SaveScrollPosition

func (s *LibraryScreen) SaveScrollPosition()

SaveScrollPosition saves the current scroll position before a rebuild This should be called before rebuildCurrentScreen

func (*LibraryScreen) SetConfig

func (s *LibraryScreen) SetConfig(config *storage.Config)

SetConfig updates the config reference

func (*LibraryScreen) SetLibrary

func (s *LibraryScreen) SetLibrary(library *storage.Library)

SetLibrary updates the library reference

func (*LibraryScreen) SetSearchText

func (s *LibraryScreen) SetSearchText(text string)

SetSearchText sets the search filter text and resets scroll position

type NavTransition struct {
	ToZone  string // Target zone name
	ToIndex int    // Index in target zone (-1 = preserve column/position, -2 = first, -3 = last)
}

NavTransition defines where to go when leaving a zone

type NavZone struct {
	Type    string   // types.NavZoneHorizontal, types.NavZoneVertical, or types.NavZoneGrid
	Keys    []string // Button keys in order (left-to-right for horizontal, top-to-bottom for vertical, row-major for grid)
	Columns int      // Number of columns for grid zones (ignored for other types)
}

NavZone defines a navigation zone with ordered buttons

type ScanProgress

type ScanProgress struct {
	Phase           int
	Progress        float64
	GamesFound      int
	ArtworkTotal    int
	ArtworkComplete int
	StatusText      string
}

ScanProgress represents progress updates from the scanner This mirrors the ui.ScanProgress type

type ScanProgressScreen

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

ScanProgressScreen displays ROM scanning progress

func NewScanProgressScreen

func NewScanProgressScreen(callback ScreenCallback) *ScanProgressScreen

NewScanProgressScreen creates a new scan progress screen

func (*ScanProgressScreen) Build

func (s *ScanProgressScreen) Build() *widget.Container

Build creates the scan progress screen UI

func (*ScanProgressScreen) IsCancelled

func (s *ScanProgressScreen) IsCancelled() bool

IsCancelled returns true if cancel was requested

func (*ScanProgressScreen) OnEnter

func (s *ScanProgressScreen) OnEnter()

OnEnter is called when entering the scan progress screen

func (*ScanProgressScreen) OnExit

func (s *ScanProgressScreen) OnExit()

OnExit is called when leaving the scan progress screen

func (*ScanProgressScreen) SetScanner

func (s *ScanProgressScreen) SetScanner(scanner Scanner)

SetScanner sets the active scanner

func (*ScanProgressScreen) UpdateProgress

func (s *ScanProgressScreen) UpdateProgress(p ScanProgress)

UpdateProgress updates the screen with new progress information

type Scanner

type Scanner interface {
	Cancel()
}

Scanner interface for decoupling

type ScreenCallback

type ScreenCallback = types.ScreenCallback

Re-export interfaces from types package for backward compatibility

type SettingsScreen

type SettingsScreen struct {
	BaseScreen // Embedded for focus restoration
	// contains filtered or unexported fields
}

SettingsScreen displays application settings

func NewSettingsScreen

func NewSettingsScreen(callback ScreenCallback, library *storage.Library, config *storage.Config, achievementMgr *achievements.Manager, serializeSize int, systemInfo coreif.SystemInfo) *SettingsScreen

NewSettingsScreen creates a new settings screen. serializeSize is the bytes per save state for rewind duration estimates. systemInfo provides button definitions and core options for the input section.

func (*SettingsScreen) Build

func (s *SettingsScreen) Build() *widget.Container

Build creates the settings screen UI

func (*SettingsScreen) ClearPendingScan

func (s *SettingsScreen) ClearPendingScan()

ClearPendingScan delegates to library section

func (*SettingsScreen) EnsureFocusedVisible

func (s *SettingsScreen) EnsureFocusedVisible(focused widget.Focuser)

EnsureFocusedVisible scrolls the theme list to keep the focused widget visible

func (*SettingsScreen) HasPendingScan

func (s *SettingsScreen) HasPendingScan() bool

HasPendingScan delegates to library section

func (*SettingsScreen) IsInputCaptureActive added in v0.2.0

func (s *SettingsScreen) IsInputCaptureActive() bool

IsInputCaptureActive returns true when the input section is waiting for a key/button press

func (*SettingsScreen) OnEnter

func (s *SettingsScreen) OnEnter()

OnEnter is called when entering the settings screen

func (*SettingsScreen) SetAchievements

func (s *SettingsScreen) SetAchievements(mgr *achievements.Manager)

SetAchievements updates the achievement manager reference

func (*SettingsScreen) SetConfig

func (s *SettingsScreen) SetConfig(config *storage.Config)

SetConfig updates the config reference in all config-dependent sections

func (*SettingsScreen) SetLibrary

func (s *SettingsScreen) SetLibrary(library *storage.Library)

SetLibrary updates the library reference in the library section

func (*SettingsScreen) Update

func (s *SettingsScreen) Update()

Update handles per-frame updates for settings sections

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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