widgets

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 11 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 widgets is wayle-widgets: the controls the shell surfaces and the settings app share.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Center

func Center(w widget.Widget) widget.Widget

Center keeps w at its natural size in the middle of the space its parent gives it (halign and valign center) and returns it.

func ChoiceRows

func ChoiceRows(font render.Font, choices []portaldialogs.Choice, class string) ([]widget.Widget, func() []portaldialogs.Selection)

ChoiceRows builds a row per portal choice, a check button for a yes/no and a labelled dropdown otherwise, each starting at its choice's start value, and the function reading what the user picked. The rows carry class and their labels class+"-label".

func DialogBody added in v0.2.0

func DialogBody(rows ...widget.Widget) *widget.Box

DialogBody stacks a dialog's rows for its card's content, the theme's double spacing apart; nil rows are skipped.

func DialogButton added in v0.2.0

func DialogButton(font render.Font, text, class, variant string, onClick func()) *widget.Button

DialogButton is a text button in lys-ui's variant (css.Outline, css.SuggestedAction), carrying class and its label class+"-label".

func DialogCard added in v0.2.0

func DialogCard(font render.Font, title, class string, width int) *widget.Card

DialogCard is a dialog's surface: lys-ui's card under title, width px wide, carrying class.

func DialogText added in v0.2.0

func DialogText(font render.Font, text string, classes ...string) *widget.Label

DialogText is a wrapping line at the body size.

func EmptyState added in v0.2.0

func EmptyState(font render.Font, px float64, icon, title, description string) *widget.StatusPage

EmptyState is the empty-state template on lys-ui's StatusPage: the icon on its muted tile over the title and the wrapped description, centered in whatever page holds it.

func EmptyStateIcon added in v0.2.0

func EmptyStateIcon(font render.Font, px float64, icon, title, description string) (*widget.StatusPage, *widget.Icon)

EmptyStateIcon is EmptyState that also hands back its icon, for pages whose glyph follows state.

func NewAsyncFileIcon added in v0.3.7

func NewAsyncFileIcon(path, fallback string, size int, post func(func()), ready func()) *widget.Icon

NewAsyncFileIcon is an icon showing fallback, a theme name or "" for nothing, until path has been decoded off the loop at its tree's scale, so no paint reads the file. A file that would paint nothing (missing, a FIFO or device, undecodable) keeps the fallback. ready runs on the loop through post once the file shows; it may be nil.

func Pin added in v0.2.0

func Pin(w widget.Widget, width, height int) widget.Widget

Pin holds w at exactly width x height on each non-zero axis, its size request flooring and its maximum capping it, so content that measures larger is clipped, and returns it. A zero axis keeps w's natural extent. Pinning again re-pins it (a column dragged wider).

func TextPx added in v0.2.0

func TextPx(role styling.TextRole, scale float64) float64

TextPx is role's size in pixels at scale over the desktop's body size, the rem the stylesheet's --text-* tokens resolve against.

Types

type DebouncedSlider

type DebouncedSlider struct {
	*widget.Box
	// Knob is the slider itself (class it, read it).
	Knob *pressSlider

	// Format renders the value label (default "{:.0}%").
	Format func(float64) string

	// OnCommit hears the throttled user commits on the loop.
	OnCommit func(float64)
	// Write turns a committed value, on the loop, into the backend write
	// that applies it (nil writes nothing), run off the loop one at a
	// time, the latest commit's replacing any queued while one runs;
	// outside values are ignored until the last write has landed and
	// the release grace has passed after it. A slow backend (a display
	// over DDC/CI) otherwise lands concurrent writes out of order and
	// echoes stale values onto the slider.
	Write func(float64) func()
	// OnValue sees every value change, the user's and set's alike
	// (the value-changed notify a #[watch] reads).
	OnValue func(float64)
	// contains filtered or unexported fields
}

DebouncedSlider is wayle-widgets' DebouncedSlider: a slider with an optional value label that commits (backend writes) at most every 100ms while dragged, with a trailing commit of the last value and one on release, and ignores external values while held and for 150ms after.

func NewDebouncedSlider

func NewDebouncedSlider(value float64, font render.Font, px float64, color render.Color, invoke func(func())) *DebouncedSlider

NewDebouncedSlider builds a 0-100 slider (every lys-shell slider is a percentage); with a font the value label shows (format, default "{:.0}%"). invoke runs the trailing commit on the loop.

func NewRangedSlider

func NewRangedSlider(min, max, value float64, font render.Font, px float64, color render.Color, invoke func(func())) *DebouncedSlider

NewRangedSlider is NewDebouncedSlider over [min, max].

func (*DebouncedSlider) Label

func (d *DebouncedSlider) Label() *widget.Label

Label is the value label, nil without a font.

func (*DebouncedSlider) Set

func (d *DebouncedSlider) Set(v float64)

Set is set_value_external: an outside value, ignored while the user interacts.

func (*DebouncedSlider) SetClock

func (d *DebouncedSlider) SetClock(now func() time.Time)

SetClock replaces the clock the throttle and the release grace read (a test seam).

func (*DebouncedSlider) SetFormat

func (d *DebouncedSlider) SetFormat(format func(float64) string)

SetFormat replaces the value label's format and re-renders it.

func (*DebouncedSlider) Value

func (d *DebouncedSlider) Value() float64

Value is the slider's current value.

func (*DebouncedSlider) ValueLabel

func (d *DebouncedSlider) ValueLabel() *widget.Label

ValueLabel hands back the formatted value label, for the caller to class the way its stylesheet names it (audio-slider-value, brightness-slider-value, ...).

Jump to

Keyboard shortcuts

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