widgets

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 15 Imported by: ? 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 holds 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

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

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

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

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

DialogText is a wrapping line at the body size.

func EmptyState

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

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 HexColor

func HexColor(c render.Color) string

HexColor is c as a #rrggbb markup color.

func MediaArt

func MediaArt(url string) (*widget.Image, bool)

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

func NewAppIcon(name string, size int, post func(func())) *widget.Icon

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.

func Pin

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

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 CodeView

type CodeView struct {
	widget.Base
	// contains filtered or unexported fields
}

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

func NewCodeView(font render.Font, px float64) *CodeView

NewCodeView is an empty code view setting text at px.

func (*CodeView) Arrange

func (c *CodeView) Arrange(r render.Rect)

Arrange finds, highlights and lays out the lines that fit, top down.

func (*CodeView) ArrangeRoot

func (c *CodeView) ArrangeRoot(r render.Rect)

ArrangeRoot mirrors Arrange for the root path.

func (*CodeView) Children

func (c *CodeView) Children() []widget.Widget

Children are the rows shown and the style probes.

func (*CodeView) HitTest

func (c *CodeView) HitTest(p widget.Point) widget.Widget

HitTest makes the view the leaf the pointer lands on.

func (*CodeView) Measure

func (c *CodeView) Measure(widget.Axis, int) widget.Sizes

Measure is flexible: the pane gives the view its room.

func (*CodeView) Name

func (c *CodeView) Name() string

Name is the file name the text was highlighted for.

func (*CodeView) Paint

func (c *CodeView) Paint(cv *render.Canvas)

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.

func (*CodeView) SetText

func (c *CodeView) SetText(text, name string)

SetText shows text, highlighted as the language its name, #! line or modeline says, plain when none does.

func (*CodeView) Text

func (c *CodeView) Text() string

Text is the text shown.

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, ...).

Jump to

Keyboard shortcuts

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