Documentation
¶
Overview ¶
Package widgets is wayle-widgets: the controls the shell surfaces and the settings app share.
Index ¶
- func Center(w widget.Widget) widget.Widget
- func ChoiceRows(font render.Font, choices []portaldialogs.Choice, class string) ([]widget.Widget, func() []portaldialogs.Selection)
- func DialogBody(rows ...widget.Widget) *widget.Box
- func DialogButton(font render.Font, text, class, variant string, onClick func()) *widget.Button
- func DialogCard(font render.Font, title, class string, width int) *widget.Card
- func DialogText(font render.Font, text string, classes ...string) *widget.Label
- func EmptyState(font render.Font, px float64, icon, title, description string) *widget.StatusPage
- func EmptyStateIcon(font render.Font, px float64, icon, title, description string) (*widget.StatusPage, *widget.Icon)
- func Pin(w widget.Widget, width, height int) widget.Widget
- func TextPx(role styling.TextRole, scale float64) float64
- type DebouncedSlider
- func (d *DebouncedSlider) Label() *widget.Label
- func (d *DebouncedSlider) Set(v float64)
- func (d *DebouncedSlider) SetClock(now func() time.Time)
- func (d *DebouncedSlider) SetFormat(format func(float64) string)
- func (d *DebouncedSlider) Value() float64
- func (d *DebouncedSlider) ValueLabel() *widget.Label
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Center ¶
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
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
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
DialogCard is a dialog's surface: lys-ui's card under title, width px wide, carrying class.
func DialogText ¶ added in v0.2.0
DialogText is a wrapping line at the body size.
func EmptyState ¶ added in v0.2.0
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.
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, ...).