screens

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: GPL-3.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const SettingsSectionLibrary = "section-library"

SettingsSectionLibrary is the focus key of the Library settings section

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 targets and navigation zones. Call this at the start of Build() before registering new targets.

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.Focuser

FindFocusInDirection finds the next target 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) FindFocusLinear added in v0.4.5

func (b *BaseScreen) FindFocusLinear(current widget.Focuser, forward bool) widget.Focuser

FindFocusLinear moves focus to the next or previous target in the current target's navigation zone, without wrapping. forward advances to the next target; otherwise the previous. It is used as the fallback when directional zone navigation has no target (e.g. moving past the right edge of a grid row advances to the next cell), replacing ebitenui's ChangeFocus, which cannot see content inside the custom scroll view. Returns nil at the ends of the zone, when there is no current target, or when it is not in a zone.

func (*BaseScreen) GetPendingFocus added in v0.7.0

func (b *BaseScreen) GetPendingFocus() widget.Focuser

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

func (*BaseScreen) InitBase

func (b *BaseScreen) InitBase()

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

func (*BaseScreen) IsFocusTarget added in v0.7.0

func (b *BaseScreen) IsFocusTarget(f widget.Focuser) bool

IsFocusTarget reports whether f is one of the screen's registered focus targets

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) RegisterFocusWidget added in v0.7.0

func (b *BaseScreen) RegisterFocusWidget(key string, f widget.Focuser)

RegisterFocusWidget registers any focusable widget, such as a text field, as a navigation and focus restoration target. Call this during Build() like RegisterFocusButton.

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) RegisterScrollBar added in v0.8.0

func (b *BaseScreen) RegisterScrollBar(key string, view *widgets.ScrollView, bar *widget.Slider)

RegisterScrollBar registers a scroll view's slider as a navigation target under key. Right at the right edge of a zone inside the view moves to it, as does Right from the sidebar when the page has nowhere else to go. On it, Up and Down scroll the view (see ScrollBy). Left returns to the target it was entered from, and every other way out goes to the nearest target in that direction outside the view.

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 target 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) ScrollBy added in v0.8.0

func (b *BaseScreen) ScrollBy(focused widget.Focuser, direction int) bool

ScrollBy scrolls the view of the scroll bar focused one step for Up or Down. It reports false, leaving the move to navigation, when focused is not a scroll bar, for any other direction, and at the end of the view.

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) SetScrollContainer added in v0.4.5

func (b *BaseScreen) SetScrollContainer(scrollContainer *widgets.ScrollView)

SetScrollContainer stores the scroll container 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, defaultConsoleID int, cheatSystem cheats.System, cheatProvider content.CheatsSource, cheatBigEndian bool, coreOptions []coreif.CoreOption) *DetailScreen

NewDetailScreen creates a new detail screen. cheatSystem is the core's cheat system, or 0 when the core has no cheat support; the Cheats page is listed only when it is set. cheatProvider supplies the database cheats, nil when the core has none. cheatBigEndian is the byte order of the core's memory, which cheats are converted to. coreOptions are the core's options, of which the Settings page lists the per game ones.

func (*DetailScreen) Build

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

Build creates the detail screen UI

func (*DetailScreen) EnsureFocusedVisible added in v0.7.0

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

EnsureFocusedVisible scrolls the page content to keep the focused widget visible

func (*DetailScreen) HandleBack added in v0.7.0

func (s *DetailScreen) HandleBack() bool

HandleBack handles Back on the selected page, reporting whether it was used there. Back closes an open cheat form or cancels an armed cheat or screenshot delete.

func (*DetailScreen) OnEnter

func (s *DetailScreen) OnEnter()

OnEnter is called when entering the detail screen

func (*DetailScreen) OnExit added in v0.7.0

func (s *DetailScreen) OnExit()

OnExit is called when leaving the detail screen. It frees the box art, screenshot preview, and artwork textures, which are loaded again on return.

func (*DetailScreen) SetConfig added in v0.8.0

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

SetConfig updates the config reference

func (*DetailScreen) SetGame

func (s *DetailScreen) SetGame(gameID string)

SetGame sets the game to display

func (*DetailScreen) Update added in v0.7.0

func (s *DetailScreen) Update()

Update runs each frame while the detail screen is shown

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 FilePickerScreen added in v0.7.0

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

FilePickerScreen is the full-screen file and folder picker. The path field is the source of truth: in folder mode Accept takes the folder the field names, in file mode the file selected from the list or typed and submitted.

func NewFilePickerScreen added in v0.7.0

func NewFilePickerScreen(callback ScreenCallback, close func()) *FilePickerScreen

NewFilePickerScreen creates the picker. close is called on Accept or Cancel to return to the screen that opened it.

