theme

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 17 Imported by: 0 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

Overview

Package theme is how the splash looks: the validated theme.yaml, and the drawing of a frame from the splash's state, damage included, with no KMS underneath so tests can render it.

Index

Constants

View Source
const (
	CapsLockHint = "Caps Lock is on"
	EscHint      = "Esc: boot messages"
	UpdateHint   = "Do not turn off"
)
View Source
const (
	IntroPhases     = 9
	CrossfadePhases = 5
	LeavePhases     = 9
)
View Source
const (
	FillPerPercent = 100
	FullFill       = Fill(protocol.MaxPercent) * FillPerPercent
)
View Source
const Frames = 36

Frames is how many steps one turn of the throbber takes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ask

type Ask struct {
	Caret  int
	Breath int
	Shake  int
}

type Fade

type Fade struct {
	Kind FadeKind
	Left int
}

type FadeKind

type FadeKind uint8
const (
	FadeIn FadeKind = iota + 1
	Crossfade
	FadeOut
)

type Fill

type Fill int

func FillOf

func FillOf(p protocol.Percent) Fill

type Hints

type Hints struct {
	CapsLock bool
	Keymap   string
}
type Logo uint8

Logo is what the splash shows as its logo.

const (
	// it left one on screen, otherwise the lys logo.
	FirmwareLogo Logo = iota
	LysLogo
)

type LogoRaster

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

LogoRaster is the lys logo rasterized for a scale in a colour.

func RasterizeLogo(scale int, c render.Color) (*LogoRaster, error)

RasterizeLogo draws the lys logo at scale in c, milliseconds of work that does not belong on the frame loop and needs no Renderer.

type Progress

type Progress struct {
	Known bool
	From  Fill
	To    Fill
	Left  int
}

func (Progress) At

func (p Progress) At(f Fill) Progress

func (Progress) Percent

func (p Progress) Percent() protocol.Percent

func (Progress) Shown

func (p Progress) Shown() Fill

func (Progress) Toward

func (p Progress) Toward(to protocol.Percent) Progress

type Prompt

type Prompt struct {
	Kind  PromptKind
	Text  string
	Shown string
	Retry bool
}

Prompt is the question on screen and what is shown of the answer typed so far: one bullet per character for a password, the text for a question.

type PromptKind

type PromptKind uint8

PromptKind is what a prompt asks for.

const (
	NoPrompt PromptKind = iota
	PasswordPrompt
	QuestionPrompt
)

The prompt kinds.

type Renderer

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

Renderer draws frames from states with one theme. It is not safe for concurrent use.

func NewRenderer

func NewRenderer(t Theme, bgrt *splashframe.BGRT) (*Renderer, error)

NewRenderer prepares drawing with t; bgrt is the firmware's logo, nil when it left none.

func (r *Renderer) AddLogo(l *LogoRaster)

AddLogo keeps a logo for the frames at its scale; one in a colour other than LogoColor, rasterized for a theme since replaced, is never drawn.

func (*Renderer) Crossfade

func (r *Renderer) Crossfade(from, to State) State

func (*Renderer) Draw

func (r *Renderer) Draw(f kms.Frame, scale int, prev *State, cur State) (kms.Damage, error)

Draw brings frame f, shown at scale, from prev to cur and returns the rectangles it changed. With prev nil the whole frame is drawn; otherwise only the pixels whose state differs are redrawn: the entry for a key typed, the text's extent for a message, the columns between two fills of a bar, and while a fade runs the status group and the logo when it fades too.

func (*Renderer) Intro

func (r *Renderer) Intro(s State) State

func (*Renderer) LastFrame

func (r *Renderer) LastFrame(outputs []splashframe.Output) splashframe.LastFrame

func (*Renderer) Leave

func (r *Renderer) Leave(s State) State
func (r *Renderer) Logo(size image.Point, scale int) image.Rectangle

func (*Renderer) LogoColor

func (r *Renderer) LogoColor() render.Color

LogoColor is the colour the renderer draws the lys logo in: the theme's accent, the throbber's and the bar's.

func (r *Renderer) NeedsLogo(scale int) bool

NeedsLogo says a first frame at scale would rasterize the logo.

func (*Renderer) NextFill

func (r *Renderer) NextFill(s State, size image.Point, scale int) Fill

func (*Renderer) PhasesToNextPicture

func (r *Renderer) PhasesToNextPicture(s State, size image.Point, scale int) int

type State

type State struct {
	Hidden   bool
	Message  string
	Status   string
	Prompt   Prompt
	Ask      Ask
	Hints    Hints
	Updating bool
	Progress Progress
	Phase    int
	Leaving  bool
	Fade     Fade
}

State is what the splash shows.

func (State) Advance

func (s State) Advance(n int) State

func (State) AdvanceFade

func (s State) AdvanceFade(n int) State

func (State) CapsLockShown

func (s State) CapsLockShown() string

func (State) Fading

func (s State) Fading() bool

func (State) KeymapShown

func (s State) KeymapShown() string

func (State) Returned

func (s State) Returned() State

func (State) WithPrompt

func (s State) WithPrompt(p Prompt) State

type Theme

type Theme struct {
	Background render.Color
	Foreground render.Color
	Secondary  render.Color
	Accent     render.Color
	Error      render.Color
	Throbber   Throbber
	// Units shows the name of each unit systemd starts on the status line.
	Units         bool
	PromptHints   bool
	ReducedMotion bool
}

Theme is a validated theme.

func Default

func Default() Theme

func Load

func Load(path string) (Theme, error)

Load reads the theme at path. A missing file is the default theme; a file that cannot be read or does not validate is an error naming the file and the field, returned with the default theme for the splash to fall back to.

func Parse

func Parse(file string, data []byte) (Theme, error)

Parse validates a theme.yaml read from file; a field it leaves out keeps the default theme's value.

type Throbber

type Throbber uint8

Throbber is the busy animation's style.

const (
	// Spinner is an arc turning around a faint ring.
	Spinner Throbber = iota
	// Dots is three dots lighting up in turn.
	Dots
)

Jump to

Keyboard shortcuts

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