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 []portalreq.Choice, class string) ([]widget.Widget, func() []portalreq.Selection)
- 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
- type Pinned
- func (f *Pinned) Arrange(r render.Rect)
- func (f *Pinned) ArrangeRoot(r render.Rect)
- func (f *Pinned) Children() []widget.Widget
- func (f *Pinned) HitTest(pt widget.Point) widget.Widget
- func (f *Pinned) Measure(con widget.Constraints) widget.Size
- func (f *Pinned) Paint(cv *render.Canvas)
- func (f *Pinned) SetSize(w, h int)
- func (f *Pinned) Size() (w, h int)
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 []portalreq.Choice, class string) ([]widget.Widget, func() []portalreq.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".
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.
OnCommit func(float64)
// 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, ...).
type Pinned ¶
Pinned holds a child at an exact size on each non-zero axis, the extent GTK reaches with a size request where the content measures smaller and a clip where it measures larger: the file chooser's resizable columns and HiDPI thumbnails, a portal header image. A zero axis keeps the child's natural extent. (Minimum sizes are lys-ui's SetSizeRequest; this is for boxes that must not grow.)
func (*Pinned) ArrangeRoot ¶
ArrangeRoot mirrors Arrange for the tree-root path.
func (*Pinned) Measure ¶
func (f *Pinned) Measure(con widget.Constraints) widget.Size
Measure reports the pinned axes and the child's natural others.