func (*FilePickerScreen) Build added in v0.7.0

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

Build creates the picker UI. The sidebar and list are filled by refreshPlaces and refreshList so later changes update them in place without recreating the path field.

func (*FilePickerScreen) Cancel added in v0.7.0

func (s *FilePickerScreen) Cancel()

Cancel closes the picker without a result.

func (*FilePickerScreen) EnsureFocusedVisible added in v0.7.0

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

EnsureFocusedVisible scrolls the list to keep a focused row visible. Sidebar and button focus does not scroll the list.

func (*FilePickerScreen) NavigatePath added in v0.7.0

func (s *FilePickerScreen) NavigatePath(focused widget.Focuser, direction int) (widget.Focuser, bool)

NavigatePath handles navigation into and out of the path field, which is not a button and so is outside the zone navigation. Down from the field moves to the first list row; other directions stay in the field so left and right move the caret. Up from the first list row moves to the field. Returns the widget to focus (nil to stay) and whether it handled the move.

func (*FilePickerScreen) Open added in v0.7.0

Open resets the picker for a new request, starting in the home folder.

func (*FilePickerScreen) SaveFocusState added in v0.7.0

func (s *FilePickerScreen) SaveFocusState(focused widget.Focuser)

SaveFocusState records focus before a rebuild. The path field is not a button, so its focus is kept as a request the App applies after the rebuild.

func (*FilePickerScreen) TakePathFocusRequest added in v0.7.0

func (s *FilePickerScreen) TakePathFocusRequest() (*widget.TextInput, bool)

TakePathFocusRequest returns the path field when it should receive focus, clearing the request. Text is selected first when the request came from the focus shortcut so typing replaces it.

func (*FilePickerScreen) Update added in v0.7.0

func (s *FilePickerScreen) Update()

Update runs each frame while the picker is open: Ctrl/Cmd+L focuses the path field, clipboard shortcuts apply to it, and the sidebar places are re-polled.

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, updates types.Updates) *LibraryScreen

NewLibraryScreen creates a new library screen. updates is nil when the update system is off.

func (*LibraryScreen) ApplyPendingScroll added in v0.8.0

func (s *LibraryScreen) ApplyPendingScroll()

ApplyPendingScroll finishes scrolling the selected game into place using the real scroll-container rects: top-aligning the card in the icon view and centering the row in the list view. The build functions can only estimate the position because widget layout is unknown until the first render after a rebuild, so this runs each frame and applies the exact position once the rects are available, then clears the request.

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) HaltArtworkLoader

func (s *LibraryScreen) HaltArtworkLoader()

HaltArtworkLoader permanently stops the background artwork loading goroutine. After halting, Start is a no-op.

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

func (*LibraryScreen) UpdateArtwork

func (s *LibraryScreen) UpdateArtwork()

UpdateArtwork checks if new artwork has been cached by the background loader and updates existing widget graphics in place without rebuilding the screen.

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 {
	Progress         float64
	CountText        string // Games counted so far, such as "Found: 3 games"
	DownloadTotal    int    // files to download; 0 outside the artwork download phase
	DownloadComplete int
	StatusText       string
}

ScanProgress represents progress updates from a library scan or clean

type ScanProgressScreen

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

ScanProgressScreen displays library scan and clean progress. Progress updates change the built widgets in place rather than rebuilding the screen, so a press on Cancel is never lost to a rebuild between the button's press and release.

func NewScanProgressScreen

func NewScanProgressScreen() *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) Cancel added in v0.8.0

func (s *ScanProgressScreen) Cancel()

Cancel stops the running scan or clean once: the Cancel button is replaced by "Canceling..." right away, and the scan or clean ends at its next check. Further calls do nothing.

func (*ScanProgressScreen) OnEnter

func (s *ScanProgressScreen) OnEnter()

OnEnter is called when entering 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, in place when the screen is built

type Scanner

type Scanner interface {
	Cancel()
}

Scanner is the running scan or clean the Cancel button stops

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, appName, appVersion string, appIcon []byte, updates types.Updates) *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. updates is nil when the update system is off.

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) HandleBack added in v0.5.0

func (s *SettingsScreen) HandleBack() bool

HandleBack gives the selected section a chance to consume a back action (e.g. leaving an input sub-view). Returns true when consumed.

func (*SettingsScreen) HasPendingScan

func (s *SettingsScreen) HasPendingScan() bool

HasPendingScan delegates to library section

func (*SettingsScreen) IsInputCaptureActive

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) SelectSection added in v0.7.0

func (s *SettingsScreen) SelectSection(focusKey string)

SelectSection makes the section with the given focus key active and focuses its sidebar button. A different section starts scrolled to the top. Unknown keys are ignored.

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