Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveButtonImage(active bool) *widget.ButtonImage
- func ApplyGrayscale(src *ebiten.Image) *ebiten.Image
- func ApplyTheme(theme Theme)
- func ApplyThemeByName(name string)
- func ButtonImage() *widget.ButtonImage
- func ButtonTextColor() *widget.ButtonTextColor
- func DPIScale() float64
- func DisabledButtonImage() *widget.ButtonImage
- func FontFace() *text.Face
- func FontScale() float64
- func FormatDate(timestamp int64) string
- func FormatLastPlayed(timestamp int64) string
- func FormatPlayTime(seconds int64) string
- func IsValidThemeName(name string) bool
- func LargeFontFace() text.Face
- func MeasureWidth(s string) float64
- func PrimaryButtonImage() *widget.ButtonImage
- func Px(logical int) int
- func ScaleImage(src goimage.Image, maxWidth, maxHeight int) *ebiten.Image
- func ScaleImageUnmanaged(src goimage.Image, maxWidth, maxHeight int) *ebiten.Image
- func SetDPIScale(scale float64)
- func SetWindowScale(scale float64)
- func SliderButtonImage() *widget.ButtonImage
- func SliderTrackImage() *widget.SliderTrackImage
- func ThemeNames() []string
- func TruncateEnd(s string, maxLen int) (string, bool)
- func TruncateStart(s string, maxLen int) (string, bool)
- func TruncateToWidth(s string, face text.Face, maxWidth float64) (string, bool)
- func WindowScaleFor(logicalW, logicalH int) float64
- func WrapLines(s string, face text.Face, maxWidth float64) []string
- func WrapToBox(s string, face text.Face, maxWidth, maxHeight float64) string
- type Theme
Constants ¶
const ( MinWindowWidth = 900 MinWindowHeight = 650 )
Window scaling. The layout is designed for the minimum window size and the whole UI, font included, grows with the window from there.
const ( )
Gamepad navigation timing constants
const (
AutoSaveInterval = 5 * time.Second
)
Auto-save timing constant
const (
ScrollWheelSensitivity = 0.05
)
Mouse wheel scroll sensitivity
Variables ¶
var ( // Standard spacing and padding values DefaultPadding = baseDefaultPadding DefaultSpacing = baseDefaultSpacing SmallSpacing = baseSmallSpacing TinySpacing = baseTinySpacing LargeSpacing = baseLargeSpacing // Scrollbar dimensions ScrollbarWidth = baseScrollbarWidth // Button padding ButtonPaddingSmall = baseButtonPaddingSmall ButtonPaddingMedium = baseButtonPaddingMedium )
Layout vars used across screens, scaled at runtime from the base constants.
var ( ListRowHeight = baseListRowHeight ListHeaderHeight = baseListHeaderHeight // Column widths for library list view ListColFavorite = baseListColFavorite ListColGenre = baseListColGenre ListColRegion = baseListColRegion ListColPlayTime = baseListColPlayTime ListColLastPlayed = baseListColLastPlayed // Icon view IconCardTextHeight = baseIconCardTextHeight )
List and icon view layout values
var ( IconMinCardWidth = baseIconMinCardWidth IconDefaultWindowWidth = baseIconDefaultWinWidth IconUnfocusedScale = baseIconUnfocusedScale IconUnfocusedDim = baseIconUnfocusedDim )
Icon view vars for grid layouts
var ( ProgressBarWidth = baseProgressBarWidth ProgressBarHeight = baseProgressBarHeight )
Progress bar vars
var ( OverlayPadding = baseOverlayPadding OverlayMargin = baseOverlayMargin )
Overlay vars (shared by notification/search)
var ( PauseMenuMinWidth = basePauseMinWidth PauseMenuMaxWidth = basePauseMaxWidth PauseMenuMinBtnHeight = basePauseMinBtnH PauseMenuMaxBtnHeight = basePauseMaxBtnH )
Pause menu vars
var ( AchievementRowSpacing = baseAchievementRowSpac AchievementPanelMargin = baseAchievementPanelMargin AchievementMinPanelHeight = baseAchievementMinPanelH AchievementNotifyMargin = baseAchNotifyMargin AchievementNotifyBadgeSize = baseAchNotifyBadge AchievementNotifyPaddingH = baseAchNotifyPaddingH AchievementNotifyPaddingV = baseAchNotifyPaddingV AchievementNotifySpacing = baseAchNotifySpacing AchievementNotifyBorder = baseAchNotifyBorder )
Achievement UI vars
var ( AchievementBadgeSize = baseAchievementBadgeSize AchievementRowHeight = baseAchievementRowHeight AchievementOverlayWidth = baseAchievementOverlayW AchievementOverlayPadding = baseAchievementOverlayPad )
Achievement list and overlay values
var ( Background = color.NRGBA{0x1a, 0x1a, 0x2e, 0xff} // Dark blue-gray Surface = color.NRGBA{0x25, 0x25, 0x3a, 0xff} // Slightly lighter Primary = color.NRGBA{0x4a, 0x4a, 0x8a, 0xff} // Muted purple PrimaryHover = color.NRGBA{0x5a, 0x5a, 0x9a, 0xff} Text = color.NRGBA{0xff, 0xff, 0xff, 0xff} TextSecondary = color.NRGBA{0xaa, 0xaa, 0xaa, 0xff} Accent = color.NRGBA{0xff, 0xd7, 0x00, 0xff} // Gold for favorites Border = color.NRGBA{0x3a, 0x3a, 0x5a, 0xff} Black = color.NRGBA{0x00, 0x00, 0x00, 0xff} DimOverlay = color.NRGBA{0x00, 0x00, 0x00, 0xff} // Base color for screen-dimming overlays (alpha applied per use) OverlayBackground = color.NRGBA{0x1a, 0x1a, 0x2e, 0xff} // Base color for floating element backgrounds (alpha applied per use) )
Theme colors (package-level variables updated by ApplyTheme)
var ( ThemeDefault = Theme{ Name: "Default", Background: color.NRGBA{0x1a, 0x1a, 0x2e, 0xff}, Surface: color.NRGBA{0x25, 0x25, 0x3a, 0xff}, Primary: color.NRGBA{0x4a, 0x4a, 0x8a, 0xff}, PrimaryHover: color.NRGBA{0x5a, 0x5a, 0x9a, 0xff}, Text: color.NRGBA{0xff, 0xff, 0xff, 0xff}, TextSecondary: color.NRGBA{0xaa, 0xaa, 0xaa, 0xff}, Accent: color.NRGBA{0xff, 0xd7, 0x00, 0xff}, Border: color.NRGBA{0x3a, 0x3a, 0x5a, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x1a, 0x1a, 0x2e, 0xff}, } ThemeDark = Theme{ Name: "Dark", Background: color.NRGBA{0x0a, 0x0a, 0x0a, 0xff}, Surface: color.NRGBA{0x1a, 0x1a, 0x1a, 0xff}, Primary: color.NRGBA{0x1e, 0x40, 0x7a, 0xff}, PrimaryHover: color.NRGBA{0x2a, 0x50, 0x8a, 0xff}, Text: color.NRGBA{0xff, 0xff, 0xff, 0xff}, TextSecondary: color.NRGBA{0x88, 0x88, 0x88, 0xff}, Accent: color.NRGBA{0x00, 0xc8, 0x53, 0xff}, Border: color.NRGBA{0x2a, 0x2a, 0x2a, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x0a, 0x0a, 0x0a, 0xff}, } ThemeLight = Theme{ Name: "Light", Background: color.NRGBA{0xe8, 0xe8, 0xe8, 0xff}, Surface: color.NRGBA{0xf5, 0xf5, 0xf5, 0xff}, Primary: color.NRGBA{0x1a, 0x56, 0xdb, 0xff}, PrimaryHover: color.NRGBA{0x2a, 0x66, 0xeb, 0xff}, Text: color.NRGBA{0x1a, 0x1a, 0x1a, 0xff}, TextSecondary: color.NRGBA{0x66, 0x66, 0x66, 0xff}, Accent: color.NRGBA{0xe6, 0x5c, 0x00, 0xff}, Border: color.NRGBA{0xcc, 0xcc, 0xcc, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0xe8, 0xe8, 0xe8, 0xff}, } ThemeRetro = Theme{ Name: "Retro", Background: color.NRGBA{0x1c, 0x1c, 0x1c, 0xff}, Surface: color.NRGBA{0x28, 0x28, 0x28, 0xff}, Primary: color.NRGBA{0x8b, 0x00, 0x00, 0xff}, PrimaryHover: color.NRGBA{0xab, 0x20, 0x20, 0xff}, Text: color.NRGBA{0xd0, 0xd0, 0xd0, 0xff}, TextSecondary: color.NRGBA{0x80, 0x80, 0x80, 0xff}, Accent: color.NRGBA{0x00, 0xaa, 0x00, 0xff}, Border: color.NRGBA{0x3c, 0x3c, 0x3c, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x1c, 0x1c, 0x1c, 0xff}, } ThemePink = Theme{ Name: "Pink", Background: color.NRGBA{0x1a, 0x0a, 0x1a, 0xff}, Surface: color.NRGBA{0x3a, 0x1a, 0x3a, 0xff}, Primary: color.NRGBA{0xc0, 0x10, 0x70, 0xff}, PrimaryHover: color.NRGBA{0xff, 0x14, 0x93, 0xff}, Text: color.NRGBA{0xff, 0xfa, 0xfc, 0xff}, TextSecondary: color.NRGBA{0xff, 0x99, 0xcc, 0xff}, Accent: color.NRGBA{0xff, 0x00, 0xff, 0xff}, Border: color.NRGBA{0x5a, 0x2a, 0x5a, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x1a, 0x0a, 0x1a, 0xff}, } ThemeHotPink = Theme{ Name: "Hot Pink", Background: color.NRGBA{0x4d, 0x15, 0x3d, 0xff}, Surface: color.NRGBA{0x70, 0x25, 0x58, 0xff}, Primary: color.NRGBA{0xff, 0x33, 0x99, 0xff}, PrimaryHover: color.NRGBA{0xff, 0x66, 0xb2, 0xff}, Text: color.NRGBA{0xff, 0xff, 0xff, 0xff}, TextSecondary: color.NRGBA{0xff, 0xb3, 0xda, 0xff}, Accent: color.NRGBA{0xff, 0x44, 0xff, 0xff}, Border: color.NRGBA{0x99, 0x33, 0x77, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x4d, 0x15, 0x3d, 0xff}, } ThemeGreenLCD = Theme{ Name: "Green LCD", Background: color.NRGBA{0x07, 0x20, 0x07, 0xff}, Surface: color.NRGBA{0x0f, 0x38, 0x0f, 0xff}, Primary: color.NRGBA{0x30, 0x62, 0x30, 0xff}, PrimaryHover: color.NRGBA{0x4a, 0x7c, 0x4a, 0xff}, Text: color.NRGBA{0x9b, 0xbc, 0x0f, 0xff}, TextSecondary: color.NRGBA{0x5a, 0x7a, 0x0f, 0xff}, Accent: color.NRGBA{0xc0, 0xe0, 0x30, 0xff}, Border: color.NRGBA{0x20, 0x50, 0x20, 0xff}, Black: color.NRGBA{0x07, 0x20, 0x07, 0xff}, DimOverlay: color.NRGBA{0x07, 0x20, 0x07, 0xff}, OverlayBackground: color.NRGBA{0x07, 0x20, 0x07, 0xff}, } ThemeHighContrast = Theme{ Name: "High Contrast", Background: color.NRGBA{0x00, 0x00, 0x00, 0xff}, Surface: color.NRGBA{0x40, 0x40, 0x40, 0xff}, Primary: color.NRGBA{0x00, 0x80, 0xff, 0xff}, PrimaryHover: color.NRGBA{0x40, 0xa0, 0xff, 0xff}, Text: color.NRGBA{0xff, 0xff, 0xff, 0xff}, TextSecondary: color.NRGBA{0xcc, 0xcc, 0xcc, 0xff}, Accent: color.NRGBA{0xff, 0xff, 0x00, 0xff}, Border: color.NRGBA{0x66, 0x66, 0x66, 0xff}, Black: color.NRGBA{0x00, 0x00, 0x00, 0xff}, DimOverlay: color.NRGBA{0x00, 0x00, 0x00, 0xff}, OverlayBackground: color.NRGBA{0x00, 0x00, 0x00, 0xff}, } // AvailableThemes lists all themes for UI selection AvailableThemes = []Theme{ThemeDefault, ThemeDark, ThemeLight, ThemeRetro, ThemePink, ThemeHotPink, ThemeGreenLCD, ThemeHighContrast} // CurrentThemeName tracks the active theme name CurrentThemeName = "Default" )
Predefined themes
var DetailColumnWidth = baseDetailColumnWidth
Detail screen vars
var EstimatedViewportHeight = baseEstimatedViewportHeight
Scroll estimation viewport height
var (
ListMinTitleWidth = baseListMinTitleWidth
)
Library list view vars
var SettingsFolderListMinHeight = baseFolderListMinHeight
Settings screen vars
var SettingsRowHeight = baseSettingsRowHeight
Settings row height
var SidebarMinWidth = baseSidebarMinWidth
Sidebar default minimum width
Functions ¶
func ActiveButtonImage ¶
func ActiveButtonImage(active bool) *widget.ButtonImage
ActiveButtonImage returns a button image based on active state. Used for toggle buttons like view mode selectors and sidebar items.
func ApplyGrayscale ¶
ApplyGrayscale converts an ebiten image to grayscale. Returns a new image with grayscale applied.
func ApplyTheme ¶
func ApplyTheme(theme Theme)
ApplyTheme updates package-level color variables from a theme
func ApplyThemeByName ¶
func ApplyThemeByName(name string)
ApplyThemeByName applies theme by name with fallback to Default
func ButtonImage ¶
func ButtonImage() *widget.ButtonImage
ButtonImage creates a standard button image set
func ButtonTextColor ¶
func ButtonTextColor() *widget.ButtonTextColor
ButtonTextColor returns the standard button text colors
func DisabledButtonImage ¶
func DisabledButtonImage() *widget.ButtonImage
DisabledButtonImage creates a disabled-looking button image set
func FontScale ¶
func FontScale() float64
FontScale returns the window scale: how many times larger than the base design the font and layout are drawn. Overlays cache on it.
func FormatDate ¶
FormatDate formats a Unix timestamp as a date string. Returns "Unknown" for 0, otherwise "Jan 2, 2006".
func FormatLastPlayed ¶
FormatLastPlayed formats a Unix timestamp into a relative or absolute date string. Returns "Never" for 0, "Today"/"Yesterday" for recent dates, "Jan 2" for this year, or "Jan 2, 2006" for previous years.
func FormatPlayTime ¶
FormatPlayTime formats a duration in seconds into a human-readable string. Returns "—" for 0 seconds, "< 1m" for under a minute, or a formatted string like "2h 30m" or "45m".
func IsValidThemeName ¶
IsValidThemeName returns true if the name matches a known theme
func LargeFontFace ¶
LargeFontFace returns a larger font face for prominent displays like achievements, or nil when no font loaded
func MeasureWidth ¶
MeasureWidth returns the pixel width of s rendered at the current font size.
func PrimaryButtonImage ¶
func PrimaryButtonImage() *widget.ButtonImage
PrimaryButtonImage creates a prominent button image set
func ScaleImage ¶
ScaleImage scales an image to fit within maxWidth x maxHeight while preserving aspect ratio. The result is a managed (atlased) ebiten.Image, suitable for small, long-lived images that benefit from draw-call batching.
func ScaleImageUnmanaged ¶ added in v0.4.5
ScaleImageUnmanaged is like ScaleImage but returns an unmanaged (off-atlas) ebiten.Image. Each unmanaged image is its own right-sized GPU texture that is freed immediately on Deallocate, rather than being packed onto a large shared atlas page that is only released once every image on it is gone. This is the right choice for numerous or frequently rebuilt artwork (cover art, box art) where atlas packing wastes memory and fragments. The trade-off is that these images are not batched with others when drawn, which is immaterial for the handful of static artwork images on a UI screen.
func SetDPIScale ¶
func SetDPIScale(scale float64)
SetDPIScale sets the DPI scale factor and recalculates all spatial vars.
func SetWindowScale ¶ added in v0.7.0
func SetWindowScale(scale float64)
SetWindowScale sets the window scale and recalculates all spatial vars.
func SliderButtonImage ¶
func SliderButtonImage() *widget.ButtonImage
SliderButtonImage creates a slider handle button image
func SliderTrackImage ¶
func SliderTrackImage() *widget.SliderTrackImage
SliderTrackImage creates a slider track image
func ThemeNames ¶
func ThemeNames() []string
ThemeNames returns the list of valid theme name strings.
func TruncateEnd ¶
TruncateEnd truncates a string from the end, keeping the start portion. Returns the truncated string and whether truncation occurred. Useful for titles where the beginning is most relevant.
func TruncateStart ¶
TruncateStart truncates a string from the start, keeping the end portion. Returns the truncated string and whether truncation occurred. Useful for file paths where the end (filename) is most relevant.
func TruncateToWidth ¶
TruncateToWidth truncates a string to fit within a given pixel width using actual font measurement. Returns the truncated string (with "..." suffix if truncated) and whether truncation occurred. Uses binary search on rune boundaries for efficiency with proportional fonts.
func WindowScaleFor ¶ added in v0.7.0
WindowScaleFor returns the window scale for a window of the given logical size: the smaller of the width and height ratios to the minimum window size, so the layout always has at least the room it has at the minimum window. Rounded to 1% and capped at maxWindowScale.
func WrapLines ¶ added in v0.8.0
WrapLines lays s out as word-wrapped lines that fit within maxWidth pixels, keeping its line breaks: each line of s is wrapped on its own and an empty line stays empty. A single word wider than maxWidth is truncated with an ellipsis.
func WrapToBox ¶ added in v0.3.0
WrapToBox lays s out as word-wrapped lines that fit within maxWidth pixels, keeping only as many lines as fit in maxHeight and ending the last visible line with an ellipsis when text is dropped. A single word wider than maxWidth is itself truncated with an ellipsis. The returned newline-joined string never exceeds the maxWidth x maxHeight box, so a fixed-size container holding it does not grow to fit.
Types ¶
type Theme ¶
type Theme struct {
Name string
Background color.NRGBA
Surface color.NRGBA
Primary color.NRGBA
PrimaryHover color.NRGBA
Text color.NRGBA
TextSecondary color.NRGBA
Accent color.NRGBA
Border color.NRGBA
Black color.NRGBA
DimOverlay color.NRGBA
OverlayBackground color.NRGBA
}
Theme holds all color values for a UI theme
func GetThemeByName ¶
GetThemeByName returns theme by name, or ThemeDefault if not found