Documentation
¶
Overview ¶
Package screen is the login screen: one screen the greeter shows before login and the lock screen shows over a locked session, built by the same code (Build) and styled by the same lock.css rules, so the two look and behave alike. A Mode adds only what genuinely differs: the greeter's user list, username entry, session picker and power buttons.
The layout is the macOS lock screen's: the date over a large clock at the top, and at the bottom the account being asked for, the password pill under it, the caps lock warning and the error line, and under all of it the greeter's power buttons. A chip in the top right corner shows the keyboard layout when there are several.
Index ¶
- Constants
- func AvatarPicture(load func(path string) (image.Image, error), path string, scale int) image.Image
- func Background(bg *Backdrop, color render.Color) widget.Widget
- func Cover(s Spec) widget.Widget
- func FingerprintMessage(r fprint.Result) string
- func HexFill(c config.HexColor) render.Color
- func Icons() []string
- func MaxScale(outputs []*app.Output) int
- func RefusalText(r auth.Refusal) string
- func Scrim() *widget.Box
- func SquareThumbnail(src image.Image, px int) image.Image
- func Window(sheet *widget.Stylesheet, layers ...widget.Widget) widget.Widget
- type AccountTile
- type Backdrop
- type ClockTicker
- type Fingerprint
- type FingerprintPrompt
- type FingerprintReader
- type GreeterRows
- type KeyboardLayouts
- type LayoutDeps
- type LockRows
- type Mode
- type Options
- type Prompt
- type Spec
- type Surface
- type WallClock
Constants ¶
const AvatarPx = 80
AvatarPx is the side of an account's round picture.
Variables ¶
This section is empty.
Functions ¶
func AvatarPicture ¶
AvatarPicture is the image at path decoded by load and cut to what a tile shows on an output of the given buffer scale, nil when there is none or it does not read: a photo would keep megabytes for a small circle otherwise.
func Background ¶
Background builds the surface background (build_background): the backdrop scaled to cover under the .lock-bg-scrim legibility layer, or the configured color painted by a .lock-bg area when there is no backdrop.
func FingerprintMessage ¶
func RefusalText ¶
RefusalText words a refused login for the person logging in.
func Scrim ¶
Scrim is the blank-screen blackout (.lock-scrim), hidden until the blank timer shows it.
func SquareThumbnail ¶
SquareThumbnail is src's middle square area-resampled to px on a side, for a picture only ever drawn that small and cropped to cover: the source's pixels are not kept. A source no larger on either side comes back as it is.
Types ¶
type AccountTile ¶
AccountTile is one account as the login screen shows it: the round picture above the name, the picture the initials until one is set.
func NewAccountTile ¶
func NewAccountTile(font render.Font, displayName string) *AccountTile
NewAccountTile is the tile of the account called displayName.
func (*AccountTile) Initials ¶
func (a *AccountTile) Initials() string
Initials are what the picture shows without an image.
func (*AccountTile) SetPicture ¶
func (a *AccountTile) SetPicture(img image.Image)
SetPicture shows img as the account's picture.
type Backdrop ¶
type Backdrop struct {
Image render.StillImage
// contains filtered or unexported fields
}
Backdrop is a background image at the size it is shown at, blurred, with its pixels off the Go heap. Image keeps its identity for as long as the pixels live, so a GPU renderer's texture of it can be dropped by ID before the pixels are freed.
func LoadBackdrop ¶
func LoadBackdrop(mem *memory.Shared, decode func(mem *memory.Shared, path string) (imagedecode.Decoded, error), path string, sigma float64, outputs []image.Point) (*Backdrop, error)
LoadBackdrop decodes the background at path into mem and makes it a backdrop for outputs, as NewBackdrop does; the decoded image is freed before it returns.
func NewBackdrop ¶
func NewBackdrop(mem *memory.Shared, src image.Image, sigma float64, outputs []image.Point) (Backdrop, error)
NewBackdrop resamples src to the smallest size that still covers every one of outputs (device pixel sizes) and blurs it with a gaussian of standard deviation sigma in src's pixels, scaled with the image so the result looks as blurring src itself would. A src already no larger than that keeps its size: it is blurred as it is and scaled up where it is drawn. The pixels and the blur's scratch raster live in mem; the scratch is freed before it returns.
type ClockTicker ¶
type ClockTicker struct {
// contains filtered or unexported fields
}
ClockTicker shows a clock when what its formats show changes, and not in between: a clock of hours and minutes wakes the loop once a minute. Its timer runs on the wall clock, so what it shows is right the moment the machine resumes, the clock is set or the zone changes.
func NewClockTicker ¶
func NewClockTicker(wall WallClock, show func(), formats ...func(time.Time) string) *ClockTicker
NewClockTicker makes a stopped ticker that calls show on the loop whenever one of formats would give something new. With no formats nothing shows a clock, so it never arms.
func (*ClockTicker) Arm ¶
func (c *ClockTicker) Arm()
Arm keeps a clock shown just now right until Stop.
func (*ClockTicker) Start ¶
func (c *ClockTicker) Start()
Start shows the clock and keeps it right until Stop.
func (*ClockTicker) Stop ¶
func (c *ClockTicker) Stop()
Stop lets the clock go stale until the next Start.
type Fingerprint ¶
type Fingerprint struct {
Text string
OnPassword func()
}
Fingerprint is the fingerprint prompt, shown in place of the password entry while the reader listens: Text beside the glyph, and OnPassword, run when the person clicks it or types, before the typed character reaches the password entry.
func NewFingerprint ¶
func NewFingerprint(onPassword func()) *Fingerprint
type FingerprintPrompt ¶
FingerprintPrompt is the built fingerprint prompt. It takes keyboard focus while shown, so the first character typed switches to the password entry and lands in it.
func (*FingerprintPrompt) InsertRune ¶
func (f *FingerprintPrompt) InsertRune(r rune)
InsertRune hands r to the password entry once OnPassword has run.
type FingerprintReader ¶
type FingerprintReader struct {
// contains filtered or unexported fields
}
func NewFingerprintReader ¶
func NewFingerprintReader(show func()) *FingerprintReader
func (*FingerprintReader) ChoosePassword ¶
func (f *FingerprintReader) ChoosePassword()
func (*FingerprintReader) Follow ¶
func (f *FingerprintReader) Follow(r fprint.Result) (scanned bool)
func (*FingerprintReader) Reset ¶
func (f *FingerprintReader) Reset()
func (*FingerprintReader) Shown ¶
func (f *FingerprintReader) Shown() bool
func (*FingerprintReader) Stop ¶
func (f *FingerprintReader) Stop()
type GreeterRows ¶
GreeterRows are the rows only the greeter shows: the session picker under the entries and the power buttons at the bottom of the screen. Either may be nil.
type KeyboardLayouts ¶
type KeyboardLayouts struct {
// contains filtered or unexported fields
}
func NewKeyboardLayouts ¶
func NewKeyboardLayouts(d LayoutDeps) *KeyboardLayouts
func (*KeyboardLayouts) Active ¶
func (k *KeyboardLayouts) Active() string
func (*KeyboardLayouts) CanSwitch ¶
func (k *KeyboardLayouts) CanSwitch() bool
func (*KeyboardLayouts) Cycle ¶
func (k *KeyboardLayouts) Cycle()
func (*KeyboardLayouts) Set ¶
func (k *KeyboardLayouts) Set(l app.KeyboardLayout)
func (*KeyboardLayouts) ShowOn ¶
func (k *KeyboardLayouts) ShowOn(p *Prompt)
func (*KeyboardLayouts) Want ¶
func (k *KeyboardLayouts) Want(name string)
type LayoutDeps ¶
type Options ¶
type Options struct {
// Font is the face the labels and entries shape with; the
// stylesheet sets their sizes and weights.
Font render.Font
// ShowClock shows the clock and date.
ShowClock bool
// WithUsername adds a visible username entry above the secret one
// (the greeter; the lock screen authenticates the session user).
WithUsername bool
// Identity goes above the entries: the lock screen's account, the
// greeter's user list. Extra goes between the caps lock warning and
// the error line (the greeter's session picker), Footer at the
// bottom of the screen under all of it (the greeter's power
// buttons). Any may be nil.
Status, Corner widget.Widget
// Password is the secret entry's placeholder, CapsLock the caps
// lock warning's text.
Password, CapsLock string
// Focus moves keyboard focus; the username entry's Enter uses it
// to move on to the secret entry.
Focus func(widget.Widget)
NextLayout func()
// Fingerprint adds the fingerprint prompt; nil leaves it out.
Fingerprint *Fingerprint
}
Options configure one prompt.
type Prompt ¶
type Prompt struct {
// Reveal is the root: everything over the background, hidden until
// the screen shows it (CredentialBox::reveal).
Reveal *widget.Revealer
// Username is the visible username entry; nil without
// WithUsername.
Username *widget.Entry
// Entry is the secret entry; Enter submits it.
Entry *widget.Entry
// Fingerprint stands in for Entry while SetFingerprint shows it; nil
// without Options.Fingerprint.
Fingerprint *FingerprintPrompt
// Clock and Date are hidden without ShowClock.
Clock, Date *widget.Label
// Caps is the caps lock warning, hidden until SetCapsLock shows it.
Caps *widget.Label
// Error is the error and info line, hidden until it has text.
Error *widget.Label
Layout *widget.Button
// contains filtered or unexported fields
}
Prompt is a built credential prompt and the handles its screen drives.
func (*Prompt) FocusTarget ¶
FocusTarget is what keyboard focus belongs on: the fingerprint prompt while it shows, else the password entry.
func (*Prompt) PreloadIcons ¶
func (*Prompt) SetCapsLock ¶
SetCapsLock shows or hides the caps lock warning.
func (*Prompt) SetFingerprint ¶
SetFingerprint shows the fingerprint prompt in place of the password entry, or the entry again; a prompt without one keeps its entry.
func (*Prompt) SetMessage ¶
SetMessage shows text on the error line, or hides it when empty.
type Spec ¶
type Spec struct {
Mode Mode
Config config.LoginConfig
Font render.Font
Sheet *widget.Stylesheet
// Backdrop is the background image, nil for the color fill.
Backdrop *Backdrop
// Identity is who the screen asks for, above the entries: the lock
// screen's account, the greeter's user list. nil for none.
Identity widget.Widget
// Greeter holds the greeter's own rows; Build reads it in greeter
// mode only.
Greeter GreeterRows
Lock LockRows
Fingerprint *Fingerprint
// Password is the password entry's placeholder and CapsLock the caps
// lock warning's text, in the mode's locale.
Password, CapsLock string
// Focus moves keyboard focus.
Focus func(widget.Widget)
// OnSubmit receives the secret entry's text on Enter.
OnSubmit func(string)
NextLayout func()
}
Spec is one login screen surface.
type Surface ¶
type Surface struct {
Root widget.Widget
Prompt *Prompt
// Scrim is the blank-screen blackout over everything.
Scrim *widget.Box
}
Surface is a built login screen and the handles its mode drives.
type WallClock ¶
type WallClock interface {
// Now is the time in the current zone.
Now() time.Time
// Arm runs fn on the loop when the wall clock reaches at, or at once when it
// or the zone jumps, replacing what was armed.
Arm(at time.Time, fn func())
// Disarm forgets what was armed; a firing on its way finds nothing.
Disarm()
}
WallClock is the time a clock on screen shows: wallclock.SystemClock, or a fake in tests.