Documentation
¶
Overview ¶
Package widgets holds 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 HexColor(c render.Color) string
- func MediaArt(url string) (*widget.Image, bool)
- func NewAppIcon(name string, size int, post func(func())) *widget.Icon
- func NewAsyncFileIcon(path, fallback string, size int, post func(func()), ready func()) *widget.Icon
- func Pin(w widget.Widget, width, height int) widget.Widget
- func TextPx(role styling.TextRole, scale float64) float64
- type CodeView
- func (c *CodeView) Arrange(r render.Rect)
- func (c *CodeView) ArrangeRoot(r render.Rect)
- func (c *CodeView) Children() []widget.Widget
- func (c *CodeView) HitTest(p widget.Point) widget.Widget
- func (c *CodeView) Measure(widget.Axis, int) widget.Sizes
- func (c *CodeView) Name() string
- func (c *CodeView) Paint(cv *render.Canvas)
- func (c *CodeView) SetText(text, name string)
- func (c *CodeView) Text() string
- type DebouncedSlider
- func (d *DebouncedSlider) Label() *widget.Label
- func (d *DebouncedSlider) Reset(v float64)
- 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 ¶
DialogBody stacks a dialog's rows for its card's content, the theme's double spacing apart; nil rows are skipped.
func DialogButton ¶
DialogButton is a text button in lys-ui's variant (css.Outline, css.SuggestedAction), carrying class and its label class+"-label".
func DialogCard ¶
DialogCard is a dialog's surface: lys-ui's card under title, width px wide, carrying class.
func DialogText ¶
DialogText is a wrapping line at the body size.
func EmptyState ¶
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 ¶
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 MediaArt ¶
MediaArt is a player's cover at a file:// or http(s) URL, scaled to cover its box; false for any other URL, which has no art to load.
func NewAppIcon ¶
NewAppIcon is a desktop entry's Icon= value as an icon: a file decoded off the loop (through post) when the value is a path, else the theme name with GTK's app icon fallbacks; nil when the entry names none.
func NewAsyncFileIcon ¶
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.
Types ¶
type CodeView ¶
CodeView shows text as bat does: line numbers in a gutter and tokens colored from the theme's palette. Only the lines that fit are found, highlighted and laid out, so a large file costs a pane's worth; the row widgets are pooled and rebound as the text changes.
func NewCodeView ¶
NewCodeView is an empty code view setting text at px.
func (*CodeView) ArrangeRoot ¶
ArrangeRoot mirrors Arrange for the root path.
func (*CodeView) Paint ¶
Paint paints the rows shown, clipped to the view. A palette that changed since they were bound lays them out again for the next frame.
type DebouncedSlider ¶
type DebouncedSlider struct {
*widget.Box
// Knob is the slider itself (class it, read it).
Knob *pressSlider
// Format renders the value label (default: whole percent, "42%").
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 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 whole percent). 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) Reset ¶
func (d *DebouncedSlider) Reset(v float64)
Reset moves the knob to v at once, past the hold Set keeps while the user interacts, and drops a pending trailing commit: for a value the backend refused, which must not stay where the user dropped it.
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, ...).