widget

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 47 Imported by: 2 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

Accessibility semantics for the widget tree: semantic roles plus a state snapshot that assistive technology can consume. This is the plain-Go layer only - how it reaches a screen reader is recorded in docs/a11y.md.

The CSS box model the styled widgets share: a margin box a container arranges, the border box the widget owns (its Bounds, hit area, and damage), and the content box its children or text fill — with padding, per-side borders, min sizes, and the background layers painted in GTK's order. Margins are self-applied: a widget measures its margin box and insets itself inside whatever rect its container hands it, so every container gets margins for free.

Damage tracking turns per-widget invalidation flags into the repaint rects one frame needs. Widgets mark themselves through Invalidate, InvalidateRect, and InvalidateLayout; CollectDamage drains the flags into a rect list the app clips painting to and sends as wl_surface.damage_buffer.

Debug plumbing shared by every widget: optional names plus the live tree snapshot the inspector's dump and overlay render. This is the always-available half of the inspector (see docs/inspector.md): the dump only reads state, so it ships in prod binaries; the app-level overlay and its keybindings live in internal/inspect and the app package, gated behind LYS_UI_INSPECT or an explicit opt-in.

Echo masking for Entry: password fields render one dot per rune while the contents, caret, click mapping, and selection stay logical. Because masking is one-to-one per rune, every display-space index is also the logical rune index, so nothing about the editing model changes — only the pixels do.

Input method support: the widget side of zwp_text_input_v3. Editable widgets show composing (preedit) text and receive committed text through IMEClient, and expose their caret state through IMETracker so the host can push surrounding text and the caret rectangle.

The CSS interaction surfaces (docs/css.md): cursor, pointer-events, user-select, caret-shape, accent-color, appearance, and touch-action — the computed values the input path and the painters read.

Rich-label markup: a strict allowlist subset of HTML parsed into styled runs. ParseMarkup is total - it never panics on any input - and anything outside the allowlist fails the parse, which callers handle by rendering the input literally (RichLabel does).

Subtree opacity: the embeddable state and the PushAlpha discipline around child paint. A fade today would mean threading an alpha factor through every widget color by hand; an Opacity-carrying widget pushes the factor onto the canvas instead (render.Canvas.PushAlpha), so every color its subtree produces — fills, borders, text, image blits — is modulated in one place, and nested carriers multiply.

Box shadows for floating surfaces. Menus, popovers, tooltips, toasts, and dialogs all read their elevation from here, so one theme knob (ShadowBlur, ShadowColor) restyles — or disables — every shadow at once, and the look never drifts per widget.

Two invariants hold everywhere:

  • The shadow paints OUTSIDE the widget's logical bounds. Layout, hit-testing, and the bounds the damage collector sees are never widened by it: a point in the shadow gutter is not a hit, the one rule that keeps click-away dismissal and padding math honest.
  • The pixels a shadow owes beyond the bounds are tracked as a damage ring (shadowTracker), invalidated only when the bounds move or the theme's shadow restyles — a hover twitch repaints the card, never the falloff.

The CSS layer (docs/css.md): classes, ids, states, and inline styles on the shared node; prioritized stylesheets with hot reload; and the per-widget computed style the render path reads where it reads Theme fields.

The data flow is one direction. AddStylesheet and LoadStylesheet parse once and install the layer; a style generation stamp goes stale everywhere at once. Each widget's cascade is computed lazily on first read after an invalidation — never per paint — and the diff against the previous values drives the smallest correct invalidation: repaint the widget, relayout it when a layout-affecting property moved, and mark the subtree when an inherited one (a custom property included) did. A state, class, or id flip restyles the widget alone unless a loaded selector reads that fact left of a combinator; then the subtree (and, for sibling selectors, the neighbors) restyle too. With no stylesheet loaded the cascade is empty, every consumer falls through to its theme-derived value, and the pixels are exactly the pre-CSS ones.

The edit history shared by the editable text widgets (Entry, TextArea): every content mutation records a before/after state pair on a bounded stack, consecutive typed runes coalesce into one entry GTK-style, and undo/redo restore snapshots exactly as the edits left them. routeKey reaches it through Undoer.

Package widget is lys-ui's retained-mode widget layer: a tree of widgets measured against constraints, arranged into pixel rects, and painted onto a render.Canvas. Input handling arrives in M4; HitTest is already here so event dispatch can hook into the same geometry.

API conventions

Constructors are positional, in one fixed order: the font first, then the pixel size (sizePx, logical, when the widget paints text at a configurable size), then the widget's content and initial state, then colors. A nil face panics in the constructor with a message naming the argument (see requireFace) — it never fails later, deep in shaping.

Event hooks are exported function fields set after construction (Button.OnClick, Entry.OnChanged, Dropdown.OnSelect, ...), one per event, fired synchronously from whatever produced it. The Router methods and the handler interfaces they dispatch to (Clicker, KeyActionHandler, HoverSetter, ...) are input plumbing, not app hooks, and are not part of this convention.

State comes in getter/setter pairs with no Get prefix: Text and SetText, On and SetOn, Alignment and SetAlignment. Every Set* whose state is app-meaningful has a matching getter; the router-facing Set* methods (SetHovered, SetPressed, SetDragOver) are interface plumbing, not state API. Bounds returns the last arranged rect, and the zero rect before the first Arrange — a defined value, never a panic.

Every coordinate, size, and pixel parameter is logical pixels; the device scale is applied exactly once, at the buffer boundary in the app and render packages.

Index

Examples

Constants

View Source
const (
	// DirectionAuto resolves the base from the paragraph's first strong
	// character (UAX #9 rules P2-P3). It is the zero value: existing
	// LTR content renders unchanged, and a Hebrew- or Arabic-first
	// paragraph lays out right to left on its own.
	DirectionAuto = text.DirectionAuto
	// DirectionLTR forces a left-to-right base; start hugs the left.
	DirectionLTR = text.DirectionLTR
	// DirectionRTL forces a right-to-left base; start hugs the right,
	// and a Box row flows from the right edge.
	DirectionRTL = text.DirectionRTL
)
View Source
const (
	// ImageFit scales the image to fit the box with its aspect ratio
	// kept; the default.
	ImageFit = render.ImageFit
	// ImageCover fills the box completely, cropping the overflow.
	ImageCover = render.ImageCover
	// ImageNone draws the image at its natural size, one source pixel
	// per device pixel, centered and clipped.
	ImageNone = render.ImageNone
	// ImageStretch fills the box exactly, ignoring the aspect ratio.
	ImageStretch = render.ImageStretch
	// ImageScaleDown draws the natural size when it fits and shrinks to
	// fit (aspect kept) when it does not; it never enlarges.
	ImageScaleDown = render.ImageScaleDown
)
View Source
const (
	// EllipsizeNone never truncates: long text overflows and clips.
	EllipsizeNone = render.EllipsizeNone
	// EllipsizeStart cuts from the front: "…cated text".
	EllipsizeStart = render.EllipsizeStart
	// EllipsizeMiddle keeps the head and the tail: "trunc…text" - the
	// mode for paths and filenames.
	EllipsizeMiddle = render.EllipsizeMiddle
	// EllipsizeEnd cuts from the back: "truncated te…".
	EllipsizeEnd = render.EllipsizeEnd
)
View Source
const (
	LayoutMotionNone   = style.LayoutMotionNone
	LayoutMotionSmooth = style.LayoutMotionSmooth
	LayoutMotionSnappy = style.LayoutMotionSnappy
	LayoutMotionBouncy = style.LayoutMotionBouncy
)

The layout motions.

View Source
const (
	LevelBarOffsetLow  = "low"
	LevelBarOffsetHigh = "high"
	LevelBarOffsetFull = "full"
)

The default level bar offsets, GTK's names and thresholds; the theme layer colors a block carrying each (warning, accent, success).

View Source
const (
	// StylePriorityFallback is for defaults below everything.
	StylePriorityFallback = style.PriorityFallback
	// StylePriorityTheme is for a theme's stylesheet.
	StylePriorityTheme = style.PriorityTheme
	// StylePrioritySettings is for settings-derived rules.
	StylePrioritySettings = style.PrioritySettings
	// StylePriorityApplication is the application's own stylesheet;
	// LoadStylesheet installs at it.
	StylePriorityApplication = style.PriorityApplication
	// StylePriorityUser is for user overrides, and the default priority
	// of a widget's inline style.
	StylePriorityUser = style.PriorityUser
)

Style priorities, GTK's provider priorities: a higher priority wins over any specificity below it; equal priorities fall to specificity, then to load order.

View Source
const BTNLeft uint32 = 0x110

BTNLeft is the wayland button code of the primary pointer button.

View Source
const BTNMiddle uint32 = 0x112

BTNMiddle is the wayland button code of the middle pointer button, the X11 paste button.

View Source
const BTNRight uint32 = 0x111

BTNRight is the wayland button code of the secondary pointer button.

View Source
const BackLabelPrefix = "‹ "

BackLabelPrefix leads the back row's label (the parent row's label follows).

View Source
const FocusRingWidth = 3

FocusRingWidth is the width of the keyboard focus ring: the window's ring around the focused widget, and an outline-style: auto outline that declares no width of its own.

View Source
const GTKTextWidth = 150

GTKTextWidth is a GtkEntry's text width without width-chars (GtkText's MIN_TEXT_WIDTH): pass it to SetTextWidth for a field sized the way GTK sizes one.

View Source
const PopoverGap = 4

PopoverGap is the distance a popover or menu keeps from the trigger that opened it.

View Source
const TabMime = "application/x-lys-ui-tab"

TabMime is the drag payload of a dragged tab: its page id, which any TabBar in the process resolves to move the page.

View Source
const Unknown = -1

Unknown is a forSize the measuring container does not know yet: a width asked before any height is decided.

Variables

View Source
var ErrGPUAreaOffscreen = errors.New("widget: the GPUArea is not on screen yet")

ErrGPUAreaOffscreen reports a GPUArea call before the area is on screen: frames are imported and presented once OnFrame first runs.

View Source
var ErrNotFocusable = errors.New("widget: not focusable")

ErrNotFocusable is SetFocus refusing a widget that cannot take focus: it has no KeyActionHandler, opted out, or is disabled or hidden.

View Source
var ErrNotInTree = errors.New("widget: not in the focused tree")

ErrNotInTree is SetFocus refusing a widget outside the router's tree.

Functions

func A11yGeneration added in v0.2.5

func A11yGeneration() uint64

A11yGeneration moves whenever what an assistive technology reads may have changed: on any damage, and on the changes that paint nothing. Safe from any goroutine.

func ActivateMnemonic

func ActivateMnemonic(w Widget, sym xkb.Keysym) bool

ActivateMnemonic fires the first mnemonic bound to sym at or below w, in paint order, and reports whether one fired. Hosts that hold raw keys for a tree (a popover's key root) route Alt-letter presses through here.

func ArrangeAsChild

func ArrangeAsChild(w Widget, r render.Rect)

ArrangeAsChild arranges w in r as a container arranges its child: inside its margin, held to its CSS bounds. MeasureAsChild's pair.

func BackdropRegion

func BackdropRegion(root Widget) []render.Rect

BackdropRegion is the region behind root's tree a compositor blurs: the rounded border boxes, at the rects they show at, of the shown widgets whose style blurs their backdrop (backdrop-filter, the glass family). A glass root is the whole region. A tree without any is the root's own box, a window blurred behind as a whole.

The answer is kept on root until a widget moved, restyled, or the tree changed (shapeGen), so a frame that changed none of it walks nothing. The slice stays root's: the caller reads it and copies what it keeps.

func BackdropWalks added in v0.2.5

func BackdropWalks() int

BackdropWalks counts the tree walks BackdropRegion made; tests use it to pin that a frame changing no shape walks nothing.

func CSSCursorOf

func CSSCursorOf(w Widget) string

CSSCursorOf returns the cursor the stylesheet asks for over w: an xcursor shape name the session resolves ("pointer", "ns-resize", the hidden "none"), or a file request built from cursor: url() and its hotspot. Empty when no cursor declaration reaches w or it is auto — the caller falls back to the widget's own shape. The value inherits, so one declaration covers a subtree.

func CascadeBorder

func CascadeBorder(w Widget) render.Insets

CascadeBorder resolves the widget's computed border widths: the stroke a canvas-drawn primitive takes from the stylesheet (the progress ring reads the top width as its stroke).

func CascadeColor

func CascadeColor(w Widget) render.Color

CascadeColor resolves the widget's computed color: the CSS `color`, inherited down the tree, which the canvas-drawn primitives take as their ink (the progress ring's stroke). Zero paints nothing — the no-stylesheet behavior, same as everywhere else.

func CollectDamage

func CollectDamage(root Widget) (rects []render.Rect, any bool)

CollectDamage drains every pending invalidation in the tree and returns the repaint rects in root coordinates plus whether anything is owed. Rects may overlap; the caller can clip painting to their bounding box and damage each rect on the wire. Draining clears the flags, so an empty result means the tree paints identically to the last frame.

func CollectDamageInto

func CollectDamageInto(buf []render.Rect, root Widget) (rects []render.Rect, any bool)

CollectDamageInto is CollectDamage reusing buf's storage for the rects, so a frame loop that keeps its buffer drains without allocating.

func CornerRadii

func CornerRadii(w Widget) render.Corners

CornerRadii is w's border-box corner rounding as its stylesheet sets it: the shape a focus ring or a compositor blur region follows. Unstyled corners are square.

func CursorNameOf

func CursorNameOf(w Widget) string

CursorNameOf returns the hover pointer shape SetCursorName put on w, empty when none — the fallback cursorFor reads after the widget's own CursorName.

func DamageArea

func DamageArea(rects []render.Rect) int

DamageArea returns the total pixel area the rects cover, counting overlaps once per rect. Tests use it to pin how much of a frame a damage-restricted repaint touches.

func DamageGeneration

func DamageGeneration() uint64

DamageGeneration returns the current damage generation; it is never zero.

func DamageReport

func DamageReport() string

DamageReport returns the widgets that owed their whole bounds since the last call, largest first ("1920x1080 *widget.Box invalid, ..."), and clears them; "" when there were none or the build lacks the lysdebug tag. The app logs it per frame under LYS_DEBUG=damage.

func DamageWalks

func DamageWalks() uint64

DamageWalks counts the damage walks the process has run; tests use it to pin the idle skip.

func DefaultSwatches

func DefaultSwatches() []render.Color

DefaultSwatches is the preset palette a ColorButton offers: neutrals then the hues around the wheel.

func DescendsFrom

func DescendsFrom(w, ancestor Widget) bool

DescendsFrom reports whether w is ancestor or a descendant of it - the walk the input pipeline uses to find a drag handle under a press that resolved into a child control.

func Detach

func Detach(w Widget)

Detach releases what w's tree holds for being on screen, for a tree leaving it (a removed widget, a closed window or popover): every GPUArea's surface, and the rasters every Image resampled from a source only it holds. A tree shown again re-creates them on its next paint.

func DeviceScaleOf added in v0.2.5

func DeviceScaleOf(w Widget) (num, denom int)

DeviceScaleOf returns the device scale w's tree presents at, num device pixels per denom logical ones, as SetDeviceScale set it on its style root; 0/120 while unknown.

func DumpTree

func DumpTree(root Widget, r *Router) string

DumpTree renders the tree as one indented line per widget: type, debug name, bounds, role, tooltip, and the set input-state flags. The format is stable - tests pin it byte for byte - so a dump pasted into a bug report says exactly the same thing to everyone.

*widget.Box bounds=0,0+400x200
  *widget.Button name=save bounds=8,8+72x36 role=button tooltip="Save" focusable
    *widget.Label bounds=18,17+52x18 role=label focusable

Flags read "this widget IS the router's X target": focused, hover, pressed. focusable marks Tab-reachable widgets. r may be nil.

func DumpTreeTo

func DumpTreeTo(w io.Writer, root Widget, r *Router)

DumpTreeTo writes the DumpTree format to w.

func ErrorBell

func ErrorBell(w Widget)

ErrorBell signals an input w rejected (gtk_widget_error_bell): typing into a read-only field, a value that does not parse. The application rings the system bell for w's window; the compositor may flash it instead.

func FocusRingRect

func FocusRingRect(w Widget) render.Rect

FocusRingRect is the rect the keyboard focus ring of a focused w covers: its FocusRingOwner's border box grown by FocusRingWidth on every side. It is empty when the owner reports no bounds.

func FocusVisible

func FocusVisible(w Widget) bool

FocusVisible reports whether w holds a focus that should show (:focus-visible): one that arrived by keyboard traversal, not by a pointer press or SetFocus.

func FontFaceResolved added in v0.2.5

func FontFaceResolved()

FontFaceResolved tells the widgets a fallback chain has a new face: text shaped before it shapes again, and the windows lay out and paint on the loop's next pass. It is a render.Chain's onResolved, safe on any goroutine. Answers that land before the loop has taken the last one share one relayout. Without a loop, only text painted from here on is shaped anew.

func FormatColor

func FormatColor(c Color) string

FormatColor writes c as the hex form ParseColor reads back: #rrggbb when opaque, #rrggbbaa otherwise (straight alpha).

func GrabFocus

func GrabFocus(w Widget) error

GrabFocus moves the keyboard focus of w's surface to w (GTK's gtk_widget_grab_focus): a form focusing its first invalid field. A widget that cannot take focus fails with ErrNotFocusable and leaves it where it was.

func HasClass

func HasClass(w Widget, class string) bool

HasClass reports whether w carries the style class — the read side for tests and accessibility tooling.

func Host

func Host(root Widget) (unhost func())

Host marks root as the top of a tree a host shows on screen, a window's or a popover's, and returns the call that ends it. Only widgets under a hosted root animate: a subtree removed from its tree, a tree whose window closed, or one a test arranged and dropped schedules no frames. Hosting a widget twice is one hosting.

func IconSearchPaths

func IconSearchPaths() []string

IconSearchPaths returns the base directories theme icons resolve from: what SetIconSearchPaths set, else the XDG default (GTK's IconTheme.search_path).

func InkOutset

func InkOutset(w Widget) render.Insets

InkOutset is how far w paints outside its bounds: its box shadows, outline, border image and filters. A surface whose card w is reserves that room around it.

func InputRegionOf

func InputRegionOf(root Widget) ([]render.Rect, bool)

InputRegionOf is the input region of root's content: the first InputRegioner down from root through wrappers of a single child (a Revealer, a Clamp, a one-child Box), and false when there is none.

func IsEnabled

func IsEnabled(w Widget) bool

IsEnabled reports whether w accepts input: its own flag AND every ancestor's, so disabling a container disables its subtree by query (see node.SetEnabled for why propagation is a walk, not a rewrite). Widgets that carry no enable state — third-party Widget implementations without an Enabled method — read as enabled, and so does nil (nothing there to block). Parents are recorded during Arrange, so call it on an arranged tree.

func IsInteractive

func IsInteractive(w Widget) bool

IsInteractive reports whether w or any ancestor consumes presses: buttons, sliders, toggles, text inputs, and scroll areas. Hit tests return the deepest widget, often a plain label inside a control, so apps checking "was this chrome?" must walk up. Parents are recorded during Arrange, so call it on an arranged tree. Enabled state does not change the answer: a disabled button is still interactive — it consumes the press and swallows it — never chrome.

func IsVisible

func IsVisible(w Widget) bool

IsVisible folds the visibility of every ancestor: false when the widget or any container above it is hidden, by SetVisible or by a computed display: none — either way the widget is not laid out, painted, or hit. CSS visibility: hidden keeps the widget laid out and is not folded here (shown).

func LayoutPending

func LayoutPending(w Widget) bool

LayoutPending reports whether w's cached measure is stale - a descendant was parented, restyled or resized since - so a host that just arranged it must measure and arrange again before painting.

func LoadStylesheet

func LoadStylesheet(css string)

LoadStylesheet parses css and installs it as the application stylesheet (StylePriorityApplication), replacing whatever LoadStylesheet loaded before. An empty string removes it. Other stylesheets added with AddStylesheet are untouched.

func LoadStylesheetFile

func LoadStylesheetFile(path string) error

LoadStylesheetFile loads a stylesheet from path as the application stylesheet (StylePriorityApplication), replacing whatever LoadStylesheetFile loaded before, with the same hot reload AddStylesheetFile starts.

func MarkA11yChanged added in v0.2.5

func MarkA11yChanged()

MarkA11yChanged moves A11yGeneration without owing a frame: an accessible name, or a window coming or going.

func MarkLoop

func MarkLoop()

MarkLoop records the calling goroutine as the event-loop goroutine and arms the guard: a sampled widget mutation from any other goroutine now trips the off-loop hook. Application.Run marks its own goroutine; tests can mark whichever goroutine they drive the tree on.

func MeasureMissReport

func MeasureMissReport() string

MeasureMissReport returns the measure-cache misses since the last call, most frequent first ("12 uncached *widget.Box, ..."), and clears them; "" when there were none or the build lacks the lysdebug tag. The app logs it per frame under LYS_DEBUG=measure.

func MediaViewportOf

func MediaViewportOf(w Widget) (int, int)

MediaViewportOf returns the @media viewport w's tree computes against: its style root's own size, else the global one; 0×0 until either is set.

func OpenMenu

func OpenMenu(from Widget, anchor Boundser, face render.Font, sizePx float64, items []MenuItem, opts MenuOptions)

OpenMenu opens items as a popup menu beside anchor through the host of from's tree.

func OpenPopover

func OpenPopover(from Widget, anchor Boundser, content Widget, opts PopoverOptions) (close func())

OpenPopover opens content in a popover beside anchor through the host of from's tree, and returns what closes it. The popover's own node is a box around content, so content keeps its element and style.

func PaintBoxLayers

func PaintBoxLayers(cv *render.Canvas, w Widget)

PaintBoxLayers paints the widget's computed box layers — background, image, borders, shadows, and the outline — at its bounds. A custom widget's Paint calls it for its own chrome before drawing content, so the container styling stays in the cascade (the hovered row's background, the :hover rule, is this). The opacity and brightness in force wrap the layers.

func PaintChild

func PaintChild(cv *render.Canvas, w Widget)

PaintChild paints a container's child and then, when the frame armed it for that child, the keyboard focus ring (render.Canvas.MarkFocus), so later siblings cover the ring. Containers defined outside the kit call it for their children too; one that does not still gets the ring, drawn over the whole frame at its end. A child hidden by SetVisible or display: none paints nothing, whoever its container is, and nor does one its computed visibility hides, except that a Box still paints its children, which may show themselves (visibility: visible inside a hidden box).

func PaintFocusRing

func PaintFocusRing(cv *render.Canvas, w Widget)

PaintFocusRing draws the keyboard focus ring of a focused w around its FocusRingOwner: FocusRingWidth wide outside the border box, following its corner radii, in the theme's ring color at focusRingAlpha.

func PreloadThemeIcon added in v0.2.1

func PreloadThemeIcon(name string, size, num, denom int)

PreloadThemeIcon decodes the icon NewThemeIconFallback(name, size) will paint at the device scale num/denom, so its first paint reads and rasterizes nothing. It reads the disk, so it belongs off the UI loop, and it is safe from any goroutine. name may also be an absolute path.

func PseudoContent

func PseudoContent(w Widget, pseudo string) string

PseudoContent returns w's resolved pseudo-element content — the strings, attr() values, and counter readings a `content:` value joined — empty when the pseudo-element declares none.

func PseudoStyle

func PseudoStyle(w Widget, pseudo string) *style.Values

PseudoStyle returns w's computed ::before/::after/::first-letter style — the cascade the pseudo-element's rules produced, inheriting from the widget's own. nil when no rule addresses any of w's pseudo-elements or the name is not one of them. The values are fresh only after a restyle; paint paths read them through PaintBoxLayers.

func RefreshIcons

func RefreshIcons()

RefreshIcons forgets every resolved theme icon, a found file and a miss alike, so icons installed or removed under the search paths since are picked up; live themed icons re-resolve on the repaint the application requests. Safe from any goroutine.

func RevealRect

func RevealRect(w Widget, r render.Rect)

RevealRect scrolls every Scroll above w just far enough that r, in root coordinates, shows in its viewport: a rect below the viewport lands at its bottom edge, one above at its top, one taller than the viewport with its top showing. w's scroll-margin grows the target and each scroll's scroll-padding insets its viewport, and a scroll-behavior: smooth scroll animates to the reveal. The innermost scroll moves first and the outer ones reveal where r then sits, the way GTK's viewports scroll a focused widget into view. The scrolls re-lay out within the frame.

func RootFontSize

func RootFontSize() float64

RootFontSize returns the current root font size.

func SetAnimationsInstant

func SetAnimationsInstant(on bool) (restore func())

SetAnimationsInstant collapses every transition and animation tween to its end state (GTK's gtk-enable-animations off) and returns the restore function. Already-running tweens keep their schedules; only launches after the call are affected. Hosts that screenshot, test, or honor reduced motion set it.

func SetDeviceScale added in v0.2.5

func SetDeviceScale(root Widget, num, denom int)

SetDeviceScale records that root's tree presents at num device pixels per denom logical ones, and has every dynamic Icon in it decode for that scale off the loop ahead of its paint; an Icon arranged into the tree later does the same. The application calls it as a window learns its scale, before the first frame, and on every change, while the rasters on show stay until their replacements are decoded.

func SetErrorBell

func SetErrorBell(fn func(w Widget))

SetErrorBell installs the bell ErrorBell rings; nil silences it.

func SetFaceResolver

func SetFaceResolver(f func(family string, weight int) (render.Font, bool))

SetFaceResolver installs the family/weight → face lookup the font-family and font-weight declarations shape with. One resolver per process; nil restores the default no-op. It is consulted at style-invalidation time, never per paint.

func SetGPUHost

func SetGPUHost(fn func(a *GPUArea) (GPUSurface, error))

SetGPUHost installs the function that gives an on-screen GPUArea its surface; package app installs it. nil disables.

func SetIconNamespace

func SetIconNamespace(dir string, prefixes []string)

SetIconNamespace declares icon names starting with one of prefixes and a dash to be the application's own, kept in dir (relative) below the icon search paths, such as "hicolor/scalable/actions". The first themed icon an application draws otherwise lists every directory of the theme chain; these names need only dir, so an application drawing nothing else never lists the chain. A theme cannot override them. A name dir does not hold resolves as usual, so ThemeIconExists stays exact.

func SetIconSearchPaths

func SetIconSearchPaths(paths []string)

SetIconSearchPaths replaces the base directories theme icons resolve from, in priority order (GTK's IconTheme.set_search_path); nil restores the XDG default. Live themed icons re-resolve on the next repaint, which the application requests.

func SetInvoker

func SetInvoker(fn func(func())) (remove func())

SetInvoker installs the function asynchronous image loads use to run their completion on the event-loop goroutine; app calls it with Application.Invoke. Nil removes the bridge. The returned function removes this one and leaves a later install in place.

func SetMediaContrast

func SetMediaContrast(on bool)

SetMediaContrast turns the prefers-contrast media feature on or off; the desktop's contrast preference, which no Theme field carries. The whole tree restyles on a change.

func SetMediaResolution

func SetMediaResolution(dpi float64)

SetMediaResolution sets the resolution the @media resolution feature reports, in dpi. The default is 96.

func SetMediaViewport

func SetMediaViewport(w, h int)

SetMediaViewport sets the size @media width/height/aspect-ratio/ orientation conditions evaluate against for trees whose window reported no viewport of its own — the window's logical size, which the app layer feeds from its resize callback. The whole tree restyles when the size changes. Call it from the event-loop goroutine, like SetTheme.

func SetMediaViewportFor

func SetMediaViewportFor(root Widget, w, h int)

SetMediaViewportFor sets the @media viewport of one window's tree: root is the widget SetStyleRoot marked (the app layer passes each window's content root), and every widget below it computes @media conditions, the vw/vh family, and container units against this size, so two windows of one application style independently off one stylesheet. A tree whose root reports no viewport falls back to SetMediaViewport's global value; 0×0 clears the tree's own size.

func SetMessageCatalog

func SetMessageCatalog(c Catalog)

SetMessageCatalog installs c as the translation for every built-in string and every Tr, TrN and TrCtx call; nil restores the identity. It is process-wide like SetTheme: install it before building widgets.

func SetOffLoopHook

func SetOffLoopHook(hook func(what string))

SetOffLoopHook installs the debug hook fired with the sampled entry point's name when a widget mutation runs off the loop goroutine; nil disables. The hook runs on the offending goroutine and must not touch widgets. Production code leaves it nil; tests and lysdebug builds use it to enforce the threading contract.

func SetParents

func SetParents(parent Widget, kids ...Widget)

SetParents records parent as the arranging container of every child, so containers defined outside the kit wire the cascade the same way the built-in ones do during Arrange.

func SetParseWarn

func SetParseWarn(f func(msg string))

SetParseWarn installs f as the CSS engine's parse-warning sink; nil restores the library logger. One sink per process. Hosts that want stylesheet problems visible — a settings app showing theme errors — route the messages to their log or interface.

func SetReducedMotion added in v0.2.1

func SetReducedMotion(on bool)

SetReducedMotion applies the desktop's reduced-motion preference: what moves stops moving and surfaces fade instead, the prefers-reduced-motion media feature turns on, and every Theme's Moves answers false, whatever its Animations says. app.Application calls it from the portal's reduced-motion setting, so apps need not.

func SetRemovedHook

func SetRemovedHook(fn func(Widget))

SetRemovedHook installs the hook fired when a widget is detached from its container; nil disables. One hook per process, like SetInvoker — the last install wins. It runs on the goroutine that mutated the tree (the loop goroutine, per docs/threading.md), while the widget is still linked to its container, so a router can find the focus traversal neighbor of a removed focus.

func SetRootFontSize

func SetRootFontSize(px float64)

SetRootFontSize sets the root font size stylesheet units resolve against: 1rem, and the default font size (CSS's `medium`) of widgets nothing sets one for. The default is 16 logical pixels, the CSS default; GTK derives its own from the desktop font setting. The whole tree restyles.

func SetStyleAnchor

func SetStyleAnchor(w, anchor Widget)

SetStyleAnchor styles w's tree as a child of anchor while w has no layout parent: inheritance, selector ancestry, :root and the scoped sheets continue up anchor's chain, as a GTK popover's CSS node is a child of the widget it pops from. A change anchor's descendants would inherit restyles the tree too. nil unanchors it; a new anchor replaces the old.

func SetStyleRoot

func SetStyleRoot(w Widget)

SetStyleRoot makes w the root of its tree for styling: :root matches it, and nothing above it is inherited or contributes scoped sheets, while it keeps its layout parent - the app wraps every window's tree in plumbing (a fader, the inspector overlay) that invalidations must climb through but stylesheets must not see.

func SetStylesheetWatcher added in v0.2.5

func SetStylesheetWatcher(watch StylesheetWatcher)

SetStylesheetWatcher installs what tells the stylesheet files' hot reload that something changed, and watches the files already loaded. One hook per process, like SetRemovedHook; the app installs it once at startup. Without a hook (no running Application) a loaded file simply never hot-reloads.

func SetSurfaceHost

func SetSurfaceHost(root Widget, h SurfaceHost)

SetSurfaceHost makes h serve the tree under root. A root from outside this package carries no host, like SetStyleRoot's; asking its tree for a popup or a focus move then panics.

func SetSurfaceOriginResolver

func SetSurfaceOriginResolver(resolve func(root Widget) (Point, bool))

SetSurfaceOriginResolver installs the host's surface placement: resolve maps a widget tree's root (RootOf) to where its surface's (0,0) sits in its toplevel surface's coordinates, false while the compositor has not placed it. Shared-element morphs cross surfaces through it, a button into the popover it opens; one process-wide resolver, nil for none (morphs then stay inside one surface).

func SetTheme

func SetTheme(t *Theme)

SetTheme replaces the active theme. Passing nil restores DarkTheme. The next frame repaints every widget with the new palette. Any palette pair whose contrast falls below WCAG AA is reported at Warn on the injected library logger (degraded but running: the swap proceeds); with the default logger the warning is discarded and SetTheme never fails.

func SharedMorphPending

func SharedMorphPending(tree Widget) bool

SharedMorphPending reports whether a tree about to show on a surface of its own holds a tagged widget that will morph out of another surface's: a widget whose tag last showed, placed, on a different surface. A popover opening with one skips its own reveal, since the morph carries the opening.

func ShownRect

func ShownRect(w Widget) render.Rect

ShownRect is the rect w is shown at: its laid-out bounds, or mid-motion the rect its layout motion paints it at. A surface's backing (a popup's plate and shadow) follows it, so the visible box springs with the content.

func StopAssetLoads added in v0.2.5

func StopAssetLoads()

StopAssetLoads drops the icon, stylesheet image and font loads that have not started. Application calls it when its loop ends; answers from here on go nowhere, so nothing stays asked for.

func StyleBackground

func StyleBackground(w Widget) render.Color

StyleBackground returns the widget's computed background color, the diagnostic view a paint test reads.

func StylesBackground

func StylesBackground(w Widget) bool

StylesBackground reports whether the stylesheet declares w's background - a color (transparent included), an image, or another box layer - so a host that paints a default plate behind w (a popover's) can yield to it, as GTK leaves a popover's look to its CSS.

func ThemeIconExists

func ThemeIconExists(name string) bool

ThemeIconExists reports whether name resolves in the current icon theme chain (hicolor included) or the unthemed fallback directories, at any size - GTK's IconTheme.has_icon. Apps use it to pick between candidate names (a distro logo, then a generic one) before building a NewThemeIcon, since a missing theme icon paints nothing.

func ThemeIconPreloaded added in v0.2.1

func ThemeIconPreloaded(name string, size, num, denom int) bool

ThemeIconPreloaded reports whether PreloadThemeIcon's work is done for this icon, which a paint also does. It never blocks, so the UI loop may ask: while the cache is busy the answer is no.

func Tr

func Tr(s string) string

Tr translates s through the installed catalog, English without one. Every toolkit-owned label passes through it; developer surfaces (the inspector dump, traces) stay English on purpose.

func TrCtx

func TrCtx(ctx, s string) string

TrCtx translates s within ctx (gettext's msgctxt).

func TrN

func TrN(singular, plural string, n int) string

TrN translates a plural pair for n: singular for 1 and plural otherwise without a catalog, the catalog's form for n with one.

func TreeCell

func TreeCell[T any](tree *FlatTree[T], sizePx float64, cell func(T) Widget) func(FlatRow[T]) Widget

TreeCell builds the expander column's Cell: indent guides for every ancestor level, the expander toggle (a leaf paints a dot-sized gap instead), then the value's own cell. Activating the toggle calls tree.Toggle(i) and then refresh - the default refresh re-lists the owning List; pass your own when the tree feeds something else.

func UnmarkLoop

func UnmarkLoop()

UnmarkLoop disarms the guard. Run calls it when the loop exits, so post-Run teardown may touch widgets from any goroutine again.

func WaitAssetLoads added in v0.2.5

func WaitAssetLoads()

WaitAssetLoads blocks until every icon, stylesheet image and font load asked for so far has finished and queued its answer on the loop, whose next pass then applies it. It is what a test that needs a settled frame waits on; a UI loop must never call it.

func WantsExpand

func WantsExpand(w Widget, axis Axis) bool

WantsExpand reports whether w wants extra space on axis: its own setting when set, else whether any visible child wants it, GTK's computed expand. The result is cached until the subtree's layout changes.

Types

type A11yState

type A11yState struct {
	Role Role
	// Name is the accessible name: SetAccessibleName's when set, else
	// the tooltip text, else the visible label text for labeled
	// controls.
	Name string
	// Text is the current contents for text-bearing roles.
	Text string
	// Caret is the text cursor as a rune offset into Text.
	Caret int
	// SelStart and SelEnd bound the selected rune range; HasSelection
	// reports whether one is active.
	SelStart, SelEnd int
	HasSelection     bool
	// Checked is the Switch and CheckButton state.
	Checked bool
	// Pressed is a ToggleButton's active state.
	Pressed bool
	// Min, Max, and Value carry the ranged roles (slider, progress
	// bar); Step is the keyboard increment (slider only, 0 when the
	// slider divides the range itself).
	Min, Max, Value, Step float64
	// Editable reports whether the text can be changed by the user:
	// false for a read-only field, and for a disabled one — the same
	// contract the widget input paths enforce.
	Editable bool
	// Enabled reports whether the widget accepts input at all, folding
	// its ancestors in (widget.IsEnabled): a widget inside a disabled
	// container reports false, exactly as input treats it.
	Enabled bool
	// Multiline distinguishes text areas from single-line entries.
	Multiline bool
	// Focusable reports whether focus can land on the widget, by Tab,
	// a click, SetFocus or an assistive technology: an enabled, rendered
	// KeyActionHandler.
	Focusable bool
	// TabStop reports whether Tab traversal lands on it: focusable, and
	// not a row of a list, whose rows are one stop with the list.
	TabStop bool
	// Bounds is the arranged rect, so a bridge can report extents.
	Bounds render.Rect
}

A11yState is a point-in-time snapshot of what assistive technology needs about one widget: role, name, current value, text contents with caret and selection, and state flags.

func Describe

func Describe(w Widget) A11yState

Describe snapshots w's accessibility state. Focus is deliberately absent: it lives on the Router, and callers compare against Router.Focused directly.

func DescribeTree

func DescribeTree(root Widget) []A11yState

DescribeTree snapshots root and every rendered descendant in paint order, the same pre-order focus traversal uses: a widget hidden from the screen is hidden from assistive technology too.

type Accordion

type Accordion struct {
	// contains filtered or unexported fields
}

Accordion is a vertical stack of collapsible sections: each item a trigger row - the title, and a chevron that turns over as the item opens - above content whose height animates open and closed. In AccordionSingle mode opening an item closes the open one, and SetCollapsible decides whether the open item may close leaving none open. Up and Down move focus between the triggers, Home and End to the first and last. It styles as the `accordion` element, each item an .item (:checked while open) holding a button.trigger and its .content.

func NewAccordion

func NewAccordion(mode AccordionMode) *Accordion

NewAccordion returns an empty accordion in mode; a single-mode one starts not collapsible.

func (*Accordion) Append

func (a *Accordion) Append(it *AccordionItem)

Append adds it as the last item. In single mode an open item closes the open one. An item belongs to one accordion; appending it to a second is a caller bug and panics.

func (*Accordion) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Accordion) Baseline

func (c *Accordion) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Accordion) Children

func (c *Accordion) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Accordion) HitTest

func (c *Accordion) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Accordion) Items

func (a *Accordion) Items() []*AccordionItem

Items returns the items in order.

func (*Accordion) Measure

func (c *Accordion) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Accordion) NavigateFocus

func (a *Accordion) NavigateFocus(target Widget, k KeyAction) Widget

NavigateFocus implements FocusNavigator: Up and Down step between the item triggers, Home and End go to the first and last.

func (*Accordion) Paint

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

Paint draws the surface (when configured) then the root.

func (*Accordion) SetCollapsible

func (a *Accordion) SetCollapsible(on bool)

SetCollapsible lets the open item of a single-mode accordion close, leaving none open; a multiple-mode accordion always may.

type AccordionItem

type AccordionItem struct {

	// OnToggled fires after every open-state change, including ones the
	// accordion made to keep a single item open.
	OnToggled func(open bool)
	// contains filtered or unexported fields
}

AccordionItem is one section of an Accordion (NewAccordionItem).

func NewAccordionItem

func NewAccordionItem(face render.Font, title string, content Widget) *AccordionItem

NewAccordionItem returns a closed item titled title over content, for Accordion.Append.

func (*AccordionItem) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*AccordionItem) Baseline

func (c *AccordionItem) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*AccordionItem) Children

func (c *AccordionItem) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*AccordionItem) HitTest

func (c *AccordionItem) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*AccordionItem) Measure

func (c *AccordionItem) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*AccordionItem) Open

func (it *AccordionItem) Open() bool

Open reports whether the item is open (the target state, while its content may still be animating).

func (*AccordionItem) Paint

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

Paint draws the surface (when configured) then the root.

func (*AccordionItem) SetOpen

func (it *AccordionItem) SetOpen(open bool)

SetOpen opens or closes the item under its accordion's mode: opening one in single mode closes the open one, and closing the open one of a single-mode accordion that is not collapsible does nothing. An item not yet appended just opens or closes.

func (*AccordionItem) SetTitle

func (it *AccordionItem) SetTitle(s string)

SetTitle replaces the trigger's title.

func (*AccordionItem) Title

func (it *AccordionItem) Title() string

Title returns the trigger's title.

type AccordionMode

type AccordionMode uint8

AccordionMode is how many of an accordion's items may be open.

const (
	// AccordionSingle keeps at most one item open: opening one closes
	// the others.
	AccordionSingle AccordionMode = iota
	// AccordionMultiple lets any number be open.
	AccordionMultiple
)

The accordion modes.

type Action

type Action struct {
	// contains filtered or unexported fields
}

Action is a named, stateless action, relm4's RelmAction without state: menu items, buttons and accelerators activate it, and disabling it disables them all. Like every widget, it belongs to the loop goroutine.

func NewAction

func NewAction(name string, fn func()) *Action

NewAction returns an enabled action running fn on activation.

func (*Action) Activate

func (a *Action) Activate()

Activate runs the action unless it is disabled.

func (*Action) Enabled

func (c *Action) Enabled() bool

Enabled reports whether the action may be activated.

func (*Action) Name

func (c *Action) Name() string

Name returns the action's name.

func (*Action) SetEnabled

func (c *Action) SetEnabled(on bool)

SetEnabled enables or disables the action and every proxy bound to it.

func (*Action) Subscribe

func (c *Action) Subscribe(fn func()) (cancel func())

Subscribe registers fn for every enabled or state change; the returned cancel removes it.

type ActionBar

type ActionBar struct {
	// contains filtered or unexported fields
}

ActionBar is the bottom bar: one pack, centered content optional - the gtk ActionBar shape. PackStart/PackEnd as on HeaderBar.

func NewActionBar

func NewActionBar() *ActionBar

NewActionBar returns an empty bottom bar.

func (*ActionBar) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ActionBar) Baseline

func (c *ActionBar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ActionBar) Children

func (c *ActionBar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ActionBar) HitTest

func (c *ActionBar) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ActionBar) Measure

func (c *ActionBar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ActionBar) PackEnd

func (p *ActionBar) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (*ActionBar) PackStart

func (p *ActionBar) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*ActionBar) Paint

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

Paint draws the surface (when configured) then the root.

type ActionRow

type ActionRow struct {

	// OnActivate fires for an activatable row's whole-row click or
	// Enter press - the list-activation contract.
	OnActivate func()
	// contains filtered or unexported fields
}

ActionRow is the preferences vocabulary's row (#93): a title with an optional subtitle (both ellipsized in the middle when tight), start and end pack slots, activatable whole-row clicks, and a selectable state - the libadwaita AdwActionRow shape over the same Box plumbing every form was hand-built from. Styled as the `row` element inside a PreferencesGroup's `rows` list; alone it paints its surface too, so a bare row still reads.

func NewActionRow

func NewActionRow(face render.Font, sizePx float64, title, subtitle string) *ActionRow

NewActionRow returns a row with a title and an optional subtitle (empty hides the line).

func (*ActionRow) Activatable

func (r *ActionRow) Activatable() bool

Activatable reports the whole-row activation mode.

func (*ActionRow) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ActionRow) Baseline

func (c *ActionRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ActionRow) Children

func (c *ActionRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ActionRow) ClickAt

func (r *ActionRow) ClickAt(p Point)

ClickAt activates an activatable row wherever it was clicked; a non-activatable row ignores the click (its packed controls handle their own).

func (*ActionRow) Direction

func (r *ActionRow) Direction() Direction

Direction reports the row's flow direction.

func (*ActionRow) HitTest

func (c *ActionRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ActionRow) KeyAction

func (r *ActionRow) KeyAction(a KeyAction, mods Mods)

KeyAction activates an activatable row on Enter or Space.

func (*ActionRow) Measure

func (c *ActionRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ActionRow) PackEnd

func (p *ActionRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (*ActionRow) PackStart

func (p *ActionRow) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*ActionRow) Paint

func (r *ActionRow) Paint(cv *render.Canvas)

Paint draws the row surface (selected and press washes) then the composed row.

func (*ActionRow) Revealed

func (r *ActionRow) Revealed() bool

Revealed reports the disclosure state (false without one).

func (*ActionRow) Selected

func (r *ActionRow) Selected() bool

Selected reports the selected state.

func (*ActionRow) SetActivatable

func (r *ActionRow) SetActivatable(on bool)

SetActivatable makes the whole row click- and Enter-activatable, with the pointer cursor and a disclosure chevron (ShowChevron controls the chevron alone).

func (*ActionRow) SetDirection

func (r *ActionRow) SetDirection(d Direction)

SetDirection mirrors the row's packs (Box's RTL mirroring).

func (*ActionRow) SetDisclosure

func (r *ActionRow) SetDisclosure(w Widget)

SetDisclosure wires sub-content revealed under the row - the ExpanderRow mechanism, a capability of the row itself: w sits in a slide-down revealer under the line, initially collapsed.

func (*ActionRow) SetPressed

func (r *ActionRow) SetPressed(on bool)

SetPressed paints the row's :checked press feedback (the router's press/release cycle calls it on activatable rows).

func (*ActionRow) SetRevealed

func (r *ActionRow) SetRevealed(on bool)

SetRevealed opens or closes the disclosure.

func (*ActionRow) SetSearchable

func (r *ActionRow) SetSearchable(on bool)

SetSearchable includes or excludes the row from a PreferencesView search; rows are searchable by default.

func (*ActionRow) SetSelected

func (r *ActionRow) SetSelected(on bool)

SetSelected paints the row's :selected state - the list selection contract, driven by whatever owns the selection.

func (*ActionRow) SetSubtitle

func (r *ActionRow) SetSubtitle(s string)

SetSubtitle sets the subtitle; empty hides it.

func (*ActionRow) SetTitle

func (r *ActionRow) SetTitle(t string)

SetTitle sets the title; SetSubtitle the line under it (empty hides it).

func (*ActionRow) ShowChevron

func (r *ActionRow) ShowChevron(on bool)

ShowChevron shows or hides the trailing disclosure arrow independently of activation.

func (*ActionRow) Subtitle

func (r *ActionRow) Subtitle() string

Subtitle returns the subtitle's text.

func (*ActionRow) Title

func (r *ActionRow) Title() string

Title returns the current title.

type Activatable

type Activatable interface {
	Name() string
	Activate()
	Enabled() bool
	Subscribe(fn func()) (cancel func())
}

Activatable is what menu items, buttons and accelerators bind to: an action, or a stateful action's target. Activate does nothing while Enabled is false. Subscribe hears every enabled or state change.

type Adjustable

type Adjustable interface {
	// AxisRange reports the position along axis (Row: horizontal).
	AxisRange(axis Axis) ScrollRange
	// SetAxisOffset scrolls along axis, clamped.
	SetAxisOffset(axis Axis, offset int)
	// WatchRange registers fn to run whenever a range changed - the
	// offset, the page, or the total.
	WatchRange(fn func())
}

Adjustable is a scroll position a Scrollbar shows and drives - GTK's Adjustment role, implemented by Scroll.

type Alert

type Alert struct {
	// contains filtered or unexported fields
}

Alert is an inline callout in the content flow: an optional icon beside a title and a wrapped description, on a bordered card. Unlike Banner it carries no action and does not slide; it is there for as long as the content shows it. It styles as the `alert` element, with the .destructive class for that variant, and assistive technology announces it as a notification.

func NewAlert

func NewAlert(face render.Font, title, description string) *Alert

NewAlert returns a default-variant alert; an empty description shows the title alone.

func (*Alert) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Alert) Baseline

func (c *Alert) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Alert) Children

func (c *Alert) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Alert) Description

func (a *Alert) Description() string

Description returns the description.

func (*Alert) HitTest

func (c *Alert) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Alert) Measure

func (c *Alert) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Alert) Paint

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

Paint draws the surface (when configured) then the root.

func (*Alert) Role

func (a *Alert) Role() Role

Role is RoleAlert.

func (*Alert) SetDescription

func (a *Alert) SetDescription(s string)

SetDescription replaces the description; empty hides it.

func (*Alert) SetIcon

func (a *Alert) SetIcon(w Widget)

SetIcon puts w (an icon, typically 16px) before the text; nil removes it.

func (*Alert) SetTitle

func (a *Alert) SetTitle(s string)

SetTitle replaces the title.

func (*Alert) SetVariant

func (a *Alert) SetVariant(v AlertVariant)

SetVariant switches the alert's look.

func (*Alert) Title

func (a *Alert) Title() string

Title returns the title.

func (*Alert) Variant

func (a *Alert) Variant() AlertVariant

Variant returns the alert's look.

type AlertVariant

type AlertVariant uint8

AlertVariant picks an alert's look.

const (
	// AlertDefault is the neutral callout.
	AlertDefault AlertVariant = iota
	// AlertDestructive paints the callout in the destructive color.
	AlertDestructive
)

The alert variants.

type Align

type Align uint8

Align says how a grid child sits inside its cell along one axis when the cell is larger than the child's natural size.

const (
	// AlignFill stretches the child across the whole cell. It is the
	// default, so plain Attach-ed children behave like Box children.
	AlignFill Align = iota
	// AlignStart pins the child to the cell's leading edge at its
	// natural size.
	AlignStart
	// AlignCenter centers the child in the cell at its natural size.
	AlignCenter
	// AlignEnd pins the child to the cell's trailing edge at its
	// natural size.
	AlignEnd
	// AlignBaseline lines a row Box's child up on the row's shared text
	// baseline at its natural height (GTK's valign baseline); children
	// with no baseline center, and across a column it pins to the start.
	AlignBaseline
)

type AspectFrame

type AspectFrame struct {
	// contains filtered or unexported fields
}

AspectFrame keeps its child at a width:height ratio (GTK AspectFrame): it takes what its parent gives and arranges the child in the largest rect of that ratio, centered. A ratio of zero obeys the child's own natural ratio.

func NewAspectFrame

func NewAspectFrame(child Widget, ratio float64) *AspectFrame

NewAspectFrame returns a frame holding child at ratio (W/H).

func (*AspectFrame) Arrange

func (a *AspectFrame) Arrange(r render.Rect)

Arrange fits the largest rect of the ratio inside r, centered.

func (*AspectFrame) Baseline

func (c *AspectFrame) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*AspectFrame) Children

func (c *AspectFrame) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*AspectFrame) HitTest

func (c *AspectFrame) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*AspectFrame) Measure

func (a *AspectFrame) Measure(axis Axis, forSize int) Sizes

Measure is the child's request with its natural size grown along one axis to the ratio.

func (*AspectFrame) Paint

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

Paint draws the surface (when configured) then the root.

func (*AspectFrame) Ratio

func (a *AspectFrame) Ratio() float64

Ratio reports the ratio (zero: the child's).

func (*AspectFrame) SetRatio

func (a *AspectFrame) SetRatio(r float64)

SetRatio changes the ratio.

type Avatar

type Avatar struct {
	// contains filtered or unexported fields
}

Avatar is the round portrait: an image cropped to a circle, or the fallback of the name's initials on the muted fill, a person's outline for a name without any. It styles as the `avatar` element: background-color is the fallback's fill and color its initials.

func NewAvatar

func NewAvatar(face render.Font, size int, name string) *Avatar

NewAvatar returns a size-pixel avatar for name.

func (*Avatar) AccessibleName

func (n *Avatar) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Avatar) AddClass

func (n *Avatar) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Avatar) Arrange

func (a *Avatar) Arrange(r render.Rect)

Arrange records the rect.

func (*Avatar) AttachStylesheet

func (n *Avatar) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Avatar) Attr

func (n *Avatar) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Avatar) Bounds

func (n *Avatar) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Avatar) Classes

func (n *Avatar) Classes() []string

Classes returns a copy of the widget's classes.

func (*Avatar) DebugName

func (n *Avatar) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Avatar) DetachStylesheet

func (n *Avatar) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Avatar) Element

func (n *Avatar) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Avatar) Enabled

func (n *Avatar) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Avatar) HAlign

func (n *Avatar) HAlign() Align

HAlign returns the horizontal placement.

func (*Avatar) HasClass

func (n *Avatar) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Avatar) HasState

func (n *Avatar) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Avatar) HitLeaf

func (n *Avatar) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Avatar) HitTest

func (a *Avatar) HitTest(p Point) Widget

HitTest resolves inside the bounds.

func (*Avatar) HoverWithin

func (n *Avatar) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Avatar) ID

func (n *Avatar) ID() string

ID returns the style id, empty when none is set.

func (*Avatar) Initials

func (a *Avatar) Initials() string

Initials are the name's first letters, at most two: the first and the last word's, uppercased.

func (*Avatar) InlineStyle

func (n *Avatar) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Avatar) Invalidate

func (n *Avatar) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Avatar) InvalidateLayout

func (n *Avatar) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Avatar) InvalidateRect

func (n *Avatar) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Avatar) LayoutMotion

func (n *Avatar) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Avatar) Margin

func (n *Avatar) Margin() render.Insets

Margin returns the programmatic margin.

func (*Avatar) MaximumSize

func (n *Avatar) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Avatar) Measure

func (a *Avatar) Measure(axis Axis, forSize int) Sizes

Measure wants the avatar's square.

func (*Avatar) Paint

func (a *Avatar) Paint(cv *render.Canvas)

Paint draws the cropped image or the fallback disc with initials.

func (*Avatar) Parent

func (n *Avatar) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Avatar) RemoveAttr

func (n *Avatar) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Avatar) RemoveClass

func (n *Avatar) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Avatar) SetAccessibleName

func (n *Avatar) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Avatar) SetAttr

func (n *Avatar) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Avatar) SetClass

func (n *Avatar) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Avatar) SetClasses

func (n *Avatar) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Avatar) SetCursorName

func (n *Avatar) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Avatar) SetDebugName

func (n *Avatar) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Avatar) SetElement

func (n *Avatar) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Avatar) SetEnabled

func (n *Avatar) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Avatar) SetFocusOnClick

func (n *Avatar) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Avatar) SetHAlign

func (n *Avatar) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Avatar) SetHExpand

func (n *Avatar) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Avatar) SetID

func (n *Avatar) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Avatar) SetImage

func (a *Avatar) SetImage(img image.Image)

SetImage shows img instead of the initials; nil returns to them. The image is handed over read-only, as to NewImage.

func (*Avatar) SetInlineStyle

func (n *Avatar) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Avatar) SetInlineStylePriority

func (n *Avatar) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Avatar) SetLayoutMotion

func (n *Avatar) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Avatar) SetMargin

func (n *Avatar) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Avatar) SetMaximumSize

func (n *Avatar) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Avatar) SetName

func (a *Avatar) SetName(name string)

SetName changes the name and so the initials.

func (*Avatar) SetOnClickWithin

func (n *Avatar) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Avatar) SetOnFocusChanged

func (n *Avatar) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Avatar) SetOnHoverWithin

func (n *Avatar) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Avatar) SetOnPointer

func (n *Avatar) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Avatar) SetOnScroll

func (n *Avatar) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Avatar) SetSharedElement

func (n *Avatar) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Avatar) SetSizeRequest

func (n *Avatar) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Avatar) SetState

func (n *Avatar) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Avatar) SetTooltip

func (n *Avatar) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Avatar) SetTooltipMarkup

func (n *Avatar) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Avatar) SetVAlign

func (n *Avatar) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Avatar) SetVExpand

func (n *Avatar) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Avatar) SetVisible

func (n *Avatar) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Avatar) SharedElement

func (n *Avatar) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Avatar) SizeRequest

func (n *Avatar) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Avatar) TooltipMarkup

func (n *Avatar) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Avatar) TooltipText

func (n *Avatar) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Avatar) VAlign

func (n *Avatar) VAlign() Align

VAlign returns the vertical placement.

func (*Avatar) Visible

func (n *Avatar) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Axis

type Axis uint8

Axis is the main axis a Box lays its children along.

const (
	// Row lays children out left to right.
	Row Axis = iota
	// Column lays children out top to bottom.
	Column
)

type BackdropRegioner added in v0.2.1

type BackdropRegioner interface {
	BackdropRegion() []render.Rect
}

BackdropRegioner is a root that says itself what the compositor blurs behind it. A surface wider than its plate (a panel moving inside a full-output layer) needs one: asking for a backdrop-filter just to mark the plate would run a filter over its own transparent pixels every repaint, when the blur is the compositor's.

type Badge

type Badge struct {
	// contains filtered or unexported fields
}

Badge is a small inline pill label - a status, a count, a tag - with an optional leading icon. It styles as the `badge` element with the variant's class.

func NewBadge

func NewBadge(face render.Font, text string) *Badge

NewBadge returns a default-variant badge reading text.

func (*Badge) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Badge) Baseline

func (c *Badge) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Badge) Children

func (c *Badge) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Badge) HitTest

func (c *Badge) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Badge) Measure

func (c *Badge) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Badge) Paint

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

Paint draws the surface (when configured) then the root.

func (*Badge) SetIcon

func (b *Badge) SetIcon(w Widget)

SetIcon puts w (an icon, typically 12px) before the text; nil removes it.

func (*Badge) SetText

func (b *Badge) SetText(text string)

SetText replaces the badge's text.

func (*Badge) SetVariant

func (b *Badge) SetVariant(v BadgeVariant)

SetVariant switches the badge's look.

func (*Badge) Text

func (b *Badge) Text() string

Text returns the badge's text.

func (*Badge) Variant

func (b *Badge) Variant() BadgeVariant

Variant returns the badge's look.

type BadgeVariant

type BadgeVariant uint8

BadgeVariant picks a badge's look.

const (
	// BadgeDefault is the primary fill.
	BadgeDefault BadgeVariant = iota
	// BadgeSecondary is the quiet fill.
	BadgeSecondary
	// BadgeDestructive is the destructive fill.
	BadgeDestructive
	// BadgeOutline is a hairline on the background.
	BadgeOutline
)

The badge variants.

type Banner struct {

	// OnButton fires when the action button is clicked.
	OnButton func()
	// contains filtered or unexported fields
}

Banner is the strip that slides down to announce a state (adw Banner): a title, an optional action button, revealed and hidden through SetRevealed on a slide.

func NewBanner

func NewBanner(face render.Font, sizePx float64, title, buttonLabel string) *Banner

NewBanner returns a hidden banner; an empty button label shows no button.

func (*Banner) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Banner) Baseline

func (c *Banner) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Banner) Children

func (c *Banner) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Banner) HitTest

func (c *Banner) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Banner) Measure

func (c *Banner) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Banner) Paint

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

Paint draws the surface (when configured) then the root.

func (*Banner) Revealed

func (b *Banner) Revealed() bool

Revealed reports whether the banner is showing.

func (*Banner) SetRevealed

func (b *Banner) SetRevealed(on bool)

SetRevealed slides the banner in or out.

func (*Banner) SetTitle

func (b *Banner) SetTitle(s string)

SetTitle replaces the message.

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

Bar is an edge panel: start, center and end zones along its edge, the center kept centered as a CenterBox keeps it. Along a left or right edge it lays out as a column (the vertical class), its BarButtons drop their labels for their icons, its BarSeparators turn across it and its SegmentIndicators stack. It styles as the bar element with its edge's class (top, bottom, left, right).

func NewBar

func NewBar(edge BarEdge) *Bar

NewBar returns an empty bar along edge.

func (*Bar) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Bar) Baseline

func (c *Bar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Bar) Center

func (b *Bar) Center() *Box

Center is the centered zone.

func (*Bar) Children

func (c *Bar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Bar) Edge

func (b *Bar) Edge() BarEdge

Edge is the edge the bar runs along.

func (*Bar) End

func (b *Bar) End() *Box

End is the zone at the bar's end, right or bottom.

func (*Bar) HitTest

func (c *Bar) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Bar) Measure

func (c *Bar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Bar) Paint

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

Paint draws the surface (when configured) then the root.

func (*Bar) SetEdge

func (b *Bar) SetEdge(edge BarEdge)

SetEdge moves the bar to edge: the zones turn with it, and so do the bar parts inside them on their next layout.

func (*Bar) Start

func (b *Bar) Start() *Box

Start is the zone at the bar's start, left or top.

type BarButton

type BarButton struct {
	Button
	// contains filtered or unexported fields
}

BarButton is a bar's compact button: an icon, an optional label and an optional trailing badge, sized from the theme. In a vertical bar it shows its icon alone. With a popover set, a click opens it away from the bar's edge and the button stays :checked while it is open. Middle and right clicks and the wheel bind through SetOnPointer and SetOnScroll.

func NewBarButton

func NewBarButton(face render.Font, icon Widget, label string) *BarButton

NewBarButton returns a bar button of icon (nil for none) and label (empty for none) in face. Its parts sit border-spacing apart, a theme rule a stylesheet sets either way.

func (*BarButton) AccessibleName

func (n *BarButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*BarButton) AddClass

func (n *BarButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*BarButton) Arrange

func (b *BarButton) Arrange(r render.Rect)

Arrange follows the bar's orientation, then lays the button out.

func (*BarButton) AttachStylesheet

func (n *BarButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*BarButton) Attr

func (n *BarButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*BarButton) Bounds

func (n *BarButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*BarButton) Classes

func (n *BarButton) Classes() []string

Classes returns a copy of the widget's classes.

func (*BarButton) DebugName

func (n *BarButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*BarButton) DetachStylesheet

func (n *BarButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*BarButton) Element

func (n *BarButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*BarButton) Enabled

func (n *BarButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*BarButton) HAlign

func (n *BarButton) HAlign() Align

HAlign returns the horizontal placement.

func (*BarButton) HasClass

func (n *BarButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*BarButton) HasState

func (n *BarButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*BarButton) HitLeaf

func (n *BarButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*BarButton) HoverWithin

func (n *BarButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*BarButton) ID

func (n *BarButton) ID() string

ID returns the style id, empty when none is set.

func (*BarButton) InlineStyle

func (n *BarButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*BarButton) Invalidate

func (n *BarButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*BarButton) InvalidateLayout

func (n *BarButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*BarButton) InvalidateRect

func (n *BarButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*BarButton) Label

func (b *BarButton) Label() *Label

Label is the button's label, for its text, classes and limits.

func (*BarButton) LayoutMotion

func (n *BarButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*BarButton) Margin

func (n *BarButton) Margin() render.Insets

Margin returns the programmatic margin.

func (*BarButton) MaximumSize

func (n *BarButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*BarButton) Parent

func (n *BarButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*BarButton) RemoveAttr

func (n *BarButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*BarButton) RemoveClass

func (n *BarButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*BarButton) SetAccessibleName

func (n *BarButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*BarButton) SetAttr

func (n *BarButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*BarButton) SetBadge

func (b *BarButton) SetBadge(text string)

SetBadge shows text in a badge after the label; empty removes it.

func (*BarButton) SetClass

func (n *BarButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*BarButton) SetClasses

func (n *BarButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*BarButton) SetCursorName

func (n *BarButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*BarButton) SetDebugName

func (n *BarButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*BarButton) SetElement

func (n *BarButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*BarButton) SetEnabled

func (n *BarButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*BarButton) SetFocusOnClick

func (n *BarButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*BarButton) SetHAlign

func (n *BarButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*BarButton) SetHExpand

func (n *BarButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*BarButton) SetID

func (n *BarButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*BarButton) SetIcon

func (b *BarButton) SetIcon(w Widget)

SetIcon replaces the icon; nil removes it.

func (*BarButton) SetIconPosition

func (b *BarButton) SetIconPosition(p IconPosition)

SetIconPosition puts the icon before the label (IconStart, the default) or after it.

func (*BarButton) SetInlineStyle

func (n *BarButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*BarButton) SetInlineStylePriority

func (n *BarButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*BarButton) SetLabel

func (b *BarButton) SetLabel(s string)

SetLabel replaces the label text; empty hides it.

func (*BarButton) SetLayoutMotion

func (n *BarButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*BarButton) SetMargin

func (n *BarButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*BarButton) SetMaximumSize

func (n *BarButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*BarButton) SetOnClickWithin

func (n *BarButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*BarButton) SetOnFocusChanged

func (n *BarButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*BarButton) SetOnHoverWithin

func (n *BarButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*BarButton) SetOnPointer

func (n *BarButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*BarButton) SetOnScroll

func (n *BarButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*BarButton) SetPopover

func (b *BarButton) SetPopover(build func() Widget)

SetPopover makes a click open build's widget in a popover away from the bar's edge, and a click while it is open close it; nil leaves the button to its OnClick.

func (*BarButton) SetSharedElement

func (n *BarButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*BarButton) SetSizeRequest

func (n *BarButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*BarButton) SetState

func (n *BarButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*BarButton) SetTooltip

func (n *BarButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*BarButton) SetTooltipMarkup

func (n *BarButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*BarButton) SetVAlign

func (n *BarButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*BarButton) SetVExpand

func (n *BarButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*BarButton) SetVisible

func (n *BarButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*BarButton) SharedElement

func (n *BarButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*BarButton) SizeRequest

func (n *BarButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*BarButton) TooltipMarkup

func (n *BarButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*BarButton) TooltipText

func (n *BarButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*BarButton) VAlign

func (n *BarButton) VAlign() Align

VAlign returns the vertical placement.

func (*BarButton) Visible

func (n *BarButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type BarEdge

type BarEdge uint8

BarEdge is the screen edge a Bar runs along.

const (
	BarTop BarEdge = iota
	BarBottom
	BarLeft
	BarRight
)

The bar edges.

func (BarEdge) PopoverSide

func (e BarEdge) PopoverSide() PopoverSide

PopoverSide is the side a popover opens on from a bar on this edge: away from the edge, into the screen.

func (BarEdge) Vertical

func (e BarEdge) Vertical() bool

Vertical reports a bar along the left or right edge, which lays out as a column.

type BarSeparator

type BarSeparator struct {
	Separator
}

BarSeparator is a short rule across a bar between its items, inset from both of the bar's edges by the theme's padding. The stylesheet styles it: its color is the rule's, min-width the thickness of a rule across a horizontal bar and min-height its length (filling the bar when unset), swapped across a vertical bar.

func NewBarSeparator

func NewBarSeparator() *BarSeparator

NewBarSeparator returns a bar separator.

func (*BarSeparator) AccessibleName

func (n *BarSeparator) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*BarSeparator) AddClass

func (n *BarSeparator) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*BarSeparator) Arrange

func (n *BarSeparator) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*BarSeparator) AttachStylesheet

func (n *BarSeparator) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*BarSeparator) Attr

func (n *BarSeparator) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*BarSeparator) Bounds

func (n *BarSeparator) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*BarSeparator) Classes

func (n *BarSeparator) Classes() []string

Classes returns a copy of the widget's classes.

func (*BarSeparator) DebugName

func (n *BarSeparator) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*BarSeparator) DetachStylesheet

func (n *BarSeparator) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*BarSeparator) Element

func (n *BarSeparator) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*BarSeparator) Enabled

func (n *BarSeparator) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*BarSeparator) HAlign

func (n *BarSeparator) HAlign() Align

HAlign returns the horizontal placement.

func (*BarSeparator) HasClass

func (n *BarSeparator) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*BarSeparator) HasState

func (n *BarSeparator) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*BarSeparator) HitLeaf

func (n *BarSeparator) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*BarSeparator) HoverWithin

func (n *BarSeparator) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*BarSeparator) ID

func (n *BarSeparator) ID() string

ID returns the style id, empty when none is set.

func (*BarSeparator) InlineStyle

func (n *BarSeparator) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*BarSeparator) Invalidate

func (n *BarSeparator) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*BarSeparator) InvalidateLayout

func (n *BarSeparator) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*BarSeparator) InvalidateRect

func (n *BarSeparator) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*BarSeparator) LayoutMotion

func (n *BarSeparator) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*BarSeparator) Margin

func (n *BarSeparator) Margin() render.Insets

Margin returns the programmatic margin.

func (*BarSeparator) MaximumSize

func (n *BarSeparator) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*BarSeparator) Measure

func (s *BarSeparator) Measure(axis Axis, forSize int) Sizes

Measure turns the rule across the bar, then wants its thickness by its length.

func (*BarSeparator) Paint

func (s *BarSeparator) Paint(cv *render.Canvas)

Paint draws the rule in its color, centered across its slot and, at a set length, along it.

func (*BarSeparator) Parent

func (n *BarSeparator) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*BarSeparator) RemoveAttr

func (n *BarSeparator) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*BarSeparator) RemoveClass

func (n *BarSeparator) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*BarSeparator) SetAccessibleName

func (n *BarSeparator) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*BarSeparator) SetAttr

func (n *BarSeparator) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*BarSeparator) SetClass

func (n *BarSeparator) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*BarSeparator) SetClasses

func (n *BarSeparator) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*BarSeparator) SetCursorName

func (n *BarSeparator) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*BarSeparator) SetDebugName

func (n *BarSeparator) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*BarSeparator) SetElement

func (n *BarSeparator) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*BarSeparator) SetEnabled

func (n *BarSeparator) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*BarSeparator) SetFocusOnClick

func (n *BarSeparator) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*BarSeparator) SetHAlign

func (n *BarSeparator) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*BarSeparator) SetHExpand

func (n *BarSeparator) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*BarSeparator) SetID

func (n *BarSeparator) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*BarSeparator) SetInlineStyle

func (n *BarSeparator) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*BarSeparator) SetInlineStylePriority

func (n *BarSeparator) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*BarSeparator) SetLayoutMotion

func (n *BarSeparator) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*BarSeparator) SetMargin

func (n *BarSeparator) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*BarSeparator) SetMaximumSize

func (n *BarSeparator) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*BarSeparator) SetOnClickWithin

func (n *BarSeparator) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*BarSeparator) SetOnFocusChanged

func (n *BarSeparator) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*BarSeparator) SetOnHoverWithin

func (n *BarSeparator) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*BarSeparator) SetOnPointer

func (n *BarSeparator) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*BarSeparator) SetOnScroll

func (n *BarSeparator) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*BarSeparator) SetSharedElement

func (n *BarSeparator) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*BarSeparator) SetSizeRequest

func (n *BarSeparator) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*BarSeparator) SetState

func (n *BarSeparator) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*BarSeparator) SetTooltip

func (n *BarSeparator) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*BarSeparator) SetTooltipMarkup

func (n *BarSeparator) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*BarSeparator) SetVAlign

func (n *BarSeparator) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*BarSeparator) SetVExpand

func (n *BarSeparator) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*BarSeparator) SetVisible

func (n *BarSeparator) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*BarSeparator) SharedElement

func (n *BarSeparator) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*BarSeparator) SizeRequest

func (n *BarSeparator) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*BarSeparator) TooltipMarkup

func (n *BarSeparator) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*BarSeparator) TooltipText

func (n *BarSeparator) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*BarSeparator) VAlign

func (n *BarSeparator) VAlign() Align

VAlign returns the vertical placement.

func (*BarSeparator) Visible

func (n *BarSeparator) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base is the embeddable shared state for widgets defined outside the kit: it carries the arranged bounds, parent link, invalidation flags, and measure cache the frame loop leans on, exactly what internal widgets get from node. Embed it, implement the Widget interface, and route leaf hit tests through HitLeaf.

func NewBase

func NewBase() Base

NewBase returns a zero Base for embedding:

type ruler struct {
    widget.Base
    ...
}

func (*Base) AccessibleName

func (n *Base) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Base) AddClass

func (n *Base) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Base) Arrange

func (n *Base) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Base) ArrangeSelf

func (b *Base) ArrangeSelf(r render.Rect)

ArrangeSelf records the widget's own rect. A container defined outside the kit shadows the promoted node.Arrange with its child recursion; call this first so the shadowed bookkeeping still runs.

func (*Base) AttachStylesheet

func (n *Base) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Base) Attr

func (n *Base) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Base) Bounds

func (n *Base) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Base) Classes

func (n *Base) Classes() []string

Classes returns a copy of the widget's classes.

func (*Base) DebugName

func (n *Base) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Base) DetachStylesheet

func (n *Base) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Base) Element

func (n *Base) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Base) Enabled

func (n *Base) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Base) HAlign

func (n *Base) HAlign() Align

HAlign returns the horizontal placement.

func (*Base) HasClass

func (n *Base) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Base) HasState

func (n *Base) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Base) HitLeaf

func (n *Base) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Base) HoverWithin

func (n *Base) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Base) ID

func (n *Base) ID() string

ID returns the style id, empty when none is set.

func (*Base) InlineStyle

func (n *Base) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Base) Invalidate

func (n *Base) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Base) InvalidateLayout

func (n *Base) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Base) InvalidateRect

func (n *Base) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Base) LayoutMotion

func (n *Base) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Base) Margin

func (n *Base) Margin() render.Insets

Margin returns the programmatic margin.

func (*Base) MaximumSize

func (n *Base) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Base) Parent

func (n *Base) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Base) RemoveAttr

func (n *Base) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Base) RemoveClass

func (n *Base) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Base) SetAccessibleName

func (n *Base) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Base) SetAttr

func (n *Base) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Base) SetClass

func (n *Base) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Base) SetClasses

func (n *Base) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Base) SetCursorName

func (n *Base) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Base) SetDebugName

func (n *Base) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Base) SetElement

func (n *Base) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Base) SetEnabled

func (n *Base) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Base) SetFocusOnClick

func (n *Base) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Base) SetHAlign

func (n *Base) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Base) SetHExpand

func (n *Base) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Base) SetID

func (n *Base) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Base) SetInlineStyle

func (n *Base) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Base) SetInlineStylePriority

func (n *Base) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Base) SetLayoutMotion

func (n *Base) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Base) SetMargin

func (n *Base) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Base) SetMaximumSize

func (n *Base) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Base) SetOnClickWithin

func (n *Base) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Base) SetOnFocusChanged

func (n *Base) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Base) SetOnHoverWithin

func (n *Base) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Base) SetOnPointer

func (n *Base) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Base) SetOnScroll

func (n *Base) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Base) SetSharedElement

func (n *Base) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Base) SetSizeRequest

func (n *Base) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Base) SetState

func (n *Base) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Base) SetTooltip

func (n *Base) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Base) SetTooltipMarkup

func (n *Base) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Base) SetVAlign

func (n *Base) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Base) SetVExpand

func (n *Base) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Base) SetVisible

func (n *Base) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Base) SharedElement

func (n *Base) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Base) SizeRequest

func (n *Base) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Base) TooltipMarkup

func (n *Base) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Base) TooltipText

func (n *Base) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Base) VAlign

func (n *Base) VAlign() Align

VAlign returns the vertical placement.

func (*Base) Visible

func (n *Base) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Baseliner

type Baseliner interface {
	Baseline() (int, bool)
}

Baseliner reports a widget's first text baseline (GTK's baseline): the distance from the top of the rect its parent arranges it in, at its natural height, down to the baseline its first line of text sits on. ok is false for a widget without text. A row Box lines up the children it holds with AlignBaseline on it, so labels, entries, and buttons of different sizes read as one line.

type Binding

type Binding[T any] struct {
	// contains filtered or unexported fields
}

Binding is a loop-owned observable model value, lys-ui's counterpart of relm4's binding module: one T that any number of widgets observe. Set applies the value and notifies the subscribers synchronously, which is what a widget connector needs - the new value is on screen by the time Set returns. Two rules keep two-way wiring echo-free by construction: an equal value is a no-op (nothing notifies), and a Set from inside a notification is deferred until that notification finishes, so a subscriber writing back cannot recurse.

Like every widget mutation, Get/Set/Subscribe belong on the loop goroutine (docs/threading.md); they are sampled by the off-loop hook.

func NewBinding

func NewBinding[T any](initial T) *Binding[T]

NewBinding creates a Binding holding initial.

func (*Binding[T]) Get

func (b *Binding[T]) Get() T

Get returns the current value.

func (*Binding[T]) Set

func (b *Binding[T]) Set(v T)

Set applies v and notifies the subscribers - unless v equals the current value, which is a no-op, or a notification is running, in which case v replaces the deferred write and is applied (and notified) when the running notification completes.

func (*Binding[T]) Subscribe

func (b *Binding[T]) Subscribe(fn func(T)) (cancel func())

Subscribe registers fn for every change. The returned cancel removes it (idempotent, loop-side like the rest of the Binding API).

type Boundser

type Boundser interface {
	Bounds() render.Rect
}

Boundser exposes a widget's arranged rect; the app draws the focus ring around whatever widget.Boundser the router focuses.

type Box

type Box struct {
	// contains filtered or unexported fields
}

Box is a container that lays its children along one axis with fixed spacing and padding. The cross axis stretches children to the inner height (Row) or width (Column) of the box, unless a child was added with AppendAligned.

Every child gets its minimum; the room up to the naturals goes to the children furthest below theirs last, and what is left past every natural is shared equally among the expanding children (GTK's box allocation). Short of the minimums the children overflow the box and the painter's clip decides what is visible.

A row's start/end semantics mirror with the box's direction: an RTL row flows from the right edge, so the first child sits rightmost, where an RTL reader starts. Columns are unaffected.

A stylesheet display declaration lays the children out by CSS instead — normal flow or flexbox (docs/css.md's Layout) — with the settings above standing in wherever the stylesheet is silent.

func NewBox

func NewBox(axis Axis, spacing, padding int) *Box

NewBox returns an empty box along axis with the given spacing between children and padding on every side.

func NewBulletList

func NewBulletList(face render.Font, sizePx float64, items ...string) *Box

NewBulletList is a typography list: each item a wrapped label behind a bullet, indented.

func NewFieldGroup

func NewFieldGroup() *Box

NewFieldGroup returns the column fields stack in, styled as the `fieldgroup` element.

func NewKbdGroup

func NewKbdGroup(face render.Font, keys ...string) *Box

NewKbdGroup draws a key combination as keycaps side by side: NewKbdGroup(face, "Ctrl", "Shift", "P").

func NewShortcutLabel

func NewShortcutLabel(face render.Font, keys string) *Box

NewShortcutLabel draws keys as keycaps (adw ShortcutLabel): each key of an accelerator its own .keycap label, the steps of a chord set apart.

func NewSkeleton

func NewSkeleton(width, height int) *Box

NewSkeleton is a width x height placeholder block that pulses while content loads: the `skeleton` element, a muted rounded fill whose pulse stops under reduced motion.

func NewTooltipCard

func NewTooltipCard(face render.Font, text string, markup bool) *Box

NewTooltipCard is a tooltip's card: the text, parsed as markup when markup is set, in the small size on the primary fill. It styles as the `tooltip` element.

func (*Box) AccessibleName

func (n *Box) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Box) AddClass

func (n *Box) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Box) Append

func (b *Box) Append(w Widget, expand bool) *Box

Append adds a widget to the box and reports whether it should expand into leftover main-axis space. It returns the box for chaining. The box's measure cache drops so the next frame sees the new child.

func (*Box) AppendAligned

func (b *Box) AppendAligned(w Widget, expand bool, cross Align) *Box

AppendAligned adds a child placed across the box by cross, GTK's valign in a row and halign in a column: AlignFill stretches it (Append), the others keep its natural cross size pinned to the start, center or end.

func (*Box) Arrange

func (b *Box) Arrange(r render.Rect)

Arrange positions the children inside the content box — by the CSS layout its display declares, or the programmatic box layout — and orders them for paint and hit testing by their stacking keys. r is the margin box; Bounds records the border box.

func (*Box) ArrangeRoot

func (b *Box) ArrangeRoot(r render.Rect)

ArrangeRoot records the box's own rect.

func (*Box) AttachStylesheet

func (n *Box) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Box) Attr

func (n *Box) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Box) Axis

func (b *Box) Axis() Axis

Axis returns the axis the children lie along.

func (*Box) Baseline

func (b *Box) Baseline() (int, bool)

Baseline implements Baseliner. A row's is its baseline group's, centered across the row as Arrange places it, else its first child with a baseline where its alignment puts it; a column's is its first child's. The children sit at their shares of the box's arranged width, or of its natural width before it is arranged.

func (*Box) Bounds

func (n *Box) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Box) Children

func (b *Box) Children() []Widget

Children exposes the box's children in append order for focus traversal.

func (*Box) Classes

func (n *Box) Classes() []string

Classes returns a copy of the widget's classes.

func (*Box) Clear

func (b *Box) Clear()

Clear detaches every child at once — the wholesale rebuild path. Each child's parent link clears and the removal hook fires per child; clearing an empty box does nothing.

func (*Box) DebugName

func (n *Box) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Box) DetachStylesheet

func (n *Box) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Box) Direction

func (b *Box) Direction() Direction

Direction returns the base direction the main axis flows along.

func (*Box) Element

func (n *Box) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Box) Enabled

func (n *Box) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Box) HAlign

func (n *Box) HAlign() Align

HAlign returns the horizontal placement.

func (*Box) HasClass

func (n *Box) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Box) HasState

func (n *Box) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Box) HitLeaf

func (n *Box) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Box) HitTest

func (b *Box) HitTest(p Point) Widget

HitTest returns the deepest child under p, topmost in stacking order first and only inside the overflow clip, or the box itself when p is inside its bounds but over no child (padding, spacing, leftover space) — never a display:contents box, which has no area of its own.

func (*Box) Homogeneous

func (b *Box) Homogeneous() bool

Homogeneous reports whether the children share the largest child's main-axis size.

func (*Box) HoverWithin

func (n *Box) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Box) ID

func (n *Box) ID() string

ID returns the style id, empty when none is set.

func (*Box) InlineStyle

func (n *Box) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Box) InsertAligned

func (b *Box) InsertAligned(i int, w Widget, expand bool, cross Align)

InsertAligned is InsertAt with AppendAligned's cross placement.

func (*Box) InsertAt

func (b *Box) InsertAt(i int, w Widget, expand bool)

InsertAt puts w at index i with Append's expand meaning, so dynamic UIs can reorder without a rebuild. Out-of-range indexes clamp to the ends; the measure cache drops like every other mutation.

func (*Box) Invalidate

func (n *Box) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Box) InvalidateLayout

func (n *Box) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Box) InvalidateRect

func (n *Box) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Box) LayoutMotion

func (n *Box) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Box) Margin

func (n *Box) Margin() render.Insets

Margin returns the programmatic margin.

func (*Box) MaximumSize

func (n *Box) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Box) Measure

func (b *Box) Measure(axis Axis, forSize int) Sizes

Measure reports the box's request inside its CSS box (padding, border, margin, min sizes): along its axis the children's requests end to end with the spacing between, every child the largest one's when homogeneous; across, the largest child's at the share of the main extent each would get, which Arrange hands out the same way. The result is cached until an InvalidateLayout anywhere in the subtree, so a static tree costs no recursion on later frames.

func (*Box) Move

func (b *Box) Move(from, to int)

Move moves the child at index from to index to (both clamped), in place: the child stays attached, so its focus and state survive.

func (*Box) Padding

func (b *Box) Padding() render.Insets

Padding returns the programmatic padding.

func (*Box) Paint

func (b *Box) Paint(cv *render.Canvas)

Paint draws the box's CSS layers when the stylesheet gives it any (a bare box paints nothing — theme-only boxes are transparent), then the children in stacking order, then the outline; opacity and filter wrap it all. A transform declaration paints the whole subtree into an offscreen layer and composites it back through the affine, so the transform applies to the children as one.

func (*Box) Parent

func (n *Box) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Box) Remove

func (b *Box) Remove(w Widget) bool

Remove detaches w, found by identity, and reports whether it was a child. The removed widget's parent link clears, so it can be appended elsewhere without a double parent; removing a widget that is not (or no longer) a child reports false and changes nothing. The measure cache drops so the next frame reflows without it.

func (*Box) RemoveAt

func (b *Box) RemoveAt(i int)

RemoveAt detaches the child at index i; an out-of-range index is a no-op.

func (*Box) RemoveAttr

func (n *Box) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Box) RemoveClass

func (n *Box) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Box) SetAccessibleName

func (n *Box) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Box) SetAttr

func (n *Box) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Box) SetAxis

func (b *Box) SetAxis(a Axis)

SetAxis lays the children along a instead (GTK's orientable): a field turning horizontal when it gets wide.

func (*Box) SetClass

func (n *Box) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Box) SetClasses

func (n *Box) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Box) SetCursorName

func (n *Box) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Box) SetDebugName

func (n *Box) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Box) SetDirection

func (b *Box) SetDirection(d Direction)

SetDirection selects the base direction the box's main axis flows along: an RTL row lays its children out right to left, mirroring start/end placement. Columns ignore it. Changing the direction re-arranges.

func (*Box) SetElement

func (n *Box) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Box) SetEnabled

func (b *Box) SetEnabled(enabled bool)

SetEnabled turns the box's subtree on or off: the per-query enable walk (IsEnabled) folds the box's flag into every descendant, whose own flag stays untouched — re-enabling the box never resurrects a child the app disabled on purpose. The walk marks the whole subtree for repaint, since each descendant's effective state changed.

func (*Box) SetFocusOnClick

func (n *Box) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Box) SetHAlign

func (n *Box) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Box) SetHExpand

func (n *Box) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Box) SetHomogeneous

func (b *Box) SetHomogeneous(on bool)

SetHomogeneous equalizes the children's main-axis sizes to the largest child's (gtk_box_set_homogeneous). Changing it relayouts.

func (*Box) SetID

func (n *Box) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Box) SetInlineStyle

func (n *Box) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Box) SetInlineStylePriority

func (n *Box) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Box) SetLayoutMotion

func (n *Box) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Box) SetMargin

func (n *Box) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Box) SetMaximumSize

func (n *Box) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Box) SetOnClickWithin

func (n *Box) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Box) SetOnFocusChanged

func (n *Box) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Box) SetOnHoverWithin

func (n *Box) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Box) SetOnPointer

func (n *Box) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Box) SetOnScroll

func (n *Box) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Box) SetPadding

func (b *Box) SetPadding(p render.Insets)

SetPadding sets the box's programmatic padding per side; the stylesheet's padding still wins where it sets a side. The box relayouts.

func (*Box) SetSharedElement

func (n *Box) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Box) SetSizeRequest

func (n *Box) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Box) SetSpacing

func (b *Box) SetSpacing(spacing int)

SetSpacing sets the programmatic gap between children.

func (*Box) SetState

func (n *Box) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Box) SetTooltip

func (n *Box) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Box) SetTooltipMarkup

func (n *Box) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Box) SetVAlign

func (n *Box) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Box) SetVExpand

func (n *Box) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Box) SetVisible

func (n *Box) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Box) SharedElement

func (n *Box) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Box) SizeRequest

func (n *Box) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Box) Spacing

func (b *Box) Spacing() int

Spacing returns the programmatic gap between children.

func (*Box) TooltipMarkup

func (n *Box) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Box) TooltipText

func (n *Box) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Box) VAlign

func (n *Box) VAlign() Align

VAlign returns the vertical placement.

func (*Box) Visible

func (n *Box) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Breadcrumb struct {

	// OnNavigate fires with the index into the path of the ancestor the
	// user activated.
	OnNavigate func(i int)
	// contains filtered or unexported fields
}

Breadcrumb is the path to the current page: a link per ancestor, chevrons between, and the current page last, not a link. A path longer than SetMaxItems collapses its middle into an ellipsis that opens the hidden ancestors as a menu. It styles as the `breadcrumb` element: each link a button.crumb, the current page a .page label, the separators .separator and the ellipsis button.ellipsis.

func NewBreadcrumb

func NewBreadcrumb(face render.Font, path ...string) *Breadcrumb

NewBreadcrumb returns a breadcrumb over path, the root first and the current page last.

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (c *Breadcrumb) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (c *Breadcrumb) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (c *Breadcrumb) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (c *Breadcrumb) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

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

Paint draws the surface (when configured) then the root.

func (b *Breadcrumb) Path() []string

Path returns the path.

func (b *Breadcrumb) SetMaxItems(n int)

SetMaxItems collapses a path of more than n items: the first, an ellipsis for the middle, and the last n-2. Below 3, or 0, the whole path shows.

func (b *Breadcrumb) SetPath(path ...string)

SetPath replaces the path.

type Breakpoint

type Breakpoint struct {
	Max int
	Min int
	// Apply runs when the breakpoint starts holding; Unapply, when it
	// stops. Batches of setters are just closures.
	Apply   func()
	Unapply func()
}

Breakpoint applies while the allocated width is at or below Max (or at or above Min, when Max is zero) - the adw 1.4 condition model narrowed to the width axis the adaptive shell needs.

type BreakpointBin

type BreakpointBin struct {
	// contains filtered or unexported fields
}

BreakpointBin wraps one widget and runs its breakpoints' apply batches as the allocated width crosses them - the seam an adaptive shell swaps layouts through. Conditions evaluate at the top of Arrange, before the child is laid out, so a batch's changes land in the same pass; a batch that changes what the child wants calls InvalidateLayout and the engine re-measures on demand.

func NewBreakpointBin

func NewBreakpointBin(child Widget) *BreakpointBin

NewBreakpointBin returns a bin over child with no breakpoints.

func (*BreakpointBin) Add

func (b *BreakpointBin) Add(bp Breakpoint)

Add appends a breakpoint; apply order is add order.

func (*BreakpointBin) Arrange

func (b *BreakpointBin) Arrange(r render.Rect)

Arrange evaluates every breakpoint against the allocated width, then lays the child out.

func (*BreakpointBin) Baseline

func (c *BreakpointBin) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*BreakpointBin) Children

func (c *BreakpointBin) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*BreakpointBin) HitTest

func (c *BreakpointBin) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*BreakpointBin) Measure

func (c *BreakpointBin) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*BreakpointBin) Paint

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

Paint draws the surface (when configured) then the root.

func (*BreakpointBin) Width

func (b *BreakpointBin) Width() int

Width reports the last allocated width (the condition input).

type Button

type Button struct {

	// Background colors, one per visual state. A zero color means
	// "unset": the stylesheet's background-color, else the theme
	// surface for that state.
	Bg        render.Color
	BgHover   render.Color
	BgPressed render.Color

	// BgExplicit makes Bg, BgHover, and BgPressed literal: a zero color
	// is transparent instead of unset, so a button can rest on
	// whatever sits behind it and fill only on hover. Like any
	// programmatic color it outranks the stylesheet. A transparent
	// fill under a stylesheet border strokes just the rounded ring
	// (render.Canvas.RoundedBorder).
	BgExplicit bool

	// Hovered and Pressed select the painted state; Pressed wins.
	Hovered, Pressed bool

	// OnClick fires from Click, the hook M4 input will call.
	OnClick func()
	// contains filtered or unexported fields
}

Button is a clickable region with a rounded background and one child, usually a Box of an icon and a label. Input arrives in M4; the hover and pressed states are plain fields so tests and future input code drive them directly.

func NewButton

func NewButton(child Widget, padding, radius int) *Button

NewButton returns a button wrapping child with the given inner padding and corner radius. The pointer turns to the hand over it: every button is clickable, the way wayle's button primitives ask.

func (*Button) AccessibleName

func (n *Button) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Button) AddClass

func (n *Button) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Button) Arrange

func (b *Button) Arrange(r render.Rect)

Arrange insets the child by the box inside r, the margin box; Bounds records the border box.

func (*Button) ArrangeRoot

func (b *Button) ArrangeRoot(r render.Rect)

ArrangeRoot records the button's own rect.

func (*Button) AttachStylesheet

func (n *Button) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Button) Attr

func (n *Button) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Button) Baseline

func (b *Button) Baseline() (int, bool)

Baseline implements Baseliner: the child's, inside the button's box.

func (*Button) BindAction

func (b *Button) BindAction(a Activatable) (unbind func())

BindAction makes the button a proxy of a: a click activates it, and the button is enabled exactly while the action is. The returned unbind detaches it.

func (*Button) Bounds

func (n *Button) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Button) Children

func (b *Button) Children() []Widget

Children returns the button's content.

func (*Button) Classes

func (n *Button) Classes() []string

Classes returns a copy of the widget's classes.

func (*Button) ClickAt

func (b *Button) ClickAt(p Point)

ClickAt fires the OnClick hook, ignoring the release point. It is a no-op without one, and a no-op while disabled: a dead button never fires.

func (*Button) DebugName

func (n *Button) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Button) DetachStylesheet

func (n *Button) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Button) Element

func (n *Button) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Button) Enabled

func (n *Button) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Button) HAlign

func (n *Button) HAlign() Align

HAlign returns the horizontal placement.

func (*Button) HasClass

func (n *Button) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Button) HasState

func (n *Button) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Button) HitLeaf

func (n *Button) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Button) HitTest

func (b *Button) HitTest(p Point) Widget

HitTest returns the button when p is inside its bounds.

func (*Button) HoverWithin

func (n *Button) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Button) ID

func (n *Button) ID() string

ID returns the style id, empty when none is set.

func (*Button) InlineStyle

func (n *Button) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Button) InsertRune

func (b *Button) InsertRune(r rune)

InsertRune implements RuneHandler: Space activates the button, the other half of the GTK activation pair. Text never reaches a focused button, so a blank rune can only mean "activate".

func (*Button) Invalidate

func (n *Button) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Button) InvalidateLayout

func (n *Button) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Button) InvalidateRect

func (n *Button) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Button) KeyAction

func (b *Button) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: Enter activates the button when focused, which is what makes it reachable by Tab at all - the traversal only collects KeyActionHandler implementations.

func (*Button) LayoutMotion

func (n *Button) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Button) Margin

func (n *Button) Margin() render.Insets

Margin returns the programmatic margin.

func (*Button) MaximumSize

func (n *Button) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Button) Measure

func (b *Button) Measure(axis Axis, forSize int) Sizes

Measure pads the child's natural size inside the CSS box: the constructor padding (or the stylesheet's, per side), border, margin, and min sizes.

func (*Button) Paint

func (b *Button) Paint(cv *render.Canvas)

Paint draws the state's background, then the child. A zero Bg family falls back to the theme. Disabled, the fill is the derived disabled surface and the child paints through the shared disabled fade, so whatever a button wraps (label, icon) mutes without the child knowing about the state.

The stylesheet layers between the programmatic colors and the theme per state slot; its shadows, background image, border ring (rounded, per side), and outline paint around the fill, and opacity and filter wrap the whole button.

func (*Button) Parent

func (n *Button) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Button) RemoveAttr

func (n *Button) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Button) RemoveClass

func (n *Button) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Button) Role

func (b *Button) Role() Role

Role implements Roleer.

func (*Button) SetAccessibleName

func (n *Button) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Button) SetAttr

func (n *Button) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Button) SetClass

func (n *Button) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Button) SetClasses

func (n *Button) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Button) SetCursorName

func (n *Button) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Button) SetDebugName

func (n *Button) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Button) SetElement

func (n *Button) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Button) SetEnabled

func (n *Button) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Button) SetFocusOnClick

func (n *Button) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Button) SetHAlign

func (n *Button) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Button) SetHExpand

func (n *Button) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Button) SetHovered

func (b *Button) SetHovered(on bool)

SetHovered implements HoverSetter; the hover shade repaints.

func (*Button) SetID

func (n *Button) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Button) SetInlineStyle

func (n *Button) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Button) SetInlineStylePriority

func (n *Button) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Button) SetLayoutMotion

func (n *Button) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Button) SetMargin

func (n *Button) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Button) SetMaximumSize

func (n *Button) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Button) SetOnClickWithin

func (n *Button) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Button) SetOnFocusChanged

func (n *Button) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Button) SetOnHoverWithin

func (n *Button) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Button) SetOnPointer

func (n *Button) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Button) SetOnScroll

func (n *Button) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Button) SetPressed

func (b *Button) SetPressed(on bool)

SetPressed implements PressSetter; the pressed shade repaints.

func (*Button) SetSharedElement

func (n *Button) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Button) SetSizeRequest

func (n *Button) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Button) SetState

func (n *Button) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Button) SetTooltip

func (n *Button) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Button) SetTooltipMarkup

func (n *Button) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Button) SetVAlign

func (n *Button) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Button) SetVExpand

func (n *Button) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Button) SetVisible

func (n *Button) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Button) SharedElement

func (n *Button) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Button) SizeRequest

func (n *Button) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Button) TooltipMarkup

func (n *Button) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Button) TooltipText

func (n *Button) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Button) VAlign

func (n *Button) VAlign() Align

VAlign returns the vertical placement.

func (*Button) Visible

func (n *Button) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ButtonContent

type ButtonContent struct {
	// contains filtered or unexported fields
}

ButtonContent is the icon-and-label pair buttons wear (adw ButtonContent): either half may be empty.

func NewButtonContent

func NewButtonContent(face render.Font, sizePx float64, iconName, label string) *ButtonContent

NewButtonContent returns the pair; an empty icon name or label drops that half.

func (*ButtonContent) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ButtonContent) Baseline

func (c *ButtonContent) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ButtonContent) Children

func (c *ButtonContent) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ButtonContent) HitTest

func (c *ButtonContent) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ButtonContent) Measure

func (c *ButtonContent) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ButtonContent) Paint

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

Paint draws the surface (when configured) then the root.

func (*ButtonContent) SetIconName

func (c *ButtonContent) SetIconName(name string)

SetIconName replaces the icon; empty drops it.

func (*ButtonContent) SetLabel

func (c *ButtonContent) SetLabel(s string)

SetLabel replaces the label text.

type ButtonGroup

type ButtonGroup struct {
	// contains filtered or unexported fields
}

ButtonGroup joins buttons into one control: side by side or stacked, only the outer corners rounded and the inner borders shared, with SetSeparator lines between and groups nesting in groups. It styles as the `buttongroup` element, .vertical when stacked.

func NewButtonGroup

func NewButtonGroup(buttons ...Widget) *ButtonGroup

NewButtonGroup joins buttons side by side.

func (*ButtonGroup) Append

func (g *ButtonGroup) Append(w Widget)

Append adds w (a button, a separator, a nested group) at the end. Nested groups sit apart.

func (*ButtonGroup) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ButtonGroup) Baseline

func (c *ButtonGroup) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ButtonGroup) Children

func (c *ButtonGroup) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ButtonGroup) HitTest

func (c *ButtonGroup) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ButtonGroup) Measure

func (c *ButtonGroup) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ButtonGroup) Paint

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

Paint draws the surface (when configured) then the root.

func (*ButtonGroup) SetVertical

func (g *ButtonGroup) SetVertical(on bool)

SetVertical stacks the buttons.

type ButtonRow

type ButtonRow struct {
	*ActionRow
}

ButtonRow is a full-width activatable row wearing a button look: the title centered, activation whole-row, for the destructive and affirmative actions a preferences page ends with.

func NewButtonRow

func NewButtonRow(face render.Font, sizePx float64, title string, onClick func()) *ButtonRow

NewButtonRow returns the activatable centered row; onClick is its activation.

func (ButtonRow) Arrange

func (c ButtonRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (ButtonRow) Baseline

func (c ButtonRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (ButtonRow) Children

func (c ButtonRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (ButtonRow) HitTest

func (c ButtonRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (ButtonRow) Measure

func (c ButtonRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (ButtonRow) PackEnd

func (p ButtonRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (ButtonRow) PackStart

func (p ButtonRow) PackStart(w Widget)

PackStart adds w to the leading slot.

type Calendar

type Calendar struct {

	// Detail, when set, describes a date - an event title, a holiday -
	// shown as the tooltip of the day under the pointer ("" for none).
	Detail func(date Date) string

	// OnSelect fires with the picked day in single mode, on every
	// applied selection - click, keyboard, or Select.
	OnSelect func(Date)
	// OnRangeSelect fires in range mode on every pick: the start and,
	// once picked, the end (zero until then).
	OnRangeSelect func(from, to Date)
	// contains filtered or unexported fields
}

Calendar is a month grid: the month title between previous and next buttons, the weekday header, and the days with the adjacent months' leading and trailing days muted. Today takes the muted wash, a picked day the primary fill, and a range's days between its ends a band. SetMonths shows several months side by side, the date range picker's two. Colors come from the typed theme.

Pointer: a click picks its day; the buttons step the shown months. Keyboard: in single mode the arrows move the selection a day (a week vertically) and PageUp/PageDown a month (Shift: a year), the view following; in range mode they move a cursor and Enter or Space picks it.

func NewCalendar

func NewCalendar(face render.Font, sizePx float64, initial Date) *Calendar

NewCalendar returns a single-mode calendar showing initial's month with initial selected; a zero initial shows today's month with no selection. Today is read from the clock now (SetToday overrides).

func (*Calendar) AccessibleName

func (n *Calendar) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Calendar) AddClass

func (n *Calendar) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Calendar) Arrange

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

Arrange records the rect, widens the day columns to share a wider one, and places the previous button at the first month's left and the next at the last month's right.

func (*Calendar) AttachStylesheet

func (n *Calendar) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Calendar) Attr

func (n *Calendar) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Calendar) Bounds

func (n *Calendar) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Calendar) Children

func (c *Calendar) Children() []Widget

Children exposes the navigation buttons for focus traversal and the damage walk; the day cells are painted geometry, not widgets.

func (*Calendar) Classes

func (n *Calendar) Classes() []string

Classes returns a copy of the widget's classes.

func (*Calendar) ClearMarks

func (c *Calendar) ClearMarks()

ClearMarks removes every mark.

func (*Calendar) ClickAt

func (c *Calendar) ClickAt(p Point)

ClickAt picks the day under p; clicks off the day grid change nothing.

func (*Calendar) DayMarked

func (c *Calendar) DayMarked(d Date) bool

DayMarked reports d's mark.

func (*Calendar) DebugName

func (n *Calendar) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Calendar) DetachStylesheet

func (n *Calendar) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Calendar) Element

func (n *Calendar) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Calendar) Enabled

func (n *Calendar) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Calendar) HAlign

func (n *Calendar) HAlign() Align

HAlign returns the horizontal placement.

func (*Calendar) HasClass

func (n *Calendar) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Calendar) HasState

func (n *Calendar) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Calendar) HitLeaf

func (n *Calendar) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Calendar) HitTest

func (c *Calendar) HitTest(p Point) Widget

HitTest returns a navigation button under p, else the calendar (the day cells are its own geometry).

func (*Calendar) HoverMove

func (c *Calendar) HoverMove(p Point)

HoverMove tracks the day under the pointer for its Detail tooltip.

func (*Calendar) HoverWithin

func (n *Calendar) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Calendar) ID

func (n *Calendar) ID() string

ID returns the style id, empty when none is set.

func (*Calendar) InlineStyle

func (n *Calendar) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Calendar) Invalidate

func (n *Calendar) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Calendar) InvalidateLayout

func (n *Calendar) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Calendar) InvalidateRect

func (n *Calendar) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Calendar) KeyAction

func (c *Calendar) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: the arrows move a day (a week vertically) and PageUp/PageDown a month (with Shift, a year) - the selection itself in single mode, the cursor in range mode, where Enter and Space pick it. The view follows. Disabled calendars ignore keys.

func (*Calendar) LayoutMotion

func (n *Calendar) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Calendar) Margin

func (n *Calendar) Margin() render.Insets

Margin returns the programmatic margin.

func (*Calendar) MarkDay

func (c *Calendar) MarkDay(d Date)

MarkDay marks d (GTK mark_day): a dot under its number. Marks are per date, so they stay with their month as the view moves.

func (*Calendar) MaximumSize

func (n *Calendar) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Calendar) Measure

func (c *Calendar) Measure(axis Axis, forSize int) Sizes

Measure wants each month's title, header and six week rows of natural cells, side by side.

func (*Calendar) Mode

func (c *Calendar) Mode() CalendarMode

Mode returns what clicks pick.

func (*Calendar) Paint

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

Paint draws each month's title, weekday header and days, then the navigation buttons.

func (*Calendar) Parent

func (n *Calendar) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Calendar) Range

func (c *Calendar) Range() (from, to Date)

Range returns range mode's start and end (zero while unpicked).

func (*Calendar) RemoveAttr

func (n *Calendar) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Calendar) RemoveClass

func (n *Calendar) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Calendar) Role

func (c *Calendar) Role() Role

Role implements Roleer.

func (*Calendar) Select

func (c *Calendar) Select(d Date)

Select applies d as single mode's selection, shows its month if it is not shown, and fires OnSelect. A zero d clears the selection, keeping the shown month and the keyboard's day.

func (*Calendar) Selection

func (c *Calendar) Selection() Date

Selection returns single mode's selected day, zero when none.

func (*Calendar) SetAccessibleName

func (n *Calendar) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Calendar) SetAttr

func (n *Calendar) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Calendar) SetClass

func (n *Calendar) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Calendar) SetClasses

func (n *Calendar) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Calendar) SetCursorName

func (n *Calendar) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Calendar) SetDebugName

func (n *Calendar) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Calendar) SetElement

func (n *Calendar) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Calendar) SetEnabled

func (n *Calendar) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Calendar) SetFirstWeekday

func (c *Calendar) SetFirstWeekday(day time.Weekday)

SetFirstWeekday makes day the week's first column, overriding the name set's (lys-shell's calendar takes it from its config).

func (*Calendar) SetFocusOnClick

func (n *Calendar) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Calendar) SetHAlign

func (n *Calendar) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Calendar) SetHExpand

func (n *Calendar) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Calendar) SetHovered

func (c *Calendar) SetHovered(on bool)

SetHovered forgets the day when the pointer leaves.

func (*Calendar) SetID

func (n *Calendar) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Calendar) SetInlineStyle

func (n *Calendar) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Calendar) SetInlineStylePriority

func (n *Calendar) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Calendar) SetLayoutMotion

func (n *Calendar) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Calendar) SetMargin

func (n *Calendar) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Calendar) SetMaximumSize

func (n *Calendar) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Calendar) SetMode

func (c *Calendar) SetMode(m CalendarMode)

SetMode switches between picking a day and a range; the picks of the other mode clear.

func (*Calendar) SetMonths

func (c *Calendar) SetMonths(n int)

SetMonths shows n months side by side from the shown one, at least one.

func (*Calendar) SetNames

func (c *Calendar) SetNames(names CalendarNames)

SetNames swaps the locale's names; nil restores CalendarCatalog.

func (*Calendar) SetOnClickWithin

func (n *Calendar) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Calendar) SetOnFocusChanged

func (n *Calendar) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Calendar) SetOnHoverWithin

func (n *Calendar) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Calendar) SetOnPointer

func (n *Calendar) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Calendar) SetOnScroll

func (n *Calendar) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Calendar) SetRange

func (c *Calendar) SetRange(from, to Date)

SetRange applies a range, the earlier day starting it, and shows its start's month; it fires nothing.

func (*Calendar) SetSharedElement

func (n *Calendar) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Calendar) SetSizeRequest

func (n *Calendar) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Calendar) SetState

func (n *Calendar) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Calendar) SetToday

func (c *Calendar) SetToday(d Date)

SetToday sets the day marked as today (NewCalendar reads the clock).

func (*Calendar) SetTooltip

func (n *Calendar) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Calendar) SetTooltipMarkup

func (n *Calendar) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Calendar) SetVAlign

func (n *Calendar) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Calendar) SetVExpand

func (n *Calendar) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Calendar) SetVisible

func (n *Calendar) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Calendar) SetWeekend

func (c *Calendar) SetWeekend(days ...time.Weekday)

SetWeekend names the weekend days, Saturday and Sunday by default: their cells take the `calendar .weekend` rule's color and background, which the theme leaves unset.

func (*Calendar) SharedElement

func (n *Calendar) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Calendar) ShowMonth

func (c *Calendar) ShowMonth(d Date)

ShowMonth shows the month of d first, leaving the picks alone.

func (*Calendar) Shown

func (c *Calendar) Shown() Date

Shown returns the first day of the first shown month.

func (*Calendar) SizeRequest

func (n *Calendar) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Calendar) TooltipAnchor

func (c *Calendar) TooltipAnchor() render.Rect

TooltipAnchor implements TooltipAnchorer: the hovered day's cell while its Detail names the tooltip, else the whole calendar.

func (*Calendar) TooltipMarkup

func (n *Calendar) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Calendar) TooltipText

func (c *Calendar) TooltipText() string

TooltipText is the hovered day's Detail, else the calendar's own tooltip.

func (*Calendar) UnmarkDay

func (c *Calendar) UnmarkDay(d Date)

UnmarkDay removes d's mark.

func (*Calendar) VAlign

func (n *Calendar) VAlign() Align

VAlign returns the vertical placement.

func (*Calendar) Visible

func (n *Calendar) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type CalendarCatalog

type CalendarCatalog struct{}

CalendarCatalog is the default name set, read through the installed message catalog (SetCatalog) the GTK way, English without one: the month and weekday names translate as themselves, the week's first day is the translation of "calendar:week_start:0" (a translator writes calendar:week_start:1 for Monday), and dates follow the translation of the layout "%B %-d, %Y" (see formatDate).

func (CalendarCatalog) FirstWeekday

func (CalendarCatalog) FirstWeekday() time.Weekday

FirstWeekday implements CalendarNames.

func (CalendarCatalog) FormatDate

func (n CalendarCatalog) FormatDate(d Date) string

FormatDate implements CalendarNames.

func (CalendarCatalog) MonthName

func (CalendarCatalog) MonthName(m time.Month) string

MonthName implements CalendarNames.

func (CalendarCatalog) WeekdayName

func (CalendarCatalog) WeekdayName(w time.Weekday) string

WeekdayName implements CalendarNames.

type CalendarENUS

type CalendarENUS struct{}

CalendarENUS is the en-US name set: full English month names, two-letter weekday abbreviations, weeks starting Sunday, dates as "October 24, 2026".

func (CalendarENUS) FirstWeekday

func (CalendarENUS) FirstWeekday() time.Weekday

FirstWeekday implements CalendarNames.

func (CalendarENUS) FormatDate

func (n CalendarENUS) FormatDate(d Date) string

FormatDate implements CalendarNames.

func (CalendarENUS) MonthName

func (CalendarENUS) MonthName(m time.Month) string

MonthName implements CalendarNames.

func (CalendarENUS) WeekdayName

func (CalendarENUS) WeekdayName(w time.Weekday) string

WeekdayName implements CalendarNames.

type CalendarMode

type CalendarMode uint8

CalendarMode is what a Calendar's clicks pick.

const (
	// CalendarSingle picks one day.
	CalendarSingle CalendarMode = iota
	// CalendarRange picks a span: the first pick starts it, the second
	// ends it (the earlier of the two starting), a third starts anew.
	CalendarRange
)

The calendar modes.

type CalendarNames

type CalendarNames interface {
	// MonthName is the full month name for the title.
	MonthName(time.Month) string
	// WeekdayName is the short weekday label for the header.
	WeekdayName(time.Weekday) string
	// FirstWeekday is the week's first column (Sunday for en-US).
	FirstWeekday() time.Weekday
	// FormatDate writes a day the way the locale does: "October 24,
	// 2026" in en-US.
	FormatDate(Date) string
}

CalendarNames supplies a Calendar's localized pieces. A nil interface (the default) reads them through the message catalog (CalendarCatalog); supply your own to localize otherwise.

type Card

type Card struct {
	// contains filtered or unexported fields
}

Card is the card anatomy as one widget: a header with the title, an optional muted description and an optional trailing action, then the content, then a footer of actions, right-aligned unless SetFooterAlign says otherwise. The sections space themselves and pad the card from the theme (three Spacing between them, three Padding around), so a caller sets no margins; the text sizes follow the theme's TextSize, the title at TitleSize. It is the card element, styled as the .card class is, and its parts the .card-header, .card-title, .card-description, .card-action, .card-content and .card-footer classes a stylesheet restyles.

func NewCard

func NewCard(face render.Font, title string) *Card

NewCard returns a card with the title and nothing else.

func (*Card) Action

func (c *Card) Action() Widget

Action returns the header's trailing widget, nil when none.

func (*Card) AppendFooter

func (c *Card) AppendFooter(w Widget)

AppendFooter adds w to the footer, after the ones already there; the footer shows once it holds anything.

func (*Card) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Card) Baseline

func (c *Card) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Card) Children

func (c *Card) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Card) ClearFooter

func (c *Card) ClearFooter()

ClearFooter empties and hides the footer.

func (*Card) Content

func (c *Card) Content() Widget

Content returns the content, nil when none.

func (*Card) Description

func (c *Card) Description() string

Description returns the description.

func (*Card) HitTest

func (c *Card) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Card) Measure

func (c *Card) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Card) Paint

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

Paint draws the surface (when configured) then the root.

func (*Card) SetAction

func (c *Card) SetAction(w Widget)

SetAction puts w at the header's trailing edge, level with the title; nil removes it.

func (*Card) SetContent

func (c *Card) SetContent(w Widget)

SetContent puts w between the header and the footer; nil removes it.

func (*Card) SetDescription

func (c *Card) SetDescription(s string)

SetDescription sets the muted line under the title; empty hides it.

func (*Card) SetFooterAlign

func (c *Card) SetFooterAlign(a Align)

SetFooterAlign places the footer's actions: AlignEnd (the default), AlignStart, AlignCenter, or AlignFill to spread the row across.

func (*Card) SetTitle

func (c *Card) SetTitle(s string)

SetTitle replaces the title.

func (*Card) Title

func (c *Card) Title() string

Title returns the title.

type Carousel struct {

	// OnPage fires when the settled page changes.
	OnPage func(i int)
	// contains filtered or unexported fields
}

Carousel is a horizontal swipeable page strip: pages side by side at the carousel's width, pointer drags and touchpad swipes pan, releases snap to the nearest page on the animation clock, the round previous and next buttons step a page (disabled at the ends, Left and Right on them step too), and the painted dots index the position. It styles as the `carousel` element: the button.nav pair.

func NewCarousel

func NewCarousel(face render.Font, sizePx float64) *Carousel

NewCarousel returns an empty carousel.

func (*Carousel) AccessibleName

func (n *Carousel) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Carousel) AddClass

func (n *Carousel) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Carousel) Append

func (c *Carousel) Append(w Widget)

Append adds a page at the end.

func (*Carousel) Arrange

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

Arrange lays the pages side by side at the carousel's width (each aligned in its slot), offset by the fractional page position, and the previous and next buttons inside the sides, centered.

func (*Carousel) AttachStylesheet

func (n *Carousel) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Carousel) Attr

func (n *Carousel) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Carousel) Bounds

func (n *Carousel) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Carousel) Children

func (c *Carousel) Children() []Widget

Children are the pages and the previous and next buttons.

func (*Carousel) Classes

func (n *Carousel) Classes() []string

Classes returns a copy of the widget's classes.

func (*Carousel) DebugName

func (n *Carousel) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Carousel) DetachStylesheet

func (n *Carousel) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Carousel) DragMove

func (c *Carousel) DragMove(p Point)

DragMove pans the pages with the pointer.

func (*Carousel) Element

func (n *Carousel) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Carousel) Enabled

func (n *Carousel) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Carousel) Gesture

func (c *Carousel) Gesture(g Gesture) bool

Gesture implements GestureHandler: a touchpad swipe pans the pages like a drag, snapping when the fingers lift (touchscreen drags reach the carousel through the touch pointer emulation).

func (*Carousel) HAlign

func (n *Carousel) HAlign() Align

HAlign returns the horizontal placement.

func (*Carousel) HasClass

func (n *Carousel) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Carousel) HasState

func (n *Carousel) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Carousel) HitLeaf

func (n *Carousel) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Carousel) HitTest

func (c *Carousel) HitTest(p Point) Widget

HitTest resolves the buttons, else the carousel itself.

func (*Carousel) HoverWithin

func (n *Carousel) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Carousel) ID

func (n *Carousel) ID() string

ID returns the style id, empty when none is set.

func (*Carousel) InlineStyle

func (n *Carousel) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Carousel) InterceptKey

func (c *Carousel) InterceptKey(target Widget, a KeyAction, _ Mods) bool

InterceptKey implements KeyInterceptor: Left and Right on the previous or next button step a page.

func (*Carousel) Invalidate

func (n *Carousel) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Carousel) InvalidateLayout

func (n *Carousel) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Carousel) InvalidateRect

func (n *Carousel) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Carousel) LayoutMotion

func (n *Carousel) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Carousel) Margin

func (n *Carousel) Margin() render.Insets

Margin returns the programmatic margin.

func (*Carousel) MaximumSize

func (n *Carousel) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Carousel) Measure

func (c *Carousel) Measure(axis Axis, forSize int) Sizes

Measure wants the widest page's request: each page lays out at the carousel's full width, the tallest at that width wins.

func (*Carousel) Page

func (c *Carousel) Page() int

Page shows page i (animated snap).

func (*Carousel) Pages

func (c *Carousel) Pages() int

Pages reports the page count.

func (*Carousel) Paint

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

Paint draws the visible pages clipped, then the indicator dots and the buttons.

func (*Carousel) Parent

func (n *Carousel) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Carousel) PressAt

func (c *Carousel) PressAt(p Point)

PressAt begins a drag from the current page offset.

func (*Carousel) PressEnd

func (c *Carousel) PressEnd()

PressEnd snaps to the nearest page when a drag ends - released, cancelled, or lost alike.

func (*Carousel) RemoveAttr

func (n *Carousel) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Carousel) RemoveClass

func (n *Carousel) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Carousel) SetAccessibleName

func (n *Carousel) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Carousel) SetAttr

func (n *Carousel) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Carousel) SetClass

func (n *Carousel) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Carousel) SetClasses

func (n *Carousel) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Carousel) SetCursorName

func (n *Carousel) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Carousel) SetDebugName

func (n *Carousel) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Carousel) SetElement

func (n *Carousel) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Carousel) SetEnabled

func (n *Carousel) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Carousel) SetFocusOnClick

func (n *Carousel) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Carousel) SetHAlign

func (n *Carousel) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Carousel) SetHExpand

func (n *Carousel) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Carousel) SetID

func (n *Carousel) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Carousel) SetInlineStyle

func (n *Carousel) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Carousel) SetInlineStylePriority

func (n *Carousel) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Carousel) SetLayoutMotion

func (n *Carousel) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Carousel) SetMargin

func (n *Carousel) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Carousel) SetMaximumSize

func (n *Carousel) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Carousel) SetOnClickWithin

func (n *Carousel) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Carousel) SetOnFocusChanged

func (n *Carousel) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Carousel) SetOnHoverWithin

func (n *Carousel) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Carousel) SetOnPointer

func (n *Carousel) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Carousel) SetOnScroll

func (n *Carousel) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Carousel) SetPage

func (c *Carousel) SetPage(i int)

SetPage snaps to page i without animation.

func (*Carousel) SetSharedElement

func (n *Carousel) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Carousel) SetSizeRequest

func (n *Carousel) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Carousel) SetState

func (n *Carousel) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Carousel) SetTooltip

func (n *Carousel) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Carousel) SetTooltipMarkup

func (n *Carousel) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Carousel) SetVAlign

func (n *Carousel) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Carousel) SetVExpand

func (n *Carousel) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Carousel) SetVisible

func (n *Carousel) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Carousel) SharedElement

func (n *Carousel) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Carousel) SizeRequest

func (n *Carousel) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Carousel) TooltipMarkup

func (n *Carousel) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Carousel) TooltipText

func (n *Carousel) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Carousel) VAlign

func (n *Carousel) VAlign() Align

VAlign returns the vertical placement.

func (*Carousel) Visible

func (n *Carousel) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Catalog

type Catalog interface {
	Get(id string) string
	GetN(singular, plural string, n int) string
	GetCtx(ctx, id string) string
}

Catalog translates user-facing strings, the gettext model: the key is the English string itself, plural pairs choose a form for n, and a context disambiguates equal English strings. *i18n.Catalog implements it from .po and .mo files; an untranslated key comes back unchanged.

type CenterBox

type CenterBox struct {
	// contains filtered or unexported fields
}

CenterBox lays three children like gtk::CenterBox along its orientation (Row by default): the center one at the middle of the allocation, the start and end children at the ends. The center child stays centered however long the sides run, until one would overlap it: then it moves just clear of that side (GtkCenterLayout).

func NewCenterBox

func NewCenterBox(start, center, end Widget) *CenterBox

NewCenterBox returns a three-slot row; any slot may be nil.

func (*CenterBox) AccessibleName

func (n *CenterBox) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*CenterBox) AddClass

func (n *CenterBox) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*CenterBox) Arrange

func (b *CenterBox) Arrange(r render.Rect)

Arrange places the start slot at the start, the end slot at the end, and the center slot at the middle unless a side would overlap it; every slot spans the box's thickness.

func (*CenterBox) ArrangeRoot

func (b *CenterBox) ArrangeRoot(r render.Rect)

ArrangeRoot records the box's own rect.

func (*CenterBox) AttachStylesheet

func (n *CenterBox) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*CenterBox) Attr

func (n *CenterBox) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*CenterBox) Bounds

func (n *CenterBox) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*CenterBox) Children

func (b *CenterBox) Children() []Widget

Children exposes the slots in start, center, end order.

func (*CenterBox) Classes

func (n *CenterBox) Classes() []string

Classes returns a copy of the widget's classes.

func (*CenterBox) DebugName

func (n *CenterBox) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*CenterBox) DetachStylesheet

func (n *CenterBox) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*CenterBox) Element

func (n *CenterBox) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*CenterBox) Enabled

func (n *CenterBox) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*CenterBox) HAlign

func (n *CenterBox) HAlign() Align

HAlign returns the horizontal placement.

func (*CenterBox) HasClass

func (n *CenterBox) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*CenterBox) HasState

func (n *CenterBox) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*CenterBox) HitLeaf

func (n *CenterBox) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*CenterBox) HitTest

func (b *CenterBox) HitTest(p Point) Widget

HitTest returns the slot under p, else the box.

func (*CenterBox) HoverWithin

func (n *CenterBox) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*CenterBox) ID

func (n *CenterBox) ID() string

ID returns the style id, empty when none is set.

func (*CenterBox) InlineStyle

func (n *CenterBox) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*CenterBox) Invalidate

func (n *CenterBox) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*CenterBox) InvalidateLayout

func (n *CenterBox) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*CenterBox) InvalidateRect

func (n *CenterBox) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*CenterBox) LayoutMotion

func (n *CenterBox) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*CenterBox) Margin

func (n *CenterBox) Margin() render.Insets

Margin returns the programmatic margin.

func (*CenterBox) MaximumSize

func (n *CenterBox) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*CenterBox) Measure

func (b *CenterBox) Measure(axis Axis, forSize int) Sizes

Measure sizes to the three naturals end to end along the axis, as thick as the thickest.

func (*CenterBox) Orientation

func (b *CenterBox) Orientation() Axis

Orientation is the axis the slots run along.

func (*CenterBox) Paint

func (b *CenterBox) Paint(cv *render.Canvas)

Paint draws the box's CSS layers, then the slots.

func (*CenterBox) Parent

func (n *CenterBox) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*CenterBox) RemoveAttr

func (n *CenterBox) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*CenterBox) RemoveClass

func (n *CenterBox) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*CenterBox) SetAccessibleName

func (n *CenterBox) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*CenterBox) SetAttr

func (n *CenterBox) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*CenterBox) SetClass

func (n *CenterBox) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*CenterBox) SetClasses

func (n *CenterBox) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*CenterBox) SetCursorName

func (n *CenterBox) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*CenterBox) SetDebugName

func (n *CenterBox) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*CenterBox) SetElement

func (n *CenterBox) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*CenterBox) SetEnabled

func (n *CenterBox) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*CenterBox) SetFocusOnClick

func (n *CenterBox) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*CenterBox) SetHAlign

func (n *CenterBox) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*CenterBox) SetHExpand

func (n *CenterBox) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*CenterBox) SetID

func (n *CenterBox) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*CenterBox) SetInlineStyle

func (n *CenterBox) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*CenterBox) SetInlineStylePriority

func (n *CenterBox) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*CenterBox) SetLayoutMotion

func (n *CenterBox) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*CenterBox) SetMargin

func (n *CenterBox) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*CenterBox) SetMaximumSize

func (n *CenterBox) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*CenterBox) SetOnClickWithin

func (n *CenterBox) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*CenterBox) SetOnFocusChanged

func (n *CenterBox) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*CenterBox) SetOnHoverWithin

func (n *CenterBox) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*CenterBox) SetOnPointer

func (n *CenterBox) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*CenterBox) SetOnScroll

func (n *CenterBox) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*CenterBox) SetOrientation

func (b *CenterBox) SetOrientation(a Axis)

SetOrientation lays the slots along a (gtk_orientable_set_orientation): a Column runs top to bottom.

func (*CenterBox) SetSharedElement

func (n *CenterBox) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*CenterBox) SetSizeRequest

func (n *CenterBox) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*CenterBox) SetState

func (n *CenterBox) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*CenterBox) SetTooltip

func (n *CenterBox) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*CenterBox) SetTooltipMarkup

func (n *CenterBox) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*CenterBox) SetVAlign

func (n *CenterBox) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*CenterBox) SetVExpand

func (n *CenterBox) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*CenterBox) SetVisible

func (n *CenterBox) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*CenterBox) SharedElement

func (n *CenterBox) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*CenterBox) SizeRequest

func (n *CenterBox) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*CenterBox) TooltipMarkup

func (n *CenterBox) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*CenterBox) TooltipText

func (n *CenterBox) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*CenterBox) VAlign

func (n *CenterBox) VAlign() Align

VAlign returns the vertical placement.

func (*CenterBox) Visible

func (n *CenterBox) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Chart

type Chart struct {
	// contains filtered or unexported fields
}

Chart plots categories of data: bars grouped or stacked, areas, lines, a pie or donut, a radar, or radial bars, in the theme's chart colors (@chart_1 to @chart_5). The cartesian kinds draw a value axis on rounded ticks, horizontal grid lines and the category labels; every kind but the radial one has a legend of the series (pie: of the categories). Hovering a category or a wedge shows a tooltip card with its values. Changing the data (SetData) eases the shown values to the new ones. Assistive technology reads a summary of the data. It styles as the `chart` element.

func NewChart

func NewChart(face render.Font, kind ChartKind, labels []string, series ...ChartSeries) *Chart

NewChart returns a chart of kind over the categories' labels.

func (*Chart) AccessibleName

func (n *Chart) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Chart) AddClass

func (n *Chart) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Chart) Arrange

func (n *Chart) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Chart) AttachStylesheet

func (n *Chart) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Chart) Attr

func (n *Chart) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Chart) Bounds

func (n *Chart) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Chart) Classes

func (n *Chart) Classes() []string

Classes returns a copy of the widget's classes.

func (*Chart) DebugName

func (n *Chart) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Chart) DetachStylesheet

func (n *Chart) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Chart) Element

func (n *Chart) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Chart) Enabled

func (n *Chart) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Chart) HAlign

func (n *Chart) HAlign() Align

HAlign returns the horizontal placement.

func (*Chart) HasClass

func (n *Chart) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Chart) HasState

func (n *Chart) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Chart) HitLeaf

func (n *Chart) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Chart) HitTest

func (c *Chart) HitTest(p Point) Widget

HitTest takes the pointer over the chart.

func (*Chart) HoverMove

func (c *Chart) HoverMove(p Point)

HoverMove picks the category, or the pie's wedge, under the pointer.

func (*Chart) HoverWithin

func (n *Chart) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Chart) ID

func (n *Chart) ID() string

ID returns the style id, empty when none is set.

func (*Chart) InlineStyle

func (n *Chart) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Chart) Invalidate

func (n *Chart) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Chart) InvalidateLayout

func (n *Chart) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Chart) InvalidateRect

func (n *Chart) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Chart) LayoutMotion

func (n *Chart) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Chart) Margin

func (n *Chart) Margin() render.Insets

Margin returns the programmatic margin.

func (*Chart) MaximumSize

func (n *Chart) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Chart) Measure

func (c *Chart) Measure(axis Axis, forSize int) Sizes

Measure wants the natural plot size.

func (*Chart) Paint

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

Paint draws the chart, its legend and, on hover, the tooltip.

func (*Chart) Parent

func (n *Chart) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Chart) RemoveAttr

func (n *Chart) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Chart) RemoveClass

func (n *Chart) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Chart) Role

func (c *Chart) Role() Role

Role is RoleChart.

func (*Chart) SetAccessibleName

func (n *Chart) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Chart) SetAttr

func (n *Chart) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Chart) SetClass

func (n *Chart) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Chart) SetClasses

func (n *Chart) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Chart) SetCursorName

func (n *Chart) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Chart) SetData

func (c *Chart) SetData(labels []string, series ...ChartSeries)

SetData replaces the categories and the series, easing the shown values to the new ones.

func (*Chart) SetDebugName

func (n *Chart) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Chart) SetDonut

func (c *Chart) SetDonut(on bool)

SetDonut cuts a pie chart's middle out.

func (*Chart) SetElement

func (n *Chart) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Chart) SetEnabled

func (n *Chart) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Chart) SetFocusOnClick

func (n *Chart) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Chart) SetHAlign

func (n *Chart) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Chart) SetHExpand

func (n *Chart) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Chart) SetHovered

func (c *Chart) SetHovered(on bool)

SetHovered clears the tooltip when the pointer leaves.

func (*Chart) SetID

func (n *Chart) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Chart) SetInlineStyle

func (n *Chart) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Chart) SetInlineStylePriority

func (n *Chart) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Chart) SetLayoutMotion

func (n *Chart) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Chart) SetLegend

func (c *Chart) SetLegend(on bool)

SetLegend shows or hides the legend.

func (*Chart) SetMargin

func (n *Chart) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Chart) SetMaximumSize

func (n *Chart) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Chart) SetOnClickWithin

func (n *Chart) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Chart) SetOnFocusChanged

func (n *Chart) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Chart) SetOnHoverWithin

func (n *Chart) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Chart) SetOnPointer

func (n *Chart) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Chart) SetOnScroll

func (n *Chart) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Chart) SetSharedElement

func (n *Chart) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Chart) SetSizeRequest

func (n *Chart) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Chart) SetStacked

func (c *Chart) SetStacked(on bool)

SetStacked stacks a bar or area chart's series.

func (*Chart) SetState

func (n *Chart) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Chart) SetTooltip

func (n *Chart) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Chart) SetTooltipMarkup

func (n *Chart) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Chart) SetVAlign

func (n *Chart) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Chart) SetVExpand

func (n *Chart) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Chart) SetVisible

func (n *Chart) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Chart) SharedElement

func (n *Chart) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Chart) SizeRequest

func (n *Chart) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Chart) Summary

func (c *Chart) Summary() string

Summary is the chart's data in words: its kind, then each series' values by category.

func (*Chart) TooltipMarkup

func (n *Chart) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Chart) TooltipText

func (n *Chart) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Chart) VAlign

func (n *Chart) VAlign() Align

VAlign returns the vertical placement.

func (*Chart) Visible

func (n *Chart) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ChartKind

type ChartKind uint8

ChartKind is how a Chart draws its data.

const (
	// ChartBar draws a bar per series per category, grouped, or
	// stacked with SetStacked.
	ChartBar ChartKind = iota
	// ChartArea fills each series' line down to the baseline, stacked
	// with SetStacked.
	ChartArea
	// ChartLine strokes each series' line.
	ChartLine
	// ChartPie draws the first series as wedges per category; a donut
	// with SetDonut.
	ChartPie
	// ChartRadar draws each series as a polygon over the categories'
	// spokes.
	ChartRadar
	// ChartRadial draws the first series as concentric bars per
	// category, each around a track.
	ChartRadial
)

The chart kinds.

func (ChartKind) String

func (k ChartKind) String() string

String names the kind, for the accessible summary.

type ChartSeries

type ChartSeries struct {
	Name   string
	Values []float64
	Color  render.Color
}

ChartSeries is one series of a Chart: a name and a value per category; Color 0 takes the theme's next chart color.

type CheckButton

type CheckButton struct {

	// OnChanged fires after every state change, including programmatic
	// ones.
	OnChanged func(checked bool)
	// contains filtered or unexported fields
}

CheckButton is a boolean checkbox with a painted check mark, and an optional child (its label) beside the mark that clicks toggle too.

func NewCheckButton

func NewCheckButton(checked bool) *CheckButton

NewCheckButton returns a checkbox in the given state. The pointer turns to the hand over it, the way wayle's checkbox primitive asks.

func (*CheckButton) AccessibleName

func (n *CheckButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*CheckButton) AddClass

func (n *CheckButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*CheckButton) Arrange

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

Arrange records the box. Without a child the check fills the content box; with one it keeps its size at the start, centered across, and the child takes the rest.

func (*CheckButton) AttachStylesheet

func (n *CheckButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*CheckButton) Attr

func (n *CheckButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*CheckButton) BindAction

func (c *CheckButton) BindAction(target Checkable) (unbind func())

BindAction makes the check button a proxy of c, like ToggleButton.BindAction.

func (*CheckButton) BindChecked

func (c *CheckButton) BindChecked(b *Binding[bool]) (unbind func())

BindChecked wires the binding two-way to the checkbox's state.

func (*CheckButton) Bounds

func (n *CheckButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*CheckButton) Checked

func (c *CheckButton) Checked() bool

Checked reports the state.

func (*CheckButton) Child

func (c *CheckButton) Child() Widget

Child is the widget SetChild placed, nil for none.

func (*CheckButton) Classes

func (n *CheckButton) Classes() []string

Classes returns a copy of the widget's classes.

func (*CheckButton) ClickAt

func (c *CheckButton) ClickAt(Point)

ClickAt toggles the checkbox; the Router invokes it on press+release. Disabled checkboxes ignore clicks.

func (*CheckButton) DebugName

func (n *CheckButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*CheckButton) DetachStylesheet

func (n *CheckButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*CheckButton) Element

func (n *CheckButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*CheckButton) Enabled

func (n *CheckButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*CheckButton) HAlign

func (n *CheckButton) HAlign() Align

HAlign returns the horizontal placement.

func (*CheckButton) HasClass

func (n *CheckButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*CheckButton) HasState

func (n *CheckButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*CheckButton) HitLeaf

func (n *CheckButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*CheckButton) HitTest

func (c *CheckButton) HitTest(p Point) Widget

HitTest returns the checkbox when p is inside its bounds.

func (*CheckButton) HoverWithin

func (n *CheckButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*CheckButton) ID

func (n *CheckButton) ID() string

ID returns the style id, empty when none is set.

func (*CheckButton) Inconsistent

func (c *CheckButton) Inconsistent() bool

Inconsistent reports the indeterminate state.

func (*CheckButton) InlineStyle

func (n *CheckButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*CheckButton) InsertRune

func (c *CheckButton) InsertRune(r rune)

InsertRune implements RuneHandler: Space toggles, the other half of the GTK activation pair. Disabled checkboxes ignore it.

func (*CheckButton) Invalidate

func (n *CheckButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*CheckButton) InvalidateLayout

func (n *CheckButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*CheckButton) InvalidateRect

func (n *CheckButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*CheckButton) KeyAction

func (c *CheckButton) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: Enter toggles when focused, which makes the checkbox reachable and activatable by keyboard only. Disabled checkboxes ignore keys.

func (*CheckButton) LayoutMotion

func (n *CheckButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*CheckButton) Margin

func (n *CheckButton) Margin() render.Insets

Margin returns the programmatic margin.

func (*CheckButton) MaximumSize

func (n *CheckButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*CheckButton) Measure

func (c *CheckButton) Measure(axis Axis, forSize int) Sizes

Measure sizes the indicator and the child after it, inside the checkbox's CSS box.

func (*CheckButton) Paint

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

Paint draws the indicator through the check node: the box layers (background, border, radius) it resolves, the tick or minus bar in its color. Unstyled, a 2px theme-border ring around the theme surface, accent-filled with a mark while checked or inconsistent. Disabled, ring and mark fade through the derived disabled colors.

func (*CheckButton) Parent

func (n *CheckButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*CheckButton) RemoveAttr

func (n *CheckButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*CheckButton) RemoveClass

func (n *CheckButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*CheckButton) Role

func (c *CheckButton) Role() Role

Role implements Roleer.

func (*CheckButton) SetAccessibleName

func (n *CheckButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*CheckButton) SetAttr

func (n *CheckButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*CheckButton) SetChecked

func (c *CheckButton) SetChecked(checked bool)

SetChecked changes the state and fires OnChanged when it flipped.

func (*CheckButton) SetChild

func (c *CheckButton) SetChild(w Widget)

SetChild places w after the check (gtk_check_button_set_child): a label, typically, styled as `checkbutton > label`. The checkbox stays the leaf: a click on the child toggles it. nil removes the child.

func (*CheckButton) SetClass

func (n *CheckButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*CheckButton) SetClasses

func (n *CheckButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*CheckButton) SetCursorName

func (n *CheckButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*CheckButton) SetDebugName

func (n *CheckButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*CheckButton) SetElement

func (n *CheckButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*CheckButton) SetEnabled

func (n *CheckButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*CheckButton) SetFocusOnClick

func (n *CheckButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*CheckButton) SetGroup

func (c *CheckButton) SetGroup(other *CheckButton)

SetGroup makes c a radio button in other's group: drawn as a round `radio` indicator, checking it unchecks the others, and a click on the checked one keeps it checked.

func (*CheckButton) SetHAlign

func (n *CheckButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*CheckButton) SetHExpand

func (n *CheckButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*CheckButton) SetID

func (n *CheckButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*CheckButton) SetInconsistent

func (c *CheckButton) SetInconsistent(on bool)

SetInconsistent marks the check indeterminate (`:indeterminate`), the neither-checked-nor-unchecked state a tri-state control shows.

func (*CheckButton) SetInlineStyle

func (n *CheckButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*CheckButton) SetInlineStylePriority

func (n *CheckButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*CheckButton) SetLayoutMotion

func (n *CheckButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*CheckButton) SetMargin

func (n *CheckButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*CheckButton) SetMaximumSize

func (n *CheckButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*CheckButton) SetOnClickWithin

func (n *CheckButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*CheckButton) SetOnFocusChanged

func (n *CheckButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*CheckButton) SetOnHoverWithin

func (n *CheckButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*CheckButton) SetOnPointer

func (n *CheckButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*CheckButton) SetOnScroll

func (n *CheckButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*CheckButton) SetSharedElement

func (n *CheckButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*CheckButton) SetSizeRequest

func (n *CheckButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*CheckButton) SetState

func (n *CheckButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*CheckButton) SetTooltip

func (n *CheckButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*CheckButton) SetTooltipMarkup

func (n *CheckButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*CheckButton) SetVAlign

func (n *CheckButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*CheckButton) SetVExpand

func (n *CheckButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*CheckButton) SetVisible

func (n *CheckButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*CheckButton) SharedElement

func (n *CheckButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*CheckButton) SizeRequest

func (n *CheckButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*CheckButton) Toggle

func (c *CheckButton) Toggle()

Toggle flips the state and fires OnChanged; a radio button only ever checks - clicking the checked one keeps it checked.

func (*CheckButton) TooltipMarkup

func (n *CheckButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*CheckButton) TooltipText

func (n *CheckButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*CheckButton) VAlign

func (n *CheckButton) VAlign() Align

VAlign returns the vertical placement.

func (*CheckButton) Visible

func (n *CheckButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Checkable

type Checkable interface {
	Activatable
	Checked() bool
}

Checkable is an Activatable with a checked state: a toggle or a radio target, rendered as a check or radio menu item.

func Toggle

func Toggle(a *StateAction[bool]) Checkable

Toggle is the Checkable that flips a bool action: a check item, a toggle button.

type Chip

type Chip struct {
	// contains filtered or unexported fields
}

Chip is a badge-shaped control: an optional leading widget, its text (or any content in its place, an entry for a renamable chip), and, while OnDismiss is set, a dismiss button that is keyboard reachable. It styles as the chip element, the dismissible class while it has the button. In a ChipBox it drags by its body.

func NewChip

func NewChip(face render.Font, text string) *Chip

NewChip returns a chip reading text.

func (*Chip) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Chip) Baseline

func (c *Chip) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Chip) Children

func (c *Chip) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Chip) DragContent

func (c *Chip) DragContent() *DragContent

DragContent implements DragSource: a chip in a ChipBox offers its move, marked dragging while it travels.

func (*Chip) HitTest

func (c *Chip) HitTest(p Point) Widget

HitTest keeps the dismiss button's and the content's controls their presses; anywhere else is the chip's own, its drag handle.

func (*Chip) Measure

func (c *Chip) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Chip) Paint

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

Paint draws the surface (when configured) then the root.

func (*Chip) SetContent

func (c *Chip) SetContent(w Widget)

SetContent shows w in place of the text, an entry or nested chips; nil restores the text.

func (*Chip) SetLeading

func (c *Chip) SetLeading(w Widget)

SetLeading puts w before the content, an icon or a swatch; nil removes it.

func (*Chip) SetOnDismiss

func (c *Chip) SetOnDismiss(fn func())

SetOnDismiss shows the dismiss button, which runs fn; nil hides it.

func (*Chip) SetText

func (c *Chip) SetText(text string)

SetText replaces the text.

func (*Chip) Text

func (c *Chip) Text() string

Text returns the text.

type ChipBox

type ChipBox struct {

	// OnMoved hears a chip moved from index from of box src (the box
	// itself for a reorder) to index to of this box.
	OnMoved func(src *ChipBox, from, to int)
	// contains filtered or unexported fields
}

ChipBox wraps its chips into lines, as a FlowBox does, and reorders them by drag. It is the chipbox element, a CSS box whose padding is part of its drop area: a chip dragged within the box or from another ChipBox lands where the drop indicator shows, and OnMoved reports the move after the box made it.

func NewChipBox

func NewChipBox() *ChipBox

NewChipBox returns an empty chip box.

func (*ChipBox) Append

func (b *ChipBox) Append(c *Chip)

Append adds c after the chips already there.

func (*ChipBox) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ChipBox) Baseline

func (c *ChipBox) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ChipBox) Children

func (c *ChipBox) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ChipBox) ChipAt

func (b *ChipBox) ChipAt(i int) *Chip

ChipAt is the chip at index i, nil out of range.

func (*ChipBox) Chips

func (b *ChipBox) Chips() []*Chip

Chips are the chips in order.

func (*ChipBox) Clear

func (b *ChipBox) Clear()

Clear removes every chip.

func (*ChipBox) DragEnter

func (b *ChipBox) DragEnter(mimes []string, p Point) string

DragEnter implements DragEnterer: this process's chips are taken.

func (*ChipBox) DragHover

func (b *ChipBox) DragHover(p Point)

DragHover implements DragHoverer: the indicator follows the pointer.

func (*ChipBox) DragLeave

func (b *ChipBox) DragLeave()

DragLeave implements DragLeaver.

func (*ChipBox) Drop

func (b *ChipBox) Drop(_ string, data []byte, p Point)

Drop implements Dropper: the chip in flight moves to the indicated place. A payload that is not the chip in flight's is ignored.

func (*ChipBox) HitTest

func (c *ChipBox) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ChipBox) IndexOf

func (b *ChipBox) IndexOf(c *Chip) int

IndexOf is c's index, -1 when it is not here.

func (*ChipBox) Insert

func (b *ChipBox) Insert(i int, c *Chip)

Insert adds c at index i (clamped).

func (*ChipBox) Len

func (b *ChipBox) Len() int

Len is the chip count.

func (*ChipBox) Measure

func (c *ChipBox) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ChipBox) Paint

func (b *ChipBox) Paint(cv *render.Canvas)

Paint draws the chips, then the drop indicator: a bar in the accent in the gap before the chip a drop lands in front of, or after the last.

func (*ChipBox) Remove

func (b *ChipBox) Remove(c *Chip) bool

Remove takes c out and reports whether it was here.

type Clamp

type Clamp struct {
	// contains filtered or unexported fields
}

Clamp centers its child at a maximum width: wider allocations pad the sides, narrower ones pass through untouched (the adw Clamp, a pure measure wrapper).

func NewClamp

func NewClamp(max int, child Widget) *Clamp

NewClamp returns a clamp over child capping its width at max.

func (*Clamp) Arrange

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

Arrange centers the child's rect inside r.

func (*Clamp) Baseline

func (c *Clamp) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Clamp) Children

func (c *Clamp) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Clamp) HitTest

func (c *Clamp) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Clamp) Maximum

func (c *Clamp) Maximum() int

Maximum reports the cap.

func (*Clamp) Measure

func (c *Clamp) Measure(axis Axis, forSize int) Sizes

Measure is the child's request with its natural width capped, and its height at the capped width.

func (*Clamp) Paint

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

Paint draws the surface (when configured) then the root.

func (*Clamp) SetMaximum

func (c *Clamp) SetMaximum(max int)

SetMaximum changes the cap.

type Clicker

type Clicker interface {
	ClickAt(p Point)
}

Clicker is invoked when a press and release land on the same widget. p is the release point in root coordinates.

type Color

type Color = render.Color

Color aliases render.Color so themes read naturally without importing render at every call site.

func ParseColor

func ParseColor(s string) (Color, error)

ParseColor reads a hex color — #rgb, #rrggbb, or #rrggbbaa, the same forms the markup parser accepts — into a premultiplied Color. It reports malformed input instead of defaulting, so a config file's mistake fails loudly at theme-construction time.

type ColorButton

type ColorButton struct {
	Button

	// Presets are the picker's swatches.
	Presets []render.Color
	// Custom, when set, lists colors for the picker's custom row.
	Custom func() []render.Color
	// OnColorSet runs when the user picked or edited a color, not on
	// SetColor.
	OnColorSet func(c render.Color)
	// contains filtered or unexported fields
}

ColorButton shows the current color as a swatch on an outline icon button and opens a SwatchPicker under itself on click: a swatch picks and closes, the picker's Custom entry edits any color in place. Presets are the swatches offered, DefaultSwatches until set; Custom, when set, lists the user's own colors under them.

func NewColorButton

func NewColorButton(face render.Font, sizePx float64, c render.Color) *ColorButton

NewColorButton returns a button showing c, its picker's text in face at sizePx.

func (*ColorButton) AccessibleName

func (n *ColorButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ColorButton) AddClass

func (n *ColorButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ColorButton) AttachStylesheet

func (n *ColorButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ColorButton) Attr

func (n *ColorButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ColorButton) BindColor

func (b *ColorButton) BindColor(binding *Binding[render.Color]) (unbind func())

BindColor wires the binding two-way to the shown color: changes show, picks write back.

func (*ColorButton) Bounds

func (n *ColorButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ColorButton) Choose

func (b *ColorButton) Choose(c render.Color)

Choose applies a color the user picked: it shows it and fires OnColorSet.

func (*ColorButton) Classes

func (n *ColorButton) Classes() []string

Classes returns a copy of the widget's classes.

func (*ColorButton) Color

func (b *ColorButton) Color() render.Color

Color returns the shown color.

func (*ColorButton) DebugName

func (n *ColorButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ColorButton) DetachStylesheet

func (n *ColorButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ColorButton) Element

func (n *ColorButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ColorButton) Enabled

func (n *ColorButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ColorButton) HAlign

func (n *ColorButton) HAlign() Align

HAlign returns the horizontal placement.

func (*ColorButton) HasClass

func (n *ColorButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ColorButton) HasState

func (n *ColorButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ColorButton) HitLeaf

func (n *ColorButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ColorButton) HoverWithin

func (n *ColorButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ColorButton) ID

func (n *ColorButton) ID() string

ID returns the style id, empty when none is set.

func (*ColorButton) InlineStyle

func (n *ColorButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ColorButton) Invalidate

func (n *ColorButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ColorButton) InvalidateLayout

func (n *ColorButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ColorButton) InvalidateRect

func (n *ColorButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ColorButton) LayoutMotion

func (n *ColorButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ColorButton) Margin

func (n *ColorButton) Margin() render.Insets

Margin returns the programmatic margin.

func (*ColorButton) MaximumSize

func (n *ColorButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ColorButton) Parent

func (n *ColorButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ColorButton) RemoveAttr

func (n *ColorButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ColorButton) RemoveClass

func (n *ColorButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ColorButton) SetAccessibleName

func (n *ColorButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ColorButton) SetAttr

func (n *ColorButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ColorButton) SetClass

func (n *ColorButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ColorButton) SetClasses

func (n *ColorButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ColorButton) SetColor

func (b *ColorButton) SetColor(c render.Color)

SetColor shows c without firing OnColorSet.

func (*ColorButton) SetCursorName

func (n *ColorButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ColorButton) SetDebugName

func (n *ColorButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ColorButton) SetElement

func (n *ColorButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ColorButton) SetEnabled

func (n *ColorButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ColorButton) SetFocusOnClick

func (n *ColorButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ColorButton) SetHAlign

func (n *ColorButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ColorButton) SetHExpand

func (n *ColorButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ColorButton) SetID

func (n *ColorButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ColorButton) SetInlineStyle

func (n *ColorButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ColorButton) SetInlineStylePriority

func (n *ColorButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ColorButton) SetLayoutMotion

func (n *ColorButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ColorButton) SetMargin

func (n *ColorButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ColorButton) SetMaximumSize

func (n *ColorButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ColorButton) SetOnClickWithin

func (n *ColorButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ColorButton) SetOnFocusChanged

func (n *ColorButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ColorButton) SetOnHoverWithin

func (n *ColorButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ColorButton) SetOnPointer

func (n *ColorButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ColorButton) SetOnScroll

func (n *ColorButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ColorButton) SetSharedElement

func (n *ColorButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ColorButton) SetSizeRequest

func (n *ColorButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ColorButton) SetState

func (n *ColorButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ColorButton) SetTooltip

func (n *ColorButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ColorButton) SetTooltipMarkup

func (n *ColorButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ColorButton) SetVAlign

func (n *ColorButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ColorButton) SetVExpand

func (n *ColorButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ColorButton) SetVisible

func (n *ColorButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ColorButton) SharedElement

func (n *ColorButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ColorButton) SizeRequest

func (n *ColorButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ColorButton) TooltipMarkup

func (n *ColorButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ColorButton) TooltipText

func (n *ColorButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ColorButton) VAlign

func (n *ColorButton) VAlign() Align

VAlign returns the vertical placement.

func (*ColorButton) Visible

func (n *ColorButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ColorChooser

type ColorChooser struct {

	// OnChanged fires after every applied color change, whatever
	// produced it.
	OnChanged func(render.Color)
	// contains filtered or unexported fields
}

ColorChooser edits one color end to end: an SV square with a hue strip and an alpha strip beside it, a hex entry, and two palette rows (theme-derived presets and custom picks). OnChanged fires with the straight (non-premultiplied) color on every applied change; the SV square is two stacked linear gradients — white to hue, transparent to black — composited through the canvas's exact premultiplied blending, a shader-less SV square.

Pointer: drags on the square and both strips track the pointer; a click on a swatch picks it; the hex entry parses on change (#RGB, #RRGGBB, #RRGGBBAA, with or without the #). Keyboard: arrows move saturation (horizontal) and value (vertical), shift+arrows move the hue, PageUp/PageDown step alpha, and the entry types hex directly - the chooser is fully operable without the pointer.

func NewColorChooser

func NewColorChooser(face render.Font, sizePx float64, initial render.Color) *ColorChooser

NewColorChooser returns a chooser editing initial (its alpha comes along), preset swatches derived from the current theme.

func (*ColorChooser) AccessibleName

func (n *ColorChooser) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ColorChooser) AddClass

func (n *ColorChooser) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ColorChooser) Arrange

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

Arrange records the rect and places the hex entry and the + button.

func (*ColorChooser) AttachStylesheet

func (n *ColorChooser) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ColorChooser) Attr

func (n *ColorChooser) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ColorChooser) Bounds

func (n *ColorChooser) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ColorChooser) Children

func (c *ColorChooser) Children() []Widget

Children exposes the entry (and the + and pick buttons when their sources are wired) for focus traversal.

func (*ColorChooser) Classes

func (n *ColorChooser) Classes() []string

Classes returns a copy of the widget's classes.

func (*ColorChooser) ClickAt

func (c *ColorChooser) ClickAt(p Point)

ClickAt applies one press-release: the square and strips set their component from the point, a swatch picks its color.

func (*ColorChooser) Color

func (c *ColorChooser) Color() render.Color

Color returns the current color with its alpha.

func (*ColorChooser) DebugName

func (n *ColorChooser) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ColorChooser) DetachStylesheet

func (n *ColorChooser) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ColorChooser) DragMove

func (c *ColorChooser) DragMove(p Point)

DragMove tracks drags across the square and strips exactly like ClickAt. Disabled choosers do not drag.

func (*ColorChooser) Element

func (n *ColorChooser) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ColorChooser) Enabled

func (n *ColorChooser) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ColorChooser) HAlign

func (n *ColorChooser) HAlign() Align

HAlign returns the horizontal placement.

func (*ColorChooser) HasClass

func (n *ColorChooser) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ColorChooser) HasState

func (n *ColorChooser) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ColorChooser) HitLeaf

func (n *ColorChooser) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ColorChooser) HitTest

func (c *ColorChooser) HitTest(p Point) Widget

HitTest returns the entry or the + button under p, else the chooser (the square, strips, and swatches are its own geometry).

func (*ColorChooser) HoverWithin

func (n *ColorChooser) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ColorChooser) ID

func (n *ColorChooser) ID() string

ID returns the style id, empty when none is set.

func (*ColorChooser) InlineStyle

func (n *ColorChooser) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ColorChooser) Invalidate

func (n *ColorChooser) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ColorChooser) InvalidateLayout

func (n *ColorChooser) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ColorChooser) InvalidateRect

func (n *ColorChooser) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ColorChooser) KeyAction

func (c *ColorChooser) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: arrows move saturation and value, shift+arrows the hue, PageUp/PageDown step alpha, Home and End pin saturation. Disabled choosers ignore keys.

func (*ColorChooser) LayoutMotion

func (n *ColorChooser) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ColorChooser) Margin

func (n *ColorChooser) Margin() render.Insets

Margin returns the programmatic margin.

func (*ColorChooser) MaximumSize

func (n *ColorChooser) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ColorChooser) Measure

func (c *ColorChooser) Measure(axis Axis, forSize int) Sizes

Measure wants the SV square (160) plus the strips (24 + gaps), the entry row, and the two palette rows.

func (*ColorChooser) Paint

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

Paint draws the SV square as two stacked gradients, both strips, the cursors, and the palette rows - the square's arithmetic is the canvas's own premultiplied source-over.

func (*ColorChooser) Parent

func (n *ColorChooser) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ColorChooser) RemoveAttr

func (n *ColorChooser) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ColorChooser) RemoveClass

func (n *ColorChooser) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ColorChooser) Role

func (c *ColorChooser) Role() Role

Role implements Roleer.

func (*ColorChooser) SetAccessibleName

func (n *ColorChooser) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ColorChooser) SetAttr

func (n *ColorChooser) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ColorChooser) SetClass

func (n *ColorChooser) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ColorChooser) SetClasses

func (n *ColorChooser) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ColorChooser) SetColor

func (c *ColorChooser) SetColor(col render.Color)

SetColor applies col (firing OnChanged once) — the programmatic path.

func (*ColorChooser) SetCursorName

func (n *ColorChooser) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ColorChooser) SetDebugName

func (n *ColorChooser) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ColorChooser) SetElement

func (n *ColorChooser) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ColorChooser) SetEnabled

func (n *ColorChooser) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ColorChooser) SetEyedropper

func (c *ColorChooser) SetEyedropper(start func())

SetEyedropper wires the pick-from-screen button: start begins a screen color pick (the application's captured-screen flow, #84); without it the button stays hidden - swatches-only.

func (*ColorChooser) SetFocusOnClick

func (n *ColorChooser) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ColorChooser) SetHAlign

func (n *ColorChooser) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ColorChooser) SetHExpand

func (n *ColorChooser) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ColorChooser) SetID

func (n *ColorChooser) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ColorChooser) SetInlineStyle

func (n *ColorChooser) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ColorChooser) SetInlineStylePriority

func (n *ColorChooser) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ColorChooser) SetLayoutMotion

func (n *ColorChooser) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ColorChooser) SetMargin

func (n *ColorChooser) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ColorChooser) SetMaximumSize

func (n *ColorChooser) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ColorChooser) SetOnClickWithin

func (n *ColorChooser) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ColorChooser) SetOnFocusChanged

func (n *ColorChooser) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ColorChooser) SetOnHoverWithin

func (n *ColorChooser) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ColorChooser) SetOnPointer

func (n *ColorChooser) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ColorChooser) SetOnScroll

func (n *ColorChooser) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ColorChooser) SetPaletteSource

func (c *ColorChooser) SetPaletteSource(colors func() []render.Color, add func(render.Color))

SetPaletteSource wires the chooser's custom-palette view: colors lists the session's picks and add records a new one (the chooser calls it from the + button). Without a source the custom row stays empty and the button is hidden.

func (*ColorChooser) SetSharedElement

func (n *ColorChooser) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ColorChooser) SetSizeRequest

func (n *ColorChooser) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ColorChooser) SetState

func (n *ColorChooser) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ColorChooser) SetTooltip

func (n *ColorChooser) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ColorChooser) SetTooltipMarkup

func (n *ColorChooser) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ColorChooser) SetVAlign

func (n *ColorChooser) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ColorChooser) SetVExpand

func (n *ColorChooser) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ColorChooser) SetVisible

func (n *ColorChooser) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ColorChooser) SharedElement

func (n *ColorChooser) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ColorChooser) SizeRequest

func (n *ColorChooser) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ColorChooser) TooltipMarkup

func (n *ColorChooser) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ColorChooser) TooltipText

func (n *ColorChooser) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ColorChooser) VAlign

func (n *ColorChooser) VAlign() Align

VAlign returns the vertical placement.

func (*ColorChooser) Visible

func (n *ColorChooser) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ColorSwatch

type ColorSwatch struct {
	// contains filtered or unexported fields
}

ColorSwatch is a chip of one color: the colorswatch element, sized by its min-width and min-height, with the theme's radius and border, a checkerboard under a translucent color, and a ring while selected (the :selected state).

func NewColorSwatch

func NewColorSwatch(c render.Color) *ColorSwatch

NewColorSwatch returns a swatch of c.

func (*ColorSwatch) AccessibleName

func (n *ColorSwatch) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ColorSwatch) AddClass

func (n *ColorSwatch) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ColorSwatch) Arrange

func (n *ColorSwatch) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*ColorSwatch) AttachStylesheet

func (n *ColorSwatch) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ColorSwatch) Attr

func (n *ColorSwatch) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ColorSwatch) Bounds

func (n *ColorSwatch) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ColorSwatch) Classes

func (n *ColorSwatch) Classes() []string

Classes returns a copy of the widget's classes.

func (*ColorSwatch) Color

func (s *ColorSwatch) Color() render.Color

Color returns the shown color.

func (*ColorSwatch) DebugName

func (n *ColorSwatch) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ColorSwatch) DetachStylesheet

func (n *ColorSwatch) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ColorSwatch) Element

func (n *ColorSwatch) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ColorSwatch) Enabled

func (n *ColorSwatch) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ColorSwatch) HAlign

func (n *ColorSwatch) HAlign() Align

HAlign returns the horizontal placement.

func (*ColorSwatch) HasClass

func (n *ColorSwatch) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ColorSwatch) HasState

func (n *ColorSwatch) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ColorSwatch) HitLeaf

func (n *ColorSwatch) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ColorSwatch) HitTest

func (s *ColorSwatch) HitTest(p Point) Widget

HitTest returns the swatch inside its bounds.

func (*ColorSwatch) HoverWithin

func (n *ColorSwatch) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ColorSwatch) ID

func (n *ColorSwatch) ID() string

ID returns the style id, empty when none is set.

func (*ColorSwatch) InlineStyle

func (n *ColorSwatch) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ColorSwatch) Invalidate

func (n *ColorSwatch) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ColorSwatch) InvalidateLayout

func (n *ColorSwatch) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ColorSwatch) InvalidateRect

func (n *ColorSwatch) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ColorSwatch) LayoutMotion

func (n *ColorSwatch) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ColorSwatch) Margin

func (n *ColorSwatch) Margin() render.Insets

Margin returns the programmatic margin.

func (*ColorSwatch) MaximumSize

func (n *ColorSwatch) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ColorSwatch) Measure

func (s *ColorSwatch) Measure(axis Axis, forSize int) Sizes

Measure wants the min-width by min-height border box.

func (*ColorSwatch) Paint

func (s *ColorSwatch) Paint(cv *render.Canvas)

Paint draws the box, then the color over a checkerboard inside the border.

func (*ColorSwatch) Parent

func (n *ColorSwatch) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ColorSwatch) RemoveAttr

func (n *ColorSwatch) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ColorSwatch) RemoveClass

func (n *ColorSwatch) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ColorSwatch) Selected

func (s *ColorSwatch) Selected() bool

Selected reports whether the swatch is ringed.

func (*ColorSwatch) SetAccessibleName

func (n *ColorSwatch) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ColorSwatch) SetAttr

func (n *ColorSwatch) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ColorSwatch) SetClass

func (n *ColorSwatch) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ColorSwatch) SetClasses

func (n *ColorSwatch) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ColorSwatch) SetColor

func (s *ColorSwatch) SetColor(c render.Color)

SetColor shows c.

func (*ColorSwatch) SetCursorName

func (n *ColorSwatch) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ColorSwatch) SetDebugName

func (n *ColorSwatch) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ColorSwatch) SetElement

func (n *ColorSwatch) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ColorSwatch) SetEnabled

func (n *ColorSwatch) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ColorSwatch) SetFocusOnClick

func (n *ColorSwatch) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ColorSwatch) SetHAlign

func (n *ColorSwatch) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ColorSwatch) SetHExpand

func (n *ColorSwatch) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ColorSwatch) SetID

func (n *ColorSwatch) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ColorSwatch) SetInlineStyle

func (n *ColorSwatch) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ColorSwatch) SetInlineStylePriority

func (n *ColorSwatch) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ColorSwatch) SetLayoutMotion

func (n *ColorSwatch) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ColorSwatch) SetMargin

func (n *ColorSwatch) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ColorSwatch) SetMaximumSize

func (n *ColorSwatch) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ColorSwatch) SetOnClickWithin

func (n *ColorSwatch) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ColorSwatch) SetOnFocusChanged

func (n *ColorSwatch) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ColorSwatch) SetOnHoverWithin

func (n *ColorSwatch) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ColorSwatch) SetOnPointer

func (n *ColorSwatch) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ColorSwatch) SetOnScroll

func (n *ColorSwatch) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ColorSwatch) SetSelected

func (s *ColorSwatch) SetSelected(on bool)

SetSelected rings the swatch as the current pick.

func (*ColorSwatch) SetSharedElement

func (n *ColorSwatch) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ColorSwatch) SetSizeRequest

func (n *ColorSwatch) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ColorSwatch) SetState

func (n *ColorSwatch) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ColorSwatch) SetTooltip

func (n *ColorSwatch) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ColorSwatch) SetTooltipMarkup

func (n *ColorSwatch) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ColorSwatch) SetVAlign

func (n *ColorSwatch) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ColorSwatch) SetVExpand

func (n *ColorSwatch) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ColorSwatch) SetVisible

func (n *ColorSwatch) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ColorSwatch) SharedElement

func (n *ColorSwatch) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ColorSwatch) SizeRequest

func (n *ColorSwatch) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ColorSwatch) TooltipMarkup

func (n *ColorSwatch) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ColorSwatch) TooltipText

func (n *ColorSwatch) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ColorSwatch) VAlign

func (n *ColorSwatch) VAlign() Align

VAlign returns the vertical placement.

func (*ColorSwatch) Visible

func (n *ColorSwatch) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ColumnModel

type ColumnModel[T any] interface {
	Len() int
	Row(i int) T
}

ColumnModel is the table's data source, ListModel's typed sibling.

type ColumnView

type ColumnView[T any] struct {

	// OnRowReorder, when set, receives drag-and-drop row moves: from
	// and to are visible indices (post sort/filter), fired on the loop
	// goroutine. The application performs the move in its model - the
	// view never mutates data it does not own.
	OnRowReorder func(from, to int)
	// contains filtered or unexported fields
}

ColumnView is the virtualized table (#90): typed columns over a ColumnModel, a header row with sort indicators, sort and filter in one stable permutation, tree indentation through the tree helpers, and optional row drag reordering. List underneath does what List is for - virtualization, selection, keyboard - through the same model adapter, so a million rows cost about what twenty do.

The model layer is the GIO list-model analog, shared with the typed views (#166): sorting and a stack of toggleable filters never touch the source model, they live in a permutation of its row indices - stable (equal rows keep source order), recomputed on SortBy/SetFilter/SetModel/AddFilter/SetFilterStatus/PopFilter/ ClearFilters, and the source's own order is one call away.

func NewColumnView

func NewColumnView[T any](face render.Font, sizePx float64, model ColumnModel[T], cols []TableColumn[T]) *ColumnView[T]

NewColumnView returns a view over model with the given columns.

func (*ColumnView[T]) AddFilter

func (v *ColumnView[T]) AddFilter(keep func(T) bool) *ViewFilter[T]

AddFilter appends a filter to the stack and returns its handle; every enabled filter must accept a row for it to show.

func (*ColumnView) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ColumnView) Baseline

func (c *ColumnView) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ColumnView) Children

func (c *ColumnView) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ColumnView[T]) ClearFilters

func (v *ColumnView[T]) ClearFilters()

ClearFilters drops every filter, SetFilter's slot included.

func (*ColumnView[T]) EnableRowDrag

func (v *ColumnView[T]) EnableRowDrag(on bool)

EnableRowDrag turns row drag-and-drop on: rows become drag sources offering the internal reorder mime, and a row dropped on another fires OnRowReorder with the two visible indices.

func (*ColumnView) HitTest

func (c *ColumnView) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ColumnView[T]) List

func (v *ColumnView[T]) List() *List

List exposes the underlying list - selection, activation, keyboard, scrolling - the same surface a plain List gives.

func (*ColumnView[T]) Matching

func (v *ColumnView[T]) Matching() int

Matching reports how many rows pass the filters, the window aside.

func (*ColumnView) Measure

func (c *ColumnView) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ColumnView) Paint

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

Paint draws the surface (when configured) then the root.

func (*ColumnView[T]) PopFilter

func (v *ColumnView[T]) PopFilter()

PopFilter drops the most recently added filter.

func (*ColumnView[T]) Row

func (v *ColumnView[T]) Row(i int) T

Row returns the data of visible row i (post sort, filter and window).

func (*ColumnView[T]) Rows

func (v *ColumnView[T]) Rows() int

Rows reports the visible row count: the window's share of the matching rows.

func (*ColumnView[T]) SetColumns

func (v *ColumnView[T]) SetColumns(cols []TableColumn[T])

SetColumns replaces the columns: a column toggled visible or hidden. The sort stays on the column it was on when that column remains.

func (*ColumnView[T]) SetFilter

func (v *ColumnView[T]) SetFilter(keep func(T) bool)

SetFilter narrows the view to rows keep accepts (nil clears); the source model is untouched and the sort stays. It is one slot in the filter stack: AddFilter/SetFilterStatus/PopFilter/ClearFilters manage the rest alongside it.

func (*ColumnView[T]) SetFilterStatus

func (v *ColumnView[T]) SetFilterStatus(f *ViewFilter[T], on bool)

SetFilterStatus turns a filter AddFilter returned on or off without dropping it.

func (*ColumnView[T]) SetModel

func (v *ColumnView[T]) SetModel(m ColumnModel[T])

SetModel replaces the data source and drops the sort/filter permutation back to the source order.

func (*ColumnView[T]) SetWindow

func (v *ColumnView[T]) SetWindow(offset, limit int)

SetWindow shows only limit of the sorted, filtered rows from offset on - a page of them; limit 0 shows them all.

func (*ColumnView[T]) SortBy

func (v *ColumnView[T]) SortBy(col int, desc bool)

SortBy sorts by column col (descending with desc); col -1 returns to the source order. A column without a Sort function clears the sort instead.

func (*ColumnView[T]) SortedBy

func (v *ColumnView[T]) SortedBy() (col int, ascending bool)

SortedBy reports the active sort column (-1 when none) and its direction.

func (*ColumnView[T]) SourceIndex

func (v *ColumnView[T]) SourceIndex(i int) int

SourceIndex maps visible row i to its row in the model, -1 when out of range.

type ComboEntry

type ComboEntry struct {
	*Entry

	// OnSelected fires with the picked item (arrow keys, Enter, or a
	// click in the list) - a choice, unlike free typing.
	OnSelected func(item string)
	// contains filtered or unexported fields
}

ComboEntry is the editable dropdown, GTK's ComboBox-with-entry: an Entry whose completion lists the items (prefix match, case-insensitive), a trailing chevron toggling the full list, and OnSelected for the pick. Free text stays free - typing an unmatched value is valid input, exactly like the GTK original.

func NewComboEntry

func NewComboEntry(face render.Font, sizePx float64, items []string, selected string) *ComboEntry

NewComboEntry returns an editable dropdown over items, its text starting at selected ("" for empty).

func (ComboEntry) AccessibleName

func (n ComboEntry) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (ComboEntry) AddClass

func (n ComboEntry) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (ComboEntry) AttachStylesheet

func (n ComboEntry) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (ComboEntry) Attr

func (n ComboEntry) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (ComboEntry) Bounds

func (n ComboEntry) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (ComboEntry) Classes

func (n ComboEntry) Classes() []string

Classes returns a copy of the widget's classes.

func (ComboEntry) DebugName

func (n ComboEntry) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (ComboEntry) DetachStylesheet

func (n ComboEntry) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (ComboEntry) Element

func (n ComboEntry) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (ComboEntry) Enabled

func (n ComboEntry) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (ComboEntry) HAlign

func (n ComboEntry) HAlign() Align

HAlign returns the horizontal placement.

func (ComboEntry) HasClass

func (n ComboEntry) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (ComboEntry) HasState

func (n ComboEntry) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (ComboEntry) HitLeaf

func (n ComboEntry) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (ComboEntry) HoverWithin

func (n ComboEntry) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (ComboEntry) ID

func (n ComboEntry) ID() string

ID returns the style id, empty when none is set.

func (ComboEntry) InlineStyle

func (n ComboEntry) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (ComboEntry) Invalidate

func (n ComboEntry) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (ComboEntry) InvalidateLayout

func (n ComboEntry) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (ComboEntry) InvalidateRect

func (n ComboEntry) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (ComboEntry) LayoutMotion

func (n ComboEntry) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (ComboEntry) Margin

func (n ComboEntry) Margin() render.Insets

Margin returns the programmatic margin.

func (ComboEntry) MaximumSize

func (n ComboEntry) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (ComboEntry) Parent

func (n ComboEntry) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (ComboEntry) RemoveAttr

func (n ComboEntry) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (ComboEntry) RemoveClass

func (n ComboEntry) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (ComboEntry) SetAccessibleName

func (n ComboEntry) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (ComboEntry) SetAttr

func (n ComboEntry) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (ComboEntry) SetClass

func (n ComboEntry) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (ComboEntry) SetClasses

func (n ComboEntry) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (ComboEntry) SetCursorName

func (n ComboEntry) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (ComboEntry) SetDebugName

func (n ComboEntry) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (ComboEntry) SetElement

func (n ComboEntry) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (ComboEntry) SetEnabled

func (n ComboEntry) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (ComboEntry) SetFocusOnClick

func (n ComboEntry) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (ComboEntry) SetHAlign

func (n ComboEntry) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (ComboEntry) SetHExpand

func (n ComboEntry) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (ComboEntry) SetID

func (n ComboEntry) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (ComboEntry) SetInlineStyle

func (n ComboEntry) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (ComboEntry) SetInlineStylePriority

func (n ComboEntry) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ComboEntry) SetItems

func (c *ComboEntry) SetItems(items []string)

SetItems replaces the item list; the field's text is untouched.

func (ComboEntry) SetLayoutMotion

func (n ComboEntry) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (ComboEntry) SetMargin

func (n ComboEntry) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (ComboEntry) SetMaximumSize

func (n ComboEntry) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (ComboEntry) SetOnClickWithin

func (n ComboEntry) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (ComboEntry) SetOnFocusChanged

func (n ComboEntry) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (ComboEntry) SetOnHoverWithin

func (n ComboEntry) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (ComboEntry) SetOnPointer

func (n ComboEntry) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (ComboEntry) SetOnScroll

func (n ComboEntry) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (ComboEntry) SetSharedElement

func (n ComboEntry) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (ComboEntry) SetSizeRequest

func (n ComboEntry) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (ComboEntry) SetState

func (n ComboEntry) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (ComboEntry) SetTooltip

func (n ComboEntry) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (ComboEntry) SetTooltipMarkup

func (n ComboEntry) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (ComboEntry) SetVAlign

func (n ComboEntry) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (ComboEntry) SetVExpand

func (n ComboEntry) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (ComboEntry) SetVisible

func (n ComboEntry) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (ComboEntry) SharedElement

func (n ComboEntry) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (ComboEntry) SizeRequest

func (n ComboEntry) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (ComboEntry) TooltipMarkup

func (n ComboEntry) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (ComboEntry) TooltipText

func (n ComboEntry) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (ComboEntry) VAlign

func (n ComboEntry) VAlign() Align

VAlign returns the vertical placement.

func (ComboEntry) Visible

func (n ComboEntry) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ComboRow

type ComboRow struct {
	*ActionRow
	// contains filtered or unexported fields
}

ComboRow is an ActionRow with a Dropdown in its end slot; the selection shows on the row's face.

func NewComboRow

func NewComboRow(face render.Font, sizePx float64, title, subtitle string, items []string, selected int, on func(i int)) *ComboRow

NewComboRow returns the row over items with selected picked; on, when set, receives selection changes.

func (ComboRow) Arrange

func (c ComboRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (ComboRow) Baseline

func (c ComboRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (ComboRow) Children

func (c ComboRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ComboRow) Dropdown

func (r *ComboRow) Dropdown() *Dropdown

Dropdown returns the embedded control.

func (ComboRow) HitTest

func (c ComboRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (ComboRow) Measure

func (c ComboRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (ComboRow) PackEnd

func (p ComboRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (ComboRow) PackStart

func (p ComboRow) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*ComboRow) Selected

func (r *ComboRow) Selected() int

Selected reports the selection index.

func (*ComboRow) SetSelected

func (r *ComboRow) SetSelected(i int)

SetSelected selects i, firing on like every selection change (the Dropdown fires OnSelect whatever the source).

type Combobox

type Combobox[T comparable] struct {

	// OnChanged fires with the selection after the user changed it.
	OnChanged func(selected []T)
	// contains filtered or unexported fields
}

Combobox picks typed values from a searchable list: an outline button showing the selection that opens a Command of the options in a popover, a check trailing each selected one. A single-choice combobox closes on a pick, and picking the selected option clears it; a multiple-choice one toggles the picked option and stays open. It styles as the `combobox` element: the button.outline trigger and its .placeholder text.

func NewCombobox

func NewCombobox[T comparable](face render.Font, placeholder string, options ...ComboboxOption[T]) *Combobox[T]

NewCombobox returns a single-choice combobox over options showing placeholder while nothing is selected.

func (*Combobox) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Combobox) Baseline

func (c *Combobox) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Combobox) Children

func (c *Combobox) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Combobox) HitTest

func (c *Combobox) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Combobox) Measure

func (c *Combobox) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Combobox) Paint

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

Paint draws the surface (when configured) then the root.

func (*Combobox[T]) Selected

func (c *Combobox[T]) Selected() []T

Selected returns the selected values in option order.

func (*Combobox[T]) SetMultiple

func (c *Combobox[T]) SetMultiple(on bool)

SetMultiple lets the user pick any number of options.

func (*Combobox[T]) SetSelected

func (c *Combobox[T]) SetSelected(values ...T)

SetSelected selects values, which must all be options' values, or the call panics. It reports nothing.

type ComboboxOption

type ComboboxOption[T comparable] struct {
	Value T
	Label string
}

ComboboxOption is one choice of a Combobox: the typed value it picks and the label it shows and is searched by.

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command is a searchable list of actions: a search entry over grouped items that filters them fuzzily as the query is typed, ranking the best matches first within each group and the groups by their best, with an empty state when nothing matches. Up, Down, Home and End move the highlight while the entry keeps the focus; Enter or a click picks the highlighted item. A list built with NewCommandList has no search row: it takes the focus itself, moves the highlight on the same keys, picks on Enter or Space, and jumps by type-ahead on printable keys. It works inline or as a popover's or dialog's content. It styles as the `command` element: the .input row, .heading labels, .item rows (:selected while highlighted), .shortcut labels, .separator lines and the .empty label.

func NewCommand

func NewCommand(face render.Font, placeholder string, groups ...CommandGroup) *Command

NewCommand returns a command over groups whose search entry shows placeholder.

func NewCommandList

func NewCommandList(face render.Font, groups ...CommandGroup) *Command

NewCommandList returns a command over groups with no search row: a pick list, such as a dropdown's, that is its own focus target.

func (*Command) Arrange

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

Arrange lays the command out and reveals a highlight set before its rows had a place.

func (*Command) Baseline

func (c *Command) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Command) Children

func (c *Command) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Command) FocusTarget

func (c *Command) FocusTarget() Widget

FocusTarget returns the widget the keyboard focus belongs on: the search entry, or the command itself when it has no search row.

func (*Command) Highlighted

func (c *Command) Highlighted() (CommandItem, bool)

Highlighted returns the highlighted item and whether there is one.

func (*Command) HitTest

func (c *Command) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Command) InsertRune

func (c *Command) InsertRune(r rune)

InsertRune implements RuneHandler for a command without a search row: Space picks the highlighted item, the other half of the activation pair, and every other printable rune jumps the highlight by type-ahead over the pickable items.

func (*Command) InterceptKey

func (c *Command) InterceptKey(target Widget, a KeyAction, _ Mods) bool

InterceptKey implements KeyInterceptor: while the search entry has the focus, the navigation keys move the highlight and Enter picks.

func (*Command) KeyAction

func (c *Command) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: a command without a search row holds the focus itself and navigates on its own keys.

func (*Command) Measure

func (c *Command) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Command) Paint

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

Paint draws the surface (when configured) then the root.

func (*Command) Query

func (c *Command) Query() string

Query returns the search text, empty without a search row.

func (*Command) SetEmptyText

func (c *Command) SetEmptyText(s string)

SetEmptyText replaces the text shown when nothing matches.

func (*Command) SetGroups

func (c *Command) SetGroups(groups ...CommandGroup)

SetGroups replaces the groups and clears the query.

func (*Command) SetQuery

func (c *Command) SetQuery(q string)

SetQuery replaces the search text and filters by it. A command without a search row has no query to set, and panics.

type CommandGroup

type CommandGroup struct {
	Heading string
	Items   []CommandItem
}

CommandGroup is a headed run of items; an empty heading shows none.

type CommandItem

type CommandItem struct {
	// Label is the text shown and matched.
	Label string
	// Keywords are extra terms the search matches the item by.
	Keywords []string
	// Shortcut is the keys shown at the row's end, display only.
	Shortcut string
	// Icon leads the row; nil shows none.
	Icon Widget
	// Trailing ends the row, after the shortcut; nil shows none.
	Trailing Widget
	// OnSelect runs when the item is picked.
	OnSelect func()
	// Disabled shows the item without letting it be picked.
	Disabled bool
}

CommandItem is one entry of a Command.

type ContentPaster

type ContentPaster interface {
	PasteMimes() []string
	PasteContent(mime string, data []byte)
}

ContentPaster takes ctrl+v content in formats of its own instead of text: PasteMimes lists the mimes it reads, best first, and PasteContent receives the best one the clipboard offers. widget.Image reads images (decoding off the loop goroutine); a file list would read transfer.MimeURIList. Holding this interface is what makes a widget a non-text paste target.

type ContextMenu

type ContextMenu struct {
	// contains filtered or unexported fields
}

ContextMenu gives a region a context menu: a right click anywhere on its child, a long press, or the Menu key (Shift+F10) while something inside it has the focus opens items as a menu at the pointer - submenus, check and radio items and shortcuts included, as Menu renders them. It styles as the `contextmenu` element.

func NewContextMenu

func NewContextMenu(face render.Font, child Widget, items ...MenuItem) *ContextMenu

NewContextMenu wraps child with a context menu of items.

func (*ContextMenu) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ContextMenu) Baseline

func (c *ContextMenu) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ContextMenu) Children

func (c *ContextMenu) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ContextMenu) Gesture

func (c *ContextMenu) Gesture(g Gesture) bool

Gesture implements GestureHandler: a long press opens the menu where the finger is.

func (*ContextMenu) HitTest

func (c *ContextMenu) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ContextMenu) Items

func (c *ContextMenu) Items() []MenuItem

Items returns the menu's items.

func (*ContextMenu) Measure

func (c *ContextMenu) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ContextMenu) OpenContextMenu

func (c *ContextMenu) OpenContextMenu(at Point)

OpenContextMenu implements ContextMenuOpener: the menu opens at at.

func (*ContextMenu) Paint

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

Paint draws the surface (when configured) then the root.

func (*ContextMenu) SetItems

func (c *ContextMenu) SetItems(items ...MenuItem)

SetItems replaces the menu's items.

type ContextMenuOpener

type ContextMenuOpener interface {
	OpenContextMenu(at Point)
}

ContextMenuOpener is a widget that opens a context menu for itself and its descendants: a right click on one of them, a long press, or the Menu key (Shift+F10) while one has the focus. at is where the menu opens, the pointer or the focused widget's center.

type CursorNamer

type CursorNamer interface {
	// CursorName returns the xcursor shape for the hovered widget.
	CursorName() string
}

CursorNamer lets a widget request a pointer shape while hovered, using xcursor names ("xterm" for text, "left_ptr" arrow default).

type DataTable

type DataTable[T any] struct {

	// OnSelectionChanged fires with the selected model rows, ascending,
	// after the user changed them.
	OnSelectionChanged func(rows []int)
	// contains filtered or unexported fields
}

DataTable is a data table on a ColumnView: a text filter over the rows, a Columns menu that hides and shows columns, sorting by the sortable columns' headers, row selection with a check column (the header check selecting the page), and pages of rows with a pager and a count of the selected rows under the table. The rows stay virtualized: a page of a million rows costs what a page of ten does. Selection is by row of the model, so it survives paging, sorting and filtering. It styles as the `datatable` element: the .toolbar row, the .table box, and the .footer row.

func NewDataTable

func NewDataTable[T any](face render.Font, model ColumnModel[T], cols []TableColumn[T], match func(row T, query string) bool) *DataTable[T]

NewDataTable returns a table over model's rows in cols; match decides whether a row passes the filter's text (nil hides the filter).

func (*DataTable) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*DataTable) Baseline

func (c *DataTable) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*DataTable) Children

func (c *DataTable) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*DataTable[T]) ColumnVisible

func (t *DataTable[T]) ColumnVisible(i int) bool

ColumnVisible reports data column i shown.

func (*DataTable) HitTest

func (c *DataTable) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*DataTable) Measure

func (c *DataTable) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*DataTable[T]) Page

func (t *DataTable[T]) Page() int

Page returns the shown page, from 1.

func (*DataTable) Paint

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

Paint draws the surface (when configured) then the root.

func (*DataTable[T]) Selected

func (t *DataTable[T]) Selected() []int

Selected returns the selected model rows, ascending.

func (*DataTable[T]) SetColumnVisible

func (t *DataTable[T]) SetColumnVisible(i int, on bool)

SetColumnVisible shows or hides data column i (in the order the table was given them).

func (*DataTable[T]) SetPageSize

func (t *DataTable[T]) SetPageSize(n int)

SetPageSize shows n rows a page, at least one.

func (*DataTable[T]) SortBy

func (t *DataTable[T]) SortBy(i int, desc bool)

SortBy sorts by data column i (in the order the table was given them; descending with desc), or returns to the model's order for -1 or a hidden or unsortable column.

func (*DataTable[T]) View

func (t *DataTable[T]) View() *ColumnView[T]

View returns the table's column view.

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

Date is a calendar day: a year, month and day with no time of day and no zone, so it means the same day wherever it is read. The zero Date is no date.

func DateOf

func DateOf(t time.Time) Date

DateOf is t's calendar day in t's own location.

func Today

func Today() Date

Today is the local calendar day now, the one reading of the clock and zone the calendar widgets make (see Calendar.SetToday).

func (Date) AddDays

func (d Date) AddDays(n int) Date

AddDays is the day n days on (back for negative n).

func (Date) AddMonths

func (d Date) AddMonths(n int) Date

AddMonths is the same day n months on, clamped to that month's length: January 31 plus one month is the last of February.

func (Date) Before

func (d Date) Before(o Date) bool

Before reports d earlier than o.

func (Date) Compare

func (d Date) Compare(o Date) int

Compare orders days: -1 when d is earlier than o, 0 when the same, +1 when later.

func (Date) FirstOfMonth

func (d Date) FirstOfMonth() Date

FirstOfMonth is the first day of d's month.

func (Date) IsZero

func (d Date) IsZero() bool

IsZero reports the zero Date.

func (Date) String

func (d Date) String() string

String is the ISO 8601 day, 2026-10-24.

func (Date) Time

func (d Date) Time() time.Time

Time is the day's midnight in UTC.

func (Date) Weekday

func (d Date) Weekday() time.Weekday

Weekday is the day of the week.

type DatePicker

type DatePicker struct {

	// OnDate fires with a single-date picker's pick; OnRange with a
	// range picker's, once both ends are picked; OnTime with the time
	// the user set. None fires for the setters.
	OnDate  func(Date)
	OnRange func(from, to Date)
	OnTime  func(TimeOfDay)
	// contains filtered or unexported fields
}

DatePicker is a date field: an outline button showing the picked date - or range - formatted for the locale, that opens a Calendar in a popover. A single-date picker closes on a pick; a range picker shows two months and closes once the range has both ends. Presets list ready-made picks beside the calendar, and SetTimeInput adds an hour and minute under it. Dates are widget.Date and times TimeOfDay, so nothing depends on the local zone. It styles as the `datepicker` element: the button.outline trigger and its .placeholder text.

func NewDatePicker

func NewDatePicker(face render.Font, placeholder string) *DatePicker

NewDatePicker returns a single-date picker showing placeholder until a date is picked.

func (*DatePicker) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*DatePicker) Baseline

func (c *DatePicker) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*DatePicker) Children

func (c *DatePicker) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*DatePicker) Date

func (p *DatePicker) Date() Date

Date returns a single-date picker's date, zero when none.

func (*DatePicker) HitTest

func (c *DatePicker) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*DatePicker) Measure

func (c *DatePicker) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*DatePicker) Paint

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

Paint draws the surface (when configured) then the root.

func (*DatePicker) Range

func (p *DatePicker) Range() (from, to Date)

Range returns a range picker's range.

func (*DatePicker) SetDate

func (p *DatePicker) SetDate(d Date)

SetDate sets a single-date picker's date; zero clears it.

func (*DatePicker) SetMode

func (p *DatePicker) SetMode(m CalendarMode)

SetMode switches between picking a date and a range; the picks clear.

func (*DatePicker) SetNames

func (p *DatePicker) SetNames(names CalendarNames)

SetNames localizes the calendar and the formatting; nil reads the message catalog (CalendarCatalog).

func (*DatePicker) SetPresets

func (p *DatePicker) SetPresets(presets ...DatePreset)

SetPresets lists ready-made picks beside the calendar.

func (*DatePicker) SetRange

func (p *DatePicker) SetRange(from, to Date)

SetRange sets a range picker's range, the earlier day starting it.

func (*DatePicker) SetTime

func (p *DatePicker) SetTime(t TimeOfDay)

SetTime sets the time; it must be a valid wall-clock time, or the call panics.

func (*DatePicker) SetTimeInput

func (p *DatePicker) SetTimeInput(on bool)

SetTimeInput adds an hour and minute under the calendar, shown on the trigger after the date.

func (*DatePicker) Time

func (p *DatePicker) Time() TimeOfDay

Time returns the time.

type DatePreset

type DatePreset struct {
	Label    string
	From, To Date
}

DatePreset is a ready-made pick beside a DatePicker's calendar: "Today", "Next week". A single-date picker picks From; a range picker picks From to To.

type DebugNamer

type DebugNamer interface {
	// DebugName returns the debug name, empty when none is set.
	DebugName() string
}

DebugNamer is implemented by widgets carrying a debug name set with SetDebugName. Every widget that embeds node has the method; the interface lets the inspector also recognize third-party Widget implementations that mirror the API.

type DirSource

type DirSource func(dir string) ([]FileEntry, error)

DirSource lists one directory; the default walks the filesystem, hiding dot files. Tests and portal backends substitute their own. It runs off the loop goroutine and must touch no widget.

type Direction

type Direction = text.Direction

Direction names the base paragraph direction a text widget resolves and lays out with. It is text.Direction — the one resolution every text path shares; the alias lets call sites read against the widget package.

type DoubleClicker

type DoubleClicker interface {
	DoubleClickAt(p Point)
}

DoubleClicker is invoked on the second click of a double-click; p is the release point in root coordinates.

type DragContent

type DragContent = transfer.Drag

DragContent is the payload a drag carries - mime types best first with a writer, the actions offered (copy unless set), and the source's feedback and completion hooks; see transfer.Drag.

type DragEnterer

type DragEnterer interface {
	DragEnter(mimes []string, p Point) string
}

DragEnterer decides whether a widget accepts a drag hovering it, by mime. mimes lists the offered types best first; return the mime to receive on drop, or "" to reject the drag.

type DragHoverer

type DragHoverer interface {
	DragHover(p Point)
}

DragHoverer receives drag movement while a drag hovers the widget, for position-aware feedback (drop indicators, insertion gaps).

type DragIconer

type DragIconer interface {
	DragIcon() Widget
}

DragIconer is a DragSource that names the widget its drag icon renders, instead of itself: a list dragging several rows shows a stack of them.

type DragInterceptor

type DragInterceptor interface {
	InterceptDrag(from, at Point) bool
}

DragInterceptor is an ancestor that may take over a press in its subtree once the pointer moves: a swipe-to-dismiss card takes a sideways drag from the button the press landed on. It sees every move of a press it has not taken; true takes the gesture. The pressed widget's press then ends without a click, and the interceptor receives the rest: its DragMove for each move, and PressEnd at the release.

type DragLeaver

type DragLeaver interface {
	DragLeave()
}

DragLeaver receives a drag that left the widget without dropping.

type DragMover

type DragMover interface {
	DragMove(p Point)
}

DragMover receives pointer motion while the widget is pressed.

type DragOverSetter

type DragOverSetter interface {
	SetDragOver(on bool)
}

DragOverSetter receives drag-hover tracking from the Router, the highlight bit while a drag sits over the widget — the drop-target counterpart of HoverSetter.

type DragSource

type DragSource interface {
	// DragContent returns the offered payload, or nil to not drag.
	DragContent() *DragContent
}

DragSource lets a widget start a drag-and-drop: a press on it plus motion past the app's drag threshold offers DragContent through the wl_data_device. Return nil to decline this particular press.

type DrawSurface

type DrawSurface struct {

	// OnResize redraws the whole surface into the fresh backing
	// canvas; it runs on the loop, from the paint that reallocated.
	OnResize func(cv *render.Canvas)
	// OnStylus receives every tablet sample over the surface.
	OnStylus func(s Stylus)
	// contains filtered or unexported fields
}

DrawSurface is DrawingArea's retained counterpart (relm4's DrawHandler): a backing canvas whose pixels persist between paints, so an incremental application - a paint program, a plot that appends samples - draws only what changed and never repaints the rest. The application draws through Draw any time on the loop; Paint shows the backing canvas as it stands. OnStylus receives tablet samples over the area, like DrawingArea's.

A resize at the same device scale keeps the content and leaves the newly exposed area transparent; a rescale (or a first paint before any Draw, which allocates at 1x) reallocates the buffer, drops the pixels, and hands the fresh canvas to OnResize - the one place an application redraws everything it owes.

func NewDrawSurface

func NewDrawSurface(w, h int) *DrawSurface

NewDrawSurface returns a surface requesting w x h logical pixels.

func (*DrawSurface) AccessibleName

func (n *DrawSurface) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*DrawSurface) AddClass

func (n *DrawSurface) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*DrawSurface) Arrange

func (n *DrawSurface) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*DrawSurface) AttachStylesheet

func (n *DrawSurface) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*DrawSurface) Attr

func (n *DrawSurface) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*DrawSurface) Bounds

func (n *DrawSurface) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*DrawSurface) Canvas

func (d *DrawSurface) Canvas() *render.Canvas

Canvas returns the backing canvas, or nil before the surface first drew or painted. It carries the device scale the pixels were laid down at; draw through Draw, which also schedules the repaint.

func (*DrawSurface) Classes

func (n *DrawSurface) Classes() []string

Classes returns a copy of the widget's classes.

func (*DrawSurface) DebugName

func (n *DrawSurface) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*DrawSurface) DetachStylesheet

func (n *DrawSurface) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*DrawSurface) Draw

func (d *DrawSurface) Draw(r render.Rect, fn func(cv *render.Canvas))

Draw runs fn over the backing canvas with drawing clipped to r, a rect in the surface's own logical pixels, and schedules a repaint of exactly that rect. fn must draw only inside r: the clip enforces it, so a stray primitive cannot land outside the damage. It runs on the loop, like every widget mutation.

func (*DrawSurface) Element

func (n *DrawSurface) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*DrawSurface) Enabled

func (n *DrawSurface) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*DrawSurface) HAlign

func (n *DrawSurface) HAlign() Align

HAlign returns the horizontal placement.

func (*DrawSurface) HasClass

func (n *DrawSurface) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*DrawSurface) HasState

func (n *DrawSurface) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*DrawSurface) HitLeaf

func (n *DrawSurface) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*DrawSurface) HitTest

func (d *DrawSurface) HitTest(p Point) Widget

HitTest makes the whole surface the target.

func (*DrawSurface) HoverWithin

func (n *DrawSurface) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*DrawSurface) ID

func (n *DrawSurface) ID() string

ID returns the style id, empty when none is set.

func (*DrawSurface) InlineStyle

func (n *DrawSurface) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*DrawSurface) Invalidate

func (n *DrawSurface) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*DrawSurface) InvalidateLayout

func (n *DrawSurface) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*DrawSurface) InvalidateRect

func (n *DrawSurface) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*DrawSurface) LayoutMotion

func (n *DrawSurface) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*DrawSurface) Margin

func (n *DrawSurface) Margin() render.Insets

Margin returns the programmatic margin.

func (*DrawSurface) MaximumSize

func (n *DrawSurface) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*DrawSurface) Measure

func (d *DrawSurface) Measure(axis Axis, forSize int) Sizes

Measure requests the content size.

func (*DrawSurface) Paint

func (d *DrawSurface) Paint(cv *render.Canvas)

Paint shows the backing canvas, allocating it first if this paint is the surface's first look at its size or scale.

func (*DrawSurface) Parent

func (n *DrawSurface) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*DrawSurface) QueueDraw

func (d *DrawSurface) QueueDraw()

QueueDraw repaints the surface.

func (*DrawSurface) RemoveAttr

func (n *DrawSurface) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*DrawSurface) RemoveClass

func (n *DrawSurface) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*DrawSurface) SetAccessibleName

func (n *DrawSurface) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*DrawSurface) SetAttr

func (n *DrawSurface) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*DrawSurface) SetClass

func (n *DrawSurface) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*DrawSurface) SetClasses

func (n *DrawSurface) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*DrawSurface) SetContentSize

func (d *DrawSurface) SetContentSize(w, h int)

SetContentSize changes the requested size.

func (*DrawSurface) SetCursorName

func (n *DrawSurface) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*DrawSurface) SetDebugName

func (n *DrawSurface) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*DrawSurface) SetElement

func (n *DrawSurface) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*DrawSurface) SetEnabled

func (n *DrawSurface) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*DrawSurface) SetFocusOnClick

func (n *DrawSurface) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*DrawSurface) SetHAlign

func (n *DrawSurface) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*DrawSurface) SetHExpand

func (n *DrawSurface) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*DrawSurface) SetID

func (n *DrawSurface) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*DrawSurface) SetInlineStyle

func (n *DrawSurface) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*DrawSurface) SetInlineStylePriority

func (n *DrawSurface) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*DrawSurface) SetLayoutMotion

func (n *DrawSurface) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*DrawSurface) SetMargin

func (n *DrawSurface) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*DrawSurface) SetMaximumSize

func (n *DrawSurface) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*DrawSurface) SetOnClickWithin

func (n *DrawSurface) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*DrawSurface) SetOnFocusChanged

func (n *DrawSurface) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*DrawSurface) SetOnHoverWithin

func (n *DrawSurface) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*DrawSurface) SetOnPointer

func (n *DrawSurface) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*DrawSurface) SetOnScroll

func (n *DrawSurface) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*DrawSurface) SetSharedElement

func (n *DrawSurface) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*DrawSurface) SetSizeRequest

func (n *DrawSurface) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*DrawSurface) SetState

func (n *DrawSurface) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*DrawSurface) SetTooltip

func (n *DrawSurface) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*DrawSurface) SetTooltipMarkup

func (n *DrawSurface) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*DrawSurface) SetVAlign

func (n *DrawSurface) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*DrawSurface) SetVExpand

func (n *DrawSurface) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*DrawSurface) SetVisible

func (n *DrawSurface) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*DrawSurface) SharedElement

func (n *DrawSurface) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*DrawSurface) SizeRequest

func (n *DrawSurface) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*DrawSurface) Stylus

func (d *DrawSurface) Stylus(s Stylus)

Stylus implements StylusHandler.

func (*DrawSurface) TooltipMarkup

func (n *DrawSurface) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*DrawSurface) TooltipText

func (n *DrawSurface) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*DrawSurface) VAlign

func (n *DrawSurface) VAlign() Align

VAlign returns the vertical placement.

func (*DrawSurface) Visible

func (n *DrawSurface) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type DrawingArea

type DrawingArea struct {

	// OnDraw paints the area into its bounds.
	OnDraw func(cv *render.Canvas, area render.Rect)
	// OnStylus receives every tablet sample over the area.
	OnStylus func(s Stylus)
	// contains filtered or unexported fields
}

DrawingArea is a widget the application paints itself (GTK DrawingArea): OnDraw receives the canvas, clipped to the area, on every paint; QueueDraw asks for one. OnStylus receives tablet samples over the area - pressure and tilt for freehand drawing - while the pen also drives the pointer like any tool.

func NewDrawingArea

func NewDrawingArea(w, h int) *DrawingArea

NewDrawingArea returns an area requesting w x h logical pixels.

func (*DrawingArea) AccessibleName

func (n *DrawingArea) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*DrawingArea) AddClass

func (n *DrawingArea) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*DrawingArea) Arrange

func (n *DrawingArea) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*DrawingArea) AttachStylesheet

func (n *DrawingArea) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*DrawingArea) Attr

func (n *DrawingArea) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*DrawingArea) Bounds

func (n *DrawingArea) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*DrawingArea) Classes

func (n *DrawingArea) Classes() []string

Classes returns a copy of the widget's classes.

func (*DrawingArea) DebugName

func (n *DrawingArea) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*DrawingArea) DetachStylesheet

func (n *DrawingArea) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*DrawingArea) Element

func (n *DrawingArea) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*DrawingArea) Enabled

func (n *DrawingArea) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*DrawingArea) HAlign

func (n *DrawingArea) HAlign() Align

HAlign returns the horizontal placement.

func (*DrawingArea) HasClass

func (n *DrawingArea) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*DrawingArea) HasState

func (n *DrawingArea) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*DrawingArea) HitLeaf

func (n *DrawingArea) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*DrawingArea) HitTest

func (d *DrawingArea) HitTest(p Point) Widget

HitTest makes the whole area the target.

func (*DrawingArea) HoverWithin

func (n *DrawingArea) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*DrawingArea) ID

func (n *DrawingArea) ID() string

ID returns the style id, empty when none is set.

func (*DrawingArea) InlineStyle

func (n *DrawingArea) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*DrawingArea) Invalidate

func (n *DrawingArea) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*DrawingArea) InvalidateLayout

func (n *DrawingArea) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*DrawingArea) InvalidateRect

func (n *DrawingArea) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*DrawingArea) LayoutMotion

func (n *DrawingArea) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*DrawingArea) Margin

func (n *DrawingArea) Margin() render.Insets

Margin returns the programmatic margin.

func (*DrawingArea) MaximumSize

func (n *DrawingArea) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*DrawingArea) Measure

func (d *DrawingArea) Measure(axis Axis, forSize int) Sizes

Measure requests the content size.

func (*DrawingArea) Paint

func (d *DrawingArea) Paint(cv *render.Canvas)

Paint runs OnDraw clipped to the area.

func (*DrawingArea) Parent

func (n *DrawingArea) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*DrawingArea) QueueDraw

func (d *DrawingArea) QueueDraw()

QueueDraw repaints the area.

func (*DrawingArea) RemoveAttr

func (n *DrawingArea) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*DrawingArea) RemoveClass

func (n *DrawingArea) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*DrawingArea) SetAccessibleName

func (n *DrawingArea) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*DrawingArea) SetAttr

func (n *DrawingArea) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*DrawingArea) SetClass

func (n *DrawingArea) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*DrawingArea) SetClasses

func (n *DrawingArea) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*DrawingArea) SetContentSize

func (d *DrawingArea) SetContentSize(w, h int)

SetContentSize changes the requested size.

func (*DrawingArea) SetCursorName

func (n *DrawingArea) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*DrawingArea) SetDebugName

func (n *DrawingArea) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*DrawingArea) SetElement

func (n *DrawingArea) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*DrawingArea) SetEnabled

func (n *DrawingArea) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*DrawingArea) SetFocusOnClick

func (n *DrawingArea) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*DrawingArea) SetHAlign

func (n *DrawingArea) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*DrawingArea) SetHExpand

func (n *DrawingArea) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*DrawingArea) SetID

func (n *DrawingArea) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*DrawingArea) SetInlineStyle

func (n *DrawingArea) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*DrawingArea) SetInlineStylePriority

func (n *DrawingArea) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*DrawingArea) SetLayoutMotion

func (n *DrawingArea) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*DrawingArea) SetMargin

func (n *DrawingArea) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*DrawingArea) SetMaximumSize

func (n *DrawingArea) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*DrawingArea) SetOnClickWithin

func (n *DrawingArea) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*DrawingArea) SetOnFocusChanged

func (n *DrawingArea) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*DrawingArea) SetOnHoverWithin

func (n *DrawingArea) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*DrawingArea) SetOnPointer

func (n *DrawingArea) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*DrawingArea) SetOnScroll

func (n *DrawingArea) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*DrawingArea) SetSharedElement

func (n *DrawingArea) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*DrawingArea) SetSizeRequest

func (n *DrawingArea) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*DrawingArea) SetState

func (n *DrawingArea) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*DrawingArea) SetTooltip

func (n *DrawingArea) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*DrawingArea) SetTooltipMarkup

func (n *DrawingArea) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*DrawingArea) SetVAlign

func (n *DrawingArea) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*DrawingArea) SetVExpand

func (n *DrawingArea) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*DrawingArea) SetVisible

func (n *DrawingArea) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*DrawingArea) SharedElement

func (n *DrawingArea) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*DrawingArea) SizeRequest

func (n *DrawingArea) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*DrawingArea) Stylus

func (d *DrawingArea) Stylus(s Stylus)

Stylus implements StylusHandler.

func (*DrawingArea) TooltipMarkup

func (n *DrawingArea) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*DrawingArea) TooltipText

func (n *DrawingArea) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*DrawingArea) VAlign

func (n *DrawingArea) VAlign() Align

VAlign returns the vertical placement.

func (*DrawingArea) Visible

func (n *DrawingArea) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type DropActionChooser

type DropActionChooser interface {
	DropAction(offered transfer.Action) transfer.Action
}

DropActionChooser is a drop target that picks the action from those the source offers - a file view moving within one disk, copying across. Without it a drop prefers copy.

type Dropdown struct {

	// OnSelect fires exactly once per selection change, whatever
	// produced it: a pick in the list or SetSelected. Re-picking the
	// selected row is not a change and fires nothing.
	OnSelect func(i int)
	// contains filtered or unexported fields
}

Dropdown is a combobox: a closed face showing the current selection that opens its items in a popover beneath it, through the surface host of its tree (OpenPopover), as a Command list with no search row: header rows head its groups, row icons lead their items, and a check trails the selected one. The popover closes on a pick, on Esc or a click away, or on a second click on the face.

Keyboard: Enter, Space, or Down opens while focused; in the open list arrows move the highlight (Home/End jump), Enter or Space picks, and printable keys jump the highlight by type-ahead.

Type-ahead on the closed face (GTK combobox parity): printable keys cycle the selection through the rows whose label starts with the typed prefix (case-insensitive). Space never joins a prefix: it opens. Repeated keys cycle among the equal-prefix rows; the chain resets after a short idle timeout. Keys that match nothing are ignored outright.

The constructor takes the face like every other text widget: face, then sizePx, then the items. Face may be a render.Chain for mixed-script fallback; a nil face panics there (see requireFace) instead of failing later, in shaping.

Example
package main

import (
	"fmt"
	"log"

	"github.com/stubbedev/lys-lib/render"
	"golang.org/x/image/font/gofont/goregular"

	"github.com/stubbedev/lys-ui/widget"
)

func face() *render.Typeface {
	tf, err := render.LoadFont(goregular.TTF)
	if err != nil {
		log.Fatal(err)
	}
	return tf
}

// popoverHost is a stand-in for the application's surface host: it
// hands every popover's keys to the widget the popover focuses.
type popoverHost struct{ focus widget.KeyActionHandler }

func (h *popoverHost) OpenMenu(widget.Boundser, render.Font, float64, []widget.MenuItem, widget.MenuOptions) {
}

func (h *popoverHost) OpenPopover(_ widget.Boundser, _ widget.Widget, opts widget.PopoverOptions) func() {
	h.focus = opts.Focus.(widget.KeyActionHandler)
	return func() {}
}

func (h *popoverHost) Focus(widget.Widget) error { return nil }

func main() {
	// A dropdown is a closed face showing the selection; Enter, Space,
	// or Down opens the item list in a popover beneath it while
	// focused, through the surface host of its tree. The list holds the
	// focus: arrows move the highlight and Enter picks. Here the list
	// opens from the keyboard, Down walks to the second row, and Enter
	// commits it exactly once.
	dd := widget.NewDropdown(face(), 13, []string{"Light", "Dark", "System"}, 0)
	host := &popoverHost{}
	widget.SetSurfaceHost(dd, host)

	var picked string
	dd.OnSelect = func(int) { picked = dd.Selection() }
	dd.KeyAction(widget.KeyEnter, 0)
	host.focus.KeyAction(widget.KeyDown, 0)
	host.focus.KeyAction(widget.KeyEnter, 0)
	fmt.Println("picked:", picked)

	// DropdownOf carries typed values behind the labels, so handlers
	// see the value, not an index to look up.
	outputs := []widget.DropdownItem[string]{
		{Label: "eDP-1", Value: "/dev/drm0"},
		{Label: "HDMI-A-1", Value: "/dev/drm1"},
	}
	selector := widget.NewDropdownOf(face(), 13, outputs, 0)
	selector.OnSelect = func(i int, dev string) {
		fmt.Println("output", i, "->", dev)
	}
	selector.SetSelected(1)
	fmt.Println("value:", selector.Value())
}
Output:
picked: Dark
output 1 -> /dev/drm1
value: /dev/drm1

func NewDropdown

func NewDropdown(face render.Font, sizePx float64, items []string, selected int) *Dropdown

NewDropdown returns a dropdown showing items, painted with face at sizePx, with the selected index clamped into range (-1 when there are no items). Face may be a render.Chain for mixed-script fallback.

func NewDropdownRows

func NewDropdownRows(face render.Font, sizePx float64, items []DropdownRow, selected int) *Dropdown

NewDropdownRows is NewDropdown over rich rows. A selected index on a header moves to the nearest selectable row after it (before it at the end).

func (n *Dropdown) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (n *Dropdown) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (n *Dropdown) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (n *Dropdown) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (n *Dropdown) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (d *Dropdown) BindSelected(b *Binding[int]) (unbind func())

BindSelected wires the binding two-way to the dropdown's selection index.

func (n *Dropdown) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (n *Dropdown) Classes() []string

Classes returns a copy of the widget's classes.

func (d *Dropdown) ClickAt(Point)

ClickAt toggles the list; the Router invokes it when a press and release land on the face.

func (d *Dropdown) Close()

Close closes the item list's popover; a closed dropdown ignores it.

func (n *Dropdown) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (n *Dropdown) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (d *Dropdown) Direction() Direction

Direction returns the base paragraph direction the labels resolve with.

func (n *Dropdown) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (n *Dropdown) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (n *Dropdown) HAlign() Align

HAlign returns the horizontal placement.

func (n *Dropdown) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (n *Dropdown) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (n *Dropdown) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (d *Dropdown) HitTest(p Point) Widget

HitTest returns the dropdown inside its face.

func (n *Dropdown) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (n *Dropdown) ID() string

ID returns the style id, empty when none is set.

func (n *Dropdown) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (d *Dropdown) InsertRune(r rune)

InsertRune implements RuneHandler: Space opens, the other half of the activation pair (Enter is the first). Every other printable rune feeds the type-ahead chain, which moves the selection.

func (n *Dropdown) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (n *Dropdown) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (n *Dropdown) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (d *Dropdown) Items() []string

Items returns the item labels, row order.

func (d *Dropdown) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: Enter or Down opens. The open list holds the focus, so its keys reach it, not the face.

func (n *Dropdown) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (n *Dropdown) Margin() render.Insets

Margin returns the programmatic margin.

func (n *Dropdown) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (d *Dropdown) Measure(axis Axis, forSize int) Sizes

Measure wants the widest item plus arrow and padding, and one row height; the closed face keeps its width whatever the selection, so a change never relayouts the surrounding tree. 80px is the width floor. It needs the label start, the icon slot, an ellipsis and the chevron, the selection ellipsizing into what is left.

func (d *Dropdown) Open()

Open shows the item list in a popover beneath the face, at least as wide as the face and highlighted on the selection, with the keyboard focus in the list. A disabled dropdown and one with nothing to select stay closed.

func (d *Dropdown) Opened() bool

Opened reports whether the item list is showing.

func (d *Dropdown) Paint(cv *render.Canvas)

Paint draws the face — surface, selection, chevron — in its pressed shade while the list is open. A disabled dropdown fills with the derived disabled surface and paints muted.

func (n *Dropdown) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (n *Dropdown) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (n *Dropdown) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (d *Dropdown) Role() Role

Role implements Roleer.

func (d *Dropdown) Selected() int

Selected returns the selected item index, -1 when empty.

func (d *Dropdown) Selection() string

Selection returns the selected item's label, empty when none.

func (n *Dropdown) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (n *Dropdown) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (n *Dropdown) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (n *Dropdown) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (n *Dropdown) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (n *Dropdown) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (d *Dropdown) SetDirection(dir Direction)

SetDirection selects the base paragraph direction the selection label resolves and lays out with. DirectionAuto (the default) reads it off the label's first strong character. Changing the direction invalidates.

func (n *Dropdown) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (d *Dropdown) SetEnabled(enabled bool)

SetEnabled turns the dropdown on or off, following the toolkit-wide node.SetEnabled convention (the flag lives on the embedded node; Enabled reads it). Disabling closes the list; a disabled dropdown ignores clicks and keys and paints muted.

func (n *Dropdown) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (n *Dropdown) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (n *Dropdown) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (d *Dropdown) SetHovered(on bool)

SetHovered implements HoverSetter; the face's hover shade repaints.

func (n *Dropdown) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (n *Dropdown) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (n *Dropdown) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (d *Dropdown) SetItems(items []string, selected int)

SetItems replaces the items (GTK's DropDown.set_model) and selects selected, clamped as the constructor clamps it. It fires no OnSelect: the caller is choosing what shows, not the user. An open list closes at once.

func (n *Dropdown) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (n *Dropdown) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (n *Dropdown) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (n *Dropdown) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (n *Dropdown) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (n *Dropdown) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (n *Dropdown) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (n *Dropdown) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (d *Dropdown) SetRows(rows []DropdownRow, selected int)

SetRows is SetItems over rich rows.

func (d *Dropdown) SetSelected(i int)

SetSelected moves the selection to i (clamped) and fires OnSelect when the index changed.

func (n *Dropdown) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (n *Dropdown) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (n *Dropdown) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (n *Dropdown) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (n *Dropdown) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (n *Dropdown) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (n *Dropdown) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (n *Dropdown) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (n *Dropdown) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (n *Dropdown) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (n *Dropdown) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (n *Dropdown) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (n *Dropdown) VAlign() Align

VAlign returns the vertical placement.

func (n *Dropdown) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type DropdownItem[T any] struct {
	Label string
	Value T
}

DropdownItem pairs a display label with the typed value picking it reports.

type DropdownOf[T any] struct {
	*Dropdown

	// OnSelect fires exactly once per selection change with the new
	// row's index and value. It shadows the wrapped Dropdown's OnSelect
	// (a func(int)); set this one.
	OnSelect func(i int, value T)
	// contains filtered or unexported fields
}

DropdownOf is a Dropdown whose rows carry typed values: the labels feed the visible list, and a change comes back with the value behind the picked row. It is a Dropdown in every other respect — embed it in a tree as-is.

func NewDropdownOf

func NewDropdownOf[T any](face render.Font, sizePx float64, items []DropdownItem[T], selected int) *DropdownOf[T]

NewDropdownOf builds a typed dropdown from labeled values, painted with face at sizePx, showing the selected index clamped into range. Face may be a render.Chain for mixed-script fallback; a nil face panics here, naming the argument (see requireFace).

func (n DropdownOf) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (n DropdownOf) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (n DropdownOf) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (n DropdownOf) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (n DropdownOf) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (n DropdownOf) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (n DropdownOf) Classes() []string

Classes returns a copy of the widget's classes.

func (n DropdownOf) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (n DropdownOf) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (n DropdownOf) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (n DropdownOf) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (n DropdownOf) HAlign() Align

HAlign returns the horizontal placement.

func (n DropdownOf) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (n DropdownOf) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (n DropdownOf) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (n DropdownOf) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (n DropdownOf) ID() string

ID returns the style id, empty when none is set.

func (n DropdownOf) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (n DropdownOf) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (n DropdownOf) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (n DropdownOf) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (n DropdownOf) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (n DropdownOf) Margin() render.Insets

Margin returns the programmatic margin.

func (n DropdownOf) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (n DropdownOf) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (n DropdownOf) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (n DropdownOf) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (n DropdownOf) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (n DropdownOf) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (n DropdownOf) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (n DropdownOf) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (n DropdownOf) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (n DropdownOf) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (n DropdownOf) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (n DropdownOf) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (n DropdownOf) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (n DropdownOf) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (n DropdownOf) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (n DropdownOf) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (n DropdownOf) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (n DropdownOf) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (n DropdownOf) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (n DropdownOf) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (n DropdownOf) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (n DropdownOf) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (n DropdownOf) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (n DropdownOf) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (n DropdownOf) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (n DropdownOf) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (n DropdownOf) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (n DropdownOf) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (n DropdownOf) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (n DropdownOf) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (n DropdownOf) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (n DropdownOf) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (n DropdownOf) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (n DropdownOf) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (n DropdownOf) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (n DropdownOf) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (n DropdownOf) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (n DropdownOf) VAlign() Align

VAlign returns the vertical placement.

func (d *DropdownOf[T]) Value() T

Value returns the picked row's value, the zero T when nothing is selected.

func (n DropdownOf) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type DropdownRow struct {
	Label   string
	Leading func() Widget
	Header  bool
}

DropdownRow is one row of a dropdown built with NewDropdownRows, GTK's DropDown with a row factory. Leading, when set, builds the row's leading widget, an icon or a ColorSwatch: it is called for the list row and for the face, so each owns its instance. A Header row is a group caption: listed, never selected, stepped onto, or matched by type-ahead.

type Dropper

type Dropper interface {
	Drop(mime string, data []byte, p Point)
}

Dropper receives a drop: the accepted mime, its bytes, and the drop point in root coordinates.

type Echo

type Echo uint8

Echo selects how an Entry shows its contents.

const (
	// EchoNormal shows the runes as typed.
	EchoNormal Echo = iota
	// EchoPassword shows one dot per rune; the display reveals nothing
	// about the contents, not even a selection's extent.
	EchoPassword
	// EchoNone shows nothing at all.
	EchoNone
)

type Edge

type Edge uint8

Edge is one side of a rect.

const (
	EdgeBottom Edge = iota
	EdgeTop
	EdgeLeft
	EdgeRight
)

The four edges.

type EditableLabel

type EditableLabel struct {
	*Entry

	// OnChanged fires when an edit committed a different text.
	OnChanged func(text string)
	// contains filtered or unexported fields
}

EditableLabel is a label that edits in place (GTK EditableLabel): at rest it paints as plain text - the entry flat, read-only, caret hidden; a click or Enter starts editing with the text selected; Enter or losing focus commits, Escape reverts. It is the entry throughout, so editing inherits every Entry behavior (selection, undo, IME) and focus never has to move between two widgets.

func NewEditableLabel

func NewEditableLabel(face render.Font, sizePx float64, color render.Color, s string) *EditableLabel

NewEditableLabel returns a resting label showing s.

func (EditableLabel) AccessibleName

func (n EditableLabel) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (EditableLabel) AddClass

func (n EditableLabel) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (EditableLabel) AttachStylesheet

func (n EditableLabel) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (EditableLabel) Attr

func (n EditableLabel) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (EditableLabel) Bounds

func (n EditableLabel) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (EditableLabel) Classes

func (n EditableLabel) Classes() []string

Classes returns a copy of the widget's classes.

func (*EditableLabel) ClickAt

func (l *EditableLabel) ClickAt(p Point)

ClickAt starts editing at rest; while editing it places the caret.

func (*EditableLabel) CursorName

func (l *EditableLabel) CursorName() string

CursorName is the text cursor only while editing; at rest the label keeps the node-level shape like any other widget.

func (EditableLabel) DebugName

func (n EditableLabel) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (EditableLabel) DetachStylesheet

func (n EditableLabel) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*EditableLabel) Editing

func (l *EditableLabel) Editing() bool

Editing reports whether the label is in edit mode.

func (EditableLabel) Element

func (n EditableLabel) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (EditableLabel) Enabled

func (n EditableLabel) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (EditableLabel) HAlign

func (n EditableLabel) HAlign() Align

HAlign returns the horizontal placement.

func (EditableLabel) HasClass

func (n EditableLabel) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (EditableLabel) HasState

func (n EditableLabel) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (EditableLabel) HitLeaf

func (n EditableLabel) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (EditableLabel) HoverWithin

func (n EditableLabel) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (EditableLabel) ID

func (n EditableLabel) ID() string

ID returns the style id, empty when none is set.

func (EditableLabel) InlineStyle

func (n EditableLabel) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (EditableLabel) Invalidate

func (n EditableLabel) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (EditableLabel) InvalidateLayout

func (n EditableLabel) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (EditableLabel) InvalidateRect

func (n EditableLabel) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*EditableLabel) KeyAction

func (l *EditableLabel) KeyAction(a KeyAction, mods Mods)

KeyAction starts editing on Enter at rest; while editing every key is the entry's.

func (EditableLabel) LayoutMotion

func (n EditableLabel) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (EditableLabel) Margin

func (n EditableLabel) Margin() render.Insets

Margin returns the programmatic margin.

func (EditableLabel) MaximumSize

func (n EditableLabel) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (EditableLabel) Parent

func (n EditableLabel) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (EditableLabel) RemoveAttr

func (n EditableLabel) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (EditableLabel) RemoveClass

func (n EditableLabel) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (EditableLabel) SetAccessibleName

func (n EditableLabel) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (EditableLabel) SetAttr

func (n EditableLabel) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (EditableLabel) SetClass

func (n EditableLabel) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (EditableLabel) SetClasses

func (n EditableLabel) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (EditableLabel) SetCursorName

func (n EditableLabel) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (EditableLabel) SetDebugName

func (n EditableLabel) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (EditableLabel) SetElement

func (n EditableLabel) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (EditableLabel) SetEnabled

func (n EditableLabel) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (EditableLabel) SetFocusOnClick

func (n EditableLabel) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (EditableLabel) SetHAlign

func (n EditableLabel) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (EditableLabel) SetHExpand

func (n EditableLabel) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (EditableLabel) SetID

func (n EditableLabel) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (EditableLabel) SetInlineStyle

func (n EditableLabel) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (EditableLabel) SetInlineStylePriority

func (n EditableLabel) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (EditableLabel) SetLayoutMotion

func (n EditableLabel) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (EditableLabel) SetMargin

func (n EditableLabel) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (EditableLabel) SetMaximumSize

func (n EditableLabel) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (EditableLabel) SetOnClickWithin

func (n EditableLabel) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (EditableLabel) SetOnFocusChanged

func (n EditableLabel) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (EditableLabel) SetOnHoverWithin

func (n EditableLabel) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (EditableLabel) SetOnPointer

func (n EditableLabel) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (EditableLabel) SetOnScroll

func (n EditableLabel) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (EditableLabel) SetSharedElement

func (n EditableLabel) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (EditableLabel) SetSizeRequest

func (n EditableLabel) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (EditableLabel) SetState

func (n EditableLabel) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (EditableLabel) SetTooltip

func (n EditableLabel) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (EditableLabel) SetTooltipMarkup

func (n EditableLabel) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (EditableLabel) SetVAlign

func (n EditableLabel) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (EditableLabel) SetVExpand

func (n EditableLabel) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (EditableLabel) SetVisible

func (n EditableLabel) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (EditableLabel) SharedElement

func (n EditableLabel) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (EditableLabel) SizeRequest

func (n EditableLabel) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*EditableLabel) StartEditing

func (l *EditableLabel) StartEditing()

StartEditing enters edit mode with the whole text selected.

func (*EditableLabel) StopEditing

func (l *EditableLabel) StopEditing(commit bool)

StopEditing leaves edit mode, keeping the edit when commit (firing OnChanged if the text differs) and restoring the old text otherwise.

func (EditableLabel) TooltipMarkup

func (n EditableLabel) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (EditableLabel) TooltipText

func (n EditableLabel) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (EditableLabel) VAlign

func (n EditableLabel) VAlign() Align

VAlign returns the vertical placement.

func (EditableLabel) Visible

func (n EditableLabel) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Elevation

type Elevation struct {
	// contains filtered or unexported fields
}

Elevation wraps a widget and paints the theme's box shadow around it — the widget-shaped half of the shared elevation helper, for floating cards whose content does not paint its own plate. WithPlate adds a rounded fill behind the child, so a bare content tree becomes a floating card: shadow, plate, content (the dialog's shape).

The wrapper claims exactly the child's rect: Measure and Arrange pass through untouched — the shadow lives outside the logical bounds — and HitTest resolves through the child alone, so a point in the gutter is never a hit.

func NewElevation

func NewElevation(child Widget) *Elevation

NewElevation wraps child, rounding at the theme's corner radius.

func (*Elevation) AccessibleName

func (n *Elevation) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Elevation) AddClass

func (n *Elevation) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Elevation) Arrange

func (e *Elevation) Arrange(r render.Rect)

Arrange records the rect, passes it to the child, and keeps the shadow ring's damage in step with the effective (stylesheet-aware) blur.

func (*Elevation) AttachStylesheet

func (n *Elevation) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Elevation) Attr

func (n *Elevation) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Elevation) Bounds

func (n *Elevation) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Elevation) Child

func (e *Elevation) Child() Widget

Child returns the wrapped widget.

func (*Elevation) Children

func (e *Elevation) Children() []Widget

Children exposes the child for the damage collector, focus traversal, and the accessibility walk.

func (*Elevation) Classes

func (n *Elevation) Classes() []string

Classes returns a copy of the widget's classes.

func (*Elevation) DebugName

func (n *Elevation) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Elevation) DetachStylesheet

func (n *Elevation) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Elevation) Element

func (n *Elevation) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Elevation) Enabled

func (n *Elevation) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Elevation) HAlign

func (n *Elevation) HAlign() Align

HAlign returns the horizontal placement.

func (*Elevation) HasClass

func (n *Elevation) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Elevation) HasState

func (n *Elevation) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Elevation) HitLeaf

func (n *Elevation) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Elevation) HitTest

func (e *Elevation) HitTest(p Point) Widget

HitTest resolves through the child alone: the shadow gutter is never a hit, so clicks just outside the card pass through.

func (*Elevation) HoverWithin

func (n *Elevation) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Elevation) ID

func (n *Elevation) ID() string

ID returns the style id, empty when none is set.

func (*Elevation) InlineStyle

func (n *Elevation) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Elevation) Invalidate

func (n *Elevation) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Elevation) InvalidateLayout

func (n *Elevation) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Elevation) InvalidateRect

func (n *Elevation) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Elevation) LayoutMotion

func (n *Elevation) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Elevation) Margin

func (n *Elevation) Margin() render.Insets

Margin returns the programmatic margin.

func (*Elevation) MaximumSize

func (n *Elevation) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Elevation) Measure

func (e *Elevation) Measure(axis Axis, forSize int) Sizes

Measure passes through to the child.

func (*Elevation) Paint

func (e *Elevation) Paint(cv *render.Canvas)

Paint draws shadow, optional plate and border, then the child. The stylesheet's box-shadow, background-color (the plate a bare content tree floats on), border and border-radius override the constructor and theme values — the dialog and popover cards style through this.

func (*Elevation) Parent

func (n *Elevation) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Elevation) RemoveAttr

func (n *Elevation) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Elevation) RemoveClass

func (n *Elevation) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Elevation) SetAccessibleName

func (n *Elevation) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Elevation) SetAttr

func (n *Elevation) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Elevation) SetClass

func (n *Elevation) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Elevation) SetClasses

func (n *Elevation) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Elevation) SetCursorName

func (n *Elevation) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Elevation) SetDebugName

func (n *Elevation) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Elevation) SetElement

func (n *Elevation) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Elevation) SetEnabled

func (e *Elevation) SetEnabled(enabled bool)

SetEnabled turns the elevation's child on or off through the per-query enable walk, like Box.

func (*Elevation) SetFocusOnClick

func (n *Elevation) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Elevation) SetHAlign

func (n *Elevation) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Elevation) SetHExpand

func (n *Elevation) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Elevation) SetID

func (n *Elevation) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Elevation) SetInlineStyle

func (n *Elevation) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Elevation) SetInlineStylePriority

func (n *Elevation) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Elevation) SetLayoutMotion

func (n *Elevation) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Elevation) SetMargin

func (n *Elevation) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Elevation) SetMaximumSize

func (n *Elevation) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Elevation) SetOnClickWithin

func (n *Elevation) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Elevation) SetOnFocusChanged

func (n *Elevation) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Elevation) SetOnHoverWithin

func (n *Elevation) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Elevation) SetOnPointer

func (n *Elevation) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Elevation) SetOnScroll

func (n *Elevation) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Elevation) SetSharedElement

func (n *Elevation) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Elevation) SetSizeRequest

func (n *Elevation) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Elevation) SetState

func (n *Elevation) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Elevation) SetTooltip

func (n *Elevation) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Elevation) SetTooltipMarkup

func (n *Elevation) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Elevation) SetVAlign

func (n *Elevation) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Elevation) SetVExpand

func (n *Elevation) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Elevation) SetVisible

func (n *Elevation) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Elevation) SharedElement

func (n *Elevation) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Elevation) SizeRequest

func (n *Elevation) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Elevation) TooltipMarkup

func (n *Elevation) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Elevation) TooltipText

func (n *Elevation) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Elevation) VAlign

func (n *Elevation) VAlign() Align

VAlign returns the vertical placement.

func (*Elevation) Visible

func (n *Elevation) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*Elevation) WithPlate

func (e *Elevation) WithPlate(c Color) *Elevation

WithPlate sets a rounded fill painted between the shadow and the child; zero (the default) paints no plate.

func (*Elevation) WithRadius

func (e *Elevation) WithRadius(px int) *Elevation

WithRadius sets the corner radius the shadow and plate round at.

type EllipsizeMode

type EllipsizeMode = render.EllipsizeMode

EllipsizeMode names where an overflowing label truncates. It is render.EllipsizeMode; the alias lets label call sites read against the widget package.

type Entry

type Entry struct {

	// OnChanged fires after the contents change, whatever the
	// source: typing, editing keys, clipboard, or SetText.
	OnChanged func(string)
	// OnActivate fires with the contents when the user presses Enter
	// in the entry (GTK's activate): submit a password, run a search,
	// move to the next field. A disabled entry never activates.
	OnActivate func(string)
	// Completion, when set, offers matches for the current text as an
	// inline list below the field (#92): arrows move the highlight,
	// Enter picks, Esc closes, a click picks. OnComplete fires with the
	// picked match after OnChanged delivered the new text.
	Completion func(prefix string) []string
	OnComplete func(chosen string)
	// OnEscape, when set, fires on Esc while no completion list is
	// open; returning true consumes the key. SearchEntry clears the
	// field with it.
	OnEscape func() bool

	// MaxWidth caps the natural width Measure reports: a long paste
	// stops growing the layout at the cap and pans inside it instead —
	// the text widgets' counterpart of Scroll's bounded natural size.
	// Zero (the default) reports the content-hugging width. Set it
	// before the first Measure, or follow with InvalidateLayout.
	MaxWidth int
	// contains filtered or unexported fields
}

Entry is a single-line text field. Its editing state machine (insert, delete, cursor motion) is input-agnostic: keyboard input in M4 calls these methods.

Example
package main

import (
	"fmt"
	"log"

	"github.com/stubbedev/lys-lib/render"
	"golang.org/x/image/font/gofont/goregular"

	"github.com/stubbedev/lys-ui/widget"
)

func face() *render.Typeface {
	tf, err := render.LoadFont(goregular.TTF)
	if err != nil {
		log.Fatal(err)
	}
	return tf
}

func main() {
	// An entry is an editing state machine: callbacks see every
	// change, whatever produced it (typing, editing keys, clipboard,
	// SetText).
	name := widget.NewEntry(face(), 14, widget.Current().Text)
	name.SetPlaceholder("who goes there?")
	name.OnChanged = func(s string) { fmt.Println("changed:", s) }

	name.InsertRune('h')
	name.InsertRune('i')
	fmt.Println("text:", name.Text())
}
Output:
changed: h
changed: hi
text: hi

func NewEntry

func NewEntry(face render.Font, sizePx float64, color render.Color) *Entry

NewEntry returns an empty entry painted with face at sizePx. Face may be a render.Chain for mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*Entry) AccessibleName

func (n *Entry) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Entry) AddClass

func (n *Entry) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Entry) Arrange

func (e *Entry) Arrange(r render.Rect)

Arrange pins the field's rect and re-pans: a resize changes the visible width, so the caret may need pulling back into view. The resize itself already scheduled the layout damage. r is the margin box; Bounds records the field inside the stylesheet's margin.

func (*Entry) AttachStylesheet

func (n *Entry) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Entry) Attr

func (n *Entry) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Entry) Backspace

func (e *Entry) Backspace()

Backspace deletes the selection, or the grapheme cluster before the cursor when nothing is selected — an emoji family, a flag, a base rune with its combining marks go as one whole (#57); one undo entry per call. Blocked while disabled or read-only.

func (*Entry) Baseline

func (e *Entry) Baseline() (int, bool)

Baseline implements Baseliner: the text line inside the field's insets, under the margin.

func (*Entry) BindText

func (e *Entry) BindText(b *Binding[string]) (unbind func())

BindText wires the binding two-way to the entry's text: changes write through, edits write back. Entry.OnChanged fires for every source, so the write-back of the binding's own value is the equal no-op that ends the loop.

func (*Entry) Bounds

func (n *Entry) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Entry) CharExtents

func (e *Entry) CharExtents(offset int) (render.Rect, bool)

CharExtents implements TextGeometry.

func (*Entry) Classes

func (n *Entry) Classes() []string

Classes returns a copy of the widget's classes.

func (*Entry) ClickAt

func (e *Entry) ClickAt(p Point)

ClickAt places the cursor (and the selection anchor) at the clicked text position, dropping the composing display. The mapping runs through the display shape's caret table — which follows the line visually — and the pan, so a click on a half-visible rune lands on that rune, snapped to the start of its grapheme cluster (#57). Masked modes keep the cursor a logical index. A press over the trailing icon goes to the icon's handler instead.

func (*Entry) Color

func (e *Entry) Color() render.Color

Color returns the programmatic text ink, zero when the stylesheet decides.

func (*Entry) Composing

func (e *Entry) Composing() bool

Composing reports whether composing (input-method preedit) text is on show.

func (*Entry) Cursor

func (e *Entry) Cursor() int

Cursor returns the cursor position as a rune index — the internal position representation stays rune-based (#57); cluster segmentation (internal/text) maps the editing steps, which move one grapheme cluster at a time, onto those indexes. Every position the widget itself produces is a cluster boundary.

func (*Entry) CursorName

func (e *Entry) CursorName() string

CursorName reports the text caret shape while hovered.

func (*Entry) DebugName

func (n *Entry) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Entry) Delete

func (e *Entry) Delete()

Delete deletes the selection, or the grapheme cluster at the cursor when nothing is selected (#57); one undo entry per call. This is the cut half of ctrl+x; blocked while disabled or read-only.

func (*Entry) DeleteWordBackward

func (e *Entry) DeleteWordBackward()

DeleteWordBackward removes the word before the cursor — ctrl+ backspace, with alt+backspace as the macOS alias — or the selection when one is active; the whole word is one undo entry. Blocked while disabled or read-only.

func (*Entry) DeleteWordForward

func (e *Entry) DeleteWordForward()

DeleteWordForward removes the word after the cursor — ctrl+delete — or the selection when one is active; the whole word is one undo entry. Blocked while disabled or read-only.

func (*Entry) DetachStylesheet

func (n *Entry) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Entry) Direction

func (e *Entry) Direction() Direction

Direction returns the base paragraph direction the entry resolves with.

func (*Entry) DoubleClickAt

func (e *Entry) DoubleClickAt(p Point)

DoubleClickAt selects the run of same-class runes (word or whitespace) under the clicked position, over the shared word segmentation — the same words the ctrl+arrows steps land on. user-select: none keeps the click a caret placement.

func (*Entry) DragMove

func (e *Entry) DragMove(p Point)

DragMove extends the selection while the pointer drags; the anchor stays where the press landed. A motion past either edge auto-pans one step so the drag can reach text outside the viewport. Drag edges snap to cluster starts like ClickAt. user-select: none keeps the drag a pure caret move: the anchor follows the cursor.

func (*Entry) Echo

func (e *Entry) Echo() Echo

Echo returns the display mode.

func (*Entry) EchoReveal

func (e *Entry) EchoReveal(on bool)

EchoReveal shows the real contents regardless of the echo mode while on. The reveal toggle is the app's job — a peek button, a hold-to-reveal key — and the entry only renders what it is told.

func (*Entry) Element

func (n *Entry) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Entry) Ellipsize

func (e *Entry) Ellipsize() EllipsizeMode

Ellipsize returns the unfocused truncation mode.

func (*Entry) Enabled

func (n *Entry) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Entry) HAlign

func (n *Entry) HAlign() Align

HAlign returns the horizontal placement.

func (*Entry) HasClass

func (n *Entry) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Entry) HasState

func (n *Entry) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Entry) HitLeaf

func (n *Entry) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Entry) HitTest

func (e *Entry) HitTest(p Point) Widget

HitTest returns the entry when p is inside its bounds - the field or, while open, the completion list hanging under it.

func (*Entry) HoverWithin

func (n *Entry) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Entry) ID

func (n *Entry) ID() string

ID returns the style id, empty when none is set.

func (*Entry) IMECommit

func (e *Entry) IMECommit(text string)

IMECommit implements IMEClient; the insertion inside is what actually honors the disabled and read-only gates.

func (*Entry) IMECursorRect

func (e *Entry) IMECursorRect() render.Rect

IMECursorRect implements IMETracker: the caret band in root coordinates, for the input method's candidate window. Pan-aware, so the window tracks the caret inside a panning field, on either direction's reading edge.

func (*Entry) IMEDelete

func (e *Entry) IMEDelete(before, after int)

IMEDelete implements IMEClient: input-method deletion of up to before bytes before and after bytes after the caret. Blocked while disabled or read-only.

func (*Entry) IMEMultiline

func (e *Entry) IMEMultiline() bool

IMEMultiline implements IMETracker.

func (*Entry) IMEPreedit

func (e *Entry) IMEPreedit(text string, cursorBegin, cursorEnd int)

IMEPreedit implements IMEClient. A disabled or read-only entry never enters composing: the input method is told nothing back, so it stops sending preedit after the first empty commit.

func (*Entry) IMERevision added in v0.2.5

func (e *Entry) IMERevision() IMERevision

IMERevision implements IMETracker.

func (*Entry) IMESurrounding

func (e *Entry) IMESurrounding(limit int) (string, int, int)

IMESurrounding implements IMETracker.

func (*Entry) InlineStyle

func (n *Entry) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Entry) Insert

func (e *Entry) Insert(s string)

Insert inserts s at the cursor. An active selection is replaced, and the whole insertion — a paste, a drop, a committed composition — is one undo entry. Blocked while disabled or read-only.

func (*Entry) InsertRune

func (e *Entry) InsertRune(r rune)

InsertRune implements RuneHandler. Typed runes coalesce into one undo entry until a word boundary, an idle gap, or a different edit breaks the run. Blocked while disabled or read-only.

func (*Entry) Invalidate

func (n *Entry) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Entry) InvalidateLayout

func (n *Entry) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Entry) InvalidateRect

func (n *Entry) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Entry) KeyAction

func (e *Entry) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler for editing keys. Shift-extended motion grows the selection from its anchor; ctrl turns arrows and backspace/delete word-wise, alt+backspace aliasing ctrl+backspace. The bare keys edit one grapheme cluster per press (#57), so emoji and accented pairs edit whole. Interaction order: while composing, the input method owns the text and the bare backspace unwinds the composing display one rune first — that is compose state (#54), orthogonal to committed text; after it, ctrl/alt make backspace and delete word-wise over the cluster-refined words (#56); the bare keys apply to the contents one cluster at a time. A disabled entry ignores keys outright; a read-only one keeps the motion and selection keys and drops only the mutating ones.

func (*Entry) LayoutMotion

func (n *Entry) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Entry) LeadingIcon

func (e *Entry) LeadingIcon() *Icon

LeadingIcon returns the entry's leading icon, nil when unset.

func (*Entry) Margin

func (n *Entry) Margin() render.Insets

Margin returns the programmatic margin.

func (*Entry) MaximumSize

func (n *Entry) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Entry) Measure

func (e *Entry) Measure(axis Axis, forSize int) Sizes

Measure wants the text advance (or the placeholder's) plus padding; an empty field keeps its padding so the box stays visible. Composing text counts toward the wanted width. SetTextWidth fixes the text's share instead. MaxWidth caps the wanted width — a 500-character paste then stops widening the layout at the cap and pans inside it instead. The field needs only its insets and the width-chars floor (GtkText's minimum without width-chars is no text at all), the text panning inside what it gets. The stylesheet's min-* floors hold on both, and its margin sits outside the field, as in every CSS box. The open completion list claims height below the field.

func (*Entry) MoveCursor

func (e *Entry) MoveCursor(delta int)

MoveCursor moves the cursor by delta grapheme clusters, clamped to [0, len] (#57: one emoji, one step). An active selection collapses to the edge the motion points at first, without moving further - the standard first-press behavior.

func (*Entry) MoveCursorExtending

func (e *Entry) MoveCursorExtending(delta int)

MoveCursorExtending moves the cursor by delta grapheme clusters, growing or shrinking the selection from its anchor (shift+arrow behavior); selection edges land on cluster boundaries.

func (*Entry) MoveEnd

func (e *Entry) MoveEnd()

MoveEnd puts the cursor after the last rune, dropping any selection, and pans the field so the tail is on show.

func (*Entry) MoveHome

func (e *Entry) MoveHome()

MoveHome puts the cursor at the start, dropping any selection; the pan follows, back to zero.

func (*Entry) MoveWord

func (e *Entry) MoveWord(delta int)

MoveWord moves the cursor one visual word: the word edge the direction points at, gaps (whitespace, punctuation runs) skipped whole. An active selection collapses to the visually-directed edge first, without moving.

func (*Entry) MoveWordExtending

func (e *Entry) MoveWordExtending(delta int)

MoveWordExtending is MoveWord with shift held: the selection extends from its anchor to the word edge.

func (*Entry) OffsetAt

func (e *Entry) OffsetAt(p Point) int

OffsetAt implements TextGeometry.

func (*Entry) Paint

func (e *Entry) Paint(cv *render.Canvas)

Paint draws the field: placeholder when empty, text otherwise, the selection highlight, the composing text with its underline, and the cursor bar. Overflowing text pans: the content draws at -scrollX, clipped to the inner rect, so the caret never leaves the field. The placeholder only shows on an empty field and never pans. Zero color fields fall back to the theme.

State colors: a disabled field fills with the derived disabled surface and paints text at the shared disabled fade; a read-only field keeps the normal text and fades only the caret, so the two states read differently at a glance (muted text vs muted caret). The stylesheet layers between the programmatic color and the theme, and border-width rounds the fill down inside a border-color stroke.

func (*Entry) Parent

func (n *Entry) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Entry) Placeholder

func (e *Entry) Placeholder() string

Placeholder returns the text shown when the entry is empty.

func (*Entry) ReadOnly

func (e *Entry) ReadOnly() bool

ReadOnly reports whether the entry is in the read-only mode.

func (*Entry) Redo

func (e *Entry) Redo() bool

Redo reapplies the most recently undone edit, reporting whether there was one. Like Undo it is a user edit and no-ops while disabled or read-only.

func (*Entry) RemoveAttr

func (n *Entry) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Entry) RemoveClass

func (n *Entry) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Entry) Revealing

func (e *Entry) Revealing() bool

Revealing reports whether the reveal override is on.

func (*Entry) Role

func (e *Entry) Role() Role

Role implements Roleer.

func (*Entry) ScrollX

func (e *Entry) ScrollX() int

ScrollX returns the horizontal pan: the display-space x of the first on-show pixel.

func (*Entry) Select

func (e *Entry) Select(start, end int)

Select implements TextSelector.

func (*Entry) SelectAll

func (e *Entry) SelectAll()

SelectAll selects the entire contents; the pan follows the caret to the end.

func (*Entry) SelectedText

func (e *Entry) SelectedText() (string, bool)

SelectedText implements SelectedTexter.

func (*Entry) Selection

func (e *Entry) Selection() (start, end int, active bool)

Selection returns the selected rune range and whether a non-empty selection exists.

func (*Entry) SetAccessibleName

func (n *Entry) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Entry) SetAttr

func (n *Entry) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Entry) SetCaret

func (e *Entry) SetCaret(offset int)

SetCaret implements TextSelector.

func (*Entry) SetClass

func (n *Entry) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Entry) SetClasses

func (n *Entry) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Entry) SetColor

func (e *Entry) SetColor(c render.Color)

SetColor sets the programmatic text ink; zero hands the color back to the stylesheet (the text node's, else the entry's color), as a Label's does. A preset built on Entry (SearchEntry) starts from the theme's text ink, so a styled application clears it here.

func (*Entry) SetCursorName

func (n *Entry) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Entry) SetDebugName

func (n *Entry) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Entry) SetDirection

func (e *Entry) SetDirection(d Direction)

SetDirection selects the base paragraph direction the contents resolve and lay out with. DirectionAuto (the default) reads it off the text's first strong character; DirectionRTL additionally hugs short text against the right edge, where its reading starts, and mirrors the pan. Arrow and word motion always move visually - the mapping runs through the same resolution (internal/text) the paint uses - while cursor, anchor, and selection stay logical rune indexes. Changing the direction re-pans and invalidates.

func (*Entry) SetEcho

func (e *Entry) SetEcho(mode Echo)

SetEcho sets the display mode. Contents and caret/selection math stay logical whatever the mode.

func (*Entry) SetElement

func (n *Entry) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Entry) SetEllipsize

func (e *Entry) SetEllipsize(mode EllipsizeMode)

SetEllipsize truncates the shown text where mode says, as a Label does, while the field is unfocused and too short for it: a path field reads "/home/me/…/file" at rest and shows its full text to edit once focused. The text itself, the selection and the caret are untouched. EllipsizeNone, the default, always shows the text panned.

func (*Entry) SetEnabled

func (n *Entry) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Entry) SetFocusOnClick

func (n *Entry) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Entry) SetHAlign

func (n *Entry) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Entry) SetHExpand

func (n *Entry) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Entry) SetID

func (n *Entry) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Entry) SetInlineStyle

func (n *Entry) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Entry) SetInlineStylePriority

func (n *Entry) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Entry) SetLayoutMotion

func (n *Entry) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Entry) SetLeadingIcon

func (e *Entry) SetLeadingIcon(name string, px float64, onClick func())

SetLeadingIcon shows a themed icon at the entry's start — GtkEntry's primary icon, cascade-painted like the secondary one; onClick fires on a press over it, nil keeps it display-only. An empty name clears it.

func (*Entry) SetMargin

func (n *Entry) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Entry) SetMaximumSize

func (n *Entry) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Entry) SetOnClickWithin

func (n *Entry) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Entry) SetOnFocusChanged

func (n *Entry) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Entry) SetOnHoverWithin

func (n *Entry) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Entry) SetOnPointer

func (n *Entry) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Entry) SetOnScroll

func (n *Entry) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Entry) SetPlaceholder

func (e *Entry) SetPlaceholder(s string)

SetPlaceholder sets the text shown when the entry is empty.

func (*Entry) SetReadOnly

func (e *Entry) SetReadOnly(ro bool)

SetReadOnly toggles the read-only mode for copy-only fields (a generated API key, a resolved config value). The contract:

  • blocked: typing, paste, drop, composition, Backspace/Delete (cut), Undo/Redo, and — because they are user edits — new undo entries. A history built before SetReadOnly(true) is untouched, not cleared: flipping read-only back off resumes backing out the very same edits.
  • still working: selection (click, drag, double-click, SelectAll), copy through SelectedText, caret motion, and pan.
  • visual: the text keeps its normal color; only the caret fades to the disabled fade. A disabled entry is the mirror image — muted text — so the two states never look alike.

SetText remains programmatic and applies regardless.

func (*Entry) SetSharedElement

func (n *Entry) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Entry) SetSizeRequest

func (n *Entry) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Entry) SetState

func (n *Entry) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Entry) SetText

func (e *Entry) SetText(s string)

SetText replaces the contents, moves the cursor to the end, and invalidates the field.

func (*Entry) SetTextWidth

func (e *Entry) SetTextWidth(px int)

SetTextWidth fixes the text area's natural width at px, padding aside, the way GtkEntry sizes a field: what is typed pans inside it instead of resizing the layout, and an empty field keeps its width. Zero (the default) hugs the content.

func (*Entry) SetTooltip

func (n *Entry) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Entry) SetTooltipMarkup

func (n *Entry) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Entry) SetTrailingIcon

func (e *Entry) SetTrailingIcon(name string, px float64, onClick func())

SetTrailingIcon shows a themed icon at the entry's end — the entry > image node, GtkEntry's secondary icon: a password field's peek toggle, a search's clear button. The icon paints from the cascade like any image (entry.network-password-input > image colors the peek); onClick fires on a press over it, and nil keeps it display-only. An empty name clears it.

func (*Entry) SetVAlign

func (n *Entry) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Entry) SetVExpand

func (n *Entry) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Entry) SetVisible

func (n *Entry) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Entry) SetWidthChars

func (e *Entry) SetWidthChars(minChars, maxChars int)

SetWidthChars sizes the field in characters, GtkEntry's width-chars and max-width-chars: the text never narrows below minChars, and naturally takes maxChars (GTKTextWidth while maxChars is 0), at least minChars. Both 0 restores SetTextWidth's sizing.

func (*Entry) SharedElement

func (n *Entry) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Entry) SizeRequest

func (n *Entry) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Entry) Text

func (e *Entry) Text() string

Text returns the entry contents.

func (*Entry) TextWidth

func (e *Entry) TextWidth() int

TextWidth reports SetTextWidth.

func (*Entry) TooltipMarkup

func (n *Entry) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Entry) TooltipText

func (n *Entry) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Entry) TrailingIcon

func (e *Entry) TrailingIcon() *Icon

TrailingIcon returns the entry's trailing icon, nil when unset.

func (*Entry) Undo

func (e *Entry) Undo() bool

Undo restores the state before the most recent edit — contents, caret, and selection included — reporting whether there was anything to undo. Composing text drops first, like before any other edit. Undo is a user edit: disabled or read-only, it no-ops and returns false while the history waits untouched.

func (*Entry) VAlign

func (n *Entry) VAlign() Align

VAlign returns the vertical placement.

func (*Entry) Visible

func (n *Entry) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*Entry) WidthChars

func (e *Entry) WidthChars() (minChars, maxChars int)

WidthChars reports SetWidthChars.

type EntryRow

type EntryRow struct {
	*ActionRow
	// contains filtered or unexported fields
}

EntryRow is the adw signature: the entry IS the row - title label to the leading side, the free-text field filling the rest.

func NewEntryRow

func NewEntryRow(face render.Font, sizePx float64, title, initial string) *EntryRow

NewEntryRow returns the row with the field's text starting at initial.

func (EntryRow) Arrange

func (c EntryRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (EntryRow) Baseline

func (c EntryRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (EntryRow) Children

func (c EntryRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*EntryRow) Entry

func (r *EntryRow) Entry() *Entry

Entry returns the embedded field, for hooks and BindText.

func (EntryRow) HitTest

func (c EntryRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (EntryRow) Measure

func (c EntryRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (EntryRow) PackEnd

func (p EntryRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (EntryRow) PackStart

func (p EntryRow) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*EntryRow) SetText

func (r *EntryRow) SetText(s string)

SetText replaces the field's contents.

func (*EntryRow) Text

func (r *EntryRow) Text() string

Text reports the field's contents.

type Expander

type Expander struct {

	// OnToggled fires after every open-state change, including
	// programmatic ones.
	OnToggled func(open bool)
	// contains filtered or unexported fields
}

Expander is a collapsible section: a header row (the title, and a chevron at the end turning from down to up) toggles the child beneath it. Toggling animates the height over the animation clock, with the chevron turning on the same progress, and the open state is remembered — a collapsed expander reopens to where it was, and state survives being hidden by a parent. Children exposes the child only while open, so focus traversal never lands inside a closed section.

func NewExpander

func NewExpander(face render.Font, title string, child Widget) *Expander

NewExpander returns a collapsed section titled title wrapping child, painted with face at the theme's text size. Face may be a render.Chain for mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*Expander) AccessibleName

func (n *Expander) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Expander) AddClass

func (n *Expander) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Expander) Arrange

func (e *Expander) Arrange(r render.Rect)

Arrange records the rect, positions the child under the header at the animated height, and stops the reveal cold when the expander went off screen (a hidden widget holds no timer; the state keeps whatever it reached).

func (*Expander) AttachStylesheet

func (n *Expander) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Expander) Attr

func (n *Expander) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Expander) Bounds

func (n *Expander) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Expander) Children

func (e *Expander) Children() []Widget

Children exposes the child only while open, so keyboard traversal and tree walks skip a closed section's content.

func (*Expander) Classes

func (n *Expander) Classes() []string

Classes returns a copy of the widget's classes.

func (*Expander) ClickAt

func (e *Expander) ClickAt(p Point)

ClickAt toggles when the release landed on the header.

func (*Expander) DebugName

func (n *Expander) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Expander) DetachStylesheet

func (n *Expander) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Expander) Element

func (n *Expander) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Expander) Enabled

func (n *Expander) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Expander) HAlign

func (n *Expander) HAlign() Align

HAlign returns the horizontal placement.

func (*Expander) HasClass

func (n *Expander) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Expander) HasState

func (n *Expander) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Expander) HitLeaf

func (n *Expander) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Expander) HitTest

func (e *Expander) HitTest(p Point) Widget

HitTest resolves the header into the expander (clicks toggle) and otherwise delegates to the revealed child.

func (*Expander) HoverWithin

func (n *Expander) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Expander) ID

func (n *Expander) ID() string

ID returns the style id, empty when none is set.

func (*Expander) InlineStyle

func (n *Expander) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Expander) InsertRune

func (e *Expander) InsertRune(r rune)

InsertRune implements RuneHandler: Space toggles, the other half of the GTK activation pair.

func (*Expander) Invalidate

func (n *Expander) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Expander) InvalidateLayout

func (n *Expander) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Expander) InvalidateRect

func (n *Expander) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Expander) KeyAction

func (e *Expander) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: Enter toggles when focused, which makes the section reachable and operable by keyboard only.

func (*Expander) LayoutMotion

func (n *Expander) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Expander) Margin

func (n *Expander) Margin() render.Insets

Margin returns the programmatic margin.

func (*Expander) MaximumSize

func (n *Expander) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Expander) Measure

func (e *Expander) Measure(axis Axis, forSize int) Sizes

Measure reports the header plus the revealed fraction of the child.

func (*Expander) Open

func (e *Expander) Open() bool

Open reports the toggle state (the settled layout, not the animated progress).

func (*Expander) Paint

func (e *Expander) Paint(cv *render.Canvas)

Paint draws the header — hover shade, title, chevron at the reveal angle — then the child, clipped to the revealed strip.

func (*Expander) Parent

func (n *Expander) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Expander) RemoveAttr

func (n *Expander) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Expander) RemoveClass

func (n *Expander) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Expander) SetAccessibleName

func (n *Expander) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Expander) SetAttr

func (n *Expander) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Expander) SetClass

func (n *Expander) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Expander) SetClasses

func (n *Expander) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Expander) SetCursorName

func (n *Expander) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Expander) SetDebugName

func (n *Expander) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Expander) SetElement

func (n *Expander) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Expander) SetEnabled

func (e *Expander) SetEnabled(enabled bool)

SetEnabled turns the expander and its content on or off through the per-query enable walk, like Box.

func (*Expander) SetFocusOnClick

func (n *Expander) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Expander) SetHAlign

func (n *Expander) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Expander) SetHExpand

func (n *Expander) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Expander) SetHovered

func (e *Expander) SetHovered(on bool)

SetHovered implements HoverSetter; the header shade repaints.

func (*Expander) SetID

func (n *Expander) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Expander) SetInlineStyle

func (n *Expander) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Expander) SetInlineStylePriority

func (n *Expander) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Expander) SetLayoutMotion

func (n *Expander) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Expander) SetMargin

func (n *Expander) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Expander) SetMaximumSize

func (n *Expander) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Expander) SetOnClickWithin

func (n *Expander) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Expander) SetOnFocusChanged

func (n *Expander) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Expander) SetOnHoverWithin

func (n *Expander) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Expander) SetOnPointer

func (n *Expander) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Expander) SetOnScroll

func (n *Expander) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Expander) SetOpen

func (e *Expander) SetOpen(open bool)

SetOpen opens or closes the section, animating the height. Fires OnToggled when the state flipped.

func (*Expander) SetSharedElement

func (n *Expander) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Expander) SetSizeRequest

func (n *Expander) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Expander) SetState

func (n *Expander) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Expander) SetTitle

func (e *Expander) SetTitle(title string)

SetTitle replaces the header text.

func (*Expander) SetTooltip

func (n *Expander) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Expander) SetTooltipMarkup

func (n *Expander) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Expander) SetVAlign

func (n *Expander) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Expander) SetVExpand

func (n *Expander) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Expander) SetVisible

func (n *Expander) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Expander) SharedElement

func (n *Expander) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Expander) SizeRequest

func (n *Expander) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Expander) Title

func (e *Expander) Title() string

Title returns the header text.

func (*Expander) Toggle

func (e *Expander) Toggle()

Toggle flips the open state.

func (*Expander) TooltipMarkup

func (n *Expander) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Expander) TooltipText

func (n *Expander) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Expander) VAlign

func (n *Expander) VAlign() Align

VAlign returns the vertical placement.

func (*Expander) Visible

func (n *Expander) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ExpanderRow

type ExpanderRow struct {
	*ActionRow
	// contains filtered or unexported fields
}

ExpanderRow is an ActionRow whose activation discloses sub-rows: any widget (more rows, a group) inside the row's own disclosure, with the chevron's direction tracking it.

func NewExpanderRow

func NewExpanderRow(face render.Font, sizePx float64, title, subtitle string) *ExpanderRow

NewExpanderRow returns a collapsed expander; Add appends into its content.

func (*ExpanderRow) Add

func (r *ExpanderRow) Add(w Widget)

Add appends a sub-row (or any widget) to the disclosed content.

func (ExpanderRow) Arrange

func (c ExpanderRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (ExpanderRow) Baseline

func (c ExpanderRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (ExpanderRow) Children

func (c ExpanderRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ExpanderRow) Expand

func (r *ExpanderRow) Expand()

Expand toggles the disclosure.

func (*ExpanderRow) Expanded

func (r *ExpanderRow) Expanded() bool

Expanded reports the disclosure state.

func (ExpanderRow) HitTest

func (c ExpanderRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (ExpanderRow) Measure

func (c ExpanderRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (ExpanderRow) PackEnd

func (p ExpanderRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (ExpanderRow) PackStart

func (p ExpanderRow) PackStart(w Widget)

PackStart adds w to the leading slot.

type Fader

type Fader struct {
	Opacity
	// contains filtered or unexported fields
}

Fader modulates one child's whole subtree: every color the child and its descendants paint is scaled by the fader's opacity — fills, borders, text, and image blits alike — without threading an alpha through their colors. It is the one-off shape of Opacity: wrap a child, tween SetOpacity from the animation clock (anim.Animate(dur, f.SetOpacity)), and discard it with the subtree.

Layout is a pass-through — the fader claims and paints exactly the child's rect — so its invalidation covers everything the fade changes. The subtree still hit-tests at zero opacity: the factor is visual, and a mid-fade menu must keep taking clicks.

func NewFader

func NewFader(child Widget) *Fader

NewFader wraps child in a fully opaque fader.

func (*Fader) AccessibleName

func (n *Fader) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Fader) AddClass

func (n *Fader) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Fader) Arrange

func (f *Fader) Arrange(r render.Rect)

Arrange passes the rect straight through to the child.

func (*Fader) ArrangeRoot

func (f *Fader) ArrangeRoot(r render.Rect)

ArrangeRoot records the fader's own rect.

func (*Fader) AttachStylesheet

func (n *Fader) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Fader) Attr

func (n *Fader) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Fader) Bounds

func (n *Fader) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Fader) Child

func (f *Fader) Child() Widget

Child returns the wrapped widget.

func (*Fader) Children

func (f *Fader) Children() []Widget

Children exposes the child for the damage collector, focus traversal, and the accessibility walk.

func (*Fader) Classes

func (n *Fader) Classes() []string

Classes returns a copy of the widget's classes.

func (*Fader) DebugName

func (n *Fader) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Fader) DetachStylesheet

func (n *Fader) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Fader) Element

func (n *Fader) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Fader) Enabled

func (n *Fader) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Fader) HAlign

func (n *Fader) HAlign() Align

HAlign returns the horizontal placement.

func (*Fader) HasClass

func (n *Fader) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Fader) HasState

func (n *Fader) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Fader) HitLeaf

func (n *Fader) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Fader) HitTest

func (f *Fader) HitTest(p Point) Widget

HitTest returns the deepest widget under p: the child's pick, or the fader itself over its own padding-less bounds — opacity never empties the hit region.

func (*Fader) HoverWithin

func (n *Fader) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Fader) ID

func (n *Fader) ID() string

ID returns the style id, empty when none is set.

func (*Fader) InlineStyle

func (n *Fader) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Fader) Invalidate

func (n *Fader) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Fader) InvalidateLayout

func (n *Fader) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Fader) InvalidateRect

func (n *Fader) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Fader) LayoutMotion

func (n *Fader) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Fader) Margin

func (n *Fader) Margin() render.Insets

Margin returns the programmatic margin.

func (*Fader) MaximumSize

func (n *Fader) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Fader) Measure

func (f *Fader) Measure(axis Axis, forSize int) Sizes

Measure reports the child's request.

func (*Fader) Paint

func (f *Fader) Paint(cv *render.Canvas)

Paint paints the child under the fader's opacity; see Opacity.paintChild for the zero/one fast paths.

func (*Fader) Parent

func (n *Fader) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Fader) RemoveAttr

func (n *Fader) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Fader) RemoveClass

func (n *Fader) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Fader) SetAccessibleName

func (n *Fader) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Fader) SetAttr

func (n *Fader) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Fader) SetClass

func (n *Fader) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Fader) SetClasses

func (n *Fader) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Fader) SetCursorName

func (n *Fader) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Fader) SetDebugName

func (n *Fader) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Fader) SetElement

func (n *Fader) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Fader) SetEnabled

func (f *Fader) SetEnabled(enabled bool)

SetEnabled turns the fader's child on or off through the per-query enable walk, like Box.

func (*Fader) SetFocusOnClick

func (n *Fader) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Fader) SetHAlign

func (n *Fader) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Fader) SetHExpand

func (n *Fader) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Fader) SetID

func (n *Fader) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Fader) SetInlineStyle

func (n *Fader) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Fader) SetInlineStylePriority

func (n *Fader) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Fader) SetLayoutMotion

func (n *Fader) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Fader) SetMargin

func (n *Fader) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Fader) SetMaximumSize

func (n *Fader) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Fader) SetOnClickWithin

func (n *Fader) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Fader) SetOnFocusChanged

func (n *Fader) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Fader) SetOnHoverWithin

func (n *Fader) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Fader) SetOnPointer

func (n *Fader) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Fader) SetOnScroll

func (n *Fader) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Fader) SetSharedElement

func (n *Fader) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Fader) SetSizeRequest

func (n *Fader) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Fader) SetState

func (n *Fader) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Fader) SetTooltip

func (n *Fader) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Fader) SetTooltipMarkup

func (n *Fader) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Fader) SetVAlign

func (n *Fader) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Fader) SetVExpand

func (n *Fader) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Fader) SetVisible

func (n *Fader) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Fader) SharedElement

func (n *Fader) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Fader) SizeRequest

func (n *Fader) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Fader) TooltipMarkup

func (n *Fader) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Fader) TooltipText

func (n *Fader) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Fader) VAlign

func (n *Fader) VAlign() Align

VAlign returns the vertical placement.

func (*Fader) Visible

func (n *Fader) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field is a labeled form control: a label, the control, an optional description and an error message, which turns the field invalid - the control takes the .error class and the label the destructive color. The label also names the control for assistive technology unless it was named already. It styles as the `field` element (.invalid while it shows an error) with .title, .description and .error labels.

func NewField

func NewField(face render.Font, label string, control Widget) *Field

NewField returns a vertical field labeled label around control.

func (*Field) Arrange

func (f *Field) Arrange(r render.Rect)

Arrange evaluates the responsive breakpoint against the width, then lays the parts out.

func (*Field) Baseline

func (c *Field) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Field) Children

func (c *Field) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Field) Control

func (f *Field) Control() Widget

Control returns the control.

func (*Field) Description

func (f *Field) Description() string

Description returns the help text.

func (*Field) Error

func (f *Field) Error() string

Error returns the error message, empty while the field is valid.

func (*Field) HitTest

func (c *Field) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Field) Label

func (f *Field) Label() string

Label returns the label.

func (*Field) Measure

func (c *Field) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Field) Orientation

func (f *Field) Orientation() FieldOrientation

Orientation returns the layout.

func (*Field) Paint

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

Paint draws the surface (when configured) then the root.

func (*Field) SetDescription

func (f *Field) SetDescription(s string)

SetDescription sets the help text under the label; empty hides it.

func (*Field) SetError

func (f *Field) SetError(msg string)

SetError shows msg and marks the field invalid; empty clears both.

func (*Field) SetLabel

func (f *Field) SetLabel(s string)

SetLabel replaces the label.

func (*Field) SetOrientation

func (f *Field) SetOrientation(o FieldOrientation)

SetOrientation switches the layout.

type FieldOrientation

type FieldOrientation uint8

FieldOrientation is how a Field lays its label out against its control.

const (
	// FieldVertical stacks the label, the control, the description and
	// the error.
	FieldVertical FieldOrientation = iota
	// FieldHorizontal puts the label, description and error beside the
	// control: a switch or a checkbox with its text.
	FieldHorizontal
	// FieldResponsive is horizontal from fieldResponsiveMin wide, and
	// vertical below.
	FieldResponsive
)

The field orientations.

type FieldSet

type FieldSet struct {
	// contains filtered or unexported fields
}

FieldSet groups related fields under a legend: the legend, an optional description, and the fields. It styles as the `fieldset` element with a .legend label.

func NewFieldSet

func NewFieldSet(face render.Font, legend string) *FieldSet

NewFieldSet returns an empty set under legend.

func (*FieldSet) Add

func (s *FieldSet) Add(w Widget)

Add appends a field (or any widget) to the set.

func (*FieldSet) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*FieldSet) Baseline

func (c *FieldSet) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*FieldSet) Children

func (c *FieldSet) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*FieldSet) HitTest

func (c *FieldSet) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*FieldSet) Measure

func (c *FieldSet) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*FieldSet) Paint

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

Paint draws the surface (when configured) then the root.

func (*FieldSet) SetDescription

func (s *FieldSet) SetDescription(text string)

SetDescription sets the text under the legend; empty hides it.

type FileChooser

type FileChooser struct {

	// OnApply, when set, receives every validated apply: the chosen
	// absolute paths (one in save and single-open mode, the selection
	// in multiple mode, a directory in folder mode).
	OnApply func(paths []string)
	// contains filtered or unexported fields
}

FileChooser is the pure-Go file picker behind app.OpenFileDialog and app.SaveFileDialog (#82): a places row, the current directory's listing, filters, a name row in save mode, and Apply validation. It is the whole picker lys-ui needs - List, Entry, Dropdown, and Button are the parts - so it works on any compositor with no portal in sight; the directory listing comes from an injected source, the seam tests and any future portal backend plug into.

Navigation: Up climbs one directory, the place buttons jump home, to the filesystem root, or into the recents view, and activating a row enters a directory or applies a file. Apply validates: an empty selection, an empty name, or a name carrying a path separator sets the status line and applies nothing.

Listing a directory waits on the disk, so it runs off the loop: the view clears at once and fills when the answer comes, and an answer to a view left since is dropped. Without an invoker (no loop to answer on, the state before an Application exists) it runs inline.

func NewFileChooser

func NewFileChooser(face render.Font, sizePx float64, mode FileMode, startDir string, filters []FileFilter) *FileChooser

NewFileChooser returns a chooser in mode starting at startDir (the home directory when empty), filtered by filters (a nil or empty list accepts everything; more than one shows a dropdown).

func (*FileChooser) Apply

func (c *FileChooser) Apply() ([]string, bool)

Apply validates and applies the current selection: in open modes the selected files, in folder mode the selected or current directory, in save mode the name row joined onto the directory. It returns the absolute paths and reports whether the apply was valid; an invalid apply sets the status line instead.

func (*FileChooser) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*FileChooser) Baseline

func (c *FileChooser) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*FileChooser) Children

func (c *FileChooser) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*FileChooser) Dir

func (c *FileChooser) Dir() string

Dir reports the directory being browsed ("" in the recents view).

func (*FileChooser) HitTest

func (c *FileChooser) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*FileChooser) Measure

func (c *FileChooser) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*FileChooser) Paint

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

Paint draws the surface (when configured) then the root.

func (*FileChooser) SetRecentsSource

func (c *FileChooser) SetRecentsSource(paths func() []string)

SetRecentsSource wires the recents view: paths lists the recent files (most recent first) and the Recent place appears; without it the picker is a plain browser. Like a DirSource, paths runs off the loop goroutine and must touch no widget.

func (*FileChooser) SetSaveName

func (c *FileChooser) SetSaveName(name string)

SetSaveName pre-fills the save name row (save mode only).

func (*FileChooser) SetSource

func (c *FileChooser) SetSource(src DirSource)

SetSource replaces the directory listing source (tests, portals).

func (*FileChooser) SetStatus

func (c *FileChooser) SetStatus(text string)

SetStatus shows or clears the status line.

type FileEntry

type FileEntry struct {
	Name string
	Dir  bool
}

FileEntry is one row of a listing: its name and whether it is a directory.

type FileFilter

type FileFilter struct {
	Name     string
	Patterns []string
}

FileFilter names one set of acceptable files: Patterns are shell globs matched against the base name, case-insensitively ("*.png", "Makefile"). Directories always pass; an empty pattern list accepts every file.

type FileMode

type FileMode uint8

FileMode is what a FileChooser is picking.

const (
	// FileModeOpen picks one existing file.
	FileModeOpen FileMode = iota
	// FileModeOpenMultiple picks any set of existing files.
	FileModeOpenMultiple
	// FileModeOpenFolder picks one directory (the current one when no
	// row is selected).
	FileModeOpenFolder
	// FileModeSave names a file in the current directory; overwrite
	// confirmation is the caller's policy on the absolute path Apply
	// returned.
	FileModeSave
)

type Fixed

type Fixed struct {
	// contains filtered or unexported fields
}

Fixed places its children at explicit coordinates, GTK's Fixed: there are no tracks and no negotiation - a child sits at the (x, y) it was put at, negative coordinates included, at its natural size, and children may overlap freely, later puts painting and hitting on top of earlier ones.

The container measures to the union of its children's extents: from the leftmost child's left edge to the rightmost child's right edge, likewise vertically, so children at negative coordinates grow the request in that direction while still arranging at their negative offset - the painter's clip decides visibility, exactly like a squeezed Box child overflowing its cell. An empty Fixed measures as nothing.

func NewFixed

func NewFixed() *Fixed

NewFixed returns an empty fixed container.

func (*Fixed) AccessibleName

func (n *Fixed) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Fixed) AddClass

func (n *Fixed) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Fixed) Arrange

func (f *Fixed) Arrange(r render.Rect)

Arrange places every child at its coordinates at its natural size, relative to the container's origin.

func (*Fixed) ArrangeRoot

func (f *Fixed) ArrangeRoot(r render.Rect)

ArrangeRoot records the container's own rect.

func (*Fixed) AttachStylesheet

func (n *Fixed) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Fixed) Attr

func (n *Fixed) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Fixed) Bounds

func (n *Fixed) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Fixed) Children

func (f *Fixed) Children() []Widget

Children exposes the children in put order, the order focus traversal and painting follow.

func (*Fixed) Classes

func (n *Fixed) Classes() []string

Classes returns a copy of the widget's classes.

func (*Fixed) DebugName

func (n *Fixed) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Fixed) DetachStylesheet

func (n *Fixed) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Fixed) Element

func (n *Fixed) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Fixed) Enabled

func (n *Fixed) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Fixed) HAlign

func (n *Fixed) HAlign() Align

HAlign returns the horizontal placement.

func (*Fixed) HasClass

func (n *Fixed) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Fixed) HasState

func (n *Fixed) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Fixed) HitLeaf

func (n *Fixed) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Fixed) HitTest

func (f *Fixed) HitTest(p Point) Widget

HitTest returns the topmost child under p (later puts sit on top), or the fixed itself when p is inside its bounds but over no child.

func (*Fixed) HoverWithin

func (n *Fixed) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Fixed) ID

func (n *Fixed) ID() string

ID returns the style id, empty when none is set.

func (*Fixed) InlineStyle

func (n *Fixed) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Fixed) Invalidate

func (n *Fixed) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Fixed) InvalidateLayout

func (n *Fixed) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Fixed) InvalidateRect

func (n *Fixed) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Fixed) LayoutMotion

func (n *Fixed) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Fixed) Margin

func (n *Fixed) Margin() render.Insets

Margin returns the programmatic margin.

func (*Fixed) MaximumSize

func (n *Fixed) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Fixed) Measure

func (f *Fixed) Measure(axis Axis, forSize int) Sizes

Measure measures every child at its natural size and reports the union of their extents from their coordinates. The result is cached until an InvalidateLayout anywhere in the subtree.

func (*Fixed) Move

func (f *Fixed) Move(w Widget, x, y int) *Fixed

Move moves an attached child to (x, y) in place, without detaching it, so its focus and state survive; the old and new pixels both repaint. Unknown widgets are ignored.

func (*Fixed) Paint

func (f *Fixed) Paint(cv *render.Canvas)

Paint draws the children in put order, so overlapping children composite bottom to top.

func (*Fixed) Parent

func (n *Fixed) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Fixed) Put

func (f *Fixed) Put(w Widget, x, y int) *Fixed

Put adds w at (x, y) and returns the fixed for chaining. Putting a widget that is already in the container moves it to the new coordinates (a widget sits in the fixed once). The measure cache drops so the next frame reflows.

func (*Fixed) Remove

func (f *Fixed) Remove(w Widget) bool

Remove detaches w and reports whether it was attached. The removed widget's parent link clears and the removal hook fires, like every tree mutation; the measure cache drops so the next frame reflows without it.

func (*Fixed) RemoveAttr

func (n *Fixed) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Fixed) RemoveClass

func (n *Fixed) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Fixed) SetAccessibleName

func (n *Fixed) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Fixed) SetAttr

func (n *Fixed) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Fixed) SetClass

func (n *Fixed) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Fixed) SetClasses

func (n *Fixed) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Fixed) SetCursorName

func (n *Fixed) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Fixed) SetDebugName

func (n *Fixed) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Fixed) SetElement

func (n *Fixed) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Fixed) SetEnabled

func (f *Fixed) SetEnabled(enabled bool)

SetEnabled turns the fixed's subtree on or off through the per-query enable walk, like Box.

func (*Fixed) SetFocusOnClick

func (n *Fixed) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Fixed) SetHAlign

func (n *Fixed) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Fixed) SetHExpand

func (n *Fixed) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Fixed) SetID

func (n *Fixed) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Fixed) SetInlineStyle

func (n *Fixed) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Fixed) SetInlineStylePriority

func (n *Fixed) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Fixed) SetLayoutMotion

func (n *Fixed) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Fixed) SetMargin

func (n *Fixed) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Fixed) SetMaximumSize

func (n *Fixed) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Fixed) SetOnClickWithin

func (n *Fixed) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Fixed) SetOnFocusChanged

func (n *Fixed) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Fixed) SetOnHoverWithin

func (n *Fixed) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Fixed) SetOnPointer

func (n *Fixed) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Fixed) SetOnScroll

func (n *Fixed) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Fixed) SetSharedElement

func (n *Fixed) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Fixed) SetSizeRequest

func (n *Fixed) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Fixed) SetState

func (n *Fixed) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Fixed) SetTooltip

func (n *Fixed) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Fixed) SetTooltipMarkup

func (n *Fixed) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Fixed) SetVAlign

func (n *Fixed) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Fixed) SetVExpand

func (n *Fixed) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Fixed) SetVisible

func (n *Fixed) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Fixed) SharedElement

func (n *Fixed) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Fixed) SizeRequest

func (n *Fixed) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Fixed) TooltipMarkup

func (n *Fixed) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Fixed) TooltipText

func (n *Fixed) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Fixed) VAlign

func (n *Fixed) VAlign() Align

VAlign returns the vertical placement.

func (*Fixed) Visible

func (n *Fixed) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type FlatRow

type FlatRow[T any] struct {
	Index    int
	Depth    int
	Value    T
	Leaf     bool
	Expanded bool
}

FlatRow is one visible tree row: its visible index, its depth, its value, whether it can expand, and whether it currently is.

type FlatTree

type FlatTree[T any] struct {
	// contains filtered or unexported fields
}

FlatTree flattens a TreeRow forest into visible rows and owns the expansion state. It implements ColumnModel[FlatRow[T]] directly:

tree := widget.NewFlatTree(roots)
view := widget.NewColumnView(face, 14, tree, []widget.TableColumn[widget.FlatRow[item]]{{
	Title: "Name", Expand: true,
	Cell: widget.TreeCell(tree, 14, func(it item) Widget {
		return widget.NewLabel(face, 14, it.Name, 0)
	}),
}})

func NewFlatTree

func NewFlatTree[T any](roots []TreeRow[T]) *FlatTree[T]

NewFlatTree flattens roots with every collapsible row expanded.

func (*FlatTree[T]) Len

func (f *FlatTree[T]) Len() int

Len implements ColumnModel.

func (*FlatTree[T]) Notify

func (f *FlatTree[T]) Notify()

Notify runs the installed refresh hook.

func (*FlatTree[T]) Row

func (f *FlatTree[T]) Row(i int) FlatRow[T]

Row implements ColumnModel.

func (*FlatTree[T]) SetRefresh

func (f *FlatTree[T]) SetRefresh(fn func())

SetRefresh installs the hook TreeCell's toggle runs after a collapse or expand (a ColumnView's owner wires it to the view's List().Reset).

func (*FlatTree[T]) Toggle

func (f *FlatTree[T]) Toggle(i int)

Toggle flips visible row i's expansion (leaves stay). The caller refreshes the view (its List's Reset, or the view's own recompute through whatever owns it) - the tree never reaches into a view it does not own.

type FloatingPanel

type FloatingPanel struct {

	// OnOutside runs on a click outside the panel; nil passes those
	// through.
	OnOutside func()
	// OnGeometryChanged hears the panel's rect, in the area's
	// coordinates, once a move or resize gesture ended and the panel
	// was laid out there.
	OnGeometryChanged func(r render.Rect)
	// contains filtered or unexported fields
}

FloatingPanel is a movable, resizable panel over an area, an overlay or layer surface: a card centered until moved, dragged by its header (whose own controls keep their presses), resized from its bottom right corner within its size limits, and kept inside the area. A press outside the panel runs OnOutside; without it, as a window's root, the panel takes input only over itself (InputRegioner) and the rest passes through. The area is the floatingpanel element and the card its panel child, with the theme's card surface and a shadow.

func NewFloatingPanel

func NewFloatingPanel(header, body Widget) *FloatingPanel

NewFloatingPanel returns a panel of header over body; a nil header leaves the panel without a drag region.

func (*FloatingPanel) AccessibleName

func (n *FloatingPanel) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*FloatingPanel) AddClass

func (n *FloatingPanel) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*FloatingPanel) Arrange

func (f *FloatingPanel) Arrange(r render.Rect)

Arrange sizes the panel (its chosen size, else its natural one, within the limits), centers it until placed, keeps it inside the area, and pins the grip to its corner.

func (*FloatingPanel) AttachStylesheet

func (n *FloatingPanel) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*FloatingPanel) Attr

func (n *FloatingPanel) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*FloatingPanel) Bounds

func (n *FloatingPanel) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*FloatingPanel) Children

func (f *FloatingPanel) Children() []Widget

Children are the panel and its grip.

func (*FloatingPanel) Classes

func (n *FloatingPanel) Classes() []string

Classes returns a copy of the widget's classes.

func (*FloatingPanel) ClickAt

func (f *FloatingPanel) ClickAt(Point)

ClickAt is a click outside the panel.

func (*FloatingPanel) DebugName

func (n *FloatingPanel) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*FloatingPanel) DetachStylesheet

func (n *FloatingPanel) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*FloatingPanel) Element

func (n *FloatingPanel) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*FloatingPanel) Enabled

func (n *FloatingPanel) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*FloatingPanel) HAlign

func (n *FloatingPanel) HAlign() Align

HAlign returns the horizontal placement.

func (*FloatingPanel) HasClass

func (n *FloatingPanel) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*FloatingPanel) HasState

func (n *FloatingPanel) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*FloatingPanel) HitLeaf

func (n *FloatingPanel) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*FloatingPanel) HitTest

func (f *FloatingPanel) HitTest(p Point) Widget

HitTest is the grip, then the panel; outside it the area itself when OnOutside takes those presses, else nothing.

func (*FloatingPanel) HoverWithin

func (n *FloatingPanel) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*FloatingPanel) ID

func (n *FloatingPanel) ID() string

ID returns the style id, empty when none is set.

func (*FloatingPanel) InlineStyle

func (n *FloatingPanel) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*FloatingPanel) InputRegion

func (f *FloatingPanel) InputRegion() []render.Rect

InputRegion implements InputRegioner: the panel alone when presses outside pass through, everywhere when OnOutside takes them.

func (*FloatingPanel) Invalidate

func (n *FloatingPanel) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*FloatingPanel) InvalidateLayout

func (n *FloatingPanel) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*FloatingPanel) InvalidateRect

func (n *FloatingPanel) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*FloatingPanel) LayoutMotion

func (n *FloatingPanel) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*FloatingPanel) Margin

func (n *FloatingPanel) Margin() render.Insets

Margin returns the programmatic margin.

func (*FloatingPanel) MaximumSize

func (n *FloatingPanel) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*FloatingPanel) Measure

func (f *FloatingPanel) Measure(axis Axis, forSize int) Sizes

Measure asks for the panel's natural size and needs none: the area takes whatever it is given and keeps the panel inside it.

func (*FloatingPanel) Paint

func (f *FloatingPanel) Paint(cv *render.Canvas)

Paint draws the panel, then its grip.

func (*FloatingPanel) PanelRect

func (f *FloatingPanel) PanelRect() render.Rect

PanelRect is the panel's last arranged rect, in the area's coordinates.

func (*FloatingPanel) Parent

func (n *FloatingPanel) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*FloatingPanel) Recenter

func (f *FloatingPanel) Recenter()

Recenter centers the panel again, as before it was first moved.

func (*FloatingPanel) RemoveAttr

func (n *FloatingPanel) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*FloatingPanel) RemoveClass

func (n *FloatingPanel) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*FloatingPanel) SetAccessibleName

func (n *FloatingPanel) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*FloatingPanel) SetAttr

func (n *FloatingPanel) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*FloatingPanel) SetClass

func (n *FloatingPanel) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*FloatingPanel) SetClasses

func (n *FloatingPanel) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*FloatingPanel) SetCursorName

func (n *FloatingPanel) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*FloatingPanel) SetDebugName

func (n *FloatingPanel) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*FloatingPanel) SetElement

func (n *FloatingPanel) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*FloatingPanel) SetEnabled

func (n *FloatingPanel) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*FloatingPanel) SetFocusOnClick

func (n *FloatingPanel) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*FloatingPanel) SetHAlign

func (n *FloatingPanel) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*FloatingPanel) SetHExpand

func (n *FloatingPanel) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*FloatingPanel) SetID

func (n *FloatingPanel) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*FloatingPanel) SetInlineStyle

func (n *FloatingPanel) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*FloatingPanel) SetInlineStylePriority

func (n *FloatingPanel) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*FloatingPanel) SetLayoutMotion

func (n *FloatingPanel) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*FloatingPanel) SetMargin

func (n *FloatingPanel) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*FloatingPanel) SetMaximumSize

func (n *FloatingPanel) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*FloatingPanel) SetOnClickWithin

func (n *FloatingPanel) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*FloatingPanel) SetOnFocusChanged

func (n *FloatingPanel) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*FloatingPanel) SetOnHoverWithin

func (n *FloatingPanel) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*FloatingPanel) SetOnPointer

func (n *FloatingPanel) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*FloatingPanel) SetOnScroll

func (n *FloatingPanel) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*FloatingPanel) SetPanelSize

func (f *FloatingPanel) SetPanelSize(w, h int)

SetPanelSize sizes the panel w x h, within its limits; zero on an axis returns it to the content's natural size.

func (*FloatingPanel) SetPosition

func (f *FloatingPanel) SetPosition(p Point)

SetPosition places the panel's top left at p in the area, kept inside it.

func (*FloatingPanel) SetSharedElement

func (n *FloatingPanel) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*FloatingPanel) SetSizeLimits

func (f *FloatingPanel) SetSizeLimits(min, max Size)

SetSizeLimits bounds the panel's size: never below min, nor above max on an axis where it is not zero, nor beyond the area.

func (*FloatingPanel) SetSizeRequest

func (n *FloatingPanel) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*FloatingPanel) SetState

func (n *FloatingPanel) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*FloatingPanel) SetTooltip

func (n *FloatingPanel) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*FloatingPanel) SetTooltipMarkup

func (n *FloatingPanel) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*FloatingPanel) SetVAlign

func (n *FloatingPanel) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*FloatingPanel) SetVExpand

func (n *FloatingPanel) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*FloatingPanel) SetVisible

func (n *FloatingPanel) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*FloatingPanel) SharedElement

func (n *FloatingPanel) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*FloatingPanel) SizeRequest

func (n *FloatingPanel) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*FloatingPanel) TooltipMarkup

func (n *FloatingPanel) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*FloatingPanel) TooltipText

func (n *FloatingPanel) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*FloatingPanel) VAlign

func (n *FloatingPanel) VAlign() Align

VAlign returns the vertical placement.

func (*FloatingPanel) Visible

func (n *FloatingPanel) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type FlowBox

type FlowBox struct {

	// OnSelectionChanged fires with the selected indices once per
	// gesture; OnActivate fires for an activated child.
	OnSelectionChanged func(children []int)
	OnActivate         func(i int)
	// contains filtered or unexported fields
}

FlowBox lays its children out in lines, starting a new line when the next child would not fit or the line holds its maximum (GtkFlowBox, horizontal and non-homogeneous). It selects like a List - SetSelectionMode, single by default (GTK's), with clicks, rubber bands, and the keyboard moving by item and by line - and a click activates (OnActivate) unless SetSingleClickActivate(false) leaves activation to a double click. Controls inside a child keep their own clicks. Each child sits in a FlowBoxChild, the `flowboxchild` node a stylesheet addresses (`flowbox > flowboxchild.drop-before`). Its natural width is the widest line at the maximum per line; given less, it wraps and grows taller.

func NewFlowBox

func NewFlowBox(colSpacing, rowSpacing int) *FlowBox

NewFlowBox returns an empty flow box with colSpacing between the children of a line and rowSpacing between lines.

func NewWrapBox

func NewWrapBox(childSpacing, lineSpacing int, justify Justify) *FlowBox

NewWrapBox returns the adw WrapBox: a FlowBox wrapping at childSpacing/lineSpacing with justify deciding each line's leftover width - one wrapping layout, not two.

func (*FlowBox) AccessibleName

func (n *FlowBox) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*FlowBox) AddClass

func (n *FlowBox) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*FlowBox) Append

func (f *FlowBox) Append(w Widget) *FlowBoxChild

Append adds w at the end, returning its FlowBoxChild.

func (*FlowBox) Arrange

func (f *FlowBox) Arrange(r render.Rect)

Arrange places each line under the last, its children at their natural widths from the start edge, as tall as the line.

func (*FlowBox) AttachStylesheet

func (n *FlowBox) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*FlowBox) Attr

func (n *FlowBox) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*FlowBox) Bounds

func (n *FlowBox) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*FlowBox) ChildAt

func (f *FlowBox) ChildAt(i int) *FlowBoxChild

ChildAt is the FlowBoxChild at index i, nil out of range (gtk_flow_box_get_child_at_index).

func (*FlowBox) Children

func (f *FlowBox) Children() []Widget

Children exposes the FlowBoxChild wrappers.

func (*FlowBox) Classes

func (n *FlowBox) Classes() []string

Classes returns a copy of the widget's classes.

func (*FlowBox) Clear

func (f *FlowBox) Clear()

Clear detaches every child.

func (*FlowBox) DebugName

func (n *FlowBox) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*FlowBox) DetachStylesheet

func (n *FlowBox) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*FlowBox) Element

func (n *FlowBox) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*FlowBox) Enabled

func (n *FlowBox) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*FlowBox) HAlign

func (n *FlowBox) HAlign() Align

HAlign returns the horizontal placement.

func (*FlowBox) HasClass

func (n *FlowBox) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*FlowBox) HasState

func (n *FlowBox) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*FlowBox) HitLeaf

func (n *FlowBox) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*FlowBox) HitTest

func (f *FlowBox) HitTest(p Point) Widget

HitTest is the child under p, else the box.

func (*FlowBox) HoverWithin

func (n *FlowBox) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*FlowBox) ID

func (n *FlowBox) ID() string

ID returns the style id, empty when none is set.

func (*FlowBox) IndexAt

func (f *FlowBox) IndexAt(p Point) int

IndexAt is the index of the child under p, -1 over none (gtk_flow_box_get_child_at_pos).

func (*FlowBox) InlineStyle

func (n *FlowBox) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*FlowBox) Insert

func (f *FlowBox) Insert(i int, w Widget) *FlowBoxChild

Insert adds w at index i (clamped), returning its FlowBoxChild.

func (*FlowBox) Invalidate

func (n *FlowBox) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*FlowBox) InvalidateLayout

func (n *FlowBox) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*FlowBox) InvalidateRect

func (n *FlowBox) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*FlowBox) KeyAction

func (f *FlowBox) KeyAction(a KeyAction, mods Mods)

KeyAction moves and extends the selection: left and right by a child, up and down to the nearest child of the neighboring line.

func (*FlowBox) LayoutMotion

func (n *FlowBox) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*FlowBox) Len

func (f *FlowBox) Len() int

Len is the number of children.

func (*FlowBox) Margin

func (n *FlowBox) Margin() render.Insets

Margin returns the programmatic margin.

func (*FlowBox) MaximumSize

func (n *FlowBox) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*FlowBox) Measure

func (f *FlowBox) Measure(axis Axis, forSize int) Sizes

Measure needs its widest child, wrapping (GtkFlowBox's minimum width), and wants its widest line unwrapped; down, it is as tall as its lines at the width given.

func (*FlowBox) Move

func (f *FlowBox) Move(from, to int)

Move moves the child at index from to index to (both clamped), in place: the child stays attached and its selection follows it.

func (*FlowBox) Paint

func (f *FlowBox) Paint(cv *render.Canvas)

Paint draws the box's own CSS layers and its children.

func (*FlowBox) Parent

func (n *FlowBox) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*FlowBox) RemoveAt

func (f *FlowBox) RemoveAt(i int)

RemoveAt detaches the child at index i; out of range does nothing.

func (*FlowBox) RemoveAttr

func (n *FlowBox) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*FlowBox) RemoveClass

func (n *FlowBox) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*FlowBox) Select

func (s *FlowBox) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*FlowBox) SelectAll

func (s *FlowBox) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*FlowBox) SelectRows

func (s *FlowBox) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*FlowBox) Selected

func (s *FlowBox) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*FlowBox) Selection

func (s *FlowBox) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*FlowBox) SelectionMode

func (s *FlowBox) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*FlowBox) SetAccessibleName

func (n *FlowBox) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*FlowBox) SetAttr

func (n *FlowBox) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*FlowBox) SetClass

func (n *FlowBox) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*FlowBox) SetClasses

func (n *FlowBox) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*FlowBox) SetCursorName

func (n *FlowBox) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*FlowBox) SetDebugName

func (n *FlowBox) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*FlowBox) SetElement

func (n *FlowBox) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*FlowBox) SetEnabled

func (n *FlowBox) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*FlowBox) SetFocusOnClick

func (n *FlowBox) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*FlowBox) SetHAlign

func (n *FlowBox) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*FlowBox) SetHExpand

func (n *FlowBox) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*FlowBox) SetID

func (n *FlowBox) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*FlowBox) SetInlineStyle

func (n *FlowBox) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*FlowBox) SetInlineStylePriority

func (n *FlowBox) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*FlowBox) SetJustify

func (f *FlowBox) SetJustify(j Justify)

SetJustify sets how each line's leftover width is used.

func (*FlowBox) SetLayoutMotion

func (n *FlowBox) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*FlowBox) SetMargin

func (n *FlowBox) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*FlowBox) SetMaxChildrenPerLine

func (f *FlowBox) SetMaxChildrenPerLine(n int)

SetMaxChildrenPerLine caps a line's children (GTK's max-children-per-line, 7 by default); below 1 it acts as 1.

func (*FlowBox) SetMaximumSize

func (n *FlowBox) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*FlowBox) SetOnClickWithin

func (n *FlowBox) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*FlowBox) SetOnFocusChanged

func (n *FlowBox) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*FlowBox) SetOnHoverWithin

func (n *FlowBox) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*FlowBox) SetOnPointer

func (n *FlowBox) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*FlowBox) SetOnScroll

func (n *FlowBox) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*FlowBox) SetSelectionMode

func (s *FlowBox) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*FlowBox) SetSharedElement

func (n *FlowBox) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*FlowBox) SetSingleClickActivate

func (f *FlowBox) SetSingleClickActivate(on bool)

SetSingleClickActivate makes a plain click activate (on, GTK's default) or leaves activation to a double click.

func (*FlowBox) SetSizeRequest

func (n *FlowBox) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*FlowBox) SetState

func (n *FlowBox) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*FlowBox) SetTooltip

func (n *FlowBox) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*FlowBox) SetTooltipMarkup

func (n *FlowBox) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*FlowBox) SetVAlign

func (n *FlowBox) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*FlowBox) SetVExpand

func (n *FlowBox) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*FlowBox) SetVisible

func (n *FlowBox) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*FlowBox) SharedElement

func (n *FlowBox) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*FlowBox) SizeRequest

func (n *FlowBox) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*FlowBox) TooltipMarkup

func (n *FlowBox) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*FlowBox) TooltipText

func (n *FlowBox) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*FlowBox) VAlign

func (n *FlowBox) VAlign() Align

VAlign returns the vertical placement.

func (*FlowBox) Visible

func (n *FlowBox) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type FlowBoxChild

type FlowBoxChild struct {
	// contains filtered or unexported fields
}

FlowBoxChild wraps one child of a FlowBox: a CSS box around it.

func (*FlowBoxChild) AccessibleName

func (n *FlowBoxChild) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*FlowBoxChild) AddClass

func (n *FlowBoxChild) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*FlowBoxChild) Arrange

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

Arrange gives the child the content box.

func (*FlowBoxChild) AttachStylesheet

func (n *FlowBoxChild) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*FlowBoxChild) Attr

func (n *FlowBoxChild) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*FlowBoxChild) Bounds

func (n *FlowBoxChild) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*FlowBoxChild) Child

func (c *FlowBoxChild) Child() Widget

Child is the wrapped widget.

func (*FlowBoxChild) Children

func (c *FlowBoxChild) Children() []Widget

Children is the wrapped widget.

func (*FlowBoxChild) Classes

func (n *FlowBoxChild) Classes() []string

Classes returns a copy of the widget's classes.

func (*FlowBoxChild) ClickAt

func (c *FlowBoxChild) ClickAt(Point)

ClickAt selects (and maybe activates) the child.

func (*FlowBoxChild) DebugName

func (n *FlowBoxChild) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*FlowBoxChild) DetachStylesheet

func (n *FlowBoxChild) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*FlowBoxChild) DoubleClickAt

func (c *FlowBoxChild) DoubleClickAt(Point)

DoubleClickAt activates the child when a single click does not.

func (*FlowBoxChild) DragMove

func (c *FlowBoxChild) DragMove(p Point)

DragMove rubber-bands (multiple) or motion-selects from the anchor.

func (*FlowBoxChild) Element

func (n *FlowBoxChild) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*FlowBoxChild) Enabled

func (n *FlowBoxChild) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*FlowBoxChild) HAlign

func (n *FlowBoxChild) HAlign() Align

HAlign returns the horizontal placement.

func (*FlowBoxChild) HasClass

func (n *FlowBoxChild) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*FlowBoxChild) HasState

func (n *FlowBoxChild) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*FlowBoxChild) HitLeaf

func (n *FlowBoxChild) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*FlowBoxChild) HitTest

func (c *FlowBoxChild) HitTest(p Point) Widget

HitTest resolves through the child; in a selectable box the wrapper takes every press but those a control inside the child consumes.

func (*FlowBoxChild) HoverWithin

func (n *FlowBoxChild) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*FlowBoxChild) ID

func (n *FlowBoxChild) ID() string

ID returns the style id, empty when none is set.

func (*FlowBoxChild) Index

func (c *FlowBoxChild) Index() int

Index is the child's position in its FlowBox, -1 when detached.

func (*FlowBoxChild) InlineStyle

func (n *FlowBoxChild) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*FlowBoxChild) Invalidate

func (n *FlowBoxChild) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*FlowBoxChild) InvalidateLayout

func (n *FlowBoxChild) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*FlowBoxChild) InvalidateRect

func (n *FlowBoxChild) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*FlowBoxChild) KeyAction

func (c *FlowBoxChild) KeyAction(a KeyAction, mods Mods)

KeyAction is the box's: a focused child steers the selection.

func (*FlowBoxChild) LayoutMotion

func (n *FlowBoxChild) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*FlowBoxChild) Margin

func (n *FlowBoxChild) Margin() render.Insets

Margin returns the programmatic margin.

func (*FlowBoxChild) MaximumSize

func (n *FlowBoxChild) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*FlowBoxChild) Measure

func (c *FlowBoxChild) Measure(axis Axis, forSize int) Sizes

Measure is the child inside the wrapper's CSS box.

func (*FlowBoxChild) Paint

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

Paint draws the wrapper's CSS layers - a selected child over the theme's selection tint where the stylesheet names no background - and the child.

func (*FlowBoxChild) Parent

func (n *FlowBoxChild) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*FlowBoxChild) PressEnd

func (c *FlowBoxChild) PressEnd()

PressEnd closes the gesture, landing its one notification.

func (*FlowBoxChild) RemoveAttr

func (n *FlowBoxChild) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*FlowBoxChild) RemoveClass

func (n *FlowBoxChild) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*FlowBoxChild) SelectAll

func (c *FlowBoxChild) SelectAll()

SelectAll is the box's (ctrl+a on a focused child).

func (*FlowBoxChild) SetAccessibleName

func (n *FlowBoxChild) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*FlowBoxChild) SetAttr

func (n *FlowBoxChild) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*FlowBoxChild) SetClass

func (n *FlowBoxChild) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*FlowBoxChild) SetClasses

func (n *FlowBoxChild) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*FlowBoxChild) SetCursorName

func (n *FlowBoxChild) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*FlowBoxChild) SetDebugName

func (n *FlowBoxChild) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*FlowBoxChild) SetElement

func (n *FlowBoxChild) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*FlowBoxChild) SetEnabled

func (n *FlowBoxChild) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*FlowBoxChild) SetFocusOnClick

func (n *FlowBoxChild) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*FlowBoxChild) SetHAlign

func (n *FlowBoxChild) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*FlowBoxChild) SetHExpand

func (n *FlowBoxChild) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*FlowBoxChild) SetID

func (n *FlowBoxChild) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*FlowBoxChild) SetInlineStyle

func (n *FlowBoxChild) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*FlowBoxChild) SetInlineStylePriority

func (n *FlowBoxChild) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*FlowBoxChild) SetLayoutMotion

func (n *FlowBoxChild) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*FlowBoxChild) SetMargin

func (n *FlowBoxChild) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*FlowBoxChild) SetMaximumSize

func (n *FlowBoxChild) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*FlowBoxChild) SetOnClickWithin

func (n *FlowBoxChild) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*FlowBoxChild) SetOnFocusChanged

func (n *FlowBoxChild) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*FlowBoxChild) SetOnHoverWithin

func (n *FlowBoxChild) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*FlowBoxChild) SetOnPointer

func (n *FlowBoxChild) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*FlowBoxChild) SetOnScroll

func (n *FlowBoxChild) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*FlowBoxChild) SetPressed

func (c *FlowBoxChild) SetPressed(on bool)

SetPressed opens a pointer gesture anchored on the child.

func (*FlowBoxChild) SetSharedElement

func (n *FlowBoxChild) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*FlowBoxChild) SetSizeRequest

func (n *FlowBoxChild) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*FlowBoxChild) SetState

func (n *FlowBoxChild) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*FlowBoxChild) SetTooltip

func (n *FlowBoxChild) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*FlowBoxChild) SetTooltipMarkup

func (n *FlowBoxChild) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*FlowBoxChild) SetVAlign

func (n *FlowBoxChild) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*FlowBoxChild) SetVExpand

func (n *FlowBoxChild) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*FlowBoxChild) SetVisible

func (n *FlowBoxChild) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*FlowBoxChild) SharedElement

func (n *FlowBoxChild) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*FlowBoxChild) SizeRequest

func (n *FlowBoxChild) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*FlowBoxChild) TooltipMarkup

func (n *FlowBoxChild) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*FlowBoxChild) TooltipText

func (n *FlowBoxChild) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*FlowBoxChild) VAlign

func (n *FlowBoxChild) VAlign() Align

VAlign returns the vertical placement.

func (*FlowBoxChild) Visible

func (n *FlowBoxChild) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type FocusNavigator

type FocusNavigator interface {
	NavigateFocus(target Widget, a KeyAction) Widget
}

FocusNavigator is an ancestor that moves focus among its own focusable descendants on navigation keys: the roving focus of an accordion's triggers. NavigateFocus returns the widget to focus for action a headed for target, or nil to let the action through.

type FocusObserver

type FocusObserver interface {
	FocusMoved(from, to Widget)
}

FocusObserver is an ancestor that hears the keyboard focus move into, out of or within its subtree: a form validating the field the focus just left.

type FocusTrapper

type FocusTrapper interface {
	FocusTrap() Widget
}

FocusTrapper is a widget that can hold Tab traversal inside a part of itself: a modal sheet over the content. FocusTrap returns that part while it traps, nil otherwise.

type FontButton

type FontButton struct {
	Button

	// OnOpen runs on click to show a chooser starting at the choice.
	OnOpen func(current FontChoice)
	// OnFontSet runs when the user picked a font (Choose), not on
	// SetFont.
	OnFontSet func(f FontChoice)
	// contains filtered or unexported fields
}

FontButton is GTK's FontDialogButton: a button naming the current family and size that opens a font chooser on click. OnOpen is the opening hook (app.Application.AttachFontButton installs the chooser dialog); Choose applies the user's pick and fires OnFontSet.

func NewFontButton

func NewFontButton(face render.Font, sizePx float64, initial FontChoice) *FontButton

NewFontButton returns a button naming initial, its label in face at sizePx.

func (*FontButton) AccessibleName

func (n *FontButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*FontButton) AddClass

func (n *FontButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*FontButton) AttachStylesheet

func (n *FontButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*FontButton) Attr

func (n *FontButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*FontButton) BindFont

func (b *FontButton) BindFont(binding *Binding[FontChoice]) (unbind func())

BindFont wires the binding two-way to the shown choice.

func (*FontButton) Bounds

func (n *FontButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*FontButton) Choose

func (b *FontButton) Choose(f FontChoice)

Choose applies a font the user picked: it shows it and fires OnFontSet.

func (*FontButton) Classes

func (n *FontButton) Classes() []string

Classes returns a copy of the widget's classes.

func (*FontButton) DebugName

func (n *FontButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*FontButton) DetachStylesheet

func (n *FontButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*FontButton) Element

func (n *FontButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*FontButton) Enabled

func (n *FontButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*FontButton) Font

func (b *FontButton) Font() FontChoice

Font returns the shown choice.

func (*FontButton) HAlign

func (n *FontButton) HAlign() Align

HAlign returns the horizontal placement.

func (*FontButton) HasClass

func (n *FontButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*FontButton) HasState

func (n *FontButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*FontButton) HitLeaf

func (n *FontButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*FontButton) HoverWithin

func (n *FontButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*FontButton) ID

func (n *FontButton) ID() string

ID returns the style id, empty when none is set.

func (*FontButton) InlineStyle

func (n *FontButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*FontButton) Invalidate

func (n *FontButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*FontButton) InvalidateLayout

func (n *FontButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*FontButton) InvalidateRect

func (n *FontButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*FontButton) LayoutMotion

func (n *FontButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*FontButton) Margin

func (n *FontButton) Margin() render.Insets

Margin returns the programmatic margin.

func (*FontButton) MaximumSize

func (n *FontButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*FontButton) Parent

func (n *FontButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*FontButton) RemoveAttr

func (n *FontButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*FontButton) RemoveClass

func (n *FontButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*FontButton) SetAccessibleName

func (n *FontButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*FontButton) SetAttr

func (n *FontButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*FontButton) SetClass

func (n *FontButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*FontButton) SetClasses

func (n *FontButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*FontButton) SetCursorName

func (n *FontButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*FontButton) SetDebugName

func (n *FontButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*FontButton) SetElement

func (n *FontButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*FontButton) SetEnabled

func (n *FontButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*FontButton) SetFocusOnClick

func (n *FontButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*FontButton) SetFont

func (b *FontButton) SetFont(f FontChoice)

SetFont shows f without firing OnFontSet.

func (*FontButton) SetHAlign

func (n *FontButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*FontButton) SetHExpand

func (n *FontButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*FontButton) SetID

func (n *FontButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*FontButton) SetInlineStyle

func (n *FontButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*FontButton) SetInlineStylePriority

func (n *FontButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*FontButton) SetLayoutMotion

func (n *FontButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*FontButton) SetMargin

func (n *FontButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*FontButton) SetMaximumSize

func (n *FontButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*FontButton) SetOnClickWithin

func (n *FontButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*FontButton) SetOnFocusChanged

func (n *FontButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*FontButton) SetOnHoverWithin

func (n *FontButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*FontButton) SetOnPointer

func (n *FontButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*FontButton) SetOnScroll

func (n *FontButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*FontButton) SetSharedElement

func (n *FontButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*FontButton) SetSizeRequest

func (n *FontButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*FontButton) SetState

func (n *FontButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*FontButton) SetTooltip

func (n *FontButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*FontButton) SetTooltipMarkup

func (n *FontButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*FontButton) SetVAlign

func (n *FontButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*FontButton) SetVExpand

func (n *FontButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*FontButton) SetVisible

func (n *FontButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*FontButton) SharedElement

func (n *FontButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*FontButton) SizeRequest

func (n *FontButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*FontButton) TooltipMarkup

func (n *FontButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*FontButton) TooltipText

func (n *FontButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*FontButton) VAlign

func (n *FontButton) VAlign() Align

VAlign returns the vertical placement.

func (*FontButton) Visible

func (n *FontButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type FontChoice

type FontChoice struct {
	Family string
	Size   float64
}

FontChoice is a font family and size, the FontButton's value.

func (FontChoice) String

func (f FontChoice) String() string

String renders the choice as the button shows it: "Inter 13".

type Form

type Form struct {

	// OnSubmit runs when Submit finds every field valid.
	OnSubmit func()
	// contains filtered or unexported fields
}

Form validates a column of fields: each field added with a validator - a closure that reads its control's value and returns the error message, or "" while it is valid. A field shows its error once the focus leaves it, and Submit validates every field, moves the focus to the first invalid one, and runs OnSubmit only when all are valid. Enter in a text entry of the form submits. It styles as the `form` element.

func NewForm

func NewForm() *Form

NewForm returns an empty form.

func (*Form) Add

func (f *Form) Add(field *Field, validate func() string)

Add appends field, checked by validate; nil checks nothing.

func (*Form) Append

func (f *Form) Append(w Widget)

Append appends w, not a field: a fieldset's legend, the actions row.

func (*Form) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Form) Baseline

func (c *Form) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Form) Children

func (c *Form) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Form) FocusMoved

func (f *Form) FocusMoved(from, to Widget)

FocusMoved implements FocusObserver: the field the focus left shows its validation.

func (*Form) HitTest

func (c *Form) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Form) InterceptKey

func (f *Form) InterceptKey(target Widget, a KeyAction, _ Mods) bool

InterceptKey implements KeyInterceptor: Enter in a text entry of the form submits it.

func (*Form) Measure

func (c *Form) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Form) Paint

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

Paint draws the surface (when configured) then the root.

func (*Form) Submit

func (f *Form) Submit()

Submit runs OnSubmit when every field is valid.

func (*Form) Validate

func (f *Form) Validate() bool

Validate checks every field, shows each one's result, and moves the focus to the first invalid field whose control can take it. It reports whether all are valid.

type Frame

type Frame struct {
	// contains filtered or unexported fields
}

Frame is a labeled outline around a child (GTK Frame): the optional label sits above a rounded, bordered box holding the child. The outline is the frame's `border` node, so a stylesheet restyles it like any surface; with no label the frame is the outline alone.

func NewFrame

func NewFrame(face render.Font, label string, child Widget) *Frame

NewFrame returns a frame around child titled label ("" for none), the label painted with face.

func (*Frame) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Frame) Baseline

func (c *Frame) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Frame) Children

func (c *Frame) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Frame) HitTest

func (c *Frame) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Frame) Label

func (f *Frame) Label() string

Label reports the title.

func (*Frame) Measure

func (c *Frame) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Frame) Paint

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

Paint draws the surface (when configured) then the root.

func (*Frame) SetChild

func (f *Frame) SetChild(w Widget)

SetChild replaces the framed widget.

func (*Frame) SetLabel

func (f *Frame) SetLabel(s string)

SetLabel retitles the frame; "" drops the label row.

type GPUArea

type GPUArea struct {

	// OnFrame asks for a frame; it runs on the loop.
	OnFrame func(f GPUFrame)
	// contains filtered or unexported fields
}

GPUArea is GTK's GLArea without cgo: the application renders with whatever GPU stack it links (GL, Vulkan, a compute library) into dmabufs, or into CPU images, and the area presents them on its own compositor surface at its bounds, dmabufs with no copy. The surface sits below the window and shows through the area's bounds, so widgets drawn over the area stay on top of it. OnFrame paces the application: it runs once the area is on screen, after each presented frame reaches the screen, after a resize, and on QueueFrame. It styles as `gpuarea`.

func NewGPUArea

func NewGPUArea() *GPUArea

NewGPUArea returns an empty area; give it a size through the layout (expand, a minimum size in CSS).

func (*GPUArea) AccessibleName

func (n *GPUArea) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*GPUArea) AddClass

func (n *GPUArea) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*GPUArea) Arrange

func (a *GPUArea) Arrange(r render.Rect)

Arrange places the area's surface over its bounds, creating it the first time the area lands on screen.

func (*GPUArea) AttachStylesheet

func (n *GPUArea) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*GPUArea) Attr

func (n *GPUArea) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*GPUArea) Bounds

func (n *GPUArea) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*GPUArea) Classes

func (n *GPUArea) Classes() []string

Classes returns a copy of the widget's classes.

func (*GPUArea) DebugName

func (n *GPUArea) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*GPUArea) DetachStylesheet

func (n *GPUArea) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*GPUArea) Element

func (n *GPUArea) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*GPUArea) Enabled

func (n *GPUArea) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*GPUArea) Err

func (a *GPUArea) Err() error

Err returns why the area has no surface: the compositor lacks subsurfaces, or the area is not in a window.

func (*GPUArea) HAlign

func (n *GPUArea) HAlign() Align

HAlign returns the horizontal placement.

func (*GPUArea) HasClass

func (n *GPUArea) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*GPUArea) HasState

func (n *GPUArea) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*GPUArea) HitLeaf

func (n *GPUArea) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*GPUArea) HitTest

func (a *GPUArea) HitTest(p Point) Widget

HitTest returns the area when p is inside its bounds.

func (*GPUArea) HoverWithin

func (n *GPUArea) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*GPUArea) ID

func (n *GPUArea) ID() string

ID returns the style id, empty when none is set.

func (*GPUArea) Import

func (a *GPUArea) Import(b dmabuf.Buffer) (GPUBuffer, error)

Import imports a dmabuf for presenting. The import completes asynchronously; Present of a buffer still importing shows it once it is ready.

func (*GPUArea) InlineStyle

func (n *GPUArea) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*GPUArea) Invalidate

func (n *GPUArea) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*GPUArea) InvalidateLayout

func (n *GPUArea) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*GPUArea) InvalidateRect

func (n *GPUArea) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*GPUArea) LayoutMotion

func (n *GPUArea) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*GPUArea) Margin

func (n *GPUArea) Margin() render.Insets

Margin returns the programmatic margin.

func (*GPUArea) MaximumSize

func (n *GPUArea) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*GPUArea) Measure

func (a *GPUArea) Measure(axis Axis, forSize int) Sizes

Measure claims no size of its own: the layout sizes the area.

func (*GPUArea) Paint

func (a *GPUArea) Paint(cv *render.Canvas)

Paint clears the bounds to transparent, the window through which the surface below shows.

func (*GPUArea) Parent

func (n *GPUArea) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*GPUArea) Present

func (a *GPUArea) Present(b GPUBuffer) error

Present shows an imported dmabuf.

func (*GPUArea) PresentImage

func (a *GPUArea) PresentImage(img *image.RGBA) error

PresentImage shows a CPU-rendered frame (premultiplied, as image.RGBA is), copied into a shared-memory buffer.

func (*GPUArea) QueueFrame

func (a *GPUArea) QueueFrame()

QueueFrame asks for an OnFrame at the next frame, for an application that skipped presenting and wants to resume.

func (*GPUArea) RemoveAttr

func (n *GPUArea) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*GPUArea) RemoveClass

func (n *GPUArea) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*GPUArea) SetAccessibleName

func (n *GPUArea) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*GPUArea) SetAttr

func (n *GPUArea) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*GPUArea) SetClass

func (n *GPUArea) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*GPUArea) SetClasses

func (n *GPUArea) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*GPUArea) SetCursorName

func (n *GPUArea) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*GPUArea) SetDebugName

func (n *GPUArea) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*GPUArea) SetElement

func (n *GPUArea) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*GPUArea) SetEnabled

func (n *GPUArea) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*GPUArea) SetFocusOnClick

func (n *GPUArea) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*GPUArea) SetHAlign

func (n *GPUArea) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*GPUArea) SetHExpand

func (n *GPUArea) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*GPUArea) SetID

func (n *GPUArea) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*GPUArea) SetInlineStyle

func (n *GPUArea) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*GPUArea) SetInlineStylePriority

func (n *GPUArea) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*GPUArea) SetLayoutMotion

func (n *GPUArea) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*GPUArea) SetMargin

func (n *GPUArea) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*GPUArea) SetMaximumSize

func (n *GPUArea) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*GPUArea) SetOnClickWithin

func (n *GPUArea) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*GPUArea) SetOnFocusChanged

func (n *GPUArea) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*GPUArea) SetOnHoverWithin

func (n *GPUArea) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*GPUArea) SetOnPointer

func (n *GPUArea) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*GPUArea) SetOnScroll

func (n *GPUArea) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*GPUArea) SetSharedElement

func (n *GPUArea) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*GPUArea) SetSizeRequest

func (n *GPUArea) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*GPUArea) SetState

func (n *GPUArea) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*GPUArea) SetTooltip

func (n *GPUArea) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*GPUArea) SetTooltipMarkup

func (n *GPUArea) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*GPUArea) SetVAlign

func (n *GPUArea) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*GPUArea) SetVExpand

func (n *GPUArea) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*GPUArea) SetVisible

func (n *GPUArea) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*GPUArea) SharedElement

func (n *GPUArea) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*GPUArea) SizeRequest

func (n *GPUArea) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*GPUArea) TooltipMarkup

func (n *GPUArea) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*GPUArea) TooltipText

func (n *GPUArea) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*GPUArea) VAlign

func (n *GPUArea) VAlign() Align

VAlign returns the vertical placement.

func (*GPUArea) Visible

func (n *GPUArea) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type GPUBuffer

type GPUBuffer interface {
	// Ready reports whether the import finished; Present waits for it.
	Ready() bool
	// Busy reports whether the compositor still reads the buffer: do
	// not render into it until it is free.
	Busy() bool
	// Err reports a rejected import, or that the area left the screen
	// and the buffer must be imported again.
	Err() error
	// Destroy releases the compositor-side buffer; the dmabuf's fds
	// stay the caller's.
	Destroy()
}

GPUBuffer is a dmabuf the compositor imported for a GPUArea.

type GPUFrame

type GPUFrame struct {
	// Size is the area in device pixels: a frame this size shows one
	// to one, any other size is scaled to the area.
	Size Size
}

GPUFrame is a GPUArea's request for a frame.

type GPUSurface

type GPUSurface interface {
	Place(bounds render.Rect)
	Import(b dmabuf.Buffer) (GPUBuffer, error)
	Present(b GPUBuffer) error
	PresentImage(img *image.RGBA) error
	RequestFrame()
	Close()
}

GPUSurface is the presentation surface package app gives a GPUArea on screen. Applications use GPUArea's methods instead.

type Gesture

type Gesture struct {
	Kind     GestureKind
	Phase    GesturePhase
	At       Point
	Fingers  int
	DX, DY   float64
	Scale    float64
	Rotation float64
}

Gesture is one gesture event. At is where it happens (the centroid for a multi-contact gesture); DX/DY the motion since the last event; Scale and Rotation (degrees, clockwise) the pinch relative to its start.

type GestureHandler

type GestureHandler interface {
	Gesture(g Gesture) bool
}

GestureHandler takes gestures: returning true from a Begin (or a long press) claims the gesture, and its Update/End/Cancel then go to the same widget.

type GestureKind

type GestureKind uint8

GestureKind is a recognized gesture's kind.

const (
	// GestureSwipe is a multi-finger swipe (a touchpad's three
	// fingers): DX/DY carry the motion.
	GestureSwipe GestureKind = iota
	// GesturePinch is a pinch-zoom and rotation (two fingers on a
	// touchscreen, or a touchpad pinch): Scale and Rotation are
	// relative to the gesture's start.
	GesturePinch
	// GestureHold is fingers resting on a touchpad.
	GestureHold
	// GestureLongPress is a contact held still past the long-press
	// delay; consuming it cancels the press's click.
	GestureLongPress
)

Gestures.

type GesturePhase

type GesturePhase uint8

GesturePhase is where a gesture is in its life.

const (
	GestureBegin GesturePhase = iota
	GestureUpdate
	GestureEnd
	GestureCancel
)

Gesture phases. A long press arrives as one GestureEnd.

type Grid

type Grid struct {
	// contains filtered or unexported fields
}

Grid is a rows-and-columns container. Children are attached to cells - optionally spanning several - and the grid derives its tracks from the children: a column or row is as wide or tall as the tallest child claiming it alone, plus what spanning children need.

Sizing per axis: natural mode keeps every track at its own maximum; homogeneous mode gives every track the largest track's extent.

When the arranged rect is larger than the natural size, the surplus is split equally among the tracks (earlier tracks take the remainder), so a spanning child grows by the share of the tracks it spans. When it is smaller, the deficit is negotiated — the reason a grid exists where a Box only overflows: tracks shrink in proportion to their extents down to per-track floors, and only when every floor is reached does the content overflow and the painter's clip decide visibility. A floor is the largest minimum among the track's single-cell children (spanning children are not floor sources — their need spreads, it does not pin), and the grid itself reports the sum of its floors as its minimum so nested grids squeeze coherently.

Children carry no expand flags: surplus and deficit both spread uniformly over the tracks (earlier tracks take the remainder), the one deterministic rule — a child that must claim the extra belongs in a Box, whose expand flag is that negotiation.

A child smaller than its shrunken span keeps its natural size under AlignStart/Center/End (overflowing the span, exactly like a squeezed Box child keeps its natural size); AlignFill takes the shrunken span as given, so the two containers agree visually.

Children paint in attach order, so a later attach overlapping an earlier span paints on top.

func NewGrid

func NewGrid(colSpacing, rowSpacing int) *Grid

NewGrid returns an empty grid with the given spacing between columns and between rows.

func NewNavigationLinks(face render.Font, cols int, links ...NavigationLink) *Grid

NewNavigationLinks is a navigation panel: a grid of cols columns of links, each its title over a muted description.

func (*Grid) AccessibleName

func (n *Grid) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Grid) AddClass

func (n *Grid) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Grid) Arrange

func (g *Grid) Arrange(r render.Rect)

Arrange assigns every child its spanned run, sized by the fitted tracks, aligned inside it per its Align. The surplus beyond the natural size splits equally among the tracks (earlier tracks take the remainder); a smaller rect squeezes the tracks in proportion to their extents down to their floors, overflowing only once every floor is reached.

func (*Grid) ArrangeRoot

func (g *Grid) ArrangeRoot(r render.Rect)

ArrangeRoot records the grid's own rect.

func (*Grid) Attach

func (g *Grid) Attach(w Widget, col, row, colSpan, rowSpan int) *Grid

Attach puts w at (col, row) with the given spans and returns the grid for chaining. Spans below one and negative coordinates clamp to one and zero respectively.

Two conflict rules, both last-wins:

  • attaching a widget that is already attached moves it to the new cell (a widget sits in the grid once);
  • after the dust settles, whoever occupies the target cell that is not the attached widget is detached - including a widget the move lands on top of.

Overlapping a span without sharing its origin cell is not a conflict: both children stay, the later attach paints and hits on top. Every attach drops the measure cache.

func (*Grid) AttachStylesheet

func (n *Grid) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Grid) Attr

func (n *Grid) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Grid) Bounds

func (n *Grid) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Grid) Children

func (g *Grid) Children() []Widget

Children exposes the children in row-major order - the visual order focus traversal follows, so Tab reads the grid left-to-right down the rows, a spanning child visited at its origin cell - regardless of the order attachments arrived in.

func (*Grid) Classes

func (n *Grid) Classes() []string

Classes returns a copy of the widget's classes.

func (*Grid) ColumnHomogeneous

func (g *Grid) ColumnHomogeneous() bool

ColumnHomogeneous reports whether every column takes the widest column's extent.

func (*Grid) ColumnSpacing

func (g *Grid) ColumnSpacing() int

ColumnSpacing returns the gap between columns.

func (*Grid) DebugName

func (n *Grid) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Grid) DetachStylesheet

func (n *Grid) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Grid) Element

func (n *Grid) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Grid) Enabled

func (n *Grid) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Grid) HAlign

func (n *Grid) HAlign() Align

HAlign returns the horizontal placement.

func (*Grid) HasClass

func (n *Grid) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Grid) HasState

func (n *Grid) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Grid) HitLeaf

func (n *Grid) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Grid) HitTest

func (g *Grid) HitTest(p Point) Widget

HitTest returns the topmost child under p (later attaches sit on top), or the grid itself when p is inside its bounds but over no child.

func (*Grid) HoverWithin

func (n *Grid) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Grid) ID

func (n *Grid) ID() string

ID returns the style id, empty when none is set.

func (*Grid) InlineStyle

func (n *Grid) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Grid) Invalidate

func (n *Grid) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Grid) InvalidateLayout

func (n *Grid) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Grid) InvalidateRect

func (n *Grid) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Grid) LayoutMotion

func (n *Grid) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Grid) Margin

func (n *Grid) Margin() render.Insets

Margin returns the programmatic margin.

func (*Grid) MaximumSize

func (n *Grid) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Grid) Measure

func (g *Grid) Measure(axis Axis, forSize int) Sizes

Measure derives the tracks from the children's requests: across, the columns' naturals and floors; down, the rows' at the width given, the columns fitted into it first (at their naturals for none).

func (*Grid) Paint

func (g *Grid) Paint(cv *render.Canvas)

Paint paints the children in attach order, so overlapping spans composite bottom to top.

func (*Grid) Parent

func (n *Grid) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Grid) Place

func (g *Grid) Place(w Widget, col, row, colSpan, rowSpan int) *Grid

Place moves an attached child to a new cell in place, without displacing whoever sits there, so a batch of moves can pass through overlapping states: the widget stays attached and keeps its focus. Unknown widgets are ignored.

func (*Grid) Remove

func (g *Grid) Remove(w Widget) bool

Remove detaches w and reports whether it was attached. The removed widget's parent link clears and the removal hook fires, like every tree mutation; the measure cache drops so the next frame reflows without it.

func (*Grid) RemoveAttr

func (n *Grid) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Grid) RemoveClass

func (n *Grid) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Grid) RowHomogeneous

func (g *Grid) RowHomogeneous() bool

RowHomogeneous reports whether every row takes the tallest row's extent.

func (*Grid) RowSpacing

func (g *Grid) RowSpacing() int

RowSpacing returns the gap between rows.

func (*Grid) SetAccessibleName

func (n *Grid) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Grid) SetAlign

func (g *Grid) SetAlign(w Widget, h, v Align) *Grid

SetAlign selects how w sits inside its spanned run along each axis. Unknown widgets are ignored.

func (*Grid) SetAttr

func (n *Grid) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Grid) SetClass

func (n *Grid) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Grid) SetClasses

func (n *Grid) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Grid) SetColumnHomogeneous

func (g *Grid) SetColumnHomogeneous(h bool) *Grid

SetColumnHomogeneous toggles whether every column takes the widest column's extent (true) or its own maximum (false, the default).

func (*Grid) SetColumnSpacing

func (g *Grid) SetColumnSpacing(n int) *Grid

SetColumnSpacing sets the gap between columns and returns the grid for chaining. The measure cache drops so the next frame reflows.

func (*Grid) SetCursorName

func (n *Grid) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Grid) SetDebugName

func (n *Grid) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Grid) SetElement

func (n *Grid) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Grid) SetEnabled

func (g *Grid) SetEnabled(enabled bool)

SetEnabled turns the grid's subtree on or off through the per-query enable walk, like Box.

func (*Grid) SetFocusOnClick

func (n *Grid) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Grid) SetHAlign

func (n *Grid) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Grid) SetHExpand

func (n *Grid) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Grid) SetID

func (n *Grid) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Grid) SetInlineStyle

func (n *Grid) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Grid) SetInlineStylePriority

func (n *Grid) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Grid) SetLayoutMotion

func (n *Grid) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Grid) SetMargin

func (n *Grid) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Grid) SetMaximumSize

func (n *Grid) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Grid) SetOnClickWithin

func (n *Grid) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Grid) SetOnFocusChanged

func (n *Grid) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Grid) SetOnHoverWithin

func (n *Grid) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Grid) SetOnPointer

func (n *Grid) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Grid) SetOnScroll

func (n *Grid) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Grid) SetRowHomogeneous

func (g *Grid) SetRowHomogeneous(h bool) *Grid

SetRowHomogeneous toggles whether every row takes the tallest row's extent (true) or its own maximum (false, the default).

func (*Grid) SetRowSpacing

func (g *Grid) SetRowSpacing(n int) *Grid

SetRowSpacing sets the gap between rows and returns the grid for chaining.

func (*Grid) SetSharedElement

func (n *Grid) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Grid) SetSizeRequest

func (n *Grid) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Grid) SetState

func (n *Grid) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Grid) SetTooltip

func (n *Grid) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Grid) SetTooltipMarkup

func (n *Grid) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Grid) SetVAlign

func (n *Grid) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Grid) SetVExpand

func (n *Grid) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Grid) SetVisible

func (n *Grid) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Grid) SharedElement

func (n *Grid) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Grid) SizeRequest

func (n *Grid) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Grid) TooltipMarkup

func (n *Grid) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Grid) TooltipText

func (n *Grid) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Grid) VAlign

func (n *Grid) VAlign() Align

VAlign returns the vertical placement.

func (*Grid) Visible

func (n *Grid) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type GridView

type GridView struct {
	List
}

GridView is a virtualized grid over a model, GTK's GridView: cells of one size flow left to right in as many columns as the width fits (between the minimum and maximum column counts), only the visible lines exist as widgets, and selection, rubber band, keyboard motion in two dimensions and activation work as in List. It styles as `gridview` with `child` cells.

func NewGridView

func NewGridView[W Widget](model ListModel[W], cellWidth, cellHeight int) *GridView

NewGridView returns a grid over model with cells of at least cellWidth by cellHeight pixels, between 1 and 7 columns (GTK's defaults).

func (*GridView) AccessibleName

func (n *GridView) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*GridView) AddClass

func (n *GridView) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*GridView) AttachStylesheet

func (n *GridView) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*GridView) Attr

func (n *GridView) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*GridView) Bounds

func (n *GridView) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*GridView) Classes

func (n *GridView) Classes() []string

Classes returns a copy of the widget's classes.

func (*GridView) ColumnSpacing

func (g *GridView) ColumnSpacing() int

ColumnSpacing returns the programmatic gap between columns.

func (*GridView) Columns

func (g *GridView) Columns() int

Columns returns the column count of the last layout.

func (*GridView) DebugName

func (n *GridView) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*GridView) DetachStylesheet

func (n *GridView) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*GridView) Element

func (n *GridView) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*GridView) Enabled

func (n *GridView) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*GridView) HAlign

func (n *GridView) HAlign() Align

HAlign returns the horizontal placement.

func (*GridView) HasClass

func (n *GridView) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*GridView) HasState

func (n *GridView) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*GridView) HitLeaf

func (n *GridView) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*GridView) HoverWithin

func (n *GridView) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*GridView) ID

func (n *GridView) ID() string

ID returns the style id, empty when none is set.

func (*GridView) InlineStyle

func (n *GridView) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*GridView) Invalidate

func (n *GridView) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*GridView) InvalidateLayout

func (n *GridView) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*GridView) InvalidateRect

func (n *GridView) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*GridView) LayoutMotion

func (n *GridView) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*GridView) Margin

func (n *GridView) Margin() render.Insets

Margin returns the programmatic margin.

func (*GridView) MaxColumns

func (g *GridView) MaxColumns() int

MaxColumns returns the column cap, zero for none.

func (*GridView) MaximumSize

func (n *GridView) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*GridView) MinColumns

func (g *GridView) MinColumns() int

MinColumns returns the column floor.

func (*GridView) Parent

func (n *GridView) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*GridView) RemoveAttr

func (n *GridView) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*GridView) RemoveClass

func (n *GridView) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*GridView) RowSpacing

func (g *GridView) RowSpacing() int

RowSpacing returns the programmatic gap between lines.

func (*GridView) Select

func (s *GridView) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*GridView) SelectAll

func (s *GridView) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*GridView) SelectRows

func (s *GridView) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*GridView) Selected

func (s *GridView) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*GridView) Selection

func (s *GridView) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*GridView) SelectionMode

func (s *GridView) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*GridView) SetAccessibleName

func (n *GridView) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*GridView) SetAttr

func (n *GridView) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*GridView) SetClass

func (n *GridView) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*GridView) SetClasses

func (n *GridView) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*GridView) SetColumnSpacing

func (g *GridView) SetColumnSpacing(n int)

SetColumnSpacing sets the gap between columns; the stylesheet's horizontal border-spacing adds to it. A point in a gap hits no cell.

func (*GridView) SetCursorName

func (n *GridView) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*GridView) SetDebugName

func (n *GridView) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*GridView) SetElement

func (n *GridView) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*GridView) SetEnabled

func (n *GridView) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*GridView) SetFocusOnClick

func (n *GridView) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*GridView) SetHAlign

func (n *GridView) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*GridView) SetHExpand

func (n *GridView) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*GridView) SetID

func (n *GridView) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*GridView) SetInlineStyle

func (n *GridView) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*GridView) SetInlineStylePriority

func (n *GridView) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*GridView) SetLayoutMotion

func (n *GridView) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*GridView) SetMargin

func (n *GridView) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*GridView) SetMaxColumns

func (g *GridView) SetMaxColumns(n int)

SetMaxColumns sets the most columns the grid lays out; zero lifts the cap.

func (*GridView) SetMaximumSize

func (n *GridView) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*GridView) SetMinColumns

func (g *GridView) SetMinColumns(n int)

SetMinColumns sets the fewest columns the grid lays out, even when cells end up narrower than their width.

func (*GridView) SetOnClickWithin

func (n *GridView) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*GridView) SetOnFocusChanged

func (n *GridView) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*GridView) SetOnHoverWithin

func (n *GridView) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*GridView) SetOnPointer

func (n *GridView) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*GridView) SetOnScroll

func (n *GridView) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*GridView) SetRowSpacing

func (g *GridView) SetRowSpacing(n int)

SetRowSpacing sets the gap between lines; the stylesheet's vertical border-spacing adds to it.

func (*GridView) SetSelectionMode

func (s *GridView) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*GridView) SetSharedElement

func (n *GridView) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*GridView) SetSizeRequest

func (n *GridView) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*GridView) SetState

func (n *GridView) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*GridView) SetTooltip

func (n *GridView) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*GridView) SetTooltipMarkup

func (n *GridView) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*GridView) SetVAlign

func (n *GridView) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*GridView) SetVExpand

func (n *GridView) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*GridView) SetVisible

func (n *GridView) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*GridView) SharedElement

func (n *GridView) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*GridView) SizeRequest

func (n *GridView) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*GridView) TooltipMarkup

func (n *GridView) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*GridView) TooltipText

func (n *GridView) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*GridView) VAlign

func (n *GridView) VAlign() Align

VAlign returns the vertical placement.

func (*GridView) Visible

func (n *GridView) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type HeaderBar

type HeaderBar struct {

	// OnDoubleClick fires on a second press inside the grab interval -
	// the app wires it to maximize/restore.
	OnDoubleClick func()
	// contains filtered or unexported fields
}

HeaderBar is the CSD title bar: a start pack (left), the window title and subtitle (center), and an end pack with the window controls (right). Pressing the bar's own background moves the window (the app routes it to xdg_toplevel.move); a double press maximizes - both delivered through the WindowMover contract, so the bar works in any host that honors it. Styled as the `headerbar` element, its title as `headerbar title` (docs/css.md).

func NewHeaderBar

func NewHeaderBar(face render.Font, sizePx float64) *HeaderBar

NewHeaderBar returns a bar sized for face/sizePx content.

func (*HeaderBar) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*HeaderBar) Baseline

func (c *HeaderBar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*HeaderBar) Children

func (c *HeaderBar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*HeaderBar) Controls

func (h *HeaderBar) Controls() *WindowControls

Controls returns the window controls, wiring them is the app's job:

bar.Controls().ShowClose(true)
bar.Controls().OnClose = window.Close

func (*HeaderBar) HitTest

func (h *HeaderBar) HitTest(p Point) Widget

HitTest resolves into the composed row with the CSD rule applied: a press that lands on a button stays a button press; anything else on the bar - background, title, spacers - is the move surface and resolves to the bar itself.

func (*HeaderBar) Measure

func (c *HeaderBar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*HeaderBar) PackEnd

func (p *HeaderBar) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (*HeaderBar) PackStart

func (p *HeaderBar) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*HeaderBar) Paint

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

Paint draws the surface (when configured) then the root.

func (*HeaderBar) SetSubtitle

func (h *HeaderBar) SetSubtitle(s string)

SetSubtitle sets the subtitle; empty hides it.

func (*HeaderBar) SetTitle

func (h *HeaderBar) SetTitle(t string)

SetTitle sets the window title; SetSubtitle the line under it (an empty subtitle hides the row).

func (*HeaderBar) WindowDoubleClick

func (h *HeaderBar) WindowDoubleClick()

WindowDoubleClick implements WindowDoubleClickable: the second press fires the app-wired hook (maximize/restore).

func (*HeaderBar) WindowMoveGrab

func (h *HeaderBar) WindowMoveGrab() bool

WindowMoveGrab implements WindowMover: presses on the bar's own chrome move the window.

type Highlighter

type Highlighter interface {
	Highlight(line []rune, state int) (spans []TextSpan, end int)
}

Highlighter splits lines into styled spans (a GtkSourceView language). Highlight styles line given the state the line before it ended in (0 before the first line) and returns the state this one ends in, so a construct spanning lines — a multi-line string — carries on. Spans are rune ranges of the line, in order, not overlapping.

type HoverCard

type HoverCard struct {
	// contains filtered or unexported fields
}

HoverCard previews content beside a trigger: resting the pointer on the trigger opens the card after a delay, and it stays open while the pointer is on the trigger or the card, closing a moment after it leaves both. Keyboard focus on the trigger opens it the same way. The card takes no input grab: what the user points at keeps the keyboard. It styles as the `hovercard` element; the card's content as a .hovercard-content box.

func NewHoverCard

func NewHoverCard(trigger, content Widget) *HoverCard

NewHoverCard wraps trigger with a card showing content.

func (*HoverCard) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*HoverCard) Baseline

func (c *HoverCard) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*HoverCard) Children

func (c *HoverCard) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*HoverCard) FocusMoved

func (h *HoverCard) FocusMoved(_, to Widget)

FocusMoved implements FocusObserver: visible keyboard focus inside the trigger opens the card as the pointer does.

func (*HoverCard) HitTest

func (c *HoverCard) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*HoverCard) Measure

func (c *HoverCard) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*HoverCard) Open

func (h *HoverCard) Open() bool

Open reports whether the card is showing.

func (*HoverCard) Paint

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

Paint draws the surface (when configured) then the root.

type HoverMover

type HoverMover interface {
	HoverMove(p Point)
}

HoverMover receives pointer motion while the widget is hovered, even without a press: menus highlight rows with it.

type HoverSetter

type HoverSetter interface {
	SetHovered(on bool)
}

HoverSetter receives hover tracking from the Router.

type IMEClient

type IMEClient interface {
	// IMEPreedit shows composing text at the caret; cursorBegin and
	// cursorEnd are byte offsets into text marking the composing
	// caret (both -1 hide it). Empty text ends composing. The
	// composing text is display-only: Text and OnChanged stay
	// untouched until a commit lands.
	IMEPreedit(text string, cursorBegin, cursorEnd int)
	// IMEDelete removes up to before bytes before the caret and
	// after bytes after it, replacing any composing display.
	IMEDelete(before, after int)
	// IMECommit inserts committed text at the caret, replacing any
	// composing display.
	IMECommit(text string)
}

IMEClient is the widget side of an input method: an editable widget that shows composing (preedit) text and receives committed text. The methods are named after the zwp_text_input_v3 events they apply, and the host calls them in the done event's order.

type IMERevision added in v0.2.5

type IMERevision struct {
	// contains filtered or unexported fields
}

IMERevision is a comparable stamp of one editable widget's text and caret; see IMETracker.IMERevision.

type IMETracker

type IMETracker interface {
	// IMERevision names the text and caret state IMESurrounding reports:
	// while it stays equal, IMESurrounding would answer the same, so a
	// host compares it instead of building the text.
	IMERevision() IMERevision
	// IMESurrounding returns at most limit bytes of text around the
	// caret, on rune boundaries, with the cursor and anchor as byte
	// offsets into it (an anchor outside the text sits at its edge),
	// composing text excluded.
	IMESurrounding(limit int) (text string, cursor, anchor int)
	// IMECursorRect returns the caret rectangle in root coordinates,
	// for the input method's candidate window.
	IMECursorRect() render.Rect
	// IMEMultiline reports multi-line content.
	IMEMultiline() bool
}

IMETracker exposes an editable widget's text-input state for the set_surrounding_text and set_cursor_rectangle requests.

type Icon

type Icon struct {
	// contains filtered or unexported fields
}

Icon paints an icon at its natural size. The pixels come from one of four sources:

  • NewIcon: a raster the caller already made (render.LoadSVG and friends); the widget draws it as is.
  • NewThemeIcon: an icon theme name, resolved through the shared icons.Cache at the canvas device scale and re-resolved when the theme or the accent moves.
  • NewFileIcon: an image file (png, svg, svgz).
  • NewSVGIcon: embedded SVG bytes, for apps that ship their own glyphs.

A dynamic icon never reads or decodes on the UI loop: a paint draws what is decoded and otherwise asks for the decode off the loop, keeping the raster it has (nothing at first) until the result invalidates it. Without a running Application the decode runs inline at the paint.

Symbolic sources - -symbolic theme files and SVGs painting with currentColor - recolor to the theme Accent so glyphs follow the palette; SetTint pins a different color. The recoloring is a mask pass (render.Icon.Tint): alpha is kept, ink takes the tint, so gradients collapse to their alpha ramp - the symbolic contract.

func NewFileIcon

func NewFileIcon(path string, size int) *Icon

NewFileIcon returns an icon widget that loads an image file (png, svg, svgz) and draws it at size logical pixels.

func NewIcon

func NewIcon(ic *render.Icon) *Icon

NewIcon returns an icon widget around a rasterized icon.

func NewSVGIcon

func NewSVGIcon(svg []byte, size int) *Icon

NewSVGIcon returns an icon widget that rasterizes embedded SVG bytes at size logical pixels.

func NewThemeIcon

func NewThemeIcon(name string, size int) *Icon

NewThemeIcon returns an icon widget that resolves name from the icon theme at size logical pixels, rasterized at the canvas device scale. Symbolic icons recolor to the theme Accent. Resolution failures paint nothing and surface through Err.

func NewThemeIconFallback

func NewThemeIconFallback(name string, size int) *Icon

NewThemeIconFallback is NewThemeIcon with GTK's default fallbacks for app icons (GThemedIcon): a missing name resolves to its dash-shortened forms in turn, preferences-system-network to preferences-system, then preferences. A desktop entry's Icon= names a specific icon a theme may lack; the fallback re-resolves when the theme changes.

func (*Icon) AccessibleName

func (n *Icon) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Icon) AddClass

func (n *Icon) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Icon) Arrange

func (i *Icon) Arrange(r render.Rect)

Arrange records the border box inside r, the margin box.

func (*Icon) AttachStylesheet

func (n *Icon) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Icon) Attr

func (n *Icon) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Icon) Bounds

func (n *Icon) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Icon) Classes

func (n *Icon) Classes() []string

Classes returns a copy of the widget's classes.

func (*Icon) DebugName

func (n *Icon) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Icon) DetachStylesheet

func (n *Icon) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Icon) Element

func (n *Icon) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Icon) Enabled

func (n *Icon) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Icon) Err

func (i *Icon) Err() error

Err returns the resolution failure of a dynamic icon: an unknown theme name, a missing file, or undecodable data. Nil until a decode a paint asked for has failed.

func (*Icon) HAlign

func (n *Icon) HAlign() Align

HAlign returns the horizontal placement.

func (*Icon) HasClass

func (n *Icon) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Icon) HasState

func (n *Icon) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Icon) HitLeaf

func (n *Icon) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Icon) HitTest

func (i *Icon) HitTest(p Point) Widget

HitTest returns the icon when p is inside its bounds.

func (*Icon) HoverWithin

func (n *Icon) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Icon) ID

func (n *Icon) ID() string

ID returns the style id, empty when none is set.

func (*Icon) InlineStyle

func (n *Icon) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Icon) Invalidate

func (n *Icon) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Icon) InvalidateLayout

func (n *Icon) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Icon) InvalidateRect

func (n *Icon) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Icon) LayoutMotion

func (n *Icon) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Icon) Margin

func (n *Icon) Margin() render.Insets

Margin returns the programmatic margin.

func (*Icon) MaximumSize

func (n *Icon) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Icon) Measure

func (i *Icon) Measure(axis Axis, forSize int) Sizes

Measure returns the icon's pixel size inside the CSS box, clamped to con.

func (*Icon) Name

func (i *Icon) Name() string

Name returns the theme icon's name; empty for the other kinds.

func (*Icon) Paint

func (i *Icon) Paint(cv *render.Canvas)

Paint draws the icon centered in the content box, as GtkImage centers its paintable (the CSS box layers first, when the stylesheet gives the icon any). Dynamic icons resolve first, re-rasterizing when the canvas device scale, the tint, the stylesheet's size, or the icon theme cache moved on since the last frame, with what is already decoded.

func (*Icon) Parent

func (n *Icon) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Icon) RemoveAttr

func (n *Icon) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Icon) RemoveClass

func (n *Icon) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Icon) SetAccessibleName

func (n *Icon) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Icon) SetAttr

func (n *Icon) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Icon) SetClass

func (n *Icon) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Icon) SetClasses

func (n *Icon) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Icon) SetCursorName

func (n *Icon) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Icon) SetDebugName

func (n *Icon) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Icon) SetElement

func (n *Icon) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Icon) SetEnabled

func (n *Icon) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Icon) SetFocusOnClick

func (n *Icon) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Icon) SetHAlign

func (n *Icon) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Icon) SetHExpand

func (n *Icon) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Icon) SetID

func (n *Icon) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Icon) SetInlineStyle

func (n *Icon) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Icon) SetInlineStylePriority

func (n *Icon) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Icon) SetLayoutMotion

func (n *Icon) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Icon) SetMargin

func (n *Icon) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Icon) SetMaximumSize

func (n *Icon) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Icon) SetOnClickWithin

func (n *Icon) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Icon) SetOnFocusChanged

func (n *Icon) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Icon) SetOnHoverWithin

func (n *Icon) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Icon) SetOnPointer

func (n *Icon) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Icon) SetOnScroll

func (n *Icon) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Icon) SetSharedElement

func (n *Icon) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Icon) SetSizeRequest

func (n *Icon) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Icon) SetState

func (n *Icon) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Icon) SetThemeName

func (i *Icon) SetThemeName(name string)

SetThemeName swaps a theme-resolved icon's name - the state-icon pattern (battery, volume, network): one widget, the glyph follows the state. A non-theme icon ignores the call; the next paint rasterizes the new glyph.

func (*Icon) SetTint

func (i *Icon) SetTint(tint Color)

SetTint pins the symbolic recolor color; the zero color (the default) follows the theme Accent. On a static icon the raster is already final, so the tint is applied once, immediately, and cannot be undone.

func (*Icon) SetTooltip

func (n *Icon) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Icon) SetTooltipMarkup

func (n *Icon) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Icon) SetVAlign

func (n *Icon) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Icon) SetVExpand

func (n *Icon) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Icon) SetVisible

func (n *Icon) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Icon) SharedElement

func (n *Icon) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Icon) SizeRequest

func (n *Icon) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Icon) Tint

func (i *Icon) Tint() Color

Tint returns the pinned recolor color; the zero color (the default) follows the theme Accent.

func (*Icon) TooltipMarkup

func (n *Icon) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Icon) TooltipText

func (n *Icon) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Icon) VAlign

func (n *Icon) VAlign() Align

VAlign returns the vertical placement.

func (*Icon) Visible

func (n *Icon) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type IconPosition

type IconPosition uint8

IconPosition is which side of a BarButton's label its icon sits on.

const (
	IconStart IconPosition = iota
	IconEnd
)

The icon positions.

type Image

type Image struct {

	// OnLoaded fires on the loop goroutine once per settled
	// asynchronous load, with the settled widget; check Err. It does
	// not fire for synchronous sources, which are ready at
	// construction.
	OnLoaded func(img *Image)
	// OnPasteImage fires on the loop goroutine when a pasted image
	// (the ctrl+v payload it takes as a ContentPaster) finished decoding:
	// the widget has already taken it as its source. The Image is the
	// paste surface — Entry and TextArea are text-only by design.
	OnPasteImage func(img image.Image)
	// contains filtered or unexported fields
}

Image paints a raster image - album art, an avatar, a rendered snapshot - into its arranged box. It is the raster counterpart of Icon, which covers the SVG side.

Sources come in two decoding flavors:

  • Synchronous: NewImage (a decoded image.Image) and NewBytesImage decode where they are constructed and simply paint from the first frame on.
  • Asynchronous: NewFileImage and NewURLImage fetch and decode on a goroutine the first time they paint. Until the load settles they paint their placeholder color (transparent by default), and the result lands back on the loop goroutine through the invoker - Application.Invoke, the only sanctioned bridge (see docs/threading.md). OnLoaded then fires exactly once for that load, success or failure; check Err when it fires. Sources settle synchronously when no invoker is installed (no application running), and still fire OnLoaded - inline, on the goroutine that painted.

Pixels are resampled with the CatmullRom kernel to the device rect the policy places them in, so fractional scales stay crisp (stubbedev/lys-ui#14). Resamples are cached per (source, source rect, device size) in a shared LRU with a byte budget (internal/imgcache): painting the same image at the same size hits the cache and never rescales, and SetImage drops the old source's entries. A policy of ImageNone skips the cache entirely - nothing resamples. A file or URL source decodes divided by a power of two down to what its box shows, so a 96 px cover tile keeps no 3000 px picture, and decodes finer if the box outgrows that; it still measures at its natural size.

func NewBytesImage

func NewBytesImage(data []byte, name string) *Image

NewBytesImage returns an image widget around encoded image bytes (png, jpeg, gif), decoded synchronously from the cache when possible. name only labels decode errors.

func NewFileImage

func NewFileImage(path string) *Image

NewFileImage returns an image widget that loads an image file (png, jpeg, gif) on a goroutine at its first paint and draws it scaled by the widget's policy.

func NewImage

func NewImage(img image.Image) *Image

NewImage returns an image widget around a decoded image. The widget keeps the reference; treat it as read-only after handoff. To show changed pixels, SetImage the raster again, as a render.VersionedImage at its next version and with the ID it keeps for the raster (render.NewImageID), so a GPU renderer updates its texture in place. A nil img paints nothing.

func NewURLImage

func NewURLImage(url string) *Image

NewURLImage returns an image widget that fetches an image over http(s) on a goroutine at its first paint and draws it scaled by the widget's policy.

func (*Image) AccessibleName

func (n *Image) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Image) AddClass

func (n *Image) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Image) Arrange

func (im *Image) Arrange(r render.Rect)

Arrange records the rect and starts or stops playback with visibility.

func (*Image) AttachStylesheet

func (n *Image) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Image) Attr

func (n *Image) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Image) Bounds

func (n *Image) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Image) Classes

func (n *Image) Classes() []string

Classes returns a copy of the widget's classes.

func (*Image) DebugName

func (n *Image) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Image) DetachStylesheet

func (n *Image) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Image) Element

func (n *Image) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Image) Enabled

func (n *Image) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Image) Err

func (im *Image) Err() error

Err returns the load failure of the current source: a missing or undecodable file, a failed fetch, or undecodable bytes. Nil until a load tried and failed, and sticky until SetImage or friends replace the source.

func (*Image) Frame

func (im *Image) Frame() int

Frame reports the frame an animated source shows (0 for a still).

func (*Image) HAlign

func (n *Image) HAlign() Align

HAlign returns the horizontal placement.

func (*Image) HasClass

func (n *Image) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Image) HasState

func (n *Image) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Image) HitLeaf

func (n *Image) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Image) HitTest

func (im *Image) HitTest(p Point) Widget

HitTest returns the image when p is inside its bounds.

func (*Image) HoverWithin

func (n *Image) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Image) ID

func (n *Image) ID() string

ID returns the style id, empty when none is set.

func (*Image) InlineStyle

func (n *Image) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Image) Invalidate

func (n *Image) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Image) InvalidateLayout

func (n *Image) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Image) InvalidateRect

func (n *Image) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Image) KeyAction

func (im *Image) KeyAction(KeyAction, Mods)

KeyAction implements KeyActionHandler: an Image with an OnPasteImage hook is a paste target, so it joins focus traversal — the actions themselves are none of its own.

func (*Image) LayoutMotion

func (n *Image) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Image) Loaded

func (im *Image) Loaded() bool

Loaded reports whether the current source has settled. Synchronous sources are loaded from construction on.

func (*Image) Margin

func (n *Image) Margin() render.Insets

Margin returns the programmatic margin.

func (*Image) MaximumSize

func (n *Image) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Image) Measure

func (im *Image) Measure(axis Axis, forSize int) Sizes

Measure is the decoded image's pictureRequest. An unsettled source measures 0 x 0; when the load lands, InvalidateLayout drops this cache so the next frame remeasures.

func (*Image) Paint

func (im *Image) Paint(cv *render.Canvas)

Paint settles the source if needed, then draws: the placeholder while an async load is in flight, nothing after a failure, and otherwise the cached resample for the device rect the policy picked.

func (*Image) Parent

func (n *Image) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Image) PasteContent

func (im *Image) PasteContent(mime string, data []byte)

PasteContent implements ContentPaster through PasteImage.

func (*Image) PasteImage

func (im *Image) PasteImage(data []byte, mime string)

PasteImage is the ctrl+v image path: the pasted encoded bytes (with the mime they arrived as, for error messages) become the widget's source, decoded off the loop goroutine through the same invoker bridge as file loads — a large PNG never stalls the loop — and then handed to OnPasteImage. Without an invoker the decode settles synchronously, like every other source.

func (*Image) PasteMimes

func (im *Image) PasteMimes() []string

PasteMimes implements ContentPaster: the image types, best first.

func (*Image) PlaceholderColor

func (im *Image) PlaceholderColor() Color

PlaceholderColor returns what fills the bounds while an asynchronous load is in flight; the zero color paints nothing.

func (*Image) RemoveAttr

func (n *Image) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Image) RemoveClass

func (n *Image) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Image) Scale

func (im *Image) Scale() ImageScale

Scale returns the fit policy.

func (*Image) SetAccessibleName

func (n *Image) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Image) SetAttr

func (n *Image) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Image) SetClass

func (n *Image) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Image) SetClasses

func (n *Image) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Image) SetCursorName

func (n *Image) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Image) SetDebugName

func (n *Image) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Image) SetElement

func (n *Image) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Image) SetEnabled

func (n *Image) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Image) SetFile

func (im *Image) SetFile(path string)

SetFile swaps the source for a file path, reloaded asynchronously at the next paint.

func (*Image) SetFocusOnClick

func (n *Image) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Image) SetHAlign

func (n *Image) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Image) SetHExpand

func (n *Image) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Image) SetID

func (n *Image) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Image) SetImage

func (im *Image) SetImage(img image.Image)

SetImage swaps the source for a decoded image, dropping the previous source's cache entries and the measure caches that still describe the old size. The image is handed over as to NewImage.

func (*Image) SetInlineStyle

func (n *Image) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Image) SetInlineStylePriority

func (n *Image) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Image) SetLayoutMotion

func (n *Image) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Image) SetMargin

func (n *Image) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Image) SetMaximumSize

func (n *Image) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Image) SetOnClickWithin

func (n *Image) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Image) SetOnFocusChanged

func (n *Image) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Image) SetOnHoverWithin

func (n *Image) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Image) SetOnPointer

func (n *Image) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Image) SetOnScroll

func (n *Image) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Image) SetPlaceholderColor

func (im *Image) SetPlaceholderColor(c Color)

SetPlaceholderColor sets what fills the bounds while an asynchronous load is in flight; the zero color (the default) paints nothing.

func (*Image) SetScale

func (im *Image) SetScale(s ImageScale)

SetScale selects how the image fills its box: ImageFit (the default), ImageCover, or ImageNone.

func (*Image) SetSharedElement

func (n *Image) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Image) SetSizeRequest

func (n *Image) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Image) SetState

func (n *Image) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Image) SetTooltip

func (n *Image) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Image) SetTooltipMarkup

func (n *Image) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Image) SetURL

func (im *Image) SetURL(url string)

SetURL swaps the source for a URL, fetched asynchronously at the next paint.

func (*Image) SetVAlign

func (n *Image) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Image) SetVExpand

func (n *Image) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Image) SetVisible

func (n *Image) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Image) SharedElement

func (n *Image) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Image) SizeRequest

func (n *Image) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Image) TooltipMarkup

func (n *Image) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Image) TooltipText

func (n *Image) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Image) VAlign

func (n *Image) VAlign() Align

VAlign returns the vertical placement.

func (*Image) Visible

func (n *Image) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ImageScale

type ImageScale = render.ImageScale

ImageScale picks how an Image fills its arranged box. It aliases the render type so call sites never need render just for the constant.

type InputGroup

type InputGroup struct {
	// contains filtered or unexported fields
}

InputGroup is an entry with addons before and after it - icons, text, buttons - inside one shared border and one focus ring: the group draws the input's border, ring-colored while its entry has the focus, and the keyboard focus ring goes around the whole group. It styles as the `inputgroup` element; addon text and icons take the muted color.

func NewInputGroup

func NewInputGroup(entry *Entry) *InputGroup

NewInputGroup returns a group around entry with no addons yet.

func (*InputGroup) Append

func (g *InputGroup) Append(w Widget)

Append adds w as the last addon, after the entry.

func (*InputGroup) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*InputGroup) Baseline

func (c *InputGroup) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*InputGroup) Children

func (c *InputGroup) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*InputGroup) Entry

func (g *InputGroup) Entry() *Entry

Entry returns the group's entry.

func (*InputGroup) HitTest

func (c *InputGroup) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*InputGroup) Measure

func (c *InputGroup) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*InputGroup) Paint

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

Paint draws the surface (when configured) then the root.

func (*InputGroup) Prepend

func (g *InputGroup) Prepend(w Widget)

Prepend adds w as the first addon, before the entry.

type InputOTP

type InputOTP struct {

	// OnChanged fires with the code after every edit; OnComplete when
	// an edit fills the last empty slot.
	OnChanged  func(code string)
	OnComplete func(code string)
	// contains filtered or unexported fields
}

InputOTP is a one-time-code input: a fixed number of slots in groups, one character each, the groups split by a dash. It takes the focus as one field: typing fills the active slot and advances, Backspace and Delete clear, Left, Right, Home and End move, a paste fills from the active slot, and a click picks a slot. The focus ring goes around the active slot. It styles as the `inputotp` element with .slot boxes (the active one :checked) and .separator dashes.

func NewInputOTP

func NewInputOTP(face render.Font, charset OTPCharset, groups ...int) *InputOTP

NewInputOTP returns an empty code input of the groups' slot counts: NewInputOTP(face, OTPDigits, 3, 3) is two groups of three. Every group holds at least one slot, or the call panics.

func (*InputOTP) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*InputOTP) Baseline

func (c *InputOTP) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*InputOTP) Children

func (c *InputOTP) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*InputOTP) ClickAt

func (o *InputOTP) ClickAt(p Point)

ClickAt implements Clicker: a click picks the slot under it, or the first empty one past the code.

func (*InputOTP) Code

func (o *InputOTP) Code() string

Code returns the characters entered so far.

func (*InputOTP) HitTest

func (o *InputOTP) HitTest(p Point) Widget

HitTest takes every press inside the bounds, so a click on a slot focuses the input.

func (*InputOTP) Insert

func (o *InputOTP) Insert(s string)

Insert implements TextInserter: a paste fills from the active slot.

func (*InputOTP) InsertRune

func (o *InputOTP) InsertRune(r rune)

InsertRune implements RuneHandler: an accepted character fills the active slot and advances; in a full code it overwrites the active slot.

func (*InputOTP) KeyAction

func (o *InputOTP) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: clearing and moving.

func (*InputOTP) Len

func (o *InputOTP) Len() int

Len is the number of slots.

func (*InputOTP) Measure

func (c *InputOTP) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*InputOTP) Paint

func (o *InputOTP) Paint(cv *render.Canvas)

Paint draws the slots, then the caret in an empty active slot while the input has the focus.

func (*InputOTP) Role

func (o *InputOTP) Role() Role

Role is RoleEntry: a field whose text is the code.

func (*InputOTP) SetCode

func (o *InputOTP) SetCode(s string)

SetCode replaces the code with s's accepted characters, as many as fit, and puts the caret after them. It reports nothing.

type InputRegioner

type InputRegioner interface {
	InputRegion() []render.Rect
}

InputRegioner is a window's content that takes input only inside its region: outside it, pointer input passes through the surface to whatever is beneath, as on an overlay layer. An empty region takes input everywhere. The window applies it after every layout, found through InputRegionOf.

type Inscription

type Inscription struct {
	// contains filtered or unexported fields
}

Inscription is GTK's Inscription: text sized by character and line counts instead of by its content, for cells in big lists and grids. Measure shapes nothing but one reference glyph: the minimum and natural widths are MinChars and NatChars of the face's average advance, the heights MinLines and NatLines of its line height. Paint draws as many lines as fit, each ellipsized at the end.

func NewInscription

func NewInscription(face render.Font, sizePx float64, text string, color render.Color) *Inscription

NewInscription returns an inscription of text: 3 characters minimum, 10 natural, one line.

func (*Inscription) AccessibleName

func (n *Inscription) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Inscription) AddClass

func (n *Inscription) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Inscription) Arrange

func (in *Inscription) Arrange(r render.Rect)

Arrange records the bounds.

func (*Inscription) AttachStylesheet

func (n *Inscription) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Inscription) Attr

func (n *Inscription) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Inscription) Bounds

func (n *Inscription) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Inscription) Classes

func (n *Inscription) Classes() []string

Classes returns a copy of the widget's classes.

func (*Inscription) DebugName

func (n *Inscription) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Inscription) DetachStylesheet

func (n *Inscription) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Inscription) Element

func (n *Inscription) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Inscription) Enabled

func (n *Inscription) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Inscription) HAlign

func (n *Inscription) HAlign() Align

HAlign returns the horizontal placement.

func (*Inscription) HasClass

func (n *Inscription) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Inscription) HasState

func (n *Inscription) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Inscription) HitLeaf

func (n *Inscription) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Inscription) HitTest

func (in *Inscription) HitTest(p Point) Widget

HitTest returns the inscription when p is inside it.

func (*Inscription) HoverWithin

func (n *Inscription) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Inscription) ID

func (n *Inscription) ID() string

ID returns the style id, empty when none is set.

func (*Inscription) InlineStyle

func (n *Inscription) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Inscription) Invalidate

func (n *Inscription) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Inscription) InvalidateLayout

func (n *Inscription) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Inscription) InvalidateRect

func (n *Inscription) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Inscription) LayoutMotion

func (n *Inscription) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Inscription) Margin

func (n *Inscription) Margin() render.Insets

Margin returns the programmatic margin.

func (*Inscription) MaximumSize

func (n *Inscription) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Inscription) Measure

func (in *Inscription) Measure(axis Axis, forSize int) Sizes

Measure claims the natural character and line counts' extent, never below the minimum.

func (*Inscription) Paint

func (in *Inscription) Paint(cv *render.Canvas)

Paint draws the lines that fit, each ellipsized to the width.

func (*Inscription) Parent

func (n *Inscription) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Inscription) RemoveAttr

func (n *Inscription) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Inscription) RemoveClass

func (n *Inscription) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Inscription) Role

func (in *Inscription) Role() Role

Role reads as a label.

func (*Inscription) SetAccessibleName

func (n *Inscription) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Inscription) SetAlignment

func (in *Inscription) SetAlignment(a render.Alignment)

SetAlignment sets the horizontal text alignment.

func (*Inscription) SetAttr

func (n *Inscription) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Inscription) SetClass

func (n *Inscription) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Inscription) SetClasses

func (n *Inscription) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Inscription) SetColor

func (in *Inscription) SetColor(c render.Color)

SetColor sets the ink.

func (*Inscription) SetCursorName

func (n *Inscription) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Inscription) SetDebugName

func (n *Inscription) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Inscription) SetElement

func (n *Inscription) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Inscription) SetEnabled

func (n *Inscription) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Inscription) SetFocusOnClick

func (n *Inscription) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Inscription) SetHAlign

func (n *Inscription) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Inscription) SetHExpand

func (n *Inscription) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Inscription) SetID

func (n *Inscription) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Inscription) SetInlineStyle

func (n *Inscription) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Inscription) SetInlineStylePriority

func (n *Inscription) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Inscription) SetLayoutMotion

func (n *Inscription) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Inscription) SetMargin

func (n *Inscription) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Inscription) SetMaximumSize

func (n *Inscription) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Inscription) SetMinChars

func (in *Inscription) SetMinChars(n int)

SetMinChars sets the minimum width in characters.

func (*Inscription) SetMinLines

func (in *Inscription) SetMinLines(n int)

SetMinLines sets the minimum height in lines.

func (*Inscription) SetNatChars

func (in *Inscription) SetNatChars(n int)

SetNatChars sets the natural width in characters.

func (*Inscription) SetNatLines

func (in *Inscription) SetNatLines(n int)

SetNatLines sets the natural height in lines.

func (*Inscription) SetOnClickWithin

func (n *Inscription) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Inscription) SetOnFocusChanged

func (n *Inscription) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Inscription) SetOnHoverWithin

func (n *Inscription) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Inscription) SetOnPointer

func (n *Inscription) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Inscription) SetOnScroll

func (n *Inscription) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Inscription) SetSharedElement

func (n *Inscription) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Inscription) SetSizeRequest

func (n *Inscription) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Inscription) SetState

func (n *Inscription) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Inscription) SetText

func (in *Inscription) SetText(s string)

SetText replaces the text. The size does not depend on it, so only a repaint follows.

func (*Inscription) SetTooltip

func (n *Inscription) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Inscription) SetTooltipMarkup

func (n *Inscription) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Inscription) SetVAlign

func (n *Inscription) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Inscription) SetVExpand

func (n *Inscription) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Inscription) SetVisible

func (n *Inscription) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Inscription) SharedElement

func (n *Inscription) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Inscription) SizeRequest

func (n *Inscription) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Inscription) Text

func (in *Inscription) Text() string

Text returns the text.

func (*Inscription) TooltipMarkup

func (n *Inscription) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Inscription) TooltipText

func (n *Inscription) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Inscription) VAlign

func (n *Inscription) VAlign() Align

VAlign returns the vertical placement.

func (*Inscription) Visible

func (n *Inscription) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item is a content row: media - an icon on a muted tile, an avatar - then a title over a description, then actions, for lists and cards. Its text and media update in place, so a live list reconciles rows instead of rebuilding them, and SetOnActivate makes the whole row a control (click, Enter, Space). It styles as the `item` element with the variant's class (.outline, .muted), .small for the small size, .activatable while it activates, its .media tile, .title and .description.

func NewItem

func NewItem(face render.Font, title, description string) *Item

NewItem returns a default item; an empty description shows the title alone.

func (*Item) AddAction

func (it *Item) AddAction(w Widget)

AddAction appends w (a button) to the row's end.

func (*Item) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Item) Baseline

func (c *Item) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Item) Children

func (c *Item) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Item) ClickAt

func (it *Item) ClickAt(Point)

ClickAt runs the activation.

func (*Item) HitTest

func (it *Item) HitTest(p Point) Widget

HitTest resolves an activatable item to itself, but for its action buttons; a plain item hits its parts.

func (*Item) KeyAction

func (it *Item) KeyAction(a KeyAction, _ Mods)

KeyAction runs the activation on Enter or Space.

func (*Item) Measure

func (c *Item) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Item) Paint

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

Paint draws the surface (when configured) then the root.

func (*Item) SetDescription

func (it *Item) SetDescription(description string)

SetDescription replaces the description; empty hides its line.

func (*Item) SetEllipsize

func (it *Item) SetEllipsize(on bool)

SetEllipsize keeps the title and the description on one line each, ending in an ellipsis when the row is too narrow, instead of wrapping: a one-token name (a device's address) then no longer sets the row's minimum width and pushes its actions out.

func (*Item) SetMedia

func (it *Item) SetMedia(w Widget, bare bool)

SetMedia leads the row with w on a muted 32px tile (an icon), or as it is when bare (an avatar, an image); nil removes it.

func (*Item) SetOnActivate

func (it *Item) SetOnActivate(fn func())

SetOnActivate makes the whole row a control running fn on a click outside its actions, Enter or Space, with the hover fill and the focus ring; nil makes it a plain row again.

func (*Item) SetSmall

func (it *Item) SetSmall(on bool)

SetSmall switches to the small size.

func (*Item) SetTitle

func (it *Item) SetTitle(title string)

SetTitle replaces the title.

func (*Item) SetVariant

func (it *Item) SetVariant(v ItemVariant)

SetVariant switches the item's look.

type ItemGroup

type ItemGroup struct {
	// contains filtered or unexported fields
}

ItemGroup stacks Items into one list, a separator between each item and the next. It styles as the `itemgroup` element.

func NewItemGroup

func NewItemGroup(items ...Widget) *ItemGroup

NewItemGroup returns a group of items, in order.

func (*ItemGroup) Append

func (g *ItemGroup) Append(w Widget)

Append adds w at the end, after a separator when the group already holds an item.

func (*ItemGroup) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ItemGroup) Baseline

func (c *ItemGroup) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ItemGroup) Children

func (c *ItemGroup) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ItemGroup) Clear

func (g *ItemGroup) Clear()

Clear drops every item.

func (*ItemGroup) HitTest

func (c *ItemGroup) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ItemGroup) Measure

func (g *ItemGroup) Measure(axis Axis, forSize int) Sizes

Measure shows a separator only between two shown items, as a GTK boxed list does, then measures the stack: a hidden item takes the separators beside it with it.

func (*ItemGroup) Paint

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

Paint draws the surface (when configured) then the root.

func (*ItemGroup) Remove

func (g *ItemGroup) Remove(w Widget) bool

Remove drops item w with the separator that set it apart (the one before it, or after it for the first), reporting whether w was in the group.

type ItemKind

type ItemKind uint8

ItemKind distinguishes the menu row styles.

const (
	ItemAction ItemKind = iota
	ItemCheck
	ItemRadio
	ItemSeparator
	// ItemHeader is a group's caption: muted text, never hovered,
	// stepped onto, or activated.
	ItemHeader
)

Item kinds.

type ItemVariant

type ItemVariant uint8

ItemVariant picks an Item's look.

const (
	// ItemDefault is a plain row.
	ItemDefault ItemVariant = iota
	// ItemOutline draws a border around it.
	ItemOutline
	// ItemMuted gives it the muted fill.
	ItemMuted
)

The item variants.

type Justify

type Justify uint8

Justify is how a wrapping line uses the width its children leave over (adw WrapBox's justify, plus the alignment of the rest).

const (
	// JustifyStart packs children at the start edge (the default).
	JustifyStart Justify = iota
	// JustifyCenter centers each line.
	JustifyCenter
	// JustifyEnd packs children at the end edge.
	JustifyEnd
	// JustifyFill grows every child of a line by an equal share.
	JustifyFill
	// JustifySpread widens the gaps between a line's children.
	JustifySpread
)

Justifications.

type KeyAction

type KeyAction uint8

KeyAction is an editing or activation action derived from a keyboard event.

const (
	KeyBackspace KeyAction = iota
	KeyDelete
	KeyLeft
	KeyRight
	KeyUp
	KeyDown
	KeyHome
	KeyEnd
	KeyEnter
	KeyPriorPage
	KeyNextPage
	KeyDismiss
	KeySpace
	// KeyContextMenu opens the focused widget's context menu: the Menu
	// key, or Shift+F10.
	KeyContextMenu
)

Editing and activation actions, derived from keysyms by KeyActionForSym. KeyBackspace is zero, so the zero KeyAction is the common delete-backward edit.

func KeyActionForSym

func KeyActionForSym(sym xkb.Keysym) (KeyAction, bool)

KeyActionForSym maps a keysym to an editing or activation action. Popup hosts use it to route seat keyboard events into popup-local widget trees without importing the app package.

type KeyActionHandler

type KeyActionHandler interface {
	KeyAction(a KeyAction, mods Mods)
}

KeyActionHandler receives editing and activation actions with the modifiers held at the time.

type KeyInterceptor

type KeyInterceptor interface {
	InterceptKey(target Widget, a KeyAction, mods Mods) bool
}

KeyInterceptor is an ancestor that pre-empts a focused widget's key actions (GTK's KeyControllerKeyPressed on a parent). target is the focused widget the action was headed for; InterceptKey returns true when it consumed the action.

type Label

type Label struct {
	// contains filtered or unexported fields
}

Label paints text. It is passive: it hits as itself but has no interaction behavior.

The default is one line whose text overflows a narrow arrangement and clips. SetWrap turns on word wrapping at the width it is given - Measure then reports one line height per wrapped row - and SetEllipsize truncates with an ellipsis instead, at the start, middle, or end. With both on, wrapping fills rows and the ellipsis applies to the final row only (GTK's rule): a lone unbreakable token left overflowing there truncates rather than spilling. A label too small for its text is the classic tooltip case: keep the full text in SetTooltip and let the mode shorten what paints.

func NewKbd

func NewKbd(face render.Font, key string) *Label

NewKbd draws one key as a keycap: a .keycap label.

func NewLabel

func NewLabel(face render.Font, sizePx float64, text string, color render.Color) *Label

NewLabel returns a label that paints text with face at sizePx pixels in color. Face may be a render.Chain for mixed-script fallback. Constructor argument order is the toolkit-wide one: face, then sizePx, then the content, then colors. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*Label) AccessibleName

func (n *Label) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Label) AddClass

func (n *Label) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Label) Alignment

func (l *Label) Alignment() render.Alignment

Alignment returns the horizontal placement.

func (*Label) Arrange

func (l *Label) Arrange(r render.Rect)

Arrange records the border box inside r, the margin box.

func (*Label) AttachStylesheet

func (n *Label) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Label) Attr

func (n *Label) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Label) Baseline

func (l *Label) Baseline() (int, bool)

Baseline implements Baseliner: the first line inside the CSS box, raised or lowered by vertical-align (sub, super, a length, or a percentage resolved against the line-height at compute time).

func (*Label) BindText

func (l *Label) BindText(b *Binding[string]) (unbind func())

BindText wires the binding one-way to the label's text: a label never edits, so nothing writes back.

func (*Label) Bounds

func (n *Label) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Label) CharsWithin

func (l *Label) CharsWithin(px int) int

CharsWithin is how many approximate character widths fit in px, the max-width-chars that holds the label's natural width to px.

func (*Label) Classes

func (n *Label) Classes() []string

Classes returns a copy of the widget's classes.

func (*Label) Color

func (l *Label) Color() render.Color

Color returns the label's current programmatic ink, or 0 when the label inherits.

func (*Label) DebugName

func (n *Label) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Label) DetachStylesheet

func (n *Label) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Label) Direction

func (l *Label) Direction() Direction

Direction returns the base paragraph direction the label resolves with.

func (*Label) Element

func (n *Label) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Label) Ellipsize

func (l *Label) Ellipsize() EllipsizeMode

Ellipsize returns the label's truncation mode.

func (*Label) Enabled

func (n *Label) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Label) HAlign

func (n *Label) HAlign() Align

HAlign returns the horizontal placement.

func (*Label) HasClass

func (n *Label) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Label) HasState

func (n *Label) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Label) HitLeaf

func (n *Label) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Label) HitTest

func (l *Label) HitTest(p Point) Widget

HitTest returns the label when p is inside its bounds.

func (*Label) HoverWithin

func (n *Label) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Label) ID

func (n *Label) ID() string

ID returns the style id, empty when none is set.

func (*Label) InlineStyle

func (n *Label) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Label) Invalidate

func (n *Label) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Label) InvalidateLayout

func (n *Label) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Label) InvalidateRect

func (n *Label) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Label) LayoutMotion

func (n *Label) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Label) Margin

func (n *Label) Margin() render.Insets

Margin returns the programmatic margin.

func (*Label) MaxLines

func (l *Label) MaxLines() int

MaxLines returns the row limit, 0 when unlimited.

func (*Label) MaxWidthChars

func (l *Label) MaxWidthChars() int

MaxWidthChars returns the width cap in characters, 0 when uncapped.

func (*Label) MaximumSize

func (n *Label) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Label) Measure

func (l *Label) Measure(axis Axis, forSize int) Sizes

Measure reports the text's request inside the CSS box (padding, border, margin, min sizes), GTK's label measure. Across: its natural width is the text unwrapped; its minimum is the ellipsis when it ellipsizes, else the widest word when it wraps, else the whole text, so it overflows rather than clip; max-width-chars holds the natural width of one that can narrow, and width-chars floors both. Down: the rows it lays out at the width it is given, or at its natural width before any. Widths round up: Paint ellipsizes (and wraps) against the raw advance, so a width rounded to nearest would truncate a text laid out at exactly its natural size.

func (*Label) Paint

func (l *Label) Paint(cv *render.Canvas)

Paint draws the label's CSS layers (when the stylesheet gives it any), then the text inside the content box: the rows when the label is multiline, the single line ellipsized as configured otherwise.

func (*Label) Parent

func (n *Label) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Label) RemoveAttr

func (n *Label) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Label) RemoveClass

func (n *Label) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Label) Role

func (l *Label) Role() Role

Role implements Roleer.

func (*Label) SetAccessibleName

func (n *Label) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Label) SetAlignment

func (l *Label) SetAlignment(a render.Alignment)

SetAlignment selects horizontal placement when the arranged rect is wider than the text; wrapped rows align individually.

func (*Label) SetAttr

func (n *Label) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Label) SetClass

func (n *Label) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Label) SetClasses

func (n *Label) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Label) SetColor

func (l *Label) SetColor(c render.Color)

SetColor sets the label's programmatic ink, the dynamic counterpart of NewLabel's color argument: modules that restyle per state (battery thresholds, workspace focus) call it instead of rebuilding the label. A stylesheet color declaration still outranks it, per the cascade; 0 is the no-color value and falls through to the theme.

func (*Label) SetCursorName

func (n *Label) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Label) SetDebugName

func (n *Label) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Label) SetDirection

func (l *Label) SetDirection(d Direction)

SetDirection selects the base paragraph direction the text resolves and lays out with. DirectionAuto (the default) reads it off the text's first strong character, so a Hebrew- or Arabic-first label mirrors on its own; DirectionLTR and DirectionRTL force the base, and start/end alignment mirrors with it. Changing the direction re-resolves the text and drops the measure cache.

func (*Label) SetElement

func (n *Label) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Label) SetEllipsize

func (l *Label) SetEllipsize(mode EllipsizeMode)

SetEllipsize selects where an overflowing line truncates with an ellipsis: at the end, at the start, in the middle (paths and filenames), or not at all. With wrap on, the ellipsis applies to the final row only; otherwise it applies to the single line. The label's text is never rewritten - pair the mode with SetTooltip to keep the whole string reachable. Changing the mode drops the measure cache.

func (*Label) SetEnabled

func (n *Label) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Label) SetFace

func (l *Label) SetFace(face render.Font)

SetFace swaps the shaping face (a fallback chain works here too); the shaped caches drop and the bounds invalidate.

func (*Label) SetFocusOnClick

func (n *Label) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Label) SetHAlign

func (n *Label) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Label) SetHExpand

func (n *Label) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Label) SetID

func (n *Label) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Label) SetInlineStyle

func (n *Label) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Label) SetInlineStylePriority

func (n *Label) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Label) SetLayoutMotion

func (n *Label) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Label) SetMargin

func (n *Label) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Label) SetMaxLines

func (l *Label) SetMaxLines(n int)

SetMaxLines limits a wrapping, ellipsizing label to n rows (GTK's set_lines): the text past row n folds into the final row, which the ellipsize mode truncates. Like GTK it has no effect unless the label both wraps and ellipsizes. n <= 0 removes the limit.

func (*Label) SetMaxWidthChars

func (l *Label) SetMaxWidthChars(n int)

SetMaxWidthChars caps the label's natural width at n approximate character widths (GTK's max-width-chars): longer text overflows the cap and truncates by the ellipsize mode. n <= 0 removes the cap.

func (*Label) SetMaximumSize

func (n *Label) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Label) SetOnClickWithin

func (n *Label) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Label) SetOnFocusChanged

func (n *Label) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Label) SetOnHoverWithin

func (n *Label) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Label) SetOnPointer

func (n *Label) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Label) SetOnScroll

func (n *Label) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Label) SetSharedElement

func (n *Label) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Label) SetSizePx

func (l *Label) SetSizePx(px float64)

SetSizePx changes the shaping size; the shaped caches drop and the bounds invalidate.

func (*Label) SetSizeRequest

func (n *Label) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Label) SetState

func (n *Label) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Label) SetText

func (l *Label) SetText(text string)

SetText replaces the label text and invalidates the label's bounds.

func (*Label) SetTooltip

func (n *Label) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Label) SetTooltipMarkup

func (n *Label) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Label) SetVAlign

func (n *Label) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Label) SetVExpand

func (n *Label) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Label) SetVisible

func (n *Label) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Label) SetWidthChars

func (l *Label) SetWidthChars(n int)

SetWidthChars floors the label's natural width at n approximate character widths (GTK's width-chars): a shorter text still measures that wide, so labels of one row line up. n <= 0 restores the text's own width.

func (*Label) SetWrap

func (l *Label) SetWrap(on bool)

SetWrap toggles word wrapping at the width the label is given. Measure then needs only the widest word and reports one line height per row at a width, breaking at Unicode UAX #14 opportunities (spaces, hyphens, CJK); a run with no opportunity before the width - an unbreakable token - keeps its own row and overflows, clipped, never disappearing. Changing the mode drops the measure cache.

func (*Label) SharedElement

func (n *Label) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Label) SizePx

func (l *Label) SizePx() float64

SizePx returns the shaping size in logical pixels.

func (*Label) SizeRequest

func (n *Label) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Label) Text

func (l *Label) Text() string

Text returns the current label text.

func (*Label) TooltipMarkup

func (n *Label) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Label) TooltipText

func (n *Label) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Label) VAlign

func (n *Label) VAlign() Align

VAlign returns the vertical placement.

func (*Label) Visible

func (n *Label) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*Label) WidthChars

func (l *Label) WidthChars() int

WidthChars returns the natural-width floor in characters, 0 when unset.

func (*Label) Wrap

func (l *Label) Wrap() bool

Wrap reports whether the label wraps at the width it is given.

type LayoutMotion

type LayoutMotion = style.LayoutMotion

LayoutMotion is how a widget animates a change of its laid-out rect: not at all, or on one of the named springs. The stylesheet's -lys-layout-motion outranks it, as it outranks every constructor default; containers opt their children in with a selector (`.list > * { -lys-layout-motion: smooth; }`).

type LevelBar

type LevelBar struct {
	// contains filtered or unexported fields
}

LevelBar is GTK's continuous level bar: the levelbar element over a trough and one filled block (levelbar > trough > block.filled), the node tree stylesheets target for gauges. Every part paints from its cascade - there is no programmatic color; the theme layer gives the trough the view color and the offsets their tints, and a stylesheet overrides either. Offsets classify the value: the block carries the name of the lowest offset at or above it, so `levelbar block.low` restyles a nearly empty gauge.

func NewLevelBar

func NewLevelBar(value float64) *LevelBar

NewLevelBar returns a continuous level bar at value clamped to [0, 1], with GTK's default offsets (low 0.25, high 0.75, full 1).

func (*LevelBar) AddOffset

func (b *LevelBar) AddOffset(name string, value float64)

AddOffset adds or moves the named threshold.

func (*LevelBar) Arrange

func (m *LevelBar) Arrange(r render.Rect)

Arrange records the bar's border box and lays the trough across its content box at the trough's own height, centered, so a bar given more height than its trough keeps a thin trough.

func (*LevelBar) Block

func (b *LevelBar) Block() Widget

Block returns the filled block node (levelbar > trough > block.filled), the diagnostic view a paint test reads.

func (*LevelBar) HitTest

func (b *LevelBar) HitTest(p Point) Widget

HitTest returns the bar when p is inside its bounds.

func (*LevelBar) Measure

func (b *LevelBar) Measure(axis Axis, forSize int) Sizes

Measure wants the 160x10 trough inside the bar's CSS box.

func (*LevelBar) Offset

func (b *LevelBar) Offset() string

Offset reports the offset class the block carries ("" for none).

func (*LevelBar) Offsets

func (b *LevelBar) Offsets() []LevelOffset

Offsets reports the thresholds, lowest first.

func (*LevelBar) Paint

func (b *LevelBar) Paint(cv *render.Canvas)

Paint draws the trough and the proportional block.

func (*LevelBar) RemoveOffset

func (b *LevelBar) RemoveOffset(name string)

RemoveOffset drops the named threshold.

func (*LevelBar) Role

func (b *LevelBar) Role() Role

Role implements Roleer.

func (*LevelBar) SetValue

func (b *LevelBar) SetValue(v float64)

SetValue clamps v to [0, 1] and repaints the block.

func (*LevelBar) Trough

func (b *LevelBar) Trough() Widget

Trough returns the bar's trough node (levelbar > trough), the diagnostic view a paint test reads.

func (*LevelBar) Value

func (m *LevelBar) Value() float64

Value returns the fill fraction in [0, 1].

type LevelOffset

type LevelOffset struct {
	Name  string
	Value float64
}

LevelOffset is a named threshold: while the value is at or below it (and above every lower one), the block carries Name as a class.

type List

type List struct {
	OnSelect           func(i int)
	OnActivate         func(i int)
	OnSelectionChanged func(rows []int)
	// OnPointer sees every button press on the list first, with the
	// row under it (-1 below the last row); a true return consumes the
	// press, so no selection, activation or drag follows.
	OnPointer func(row int, e PointerEvent) bool
	// OnScroll sees every wheel step over the list first, with the row
	// under the pointer (-1 below the last row); a true return
	// consumes the step instead of scrolling.
	OnScroll func(row int, e ScrollEvent) bool

	// DragContent, when set, lets the selection be dragged out to other
	// applications, the way a file manager's is: a press on a selected
	// row that moves past the drag threshold offers DragContent of the
	// rows dragged - the whole selection in multiple mode, the pressed
	// row otherwise - instead of moving the selection. A press on an
	// unselected row still selects, rubber-bands and motion-selects;
	// nil (or a nil return) drags nothing.
	DragContent func(rows []int) *DragContent
	// contains filtered or unexported fields
}

List is a virtualized list view: only the rows inside the viewport are requested from the model, measured, and painted, so ten thousand rows cost about the same as ten. Selection is pointer and keyboard driven, clamps at the ends, and Enter activates.

The selection model is SetSelectionMode: single (the default), none, browse, or multiple. Selection reports the whole selected set and OnSelectionChanged fires once per gesture with it; OnSelect keeps its single-row meaning in single and browse mode and stays silent in multiple mode.

Pointer gestures land on a row proxy the List keeps over every visible row: the proxy forwards what the row widget itself implements (clicks, hover and press tracking, tooltips, cursor names) while the List owns selection. In selectable modes the proxy's drag is the List's (rubber-band in multiple, motion-select in single and browse); rows that need their own drag behavior belong in a SelectionNone list. In multiple mode a row that contains a CheckButton cedes the check to the selection model: the check reflects row membership and clicking it toggles membership instead of the check's own state.

func NewList

func NewList[W Widget](model ListModel[W], rowHeight int) *List

NewList wraps a model with a uniform row height in pixels; zero derives the height from measuring the first row.

func (*List) AccessibleName

func (n *List) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*List) AddClass

func (n *List) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*List) Arrange

func (l *List) Arrange(r render.Rect)

Arrange records the border box inside r and lays the viewport out in its content box.

func (*List) AttachStylesheet

func (n *List) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*List) Attr

func (n *List) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*List) Bounds

func (n *List) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*List) Changed

func (l *List) Changed()

Changed re-queries the model after its data changed, keeping cached row widgets whose indices still exist.

func (*List) Children

func (l *List) Children() []Widget

Children returns the realized rows in model order: the rows on screen, each the proxy around its model widget. Rows off screen do not exist.

func (*List) Classes

func (n *List) Classes() []string

Classes returns a copy of the widget's classes.

func (*List) ClickAt

func (l *List) ClickAt(p Point)

ClickAt applies a press-and-release on the list itself: a row hit that no proxy covers (a partially visible last row, say) selects that row per the mode.

func (*List) DebugName

func (n *List) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*List) DetachStylesheet

func (n *List) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*List) DragMove

func (l *List) DragMove(p Point)

DragMove implements DragMover for presses on the list itself; see dragApply.

func (*List) Element

func (n *List) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*List) Enabled

func (n *List) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*List) HAlign

func (n *List) HAlign() Align

HAlign returns the horizontal placement.

func (*List) HasClass

func (n *List) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*List) HasState

func (n *List) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*List) HitLeaf

func (n *List) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*List) HitTest

func (l *List) HitTest(p Point) Widget

HitTest returns the row proxy under p, or the list itself where no item is (see itemAt).

func (*List) HoverMove

func (l *List) HoverMove(p Point)

HoverMove implements HoverMover: tracks the hovered row for styling and per-row tooltips, none where no item is under the pointer. Browse mode selects the hovered row (focus follows the pointer). Disabled lists highlight nothing.

func (*List) HoverWithin

func (n *List) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*List) ID

func (n *List) ID() string

ID returns the style id, empty when none is set.

func (*List) InlineStyle

func (n *List) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*List) Invalidate

func (n *List) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*List) InvalidateLayout

func (n *List) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*List) InvalidateRect

func (n *List) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*List) KeyAction

func (l *List) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: selection motion clamps at the ends (pinned), PageUp/PageDown move a viewport of rows, and Enter activates exactly once per press. Multiple mode adds the cursor/anchor gestures; none mode ignores selection keys. Disabled lists ignore keys.

func (*List) LayoutMotion

func (n *List) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*List) Margin

func (n *List) Margin() render.Insets

Margin returns the programmatic margin.

func (*List) MaximumSize

func (n *List) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*List) Measure

func (l *List) Measure(axis Axis, forSize int) Sizes

Measure reports a cell's width (or 120 for rows) by the full content height at the width given, held to the max height, inside the list's CSS box: the list is the viewport, not the content. It needs one row: a short parent gets the rest back and the list scrolls it.

func (*List) Paint

func (l *List) Paint(cv *render.Canvas)

Paint draws the viewport background, the cursor ring, and exactly the visible rows; the rows paint their own hover and selection fills (the `row` node's CSS box).

func (*List) Parent

func (n *List) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*List) PressEnd

func (l *List) PressEnd()

PressEnd implements PressEnder: closes the gesture started by the press, landing the held selection notification.

func (*List) Refresh

func (l *List) Refresh()

Refresh re-queries every row widget, keeping the selection and the scroll: the rows' data changed in place (a column resized, a thumbnail arrived), where Changed would keep showing the cached widgets.

func (*List) RemoveAttr

func (n *List) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*List) RemoveClass

func (n *List) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*List) Reset

func (l *List) Reset()

Reset is for a model whose rows were replaced wholesale (a folder listing for another folder): every cached row widget, the selection and the scroll go, and OnSelectionChanged fires when a selection was dropped.

func (*List) Role

func (l *List) Role() Role

Role implements Roleer.

func (*List) ScrollBy

func (l *List) ScrollBy(dx, dy int)

ScrollBy implements ScrollHandler. Disabled lists do not scroll.

func (*List) ScrollEnd

func (l *List) ScrollEnd()

ScrollEnd implements ScrollEnder: the list glides on from the gesture's velocity.

func (*List) ScrollPixels

func (l *List) ScrollPixels(_, dy float64)

ScrollPixels implements PixelScroller: exact vertical deltas, the fraction kept for the next one.

func (*List) Select

func (s *List) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*List) SelectAll

func (s *List) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*List) SelectRows

func (s *List) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*List) Selected

func (s *List) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*List) Selection

func (s *List) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*List) SelectionMode

func (s *List) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*List) SetAccessibleName

func (n *List) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*List) SetAttr

func (n *List) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*List) SetCellWidth

func (l *List) SetCellWidth(w int)

SetCellWidth switches the list into a grid: items flow left to right in as many equal columns of at least w pixels as the width fits, every line the row height tall, still virtualized by line. Up and down move a line, left and right one item. Zero is a plain list.

func (*List) SetClass

func (n *List) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*List) SetClasses

func (n *List) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*List) SetCursorName

func (n *List) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*List) SetDebugName

func (n *List) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*List) SetElement

func (n *List) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*List) SetEnabled

func (n *List) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*List) SetFocusOnClick

func (n *List) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*List) SetHAlign

func (n *List) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*List) SetHExpand

func (n *List) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*List) SetID

func (n *List) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*List) SetInlineStyle

func (n *List) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*List) SetInlineStylePriority

func (n *List) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*List) SetLayoutMotion

func (n *List) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*List) SetMargin

func (n *List) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*List) SetMaxHeight

func (l *List) SetMaxHeight(h int)

SetMaxHeight caps the list's natural height at h pixels (0 lifts the cap): a longer model scrolls inside it, still virtualized - GTK's list in a scrolled window with a max content height.

func (*List) SetMaximumSize

func (n *List) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*List) SetOnClickWithin

func (n *List) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*List) SetOnFocusChanged

func (n *List) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*List) SetOnHoverWithin

func (n *List) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*List) SetOnPointer

func (n *List) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*List) SetOnScroll

func (n *List) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*List) SetPressed

func (l *List) SetPressed(on bool)

SetPressed implements PressSetter: true begins a pointer gesture on the list itself, false only clears the row's own pressed tracking.

func (*List) SetSelectionMode

func (s *List) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*List) SetSharedElement

func (n *List) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*List) SetSingleClickActivate

func (l *List) SetSingleClickActivate(on bool)

SetSingleClickActivate makes a plain click activate the row (OnActivate) as well as select it, GTK's single-click-activate: a picker's rows act on one click. Multiple-selection lists keep clicks for membership.

func (*List) SetSizeRequest

func (n *List) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*List) SetState

func (n *List) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*List) SetTooltip

func (n *List) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*List) SetTooltipMarkup

func (n *List) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*List) SetVAlign

func (n *List) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*List) SetVExpand

func (n *List) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*List) SetVisible

func (n *List) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*List) SharedElement

func (n *List) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*List) SizeRequest

func (n *List) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*List) TooltipMarkup

func (n *List) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*List) TooltipText

func (n *List) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*List) VAlign

func (n *List) VAlign() Align

VAlign returns the vertical placement.

func (*List) Visible

func (n *List) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ListBox

type ListBox struct {
	OnSelectionChanged func(rows []int)
	OnActivate         func(i int)
	// contains filtered or unexported fields
}

ListBox is a non-virtualized list of rows: every row is a child widget kept in the tree, measured and painted in order, so it is for short lists where a List's viewport recycling would be overhead. Selection is pointer and keyboard driven through the embedded selection model; OnSelectionChanged fires once per gesture, OnActivate on row activation (a double-click or a single click when SetSingleClickActivate is on).

func NewListBox

func NewListBox() *ListBox

NewListBox returns an empty single-select ListBox styled as a boxed list (CSS class boxedList).

func (*ListBox) AccessibleName

func (n *ListBox) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ListBox) AddClass

func (n *ListBox) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ListBox) Append

func (l *ListBox) Append(w Widget) *ListBoxRow

Append adds w as a new row at the end and returns the row.

func (*ListBox) Arrange

func (l *ListBox) Arrange(r render.Rect)

Arrange lays out the visible rows top to bottom inside the box.

func (*ListBox) AttachStylesheet

func (n *ListBox) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ListBox) Attr

func (n *ListBox) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ListBox) Bounds

func (n *ListBox) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ListBox) Children

func (l *ListBox) Children() []Widget

Children returns the rows in order, then the placeholder: what tree walks (the restyle pass, focus traversal, the accessibility bridge) descend into, as for every container.

func (*ListBox) Classes

func (n *ListBox) Classes() []string

Classes returns a copy of the widget's classes.

func (*ListBox) DebugName

func (n *ListBox) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ListBox) DetachStylesheet

func (n *ListBox) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ListBox) Element

func (n *ListBox) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ListBox) Enabled

func (n *ListBox) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ListBox) HAlign

func (n *ListBox) HAlign() Align

HAlign returns the horizontal placement.

func (*ListBox) HasClass

func (n *ListBox) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ListBox) HasState

func (n *ListBox) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ListBox) HitLeaf

func (n *ListBox) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ListBox) HitTest

func (l *ListBox) HitTest(p Point) Widget

HitTest returns the topmost visible row under p, or the placeholder when it is shown, or the list itself.

func (*ListBox) HoverWithin

func (n *ListBox) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ListBox) ID

func (n *ListBox) ID() string

ID returns the style id, empty when none is set.

func (*ListBox) InlineStyle

func (n *ListBox) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ListBox) Insert

func (l *ListBox) Insert(i int, w Widget) *ListBoxRow

Insert adds w as a new row at position i (clamped to the ends) and returns the row.

func (*ListBox) Invalidate

func (n *ListBox) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ListBox) InvalidateFilter

func (l *ListBox) InvalidateFilter()

InvalidateFilter re-runs the filter and relayouts.

func (*ListBox) InvalidateHeaders

func (l *ListBox) InvalidateHeaders()

InvalidateHeaders reruns every row's header builder and relayouts.

func (*ListBox) InvalidateLayout

func (n *ListBox) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ListBox) InvalidateRect

func (n *ListBox) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ListBox) InvalidateSort

func (l *ListBox) InvalidateSort()

InvalidateSort re-runs the sort and relayouts.

func (*ListBox) KeyAction

func (l *ListBox) KeyAction(a KeyAction, mods Mods)

KeyAction forwards a keyboard action to the selection model when the list is enabled.

func (*ListBox) LayoutMotion

func (n *ListBox) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ListBox) Len

func (l *ListBox) Len() int

Len returns the number of rows.

func (*ListBox) Margin

func (n *ListBox) Margin() render.Insets

Margin returns the programmatic margin.

func (*ListBox) MaximumSize

func (n *ListBox) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ListBox) Measure

func (l *ListBox) Measure(axis Axis, forSize int) Sizes

Measure reports the widest visible row by their total height (or the placeholder's request), at least the minimum height.

func (*ListBox) Move

func (l *ListBox) Move(from, to int)

Move relocates the row at from to position to (both clamped to the row range), adjusting the selection to follow.

func (*ListBox) Paint

func (l *ListBox) Paint(cv *render.Canvas)

Paint draws the box background, the row separators, and the visible rows in order.

func (*ListBox) Parent

func (n *ListBox) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ListBox) RemoveAt

func (l *ListBox) RemoveAt(i int)

RemoveAt removes the row at position i, doing nothing when i is out of range.

func (*ListBox) RemoveAttr

func (n *ListBox) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ListBox) RemoveClass

func (n *ListBox) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ListBox) RowAt

func (l *ListBox) RowAt(i int) *ListBoxRow

RowAt returns the row at position i, or nil when i is out of range.

func (*ListBox) Rows

func (l *ListBox) Rows() []Widget

Rows returns every row widget in order.

func (*ListBox) Select

func (s *ListBox) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*ListBox) SelectAll

func (s *ListBox) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*ListBox) SelectRows

func (s *ListBox) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*ListBox) Selected

func (s *ListBox) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*ListBox) Selection

func (s *ListBox) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*ListBox) SelectionMode

func (s *ListBox) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*ListBox) SetAccessibleName

func (n *ListBox) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ListBox) SetAttr

func (n *ListBox) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ListBox) SetClass

func (n *ListBox) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ListBox) SetClasses

func (n *ListBox) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ListBox) SetCursorName

func (n *ListBox) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ListBox) SetDebugName

func (n *ListBox) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ListBox) SetElement

func (n *ListBox) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ListBox) SetEnabled

func (n *ListBox) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ListBox) SetFilterFunc

func (l *ListBox) SetFilterFunc(keep func(*ListBoxRow) bool)

SetFilterFunc installs a filter: rows where keep returns false are hidden, and the list is recomputed. A nil keep clears the filter.

func (*ListBox) SetFocusOnClick

func (n *ListBox) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ListBox) SetHAlign

func (n *ListBox) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ListBox) SetHExpand

func (n *ListBox) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ListBox) SetHeaderFunc

func (l *ListBox) SetHeaderFunc(fn func(*ListBoxRow) Widget)

SetHeaderFunc installs a header builder: fn is called per row to produce its header widget (nil for none), and the headers are rerun. A nil fn clears all headers.

func (*ListBox) SetID

func (n *ListBox) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ListBox) SetInlineStyle

func (n *ListBox) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ListBox) SetInlineStylePriority

func (n *ListBox) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ListBox) SetLayoutMotion

func (n *ListBox) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ListBox) SetMargin

func (n *ListBox) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ListBox) SetMaximumSize

func (n *ListBox) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ListBox) SetMinHeight

func (l *ListBox) SetMinHeight(h int)

SetMinHeight floors the height the list measures to, in logical pixels: a filter that hides rows keeps the box's extent, so the layout around it never moves.

func (*ListBox) SetOnClickWithin

func (n *ListBox) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ListBox) SetOnFocusChanged

func (n *ListBox) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ListBox) SetOnHoverWithin

func (n *ListBox) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ListBox) SetOnPointer

func (n *ListBox) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ListBox) SetOnScroll

func (n *ListBox) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ListBox) SetPlaceholder

func (l *ListBox) SetPlaceholder(w Widget)

SetPlaceholder sets a widget shown when no row is visible, replacing any previous placeholder.

func (*ListBox) SetSelectionMode

func (s *ListBox) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*ListBox) SetSharedElement

func (n *ListBox) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ListBox) SetSingleClickActivate

func (l *ListBox) SetSingleClickActivate(on bool)

SetSingleClickActivate toggles whether a plain click activates a row (on by default); off means activation needs a double-click.

func (*ListBox) SetSizeRequest

func (n *ListBox) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ListBox) SetSortFunc

func (l *ListBox) SetSortFunc(cmp func(a, b *ListBoxRow) int)

SetSortFunc installs a sort comparator and recomputes the row order. A nil cmp clears the sort, restoring insertion order.

func (*ListBox) SetState

func (n *ListBox) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ListBox) SetTooltip

func (n *ListBox) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ListBox) SetTooltipMarkup

func (n *ListBox) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ListBox) SetVAlign

func (n *ListBox) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ListBox) SetVExpand

func (n *ListBox) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ListBox) SetVisible

func (n *ListBox) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ListBox) SharedElement

func (n *ListBox) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ListBox) SizeRequest

func (n *ListBox) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ListBox) TooltipMarkup

func (n *ListBox) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ListBox) TooltipText

func (n *ListBox) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ListBox) VAlign

func (n *ListBox) VAlign() Align

VAlign returns the vertical placement.

func (*ListBox) Visible

func (n *ListBox) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ListBoxRow

type ListBoxRow struct {
	// contains filtered or unexported fields
}

ListBoxRow is one row in a ListBox: a child widget with an optional header, selectable and activatable flags, and the row's own CSS box.

func (*ListBoxRow) AccessibleName

func (n *ListBoxRow) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ListBoxRow) Activatable

func (r *ListBoxRow) Activatable() bool

Activatable reports whether the row can be activated.

func (*ListBoxRow) AddClass

func (n *ListBoxRow) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ListBoxRow) Arrange

func (r *ListBoxRow) Arrange(rct render.Rect)

Arrange lays out the header (if any) on top and the child below it.

func (*ListBoxRow) AttachStylesheet

func (n *ListBoxRow) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ListBoxRow) Attr

func (n *ListBoxRow) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ListBoxRow) Bounds

func (n *ListBoxRow) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ListBoxRow) Child

func (r *ListBoxRow) Child() Widget

Child returns the row's content widget.

func (*ListBoxRow) ChildVisible

func (r *ListBoxRow) ChildVisible() bool

ChildVisible reports whether the list shows the row: false while its filter hides it (gtk_widget_get_child_visible), true when detached.

func (*ListBoxRow) Children

func (r *ListBoxRow) Children() []Widget

Children returns the header (if any) and the child widget.

func (*ListBoxRow) Classes

func (n *ListBoxRow) Classes() []string

Classes returns a copy of the widget's classes.

func (*ListBoxRow) ClickAt

func (r *ListBoxRow) ClickAt(Point)

ClickAt forwards a click to the list's row click handler.

func (*ListBoxRow) DebugName

func (n *ListBoxRow) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ListBoxRow) DetachStylesheet

func (n *ListBoxRow) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ListBoxRow) DoubleClickAt

func (r *ListBoxRow) DoubleClickAt(Point)

DoubleClickAt activates the row when single-click activation is off.

func (*ListBoxRow) DragMove

func (r *ListBoxRow) DragMove(p Point)

DragMove moves the selection to the row under p in single and browse mode (pointer-follows-selection).

func (*ListBoxRow) Element

func (n *ListBoxRow) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ListBoxRow) Enabled

func (n *ListBoxRow) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ListBoxRow) HAlign

func (n *ListBoxRow) HAlign() Align

HAlign returns the horizontal placement.

func (*ListBoxRow) HasClass

func (n *ListBoxRow) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ListBoxRow) HasState

func (n *ListBoxRow) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ListBoxRow) Header

func (r *ListBoxRow) Header() Widget

Header returns the row's header widget, or nil when it has none.

func (*ListBoxRow) HitLeaf

func (n *ListBoxRow) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ListBoxRow) HitTest

func (r *ListBoxRow) HitTest(p Point) Widget

HitTest returns the child or header widget under p when it can handle the hit, or the row itself.

func (*ListBoxRow) HoverWithin

func (n *ListBoxRow) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ListBoxRow) ID

func (n *ListBoxRow) ID() string

ID returns the style id, empty when none is set.

func (*ListBoxRow) Index

func (r *ListBoxRow) Index() int

Index returns the row's position in its ListBox, or -1 when detached.

func (*ListBoxRow) InlineStyle

func (n *ListBoxRow) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ListBoxRow) Invalidate

func (n *ListBoxRow) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ListBoxRow) InvalidateLayout

func (n *ListBoxRow) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ListBoxRow) InvalidateRect

func (n *ListBoxRow) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ListBoxRow) KeyAction

func (r *ListBoxRow) KeyAction(a KeyAction, mods Mods)

KeyAction forwards a keyboard action to the list's selection model.

func (*ListBoxRow) LayoutMotion

func (n *ListBoxRow) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ListBoxRow) Margin

func (n *ListBoxRow) Margin() render.Insets

Margin returns the programmatic margin.

func (*ListBoxRow) MaximumSize

func (n *ListBoxRow) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ListBoxRow) Measure

func (r *ListBoxRow) Measure(axis Axis, forSize int) Sizes

Measure reports the header (when shown) above the child: the wider of the two across, their heights summed.

func (*ListBoxRow) Paint

func (r *ListBoxRow) Paint(cv *render.Canvas)

Paint draws the selected tint when the row is selected and the stylesheet did not set a background, then the box, header, and child.

func (*ListBoxRow) Parent

func (n *ListBoxRow) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ListBoxRow) PressEnd

func (r *ListBoxRow) PressEnd()

PressEnd releases the list's selection press.

func (*ListBoxRow) RemoveAttr

func (n *ListBoxRow) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ListBoxRow) RemoveClass

func (n *ListBoxRow) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ListBoxRow) SelectAll

func (r *ListBoxRow) SelectAll()

SelectAll selects every row through the list's selection model.

func (*ListBoxRow) Selectable

func (r *ListBoxRow) Selectable() bool

Selectable reports whether the row responds to selection gestures.

func (*ListBoxRow) SetAccessibleName

func (n *ListBoxRow) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ListBoxRow) SetActivatable

func (r *ListBoxRow) SetActivatable(on bool)

SetActivatable toggles whether the row can be activated (firing the list's OnActivate); it also sets the cursor and activatable CSS class accordingly.

func (*ListBoxRow) SetAttr

func (n *ListBoxRow) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ListBoxRow) SetClass

func (n *ListBoxRow) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ListBoxRow) SetClasses

func (n *ListBoxRow) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ListBoxRow) SetCursorName

func (n *ListBoxRow) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ListBoxRow) SetDebugName

func (n *ListBoxRow) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ListBoxRow) SetElement

func (n *ListBoxRow) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ListBoxRow) SetEnabled

func (n *ListBoxRow) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ListBoxRow) SetFocusOnClick

func (n *ListBoxRow) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ListBoxRow) SetHAlign

func (n *ListBoxRow) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ListBoxRow) SetHExpand

func (n *ListBoxRow) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ListBoxRow) SetID

func (n *ListBoxRow) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ListBoxRow) SetInlineStyle

func (n *ListBoxRow) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ListBoxRow) SetInlineStylePriority

func (n *ListBoxRow) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ListBoxRow) SetLayoutMotion

func (n *ListBoxRow) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ListBoxRow) SetMargin

func (n *ListBoxRow) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ListBoxRow) SetMaximumSize

func (n *ListBoxRow) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ListBoxRow) SetOnClickWithin

func (n *ListBoxRow) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ListBoxRow) SetOnFocusChanged

func (n *ListBoxRow) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ListBoxRow) SetOnHoverWithin

func (n *ListBoxRow) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ListBoxRow) SetOnPointer

func (n *ListBoxRow) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ListBoxRow) SetOnScroll

func (n *ListBoxRow) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ListBoxRow) SetPressed

func (r *ListBoxRow) SetPressed(on bool)

SetPressed holds the list's selection press while on.

func (*ListBoxRow) SetSelectable

func (r *ListBoxRow) SetSelectable(on bool)

SetSelectable toggles whether the row responds to selection gestures.

func (*ListBoxRow) SetSharedElement

func (n *ListBoxRow) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ListBoxRow) SetSizeRequest

func (n *ListBoxRow) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ListBoxRow) SetState

func (n *ListBoxRow) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ListBoxRow) SetTooltip

func (n *ListBoxRow) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ListBoxRow) SetTooltipMarkup

func (n *ListBoxRow) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ListBoxRow) SetVAlign

func (n *ListBoxRow) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ListBoxRow) SetVExpand

func (n *ListBoxRow) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ListBoxRow) SetVisible

func (n *ListBoxRow) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ListBoxRow) SharedElement

func (n *ListBoxRow) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ListBoxRow) SizeRequest

func (n *ListBoxRow) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ListBoxRow) TooltipMarkup

func (n *ListBoxRow) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ListBoxRow) TooltipText

func (n *ListBoxRow) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ListBoxRow) VAlign

func (n *ListBoxRow) VAlign() Align

VAlign returns the vertical placement.

func (*ListBoxRow) Visible

func (n *ListBoxRow) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ListModel

type ListModel[W Widget] interface {
	Len() int
	Row(i int) W
}

ListModel supplies rows to a List. Row may return a fresh widget per call; the List caches the ones it is currently showing. Len and Row are re-queried on List.Changed.

type MarkupRun

type MarkupRun struct {
	// Text is the decoded plain UTF-8 text of the run. It never
	// contains '<' or an undecoded entity.
	Text string
	// Style is the style the run paints with.
	Style TextStyle
}

MarkupRun is a maximal stretch of text sharing one TextStyle.

func ParseMarkup

func ParseMarkup(markup string) (runs []MarkupRun, ok bool)

ParseMarkup parses markup into styled runs. The accepted grammar is a strict allowlist, not HTML:

<b>bold</b>  <i>italic</i>  <u>underlined</u>  <s>struck</s>
<big> <small> <tt> <sub> <sup>
<span weight="light" size="small" foreground="#rrggbb">…</span>
<a href="https://example.com">link</a>

Tags nest and combine (bold italic, colors inheriting into nested tags, relative sizes compounding). Attribute values are single- or double-quoted. A span takes Pango's attributes: foreground (fgcolor, color), background (bgcolor), alpha (fgalpha), weight, style, size, font_family (face), underline, strikethrough, letter_spacing and font_features; colors are a CSS name or #rgb, #rrggbb, #rrggbbaa hex. Anything else - an unknown tag or attribute, a malformed value, a stray or mismatched close tag, an unclosed tag, self-closing syntax, uppercase tags - fails the parse.

Text and attribute values are escaped HTML-style: write &lt; &gt; &amp; &quot; &apos; for the literal characters. A bare '&' or '<', a numeric reference (&#38;), and unknown names (&nbsp;) are outside the allowlist and fail the parse.

ParseMarkup never panics. When it reports false, callers render the input literally; RichLabel does exactly that.

type MediaControls

type MediaControls struct {
	// contains filtered or unexported fields
}

MediaControls is GTK's GtkMediaControls: a play/pause button, a seek bar over the stream's duration, the position and duration, and, when the stream has sound, a mute button and a volume slider. The seek bar is inert for a stream that cannot seek or does not know its length, and every control is inert once the stream closed or failed. It styles as `controls` with `.play`, `.seek`, `.time`, `.mute` and `.volume` parts.

func NewMediaControls

func NewMediaControls(face render.Font, sizePx float64, stream *media.Stream) *MediaControls

NewMediaControls returns controls for stream, which may be nil.

func (*MediaControls) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*MediaControls) Baseline

func (c *MediaControls) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*MediaControls) Children

func (c *MediaControls) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*MediaControls) HitTest

func (c *MediaControls) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*MediaControls) Measure

func (c *MediaControls) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*MediaControls) Paint

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

Paint draws the surface (when configured) then the root.

func (*MediaControls) SetStream

func (m *MediaControls) SetStream(stream *media.Stream)

SetStream controls stream instead; nil leaves the controls inert.

func (*MediaControls) Stream

func (m *MediaControls) Stream() *media.Stream

Stream returns the controlled stream.

type Menu struct {
	OnDismiss func()
	// OnSubmenu fires when a row with nested Items is activated; the
	// host opens a child popup for it beside the parent row.
	OnSubmenu func(index int, items []MenuItem)
	// OnHover fires when the pointer moves onto another row, with its
	// index: a nested menu opens the row's submenu, or closes the one
	// a sibling had open, on hover as GTK's does.
	OnHover func(index int)

	// AccelLabel, when set, formats each row's Accel for display (a
	// symbol form, a localized one); the binding itself is untouched.
	AccelLabel func(accel string) string
	// contains filtered or unexported fields
}

Menu is a vertical action list for popups and context menus: hovered row highlight, pointer or keyboard activation (arrows move, Enter activates, Esc dismisses, Right opens a submenu), check and radio rows, accelerator labels, per-row Alt-letter mnemonics, and nested submenus through OnSubmenu.

It styles as GTK's menu popup: the `popover.menu` card, a `contents` node padding the rows, and one `modelbutton` per row (a `separator` for ItemSeparator) — the hovered row :hover, inert rows :disabled, check and radio rows :checked while on.

Example
package main

import (
	"fmt"
	"log"

	"github.com/stubbedev/lys-lib/render"
	"golang.org/x/image/font/gofont/goregular"

	"github.com/stubbedev/lys-ui/widget"
)

func face() *render.Typeface {
	tf, err := render.LoadFont(goregular.TTF)
	if err != nil {
		log.Fatal(err)
	}
	return tf
}

func main() {
	// Menus are vertical action lists for popups: rows carry an
	// accelerator label (display-only), check and radio state, and
	// separators that keyboard motion skips.
	wrap := false
	menu := widget.NewMenu(face(), 13,
		widget.MenuItem{Label: "Cut", Accel: "Ctrl+X", OnClick: func() { fmt.Println("cut") }},
		widget.MenuItem{Label: "Copy", Accel: "Ctrl+C", OnClick: func() { fmt.Println("copy") }},
		widget.MenuSeparator(),
		widget.MenuItem{Label: "Word wrap", Kind: widget.ItemCheck, OnClick: func() { wrap = !wrap }},
	)

	// Keyboard: the first Down lands on the first selectable row, the
	// second walks past the separator, Enter activates. The host
	// closes the popup through OnDismiss; Esc maps to KeyDismiss.
	menu.KeyAction(widget.KeyDown, 0)
	menu.KeyAction(widget.KeyDown, 0)
	menu.KeyAction(widget.KeyDown, 0)
	menu.KeyAction(widget.KeyEnter, 0)
	fmt.Println("wrap:", wrap)
}
Output:
wrap: true

func NewMenu

func NewMenu(face render.Font, sizePx float64, items ...MenuItem) *Menu

NewMenu returns a menu showing items, painted with face at sizePx. Face may be a render.Chain for mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (n *Menu) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (m *Menu) ActivateMnemonic(sym xkb.Keysym) bool

ActivateMnemonic activates the row whose mnemonic letter matches sym (case-insensitive) — the Alt+letter route while the menu is open — and reports whether one fired. A submenu row opens its submenu; arrow navigation and Esc are untouched (they arrive as KeyActions, never through here).

func (n *Menu) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (n *Menu) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (n *Menu) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (n *Menu) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (n *Menu) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (n *Menu) Classes() []string

Classes returns a copy of the widget's classes.

func (m *Menu) ClickAt(p Point)

ClickAt activates the clicked row (or opens its submenu) and dismisses the menu. A disabled menu neither fires nor dismisses.

func (n *Menu) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (n *Menu) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (m *Menu) Direction() Direction

Direction returns the base paragraph direction the labels resolve with.

func (m *Menu) DragMove(p Point)

DragMove keeps hover tracking during presses. Disabled menus highlight nothing.

func (n *Menu) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (n *Menu) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (n *Menu) HAlign() Align

HAlign returns the horizontal placement.

func (n *Menu) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (n *Menu) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (n *Menu) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (m *Menu) HitTest(p Point) Widget

HitTest returns the menu when p is inside its bounds.

func (m *Menu) HoverMove(p Point)

HoverMove tracks the hovered row as the pointer moves inside. Disabled menus highlight nothing.

func (n *Menu) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (n *Menu) ID() string

ID returns the style id, empty when none is set.

func (n *Menu) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (n *Menu) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (n *Menu) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (n *Menu) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (m *Menu) Items() []MenuItem

Items returns the menu's rows.

func (m *Menu) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: arrows move the hovered row (clamped at the ends - pinned), Home/End jump, Enter activates, Esc and Left dismiss, Right opens a submenu. A disabled menu ignores keys outright.

func (n *Menu) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (n *Menu) Margin() render.Insets

Margin returns the programmatic margin.

func (n *Menu) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (m *Menu) Measure(axis Axis, forSize int) Sizes

Measure wants the widest row (label plus indicator, accelerator, and submenu arrow) plus the row and contents padding, and one band per item — the bands sized by the styled modelbuttons, as the list sizes rows.

func (m *Menu) Paint(cv *render.Canvas)

Paint draws the menu through its nodes — the `popover.menu` card, the `contents` inset, and each row (the hovered one :hover, its background and label color from the cascade), with item indicators, accelerator labels, and submenu arrows. Labels resolve under the menu's base direction: a right-to-left label shapes reordered and hugs the row's right edge; the check/radio indicators, accelerators, and submenu arrows keep their positions.

func (n *Menu) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (m *Menu) RawKey(code uint32, mods Mods, sym xkb.Keysym) bool

RawKey implements RawKeyHandler: Alt+letter (no ctrl) activates the matching row mnemonic; every other raw key is not the menu's.

func (n *Menu) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (n *Menu) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (m *Menu) Role() Role

Role implements Roleer.

func (m *Menu) RowBounds(i int) render.Rect

RowBounds is row i's rect in the menu's coordinates: where a submenu anchors beside it. Empty for an index out of range.

func (n *Menu) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (n *Menu) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (n *Menu) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (n *Menu) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (n *Menu) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (n *Menu) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (m *Menu) SetDirection(d Direction)

SetDirection selects the base paragraph direction the row labels resolve and lay out with: DirectionAuto (the default) reads it off each label's first strong character, and a right-to-left label hugs the row's right edge. Changing the direction invalidates.

func (n *Menu) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (n *Menu) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (n *Menu) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (n *Menu) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (n *Menu) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (m *Menu) SetHovered(on bool)

SetHovered clears row hover when the pointer leaves the menu.

func (n *Menu) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (n *Menu) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (n *Menu) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (m *Menu) SetItems(items ...MenuItem)

SetItems replaces the rows in place - a live model update that keeps the menu (and its popover) open; the hovered row stays when it still exists.

func (n *Menu) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (n *Menu) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (n *Menu) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (m *Menu) SetMnemonicsVisible(on bool)

SetMnemonicsVisible underlines the rows' Alt-letters, as a menu the keyboard opened shows them; a menu the pointer opened hides them until Alt is pressed.

func (n *Menu) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (n *Menu) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (n *Menu) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (n *Menu) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (n *Menu) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (n *Menu) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (n *Menu) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (n *Menu) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (n *Menu) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (n *Menu) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (n *Menu) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (n *Menu) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (n *Menu) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (n *Menu) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (n *Menu) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (n *Menu) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (n *Menu) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (n *Menu) VAlign() Align

VAlign returns the vertical placement.

func (n *Menu) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type MenuBar struct {
	// contains filtered or unexported fields
}

MenuBar is the in-window primary navigation (#91): a bordered, rounded strip of root buttons, each opening its menu below through the surface's host - the PopoverMenuBar shape. It styles as the `menubar` element, its roots as `menubar > box > button`, the root whose menu is open :checked.

Keyboard: F10 focuses the bar's first button when the app routes the key to it - MenuBar implements KeyActionHandler for exactly that handoff.

func NewMenuBar

func NewMenuBar(face render.Font, sizePx float64, menus ...MenuBarMenu) *MenuBar

NewMenuBar returns a bar with one root button per menu.

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (c *MenuBar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (c *MenuBar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (c *MenuBar) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (m *MenuBar) KeyAction(a KeyAction, mods Mods)

KeyAction handles the F10 handoff: it activates the first root, the way GTK menu bars open on F10.

func (c *MenuBar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

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

Paint draws the surface (when configured) then the root.

func (m *MenuBar) Root(i int) Boundser

Root returns root i's button, the anchor for its popover.

func (m *MenuBar) Roots() int

Roots reports the root count.

func (m *MenuBar) SetFocused(on bool)

SetFocused paints the bar's focus state (F10 handoff).

type MenuBarMenu struct {
	Label string
	Items []MenuItem
}

MenuBarMenu is one root of a MenuBar: its label and the menu it opens.

type MenuItem struct {
	Label    string
	Action   Activatable
	OnClick  func()
	Kind     ItemKind
	Checked  bool
	Group    string
	Accel    string
	Mnemonic rune
	Items    []MenuItem
	// OnOpen runs as the row's submenu opens, before it shows: a
	// DBusMenu's AboutToShow.
	OnOpen   func()
	Icon     *Icon
	Disabled bool
}

MenuItem is one row of a Menu.

Kind selects the row style: a plain action, a checkbox row (Checked toggles on activate), a radio row (Checked is exclusive within items sharing the same Group), or a separator (a real rule; skipped by keyboard motion - use MenuSeparator). Accel paints a right-aligned accelerator label, and — while the menu is open — a matching application accelerator fires the row's action through the popup key path (see RawKeyHandler). Items nests a submenu; activating such a row fires OnSubmenu so the host opens a child popup beside it.

Mnemonic is the row's Alt-letter shortcut while the menu is open: an explicit letter (case-insensitive), or zero to auto-resolve the first letter of the label no earlier row took. A letter claimed by an earlier row wins and the later one is dropped with a Debug log; the underline under the resolved letter is painted for free.

Icon paints at the row's leading edge, after any check or radio indicator, at the icon's natural size; once one row carries an icon every label shifts by the same slot so the column stays aligned. Disabled greys a row out whatever its action: it takes no hover, no keyboard motion, no mnemonic, and a click on it neither fires nor dismisses - the state an application toggles on a live row (a check item that cannot change right now) without dropping its OnClick.

Action binds the row to an action instead: activating the row activates it, a disabled action greys the row, and a Checkable action decides a check or radio row's state (ActionItem, CheckItem, RadioItem build such rows). OnClick, when also set, runs in its place.

func ActionItem

func ActionItem(label string, a Activatable) MenuItem

ActionItem is a menu row activating a.

func CheckItem

func CheckItem(label string, c Checkable) MenuItem

CheckItem is a check row showing and flipping c, such as Toggle(action).

func MenuSeparator() MenuItem

MenuSeparator returns a separator item.

func RadioItem

func RadioItem(label string, c Checkable) MenuItem

RadioItem is a radio row selecting c, such as action.Target(value).

func (it MenuItem) Enabled() bool

Enabled reports whether the row takes input: not Disabled, and its action, if any, enabled.

func (it MenuItem) IsChecked() bool

IsChecked reports a check or radio row's state: its Checkable action's when bound to one, else Checked.

func (it MenuItem) Run() func()

Run returns the row's activation: OnClick, else its action's Activate, nil for neither.

type MenuOptions struct {
	// OnClosed, when set, runs once the menu goes away.
	OnClosed func()
	// Gap is the distance between the anchor and the root menu.
	Gap int
}

MenuOptions shape a widget-opened menu.

type MenuStack struct {

	// OnDismiss runs when the stack as a whole should close.
	OnDismiss func()
	// contains filtered or unexported fields
}

MenuStack presents a Menu tree with sliding submenus: activating a row with nested Items replaces the visible level with that submenu, headed by a back row that returns to the parent (so does the Left arrow). This is GTK's default PopoverMenu presentation, and it fits a single popup surface: the stack measures to the largest level of the whole tree, so a popover sized at open never clips a submenu it slides to.

Every level is a real Menu, so rows keep all of Menu's behaviors (check/radio state, icons, disabled rows, accelerators, mnemonics). OnDismiss fires when a leaf row activates or a level asks to close (a click outside the rows, Esc); navigating between levels does not dismiss.

func NewMenuStack

func NewMenuStack(face render.Font, sizePx float64, items ...MenuItem) *MenuStack

NewMenuStack returns a stack showing items at its root, painted with face at sizePx.

func (n *MenuStack) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (s *MenuStack) ActivateMnemonic(sym xkb.Keysym) bool

ActivateMnemonic fires a mnemonic of the visible level.

func (n *MenuStack) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (s *MenuStack) Arrange(r render.Rect)

Arrange lays the visible level into the stack's box.

func (n *MenuStack) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (n *MenuStack) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (n *MenuStack) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (s *MenuStack) Children() []Widget

Children exposes the visible level to the tree walks (damage, accessibility).

func (n *MenuStack) Classes() []string

Classes returns a copy of the widget's classes.

func (s *MenuStack) ClickAt(p Point)

ClickAt activates a row of the visible level.

func (n *MenuStack) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (s *MenuStack) Depth() int

Depth is the number of visible levels: 1 at the root.

func (n *MenuStack) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (s *MenuStack) DragMove(p Point)

DragMove forwards press-drag tracking.

func (n *MenuStack) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (n *MenuStack) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (n *MenuStack) HAlign() Align

HAlign returns the horizontal placement.

func (n *MenuStack) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (n *MenuStack) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (n *MenuStack) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (s *MenuStack) HitTest(p Point) Widget

HitTest returns the stack itself inside its box: it is the input leaf and forwards to the visible level.

func (s *MenuStack) HoverMove(p Point)

HoverMove forwards row tracking.

func (n *MenuStack) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (n *MenuStack) ID() string

ID returns the style id, empty when none is set.

func (n *MenuStack) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (n *MenuStack) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (n *MenuStack) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (n *MenuStack) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (s *MenuStack) KeyAction(a KeyAction, mods Mods)

KeyAction drives the visible level; Left in a submenu goes back a level instead of closing the stack.

func (n *MenuStack) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (n *MenuStack) Margin() render.Insets

Margin returns the programmatic margin.

func (n *MenuStack) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (s *MenuStack) Measure(axis Axis, forSize int) Sizes

Measure wants the largest level of the tree, so the stack's box holds every submenu it can slide to.

func (s *MenuStack) Paint(cv *render.Canvas)

Paint draws the visible level.

func (n *MenuStack) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (s *MenuStack) RawKey(code uint32, mods Mods, sym xkb.Keysym) bool

RawKey implements RawKeyHandler through the visible level.

func (n *MenuStack) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (n *MenuStack) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (s *MenuStack) Role() Role

Role implements Roleer.

func (n *MenuStack) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (n *MenuStack) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (n *MenuStack) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (n *MenuStack) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (n *MenuStack) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (n *MenuStack) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (n *MenuStack) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (n *MenuStack) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (n *MenuStack) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (n *MenuStack) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (n *MenuStack) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (s *MenuStack) SetHovered(on bool)

SetHovered forwards hover loss to the visible level.

func (n *MenuStack) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (n *MenuStack) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (n *MenuStack) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (s *MenuStack) SetItems(items ...MenuItem)

SetItems replaces the whole tree and returns to its root level - the shape a live model update takes (a tray application re-publishing its menu while it is open).

func (n *MenuStack) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (n *MenuStack) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (n *MenuStack) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (n *MenuStack) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (n *MenuStack) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (n *MenuStack) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (n *MenuStack) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (n *MenuStack) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (n *MenuStack) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (n *MenuStack) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (n *MenuStack) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (n *MenuStack) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (n *MenuStack) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (n *MenuStack) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (n *MenuStack) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (n *MenuStack) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (n *MenuStack) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (n *MenuStack) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (n *MenuStack) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (n *MenuStack) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (s *MenuStack) Top() *Menu

Top returns the visible level.

func (n *MenuStack) VAlign() Align

VAlign returns the vertical placement.

func (n *MenuStack) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type MnemonicActivator

type MnemonicActivator interface {
	ActivateMnemonic(sym xkb.Keysym) bool
}

MnemonicActivator is implemented by widgets whose rows carry Alt-letter mnemonics (Menu): ActivateMnemonic fires the row bound to sym, case-insensitively, and reports whether one fired.

type Mods

type Mods uint8

Mods is a bitmask of held keyboard modifiers.

const (
	ModShift Mods = 1 << iota
	ModCapsLock
	ModCtrl
	ModAlt
	// ModSuper is the logo key (Mod4).
	ModSuper Mods = 1 << 6
)

Modifier bits, xkb's core modifier indices.

type Morph

type Morph struct {
	// contains filtered or unexported fields
}

Morph is a transient surface's enter and exit visual: it grows its child out of an origin side - scaling up from 92% while a rounded clip unrolls from that side and the subtree fades in - and shrinks it back on the way out. A reveal past 1 (a spring's overshoot) swells the child a touch past its size. Without morphing it only fades. Layout and hit-testing pass straight through: the motion is visual, and a surface mid-enter takes clicks like one at rest. The paint never leaves the wrapper's bounds.

func NewMorph

func NewMorph(child Widget) *Morph

NewMorph wraps child at rest, growing from its center.

func (*Morph) AccessibleName

func (n *Morph) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Morph) AddClass

func (n *Morph) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Morph) Arrange

func (m *Morph) Arrange(r render.Rect)

Arrange gives the child the content rect: r less the plate inset.

func (*Morph) ArrangeRoot

func (m *Morph) ArrangeRoot(r render.Rect)

ArrangeRoot records the wrapper's own rect.

func (*Morph) AttachStylesheet

func (n *Morph) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Morph) Attr

func (n *Morph) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Morph) BackdropRegion added in v0.2.0

func (m *Morph) BackdropRegion() []render.Rect

BackdropRegion is the region behind the surface for the compositor to blur at the current reveal: the content's (widget.BackdropRegion, or the child's own report), cut by the unrolled clip and scaled as the paint is, so the blur never leads the shape it backs. Empty while hidden.

func (*Morph) Bounds

func (n *Morph) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Morph) Child

func (m *Morph) Child() Widget

Child returns the wrapped widget.

func (*Morph) Children

func (m *Morph) Children() []Widget

Children exposes the child for the damage collector, focus traversal, and the accessibility walk.

func (*Morph) Classes

func (n *Morph) Classes() []string

Classes returns a copy of the widget's classes.

func (*Morph) DebugName

func (n *Morph) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Morph) DetachStylesheet

func (n *Morph) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Morph) Element

func (n *Morph) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Morph) Enabled

func (n *Morph) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Morph) Fade added in v0.2.0

func (m *Morph) Fade() float64

Fade is the opacity of the surface at the current reveal.

func (*Morph) HAlign

func (n *Morph) HAlign() Align

HAlign returns the horizontal placement.

func (*Morph) HasClass

func (n *Morph) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Morph) HasState

func (n *Morph) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Morph) HitLeaf

func (n *Morph) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Morph) HitTest

func (m *Morph) HitTest(p Point) Widget

HitTest returns the child's pick, or the wrapper over its bounds.

func (*Morph) HoverWithin

func (n *Morph) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Morph) ID

func (n *Morph) ID() string

ID returns the style id, empty when none is set.

func (*Morph) InlineStyle

func (n *Morph) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Morph) Invalidate

func (n *Morph) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Morph) InvalidateLayout

func (n *Morph) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Morph) InvalidateRect

func (n *Morph) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Morph) LayoutMotion

func (n *Morph) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Morph) Margin

func (n *Morph) Margin() render.Insets

Margin returns the programmatic margin.

func (*Morph) MaximumSize

func (n *Morph) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Morph) Measure

func (m *Morph) Measure(axis Axis, forSize int) Sizes

Measure reports the child's natural size plus the plate inset on every side.

func (*Morph) Paint

func (m *Morph) Paint(cv *render.Canvas)

Paint draws the child at the current reveal.

func (*Morph) Parent

func (n *Morph) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Morph) RemoveAttr

func (n *Morph) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Morph) RemoveClass

func (n *Morph) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Morph) Reveal

func (m *Morph) Reveal() float64

Reveal is the current reveal fraction.

func (*Morph) SetAccessibleName

func (n *Morph) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Morph) SetAttr

func (n *Morph) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Morph) SetClass

func (n *Morph) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Morph) SetClasses

func (n *Morph) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Morph) SetCompositorFade added in v0.2.0

func (m *Morph) SetCompositorFade(on bool)

SetCompositorFade makes the owner responsible for Fade, on the surface through the compositor, so the paint itself stays fully opaque. The compositor's blur behind the surface can then fade along with it, which no opacity painted into the buffer can do.

func (*Morph) SetCursorName

func (n *Morph) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Morph) SetDebugName

func (n *Morph) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Morph) SetElement

func (n *Morph) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Morph) SetEnabled

func (n *Morph) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Morph) SetFocusOnClick

func (n *Morph) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Morph) SetHAlign

func (n *Morph) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Morph) SetHExpand

func (n *Morph) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Morph) SetID

func (n *Morph) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Morph) SetInlineStyle

func (n *Morph) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Morph) SetInlineStylePriority

func (n *Morph) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Morph) SetLayoutMotion

func (n *Morph) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Morph) SetMargin

func (n *Morph) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Morph) SetMaximumSize

func (n *Morph) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Morph) SetOnClickWithin

func (n *Morph) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Morph) SetOnFocusChanged

func (n *Morph) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Morph) SetOnHoverWithin

func (n *Morph) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Morph) SetOnPointer

func (n *Morph) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Morph) SetOnScroll

func (n *Morph) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Morph) SetOrigin

func (m *Morph) SetOrigin(fx, fy float64)

SetOrigin sets the point the motion grows from, as fractions of the bounds: a popover below its anchor grows from (0.5, 0).

func (*Morph) SetPlate

func (m *Morph) SetPlate(inset int, plate func(cv *render.Canvas, content render.Rect))

SetPlate gives the surface a margin of inset around its content and the painter of its backing for a content rect; see the field.

func (*Morph) SetRadius

func (m *Morph) SetRadius(r int)

SetRadius rounds the unrolling clip's corners, the surface's own.

func (*Morph) SetReveal

func (m *Morph) SetReveal(reveal float64, morph bool)

SetReveal applies one motion frame: the reveal fraction and whether the child grows (true) or only fades.

func (*Morph) SetSharedElement

func (n *Morph) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Morph) SetSizeRequest

func (n *Morph) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Morph) SetState

func (n *Morph) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Morph) SetTooltip

func (n *Morph) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Morph) SetTooltipMarkup

func (n *Morph) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Morph) SetVAlign

func (n *Morph) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Morph) SetVExpand

func (n *Morph) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Morph) SetVisible

func (n *Morph) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Morph) SharedElement

func (n *Morph) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Morph) SizeRequest

func (n *Morph) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Morph) TooltipMarkup

func (n *Morph) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Morph) TooltipText

func (n *Morph) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Morph) VAlign

func (n *Morph) VAlign() Align

VAlign returns the vertical placement.

func (*Morph) Visible

func (n *Morph) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type NavigationLink struct {
	Title, Description string
	OnActivate         func()
}

NavigationLink is one link of a navigation panel's grid.

type NavigationMenu struct {
	// contains filtered or unexported fields
}

NavigationMenu is a site's top navigation: a row of triggers whose panels open in one shared viewport under the menu, so moving between triggers swaps the panel in place and the viewport resizes to it, while a caret under the open trigger slides along. Resting the pointer on a trigger opens its panel, and it stays open while the pointer is on the menu or the panel; Enter, Space or Down on a focused trigger opens it with the keyboard in the panel, Left and Right step between the triggers, and Escape closes. It styles as the `navigationmenu` element: button.trigger rows (:checked while open), the .viewport panel box, and the panels' button.link entries.

func NewNavigationMenu

func NewNavigationMenu(face render.Font, items ...NavigationMenuItem) *NavigationMenu

NewNavigationMenu returns a menu of items.

func (m *NavigationMenu) Active() int

Active is the open panel's item, -1 for none.

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (c *NavigationMenu) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (c *NavigationMenu) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (c *NavigationMenu) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (m *NavigationMenu) InterceptKey(target Widget, a KeyAction, _ Mods) bool

InterceptKey implements KeyInterceptor: on a focused trigger, Enter, Space and Down open its panel with the keyboard in it, and Escape closes.

func (c *NavigationMenu) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (m *NavigationMenu) NavigateFocus(target Widget, a KeyAction) Widget

NavigateFocus implements FocusNavigator: Left and Right step between the triggers that can take focus.

func (m *NavigationMenu) Paint(cv *render.Canvas)

Paint draws the triggers, then the caret under the open one.

type NavigationMenuItem struct {
	Label      string
	Content    Widget
	OnActivate func()
}

NavigationMenuItem is one entry of a NavigationMenu: a trigger opening Content, or - without Content - a link running OnActivate.

type NavigationPage struct {
	Title string
	W     Widget
}

NavigationPage is one page: its title and its widget.

type NavigationSplitView struct {
	// contains filtered or unexported fields
}

NavigationSplitView puts a sidebar beside content above a breakpoint and collapses to a NavigationView below it: the sidebar becomes the root page, content the pushed page - the mobile shape. ShowContent is the sidebar's activation hook; the back button and back keys return to the sidebar through the same view.

func NewNavigationSplitView

func NewNavigationSplitView(face render.Font, sizePx float64, sidebar, content *NavigationPage, collapseWidth int) *NavigationSplitView

NewNavigationSplitView returns the split over sidebar and content, collapsing at or below collapseWidth (420 when not positive).

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

Arrange evaluates the breakpoint against the allocated width, then lays out whichever layout it picked - in the same pass, so a collapse never paints one frame of the old layout.

func (c *NavigationSplitView) Collapsed() bool

Collapsed reports which layout the last width chose.

func (s *NavigationSplitView) KeyAction(a KeyAction, mods Mods)

KeyAction forwards the back keys to the collapsed view.

func (s *NavigationSplitView) Navigation() *NavigationView

Navigation returns the collapsed layout's view (its depth, pop hook and back keys).

func (s *NavigationSplitView) ShowContent()

ShowContent pushes the content page in the collapsed view; above the breakpoint the content is already showing and this is a no-op.

type NavigationView struct {

	// OnPop fires after a pop delivered the previous page (nil at the
	// root).
	OnPop func(popped, now *NavigationPage)
	// contains filtered or unexported fields
}

NavigationView is the push/pop shell: a header (back button when depth allows, the current page's title) over a Stack that slides pages in from the right on push and back on pop - the Stack's own transition doing the animating.

func NewNavigationView

func NewNavigationView(face render.Font, sizePx float64, root *NavigationPage) *NavigationView

NewNavigationView returns a view showing root.

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (c *NavigationView) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (c *NavigationView) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (v *NavigationView) Depth() int

Depth reports the pushed page count (the root included).

func (c *NavigationView) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (v *NavigationView) KeyAction(a KeyAction, mods Mods)

KeyAction implements the back keys: Alt+Left and Backspace pop.

func (c *NavigationView) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (v *NavigationView) Page() *NavigationPage

Page returns the top page.

func (v *NavigationView) Paint(cv *render.Canvas)

Paint draws the bar's surface then the column.

func (v *NavigationView) Pop() bool

Pop drops the top page (true when something popped) and slides back.

func (v *NavigationView) PopToRoot()

PopToRoot unwinds to the root page.

func (v *NavigationView) Push(p *NavigationPage)

Push shows page over the current one, sliding in from the right.

type NodeInfo

type NodeInfo struct {
	A11yState
	// TypeName is the widget's Go type, as %T prints it.
	TypeName string
	// DebugName is the SetDebugName label, empty when unnamed.
	DebugName string
	// Depth is the nesting level; the root is 0.
	Depth int
	// Focused, Hovered, and Pressed report that this widget is the
	// router's current focus, hover, or press target. All false when
	// the snapshot was taken without a Router.
	Focused, Hovered, Pressed bool
}

NodeInfo is one live snapshot row of the widget tree: identity (type, debug name), the accessibility summary (role, tooltip name, bounds, value), and the router-driven input state. Unlike the a11y snapshot (Describe), the flags here are the live input state, which is what a layout bug report needs.

func InspectTree

func InspectTree(root Widget, r *Router) []NodeInfo

InspectTree snapshots root and every descendant in paint order with nesting depth, the live-state counterpart of DescribeTree. Router may be nil, which leaves the input flags false.

type Notebook

type Notebook struct {
	OnSelect    func(name string)
	OnTabClose  func(name string)
	OnReorder   func(name string, index int)
	Closable    bool
	Reorderable bool
	// contains filtered or unexported fields
}

Notebook is a tabbed container: a tab bar on top and exactly one visible page beneath it, the GtkNotebook model. Tabs carry a name, painted as the tab's label unless SetTabLabel gave it a widget; the header, the tab row, and each tab are CSS boxes. Selecting a tab shows its page and fires OnSelect. With Closable set, each tab paints a close box and a click on it fires OnTabClose instead of selecting - hosts remove the page themselves. With Reorderable set, dragging a tab along the strip moves it (OnReorder reports the new index). Tabs that overflow the strip scroll: arrows appear at its ends, the wheel over it scrolls, and the selected tab is kept in view.

func NewNotebook

func NewNotebook(face render.Font) *Notebook

NewNotebook returns an empty notebook with tab labels painted in the given face; a render.Chain adds mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*Notebook) AccessibleName

func (n *Notebook) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Notebook) AddClass

func (n *Notebook) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Notebook) AppendTab

func (n *Notebook) AppendTab(name string, w Widget)

AppendTab adds a page under name; the first page added becomes the selected one.

func (*Notebook) Arrange

func (n *Notebook) Arrange(r render.Rect)

Arrange lays out the tab strip and the visible page beneath it.

func (*Notebook) AttachStylesheet

func (n *Notebook) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Notebook) Attr

func (n *Notebook) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Notebook) Bounds

func (n *Notebook) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Notebook) Children

func (n *Notebook) Children() []Widget

Children exposes only the visible page, so keyboard traversal skips hidden pages.

func (*Notebook) Classes

func (n *Notebook) Classes() []string

Classes returns a copy of the widget's classes.

func (*Notebook) ClickAt

func (n *Notebook) ClickAt(p Point)

ClickAt selects the tab under the point, or fires OnTabClose when the close box of a tab was pressed.

func (*Notebook) CloseTab

func (n *Notebook) CloseTab(name string) bool

CloseTab removes the page under name; the following page becomes visible. Unknown names are a no-op. Reports whether a page was removed. The closed page detaches like every tree mutation: parent link cleared, removal hook fired.

func (*Notebook) CloseTabAt

func (n *Notebook) CloseTabAt(i int)

CloseTabAt removes the page at index i, like CloseTab; an index out of range is a no-op.

func (*Notebook) CursorName

func (n *Notebook) CursorName() string

CursorName is the hovered tab label's cursor (GTK resolves it on the label itself), else the notebook's own.

func (*Notebook) DebugName

func (n *Notebook) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Notebook) DetachStylesheet

func (n *Notebook) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Notebook) DragMove

func (n *Notebook) DragMove(p Point)

DragMove moves the dragged tab into the slot under the pointer, so the strip reorders live as the pointer crosses its neighbors.

func (*Notebook) Element

func (n *Notebook) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Notebook) Enabled

func (n *Notebook) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Notebook) HAlign

func (n *Notebook) HAlign() Align

HAlign returns the horizontal placement.

func (*Notebook) HasClass

func (n *Notebook) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Notebook) HasState

func (n *Notebook) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Notebook) HitLeaf

func (n *Notebook) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Notebook) HitTest

func (n *Notebook) HitTest(p Point) Widget

HitTest resolves the tab strip into the notebook itself (clicks select or close) and otherwise delegates to the visible page.

func (*Notebook) HoverMove

func (n *Notebook) HoverMove(p Point)

HoverMove tracks whether the pointer is over the tab strip, and the tab under it (its :hover).

func (*Notebook) HoverWithin

func (n *Notebook) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Notebook) ID

func (n *Notebook) ID() string

ID returns the style id, empty when none is set.

func (*Notebook) InlineStyle

func (n *Notebook) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Notebook) InsertTab

func (n *Notebook) InsertTab(i int, name string, w Widget)

InsertTab adds a page under name at index i (clamped); the selected page stays selected.

func (*Notebook) Invalidate

func (n *Notebook) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Notebook) InvalidateLayout

func (n *Notebook) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Notebook) InvalidateRect

func (n *Notebook) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Notebook) KeyAction

func (n *Notebook) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: ctrl+PageUp/PageDown cycle through tabs. Other actions are ignored.

func (*Notebook) LayoutMotion

func (n *Notebook) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Notebook) Margin

func (n *Notebook) Margin() render.Insets

Margin returns the programmatic margin.

func (*Notebook) MaximumSize

func (n *Notebook) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Notebook) Measure

func (n *Notebook) Measure(axis Axis, forSize int) Sizes

Measure reports the widest page's request, wanting the whole tab strip across (it scrolls when narrower) and its height on top.

func (*Notebook) MoveTab

func (n *Notebook) MoveTab(from, to int)

MoveTab moves tab from to index to, the selection following its page. It is the programmatic move: OnReorder reports only the user's drags, so a handler that mirrors them into a model cannot loop.

func (*Notebook) Paint

func (n *Notebook) Paint(cv *render.Canvas)

Paint draws the tab bar through its nodes — the notebook's box, the header and tab-row boxes, and each tab (the selected one :checked: its own background and label color, the accent fill and underline as the theme's fallback where the stylesheet paints none) — and the visible page.

func (*Notebook) Parent

func (n *Notebook) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Notebook) PressAt

func (n *Notebook) PressAt(p Point)

PressAt picks up a tab for reordering.

func (*Notebook) PressEnd

func (n *Notebook) PressEnd()

PressEnd drops the tab.

func (*Notebook) RemoveAttr

func (n *Notebook) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Notebook) RemoveClass

func (n *Notebook) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Notebook) Role

func (n *Notebook) Role() Role

Role implements Roleer.

func (*Notebook) SelectTab

func (n *Notebook) SelectTab(name string)

SelectTab shows the page under name; unknown names are a no-op.

func (*Notebook) SelectedTab

func (n *Notebook) SelectedTab() string

SelectedTab returns the visible page's name, empty when none.

func (*Notebook) SetAccessibleName

func (n *Notebook) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Notebook) SetAttr

func (n *Notebook) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Notebook) SetClass

func (n *Notebook) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Notebook) SetClasses

func (n *Notebook) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Notebook) SetCursorName

func (n *Notebook) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Notebook) SetDebugName

func (n *Notebook) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Notebook) SetElement

func (n *Notebook) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Notebook) SetEnabled

func (n *Notebook) SetEnabled(enabled bool)

SetEnabled turns the notebook's subtree on or off through the per-query enable walk, like Box. Like Stack, hidden pages stay untouched: they are not painted, so they need no repaint.

func (*Notebook) SetFocusOnClick

func (n *Notebook) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Notebook) SetHAlign

func (n *Notebook) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Notebook) SetHExpand

func (n *Notebook) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Notebook) SetHovered

func (n *Notebook) SetHovered(on bool)

SetHovered forgets the strip when the pointer leaves the notebook itself (into a page, or away).

func (*Notebook) SetID

func (n *Notebook) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Notebook) SetInlineStyle

func (n *Notebook) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Notebook) SetInlineStylePriority

func (n *Notebook) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Notebook) SetLayoutMotion

func (n *Notebook) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Notebook) SetMargin

func (n *Notebook) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Notebook) SetMaximumSize

func (n *Notebook) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Notebook) SetOnClickWithin

func (n *Notebook) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Notebook) SetOnFocusChanged

func (n *Notebook) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Notebook) SetOnHoverWithin

func (n *Notebook) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Notebook) SetOnPointer

func (n *Notebook) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Notebook) SetOnScroll

func (n *Notebook) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Notebook) SetSharedElement

func (n *Notebook) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Notebook) SetSizeRequest

func (n *Notebook) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Notebook) SetState

func (n *Notebook) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Notebook) SetTabExpand

func (n *Notebook) SetTabExpand(name string, on bool)

SetTabExpand makes the named tab share the strip's leftover width with the other expanding tabs (gtk_notebook_set_tab_expand); a tab whose label wants horizontal space expands without it.

func (*Notebook) SetTabLabel

func (n *Notebook) SetTabLabel(name string, w Widget)

SetTabLabel shows w in the tab of the page under name instead of its painted name (gtk_notebook_set_tab_label); nil restores the name. The label styles as the tab's child (`tab > label`) and fills the tab's content box. Unknown names are a no-op.

func (*Notebook) SetTooltip

func (n *Notebook) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Notebook) SetTooltipMarkup

func (n *Notebook) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Notebook) SetVAlign

func (n *Notebook) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Notebook) SetVExpand

func (n *Notebook) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Notebook) SetVisible

func (n *Notebook) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Notebook) SharedElement

func (n *Notebook) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Notebook) SizeRequest

func (n *Notebook) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Notebook) TabLabel

func (n *Notebook) TabLabel(name string) Widget

TabLabel is the label widget SetTabLabel gave the page under name (gtk_notebook_get_tab_label); nil for a painted name or an unknown page.

func (*Notebook) TooltipMarkup

func (n *Notebook) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Notebook) TooltipText

func (n *Notebook) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Notebook) VAlign

func (n *Notebook) VAlign() Align

VAlign returns the vertical placement.

func (*Notebook) Visible

func (n *Notebook) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type OTPCharset

type OTPCharset uint8

OTPCharset is what an InputOTP accepts.

const (
	// OTPDigits accepts 0-9.
	OTPDigits OTPCharset = iota
	// OTPAlphanumeric accepts letters and digits, uppercased.
	OTPAlphanumeric
)

The code character sets.

type Opacity

type Opacity struct {
	// contains filtered or unexported fields
}

Opacity carries a widget's subtree opacity: a factor in [0, 1] the widget applies around its children's paint. Widgets that wrap children embed it beside node, call bindOpacity from their constructor, and route child painting through paintChild. The factor lands on the canvas's PushAlpha stack, so nested carriers compose multiplicatively and the modulation reaches every blended primitive by construction.

The type has no Opacity getter on purpose: an accessor named like the embedded field would shadow the embedding itself (toast.Opacity() would collide with the promoted Opacity field). Alpha is the getter.

func (*Opacity) Alpha

func (o *Opacity) Alpha() float64

Alpha returns the subtree opacity in [0, 1]. The zero value is fully transparent, so embedding constructors start it at 1.

func (*Opacity) SetOpacity

func (o *Opacity) SetOpacity(a float64)

SetOpacity sets the subtree opacity, clamped to [0, 1] — a spring tween's overshoot saturates instead of over-brightening. A change invalidates the host's bounds, so the next frame repaints the subtree under the new factor. Zero is a state, not a special case: painting it skips the subtree entirely, which is what makes tween endpoints free. It composes with the animation clock directly — a tween callback is just SetOpacity.

type Orientation

type Orientation uint8

Orientation is the main direction an oriented widget runs along.

const (
	// Horizontal runs left to right.
	Horizontal Orientation = iota
	// Vertical runs top to bottom.
	Vertical
)

type Overlay

type Overlay struct {
	// contains filtered or unexported fields
}

Overlay stacks all children on the same rect and paints them in add order. The last child paints on top and wins hit tests. A hidden child takes no part: it neither sizes, paints, nor hits, as in a Box.

func NewOverlay

func NewOverlay() *Overlay

NewOverlay returns an empty overlay.

func (*Overlay) AccessibleName

func (n *Overlay) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Overlay) AddClass

func (n *Overlay) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Overlay) Append

func (o *Overlay) Append(w Widget) *Overlay

Append adds a child on top.

func (*Overlay) AppendAligned

func (o *Overlay) AppendAligned(w Widget, h, v Align) *Overlay

AppendAligned adds a child on top, sized and placed per axis like a GtkOverlay child: AlignFill takes the overlay's extent, the others keep the child's natural size pinned to the start, center or end. The child hits only inside its own rect, so a corner button leaves the rest of the content clickable.

func (*Overlay) Arrange

func (o *Overlay) Arrange(r render.Rect)

Arrange records the border box and assigns the content box to every filling child, placing the aligned ones within it.

func (*Overlay) ArrangeRoot

func (o *Overlay) ArrangeRoot(r render.Rect)

ArrangeRoot records the overlay's own rect.

func (*Overlay) AttachStylesheet

func (n *Overlay) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Overlay) Attr

func (n *Overlay) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Overlay) Bounds

func (n *Overlay) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Overlay) Children

func (o *Overlay) Children() []Widget

Children exposes a snapshot of the overlay's children in add order for focus traversal. A copy, like Box.Children: tree walks must be able to survive a callback that mutates the container.

func (*Overlay) Classes

func (n *Overlay) Classes() []string

Classes returns a copy of the widget's classes.

func (*Overlay) DebugName

func (n *Overlay) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Overlay) DetachStylesheet

func (n *Overlay) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Overlay) Element

func (n *Overlay) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Overlay) Enabled

func (n *Overlay) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Overlay) HAlign

func (n *Overlay) HAlign() Align

HAlign returns the horizontal placement.

func (*Overlay) HasClass

func (n *Overlay) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Overlay) HasState

func (n *Overlay) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Overlay) HitLeaf

func (n *Overlay) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Overlay) HitTest

func (o *Overlay) HitTest(p Point) Widget

HitTest returns the topmost child under p, or the overlay inside its bounds.

func (*Overlay) HoverWithin

func (n *Overlay) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Overlay) ID

func (n *Overlay) ID() string

ID returns the style id, empty when none is set.

func (*Overlay) InlineStyle

func (n *Overlay) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Overlay) Invalidate

func (n *Overlay) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Overlay) InvalidateLayout

func (n *Overlay) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Overlay) InvalidateRect

func (n *Overlay) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Overlay) LayoutMotion

func (n *Overlay) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Overlay) Margin

func (n *Overlay) Margin() render.Insets

Margin returns the programmatic margin.

func (*Overlay) MaximumSize

func (n *Overlay) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Overlay) Measure

func (o *Overlay) Measure(axis Axis, forSize int) Sizes

Measure reports the widest request of its visible children inside the overlay's CSS box: padding, border and min sizes.

func (*Overlay) Paint

func (o *Overlay) Paint(cv *render.Canvas)

Paint draws the overlay's CSS box, then every child bottom to top.

func (*Overlay) Parent

func (n *Overlay) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Overlay) RemoveAttr

func (n *Overlay) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Overlay) RemoveClass

func (n *Overlay) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Overlay) SetAccessibleName

func (n *Overlay) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Overlay) SetAttr

func (n *Overlay) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Overlay) SetClass

func (n *Overlay) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Overlay) SetClasses

func (n *Overlay) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Overlay) SetCursorName

func (n *Overlay) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Overlay) SetDebugName

func (n *Overlay) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Overlay) SetElement

func (n *Overlay) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Overlay) SetEnabled

func (o *Overlay) SetEnabled(enabled bool)

SetEnabled turns the overlay's whole stack on or off through the per-query enable walk, like Box.

func (*Overlay) SetFocusOnClick

func (n *Overlay) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Overlay) SetHAlign

func (n *Overlay) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Overlay) SetHExpand

func (n *Overlay) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Overlay) SetID

func (n *Overlay) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Overlay) SetInlineStyle

func (n *Overlay) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Overlay) SetInlineStylePriority

func (n *Overlay) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Overlay) SetLayoutMotion

func (n *Overlay) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Overlay) SetMargin

func (n *Overlay) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Overlay) SetMaximumSize

func (n *Overlay) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Overlay) SetOnClickWithin

func (n *Overlay) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Overlay) SetOnFocusChanged

func (n *Overlay) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Overlay) SetOnHoverWithin

func (n *Overlay) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Overlay) SetOnPointer

func (n *Overlay) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Overlay) SetOnScroll

func (n *Overlay) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Overlay) SetSharedElement

func (n *Overlay) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Overlay) SetSizeRequest

func (n *Overlay) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Overlay) SetState

func (n *Overlay) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Overlay) SetTooltip

func (n *Overlay) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Overlay) SetTooltipMarkup

func (n *Overlay) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Overlay) SetVAlign

func (n *Overlay) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Overlay) SetVExpand

func (n *Overlay) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Overlay) SetVisible

func (n *Overlay) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Overlay) SharedElement

func (n *Overlay) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Overlay) SizeRequest

func (n *Overlay) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Overlay) TooltipMarkup

func (n *Overlay) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Overlay) TooltipText

func (n *Overlay) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Overlay) VAlign

func (n *Overlay) VAlign() Align

VAlign returns the vertical placement.

func (*Overlay) Visible

func (n *Overlay) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type OverlaySplitView

type OverlaySplitView struct {
	// contains filtered or unexported fields
}

OverlaySplitView is the Flap shape: wide, the sidebar beside the content; collapsed, the content full-size with the sidebar sliding in over its leading edge on ShowSidebar. Gestures wait for the touch ticket.

func NewOverlaySplitView

func NewOverlaySplitView(sidebar, content Widget, collapseWidth int) *OverlaySplitView

NewOverlaySplitView returns the split over content with sidebar; collapseWidth is 420 when not positive. Collapsed, the sidebar starts hidden.

func (*OverlaySplitView) Arrange

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

Arrange evaluates the breakpoint against the allocated width, then lays out whichever layout it picked - in the same pass, so a collapse never paints one frame of the old layout.

func (*OverlaySplitView) Collapsed

func (c *OverlaySplitView) Collapsed() bool

Collapsed reports which layout the last width chose.

func (*OverlaySplitView) ShowSidebar

func (s *OverlaySplitView) ShowSidebar(on bool)

ShowSidebar opens or closes the collapsed overlay; above the breakpoint the sidebar always shows and this is a no-op.

func (*OverlaySplitView) SidebarShowing

func (s *OverlaySplitView) SidebarShowing() bool

SidebarShowing reports whether the sidebar is on screen (always, wide).

type Pagination

type Pagination struct {

	// OnPageChanged fires with the new page after the user moved to
	// it, not after SetPage.
	OnPageChanged func(page int)
	// contains filtered or unexported fields
}

Pagination steps through numbered pages: Previous, the page links around the current one with the first and last always shown and ellipses for the gaps, and Next. Pages count from 1. It styles as the `pagination` element: each link a button.page-link, the current one :checked, the ends button.previous and button.next, the gaps .ellipsis.

func NewPagination

func NewPagination(face render.Font, count, page int) *Pagination

NewPagination returns a pagination over count pages at page, with one link on each side of the current page. count is at least 1 and page within 1..count, or the call panics.

func (*Pagination) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Pagination) Baseline

func (c *Pagination) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Pagination) Children

func (c *Pagination) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Pagination) Count

func (p *Pagination) Count() int

Count returns the page count.

func (*Pagination) HitTest

func (c *Pagination) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Pagination) Measure

func (c *Pagination) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Pagination) Page

func (p *Pagination) Page() int

Page returns the current page.

func (*Pagination) Paint

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

Paint draws the surface (when configured) then the root.

func (*Pagination) SetCount

func (p *Pagination) SetCount(count, page int)

SetCount replaces the page count and the current page; count is at least 1 and page within 1..count, or the call panics.

func (*Pagination) SetPage

func (p *Pagination) SetPage(page int)

SetPage moves to page, within 1..count or the call panics.

func (*Pagination) SetSiblings

func (p *Pagination) SetSiblings(n int)

SetSiblings sets how many links show on each side of the current page, at least 0.

type Paned

type Paned struct {

	// OnPositionChanged fires after every applied position change —
	// drag, keyboard, SetPosition, or a resize that re-normalized the
	// request — with the arranged position.
	OnPositionChanged func(position int)
	// contains filtered or unexported fields
}

Paned is a two-pane container with a draggable divider: children are arranged along the axis (Row side by side, Column stacked), the divider position is pixels from the start edge, and dragging, keyboard nudges, or SetPosition move it — the children relayout live, one frame per position change.

The position is a request the arrangement clamps: each pane holds at least its minimum, so the divider never starves a pane past what it declared it needs; when a resize makes the request impossible, the position re-normalizes to the nearest clamp — GTK's keep-child-one semantics. Position reports the arranged position; SetPosition only asks.

The handle owns a generous hit zone around the divider (the slop overlaps the panes' edges); presses there drag, and the Paned is keyboard-focusable: arrows nudge along the axis (by a twentieth of the span, one pixel minimum), Home and End pin to the extremes. The pane children keep their own input: hits outside the handle zone reach them, and they join focus traversal through Children.

func NewPaned

func NewPaned(axis Axis, start, end Widget) *Paned

NewPaned returns a paned along axis with the two children; either may be nil, in which case the other takes the whole rect and no divider is drawn.

func (*Paned) AccessibleName

func (n *Paned) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Paned) AddClass

func (n *Paned) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Paned) Arrange

func (p *Paned) Arrange(r render.Rect)

Arrange clamps the requested position, lays the panes around it, and keeps the parent links current for the walks.

func (*Paned) AttachStylesheet

func (n *Paned) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Paned) Attr

func (n *Paned) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Paned) Bounds

func (n *Paned) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Paned) Children

func (p *Paned) Children() []Widget

Children exposes the panes for focus traversal and the damage walk.

func (*Paned) Classes

func (n *Paned) Classes() []string

Classes returns a copy of the widget's classes.

func (*Paned) CursorName

func (p *Paned) CursorName() string

CursorName returns the resize cursor for the axis while the handle is the hovered widget (HitTest returns the Paned only inside the handle's hit zone, so being hovered is being on the handle).

func (*Paned) DebugName

func (n *Paned) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Paned) DetachStylesheet

func (n *Paned) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Paned) DragMove

func (p *Paned) DragMove(pt Point)

DragMove drags the divider to the pointer: the position is where the pointer sits minus half the handle, clamped by the arrangement. Disabled panes do not drag.

func (*Paned) Element

func (n *Paned) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Paned) Enabled

func (n *Paned) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Paned) HAlign

func (n *Paned) HAlign() Align

HAlign returns the horizontal placement.

func (*Paned) HasClass

func (n *Paned) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Paned) HasState

func (n *Paned) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Paned) HitLeaf

func (n *Paned) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Paned) HitTest

func (p *Paned) HitTest(pt Point) Widget

HitTest returns the Paned inside the handle's hit zone — the handle owns the press even where the slop overlaps a pane — then whatever pane is under p, else nil: the paned's own chrome swallows nothing.

func (*Paned) HoverWithin

func (n *Paned) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Paned) ID

func (n *Paned) ID() string

ID returns the style id, empty when none is set.

func (*Paned) InlineStyle

func (n *Paned) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Paned) Invalidate

func (n *Paned) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Paned) InvalidateLayout

func (n *Paned) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Paned) InvalidateRect

func (n *Paned) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Paned) KeyAction

func (p *Paned) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: arrows nudge the divider along the axis by a twentieth of the span (one pixel at least), Home and End pin it to the extremes; the cross-axis arrows and every other action are not the handle's. Disabled panes ignore keys.

func (*Paned) LayoutMotion

func (n *Paned) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Paned) Margin

func (n *Paned) Margin() render.Insets

Margin returns the programmatic margin.

func (*Paned) MaximumSize

func (n *Paned) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Paned) Measure

func (p *Paned) Measure(axis Axis, forSize int) Sizes

Measure wants the two panes' requests plus the handle along the axis, so a Paned nested in a squeezing container (a Grid) keeps both panes alive; across, the larger pane's request at its natural extent along.

func (*Paned) Paint

func (p *Paned) Paint(cv *render.Canvas)

Paint draws the panes, then the divider between them through its `separator` node: the box layers it resolves, the theme's handle looks as the fallback per state, and no divider when a pane is missing (the other still paints).

func (*Paned) Parent

func (n *Paned) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Paned) Position

func (p *Paned) Position() int

Position returns the divider's arranged position in pixels from the start edge — the clamped truth, never the unarranged request. Before the first arrangement it is zero.

func (*Paned) RemoveAttr

func (n *Paned) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Paned) RemoveClass

func (n *Paned) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Paned) Role

func (p *Paned) Role() Role

Role implements Roleer.

func (*Paned) SetAccessibleName

func (n *Paned) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Paned) SetAttr

func (n *Paned) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Paned) SetClass

func (n *Paned) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Paned) SetClasses

func (n *Paned) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Paned) SetCursorName

func (n *Paned) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Paned) SetDebugName

func (n *Paned) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Paned) SetElement

func (n *Paned) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Paned) SetEnabled

func (n *Paned) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Paned) SetFocusOnClick

func (n *Paned) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Paned) SetHAlign

func (n *Paned) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Paned) SetHExpand

func (n *Paned) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Paned) SetHovered

func (p *Paned) SetHovered(on bool)

SetHovered tracks the handle's hover shade.

func (*Paned) SetID

func (n *Paned) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Paned) SetInlineStyle

func (n *Paned) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Paned) SetInlineStylePriority

func (n *Paned) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Paned) SetLayoutMotion

func (n *Paned) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Paned) SetMargin

func (n *Paned) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Paned) SetMaxPosition

func (p *Paned) SetMaxPosition(pos int)

SetMaxPosition caps the divider at pos pixels from the start edge (the start pane's largest extent), above the start pane's floor; zero removes the cap. Drags, keys and SetPosition all stop there.

func (*Paned) SetMaximumSize

func (n *Paned) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Paned) SetOnClickWithin

func (n *Paned) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Paned) SetOnFocusChanged

func (n *Paned) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Paned) SetOnHoverWithin

func (n *Paned) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Paned) SetOnPointer

func (n *Paned) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Paned) SetOnScroll

func (n *Paned) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Paned) SetPosition

func (p *Paned) SetPosition(pos int)

SetPosition asks for a divider position in pixels from the start edge; the next arrangement clamps it between the panes' minimums and under SetMaxPosition, and fires OnPositionChanged when the arranged position moved.

func (*Paned) SetPressed

func (p *Paned) SetPressed(on bool)

SetPressed tracks the drag's pressed shade and reports the press the divider follows.

func (*Paned) SetSharedElement

func (n *Paned) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Paned) SetSizeRequest

func (n *Paned) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Paned) SetState

func (n *Paned) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Paned) SetTooltip

func (n *Paned) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Paned) SetTooltipMarkup

func (n *Paned) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Paned) SetVAlign

func (n *Paned) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Paned) SetVExpand

func (n *Paned) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Paned) SetVisible

func (n *Paned) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Paned) SharedElement

func (n *Paned) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Paned) SizeRequest

func (n *Paned) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Paned) TooltipMarkup

func (n *Paned) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Paned) TooltipText

func (n *Paned) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Paned) VAlign

func (n *Paned) VAlign() Align

VAlign returns the vertical placement.

func (*Paned) Visible

func (n *Paned) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ParamAction

type ParamAction[P comparable] struct {
	// contains filtered or unexported fields
}

ParamAction is a named action activated with a value, relm4's stateless action with a target type: one "open-file" action serving every recent-file row. Proxies bind a Target, a value fixed at binding time. The parameter is comparable because targets are compared and keyed by the accelerator registry.

func NewParamAction

func NewParamAction[P comparable](name string, fn func(P)) *ParamAction[P]

NewParamAction returns an enabled action running fn with the bound value on activation.

func (*ParamAction[P]) ActivateWith

func (a *ParamAction[P]) ActivateWith(p P)

ActivateWith runs the action with p unless it is disabled.

func (*ParamAction) Enabled

func (c *ParamAction) Enabled() bool

Enabled reports whether the action may be activated.

func (*ParamAction) Name

func (c *ParamAction) Name() string

Name returns the action's name.

func (*ParamAction) SetEnabled

func (c *ParamAction) SetEnabled(on bool)

SetEnabled enables or disables the action and every proxy bound to it.

func (*ParamAction) Subscribe

func (c *ParamAction) Subscribe(fn func()) (cancel func())

Subscribe registers fn for every enabled or state change; the returned cancel removes it.

func (*ParamAction[P]) Target

func (a *ParamAction[P]) Target(p P) Activatable

Target is the Activatable that runs the action with p.

type ParsedStylesheet added in v0.2.5

type ParsedStylesheet struct {
	// contains filtered or unexported fields
}

ParsedStylesheet is CSS parsed into rules, ready for LoadParsed. It is immutable, so it may be made on one goroutine and installed on another.

func ParseStylesheet added in v0.2.5

func ParseStylesheet(css string) *ParsedStylesheet

ParseStylesheet parses css on any goroutine. Its parse warnings are held until LoadParsed reports them on the loop.

type Pile

type Pile struct {
	// contains filtered or unexported fields
}

Pile stacks its children as cards: collapsed, the front card (index 0) shows whole and the next few peek out past one edge of it, each a step further, scaled down about its middle and fainter, showing only their box (background, border, shadow; through a box-less single-child wrapper such as a SwipeDismiss or Revealer, the box inside it) and never their content; expanded, the cards lay out as a column with a gap. The change between the two moves the cards on their layout motion, which a pile opts its children into (smooth) unless the stylesheet's -lys-layout-motion says otherwise.

The pile carries the `expanded` class while expanded; its children carry `front`, `peek` or `buried` (deeper than the peek, neither painted nor hit). Collapsed, only the front card takes the pointer.

func NewPile

func NewPile() *Pile

NewPile returns an empty, collapsed pile peeking two cards past its bottom edge.

func (*Pile) AccessibleName

func (n *Pile) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Pile) AddClass

func (n *Pile) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Pile) Append

func (p *Pile) Append(w Widget)

Append adds w behind the other cards.

func (*Pile) Arrange

func (p *Pile) Arrange(r render.Rect)

Arrange places the cards: collapsed, the front at the end away from the peek edge and each peek at the front's rect, narrowed and shifted toward the edge, the buried ones under the last peek; expanded, a column from the front's end.

func (*Pile) AttachStylesheet

func (n *Pile) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Pile) Attr

func (n *Pile) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Pile) Bounds

func (n *Pile) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Pile) Children

func (p *Pile) Children() []Widget

Children returns the cards, front first.

func (*Pile) Classes

func (n *Pile) Classes() []string

Classes returns a copy of the widget's classes.

func (*Pile) DebugName

func (n *Pile) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Pile) DetachStylesheet

func (n *Pile) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Pile) Element

func (n *Pile) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Pile) Enabled

func (n *Pile) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Pile) Expanded

func (p *Pile) Expanded() bool

Expanded reports whether the cards lay out as a column.

func (*Pile) HAlign

func (n *Pile) HAlign() Align

HAlign returns the horizontal placement.

func (*Pile) HasClass

func (n *Pile) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Pile) HasState

func (n *Pile) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Pile) HitLeaf

func (n *Pile) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Pile) HitTest

func (p *Pile) HitTest(pt Point) Widget

HitTest is the front card collapsed, any card expanded, else the pile within its bounds.

func (*Pile) HoverWithin

func (n *Pile) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Pile) ID

func (n *Pile) ID() string

ID returns the style id, empty when none is set.

func (*Pile) InlineStyle

func (n *Pile) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Pile) Insert

func (p *Pile) Insert(i int, w Widget)

Insert adds w at index i (clamped): 0 is the front.

func (*Pile) Invalidate

func (n *Pile) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Pile) InvalidateLayout

func (n *Pile) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Pile) InvalidateRect

func (n *Pile) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Pile) LayoutMotion

func (n *Pile) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Pile) Margin

func (n *Pile) Margin() render.Insets

Margin returns the programmatic margin.

func (*Pile) MaximumSize

func (n *Pile) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Pile) Measure

func (p *Pile) Measure(axis Axis, forSize int) Sizes

Measure is the front card and its peeks collapsed, the column of cards expanded, inside the pile's CSS box.

func (*Pile) Paint

func (p *Pile) Paint(cv *render.Canvas)

Paint draws the cards back to front: collapsed, the peeks as their own boxes only, then the front whole; expanded, every card.

func (*Pile) Parent

func (n *Pile) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Pile) Remove

func (p *Pile) Remove(w Widget)

Remove detaches w; a widget not in the pile is left alone.

func (*Pile) RemoveAttr

func (n *Pile) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Pile) RemoveClass

func (n *Pile) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Pile) SetAccessibleName

func (n *Pile) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Pile) SetAttr

func (n *Pile) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Pile) SetClass

func (n *Pile) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Pile) SetClasses

func (n *Pile) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Pile) SetCursorName

func (n *Pile) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Pile) SetDebugName

func (n *Pile) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Pile) SetElement

func (n *Pile) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Pile) SetEnabled

func (n *Pile) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Pile) SetExpanded

func (p *Pile) SetExpanded(on bool)

SetExpanded lays the cards out as a column (true) or stacks them.

func (*Pile) SetFocusOnClick

func (n *Pile) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Pile) SetHAlign

func (n *Pile) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Pile) SetHExpand

func (n *Pile) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Pile) SetID

func (n *Pile) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Pile) SetInlineStyle

func (n *Pile) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Pile) SetInlineStylePriority

func (n *Pile) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Pile) SetLayoutMotion

func (n *Pile) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Pile) SetMargin

func (n *Pile) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Pile) SetMaximumSize

func (n *Pile) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Pile) SetOnClickWithin

func (n *Pile) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Pile) SetOnFocusChanged

func (n *Pile) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Pile) SetOnHoverWithin

func (n *Pile) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Pile) SetOnPointer

func (n *Pile) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Pile) SetOnScroll

func (n *Pile) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Pile) SetPeek

func (p *Pile) SetPeek(n int)

SetPeek sets how many cards peek behind the front collapsed; below 0 it is 0.

func (*Pile) SetPeekEdge

func (p *Pile) SetPeekEdge(e Edge)

SetPeekEdge sets the edge the cards peek past: EdgeBottom for a pile hanging from the top of the screen, EdgeTop for one standing on the bottom, whose front card then sits lowest. Expanded, the front card stays at that same end of the column.

func (*Pile) SetPeekOffset

func (p *Pile) SetPeekOffset(px int)

SetPeekOffset sets the step, in logical pixels, each peeking card shows past the one in front of it.

func (*Pile) SetPeekOpacity

func (p *Pile) SetPeekOpacity(f float32)

SetPeekOpacity sets the opacity, as a fraction in [0, 1], each level of depth keeps of the card in front of it.

func (*Pile) SetPeekScale

func (p *Pile) SetPeekScale(f float32)

SetPeekScale sets the size, as a fraction in (0, 1], each level of depth keeps of the card in front of it, both sides scaling about the card's middle.

func (*Pile) SetSharedElement

func (n *Pile) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Pile) SetSizeRequest

func (n *Pile) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Pile) SetSpacing

func (p *Pile) SetSpacing(px int)

SetSpacing sets the gap between expanded cards.

func (*Pile) SetState

func (n *Pile) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Pile) SetTooltip

func (n *Pile) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Pile) SetTooltipMarkup

func (n *Pile) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Pile) SetVAlign

func (n *Pile) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Pile) SetVExpand

func (n *Pile) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Pile) SetVisible

func (n *Pile) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Pile) SharedElement

func (n *Pile) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Pile) SizeRequest

func (n *Pile) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Pile) TooltipMarkup

func (n *Pile) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Pile) TooltipText

func (n *Pile) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Pile) VAlign

func (n *Pile) VAlign() Align

VAlign returns the vertical placement.

func (*Pile) Visible

func (n *Pile) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type PixelClaimer

type PixelClaimer interface {
	ClaimPixels(dx, dy float64) bool
}

PixelClaimer is a widget that may take a finger scroll before the scrollers beneath it: a swipe-to-dismiss card takes a sideways one. It is offered the first deltas of a gesture no scroller holds yet; true takes them, and then the rest of the gesture (ClaimPixels) and its end (ScrollEnder).

type PixelScroller

type PixelScroller interface {
	ScrollPixels(dx, dy float64)
}

PixelScroller is a ScrollHandler that takes exact pixel deltas (touchpads, continuous devices) as well as wheel steps.

type Point

type Point struct {
	X, Y int
}

Point is a position in pixels.

type PointerEvent

type PointerEvent struct {
	// Button is the wayland button code: BTNLeft, BTNRight, BTNMiddle,
	// or a side button beyond them.
	Button uint32
	// Clicks counts the presses of this button on this widget, each
	// within the double-click window of the last: 1, 2 for a double
	// press, 3 for a triple.
	Clicks int
	// Mods are the keyboard modifiers held.
	Mods Mods
	// At is where the press landed, in root coordinates.
	At Point
}

PointerEvent is a pointer button press as a hook sees it.

type PopoverOptions

type PopoverOptions struct {
	// Focus takes the keyboard focus as the popover opens.
	Focus Widget
	// NoGrab leaves the keyboard and pointer with the window: a hover
	// card shows beside what the user is pointing at instead of taking
	// the input, and closes only when told.
	NoGrab bool
	// OnClosed runs once the popover is gone, however it closed.
	OnClosed func()
	// Gap is the distance between the anchor and the popover.
	Gap int
	// Side is the side of the anchor the popover opens on, below
	// unless set.
	Side PopoverSide
}

PopoverOptions shape a widget-opened popover.

type PopoverSide

type PopoverSide uint8

PopoverSide is the side of its anchor a popover opens on; the compositor flips it to the other side where there is no room.

const (
	PopoverBelow PopoverSide = iota
	PopoverAbove
	PopoverRight
	PopoverLeft
)

The popover sides.

type PreferencesGroup

type PreferencesGroup struct {
	// contains filtered or unexported fields
}

PreferencesGroup is a labeled boxed list of rows: a header line (title plus an optional suffix, the adw description slot), the bordered card, and rows separated by hairlines. Add appends rows; any widget works, ActionRow and friends are the point.

func NewPreferencesGroup

func NewPreferencesGroup(face render.Font, sizePx float64, title string) *PreferencesGroup

NewPreferencesGroup returns an empty group; title empty skips the header line.

func (*PreferencesGroup) Add

func (g *PreferencesGroup) Add(w Widget)

Add appends a row to the card.

func (*PreferencesGroup) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*PreferencesGroup) Baseline

func (c *PreferencesGroup) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*PreferencesGroup) Children

func (c *PreferencesGroup) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*PreferencesGroup) HitTest

func (c *PreferencesGroup) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*PreferencesGroup) Measure

func (c *PreferencesGroup) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*PreferencesGroup) Paint

func (g *PreferencesGroup) Paint(cv *render.Canvas)

Paint draws the boxed-list card around the rows with hairlines between them.

func (*PreferencesGroup) SetSuffix

func (g *PreferencesGroup) SetSuffix(s string)

SetSuffix sets the header's trailing note (the adw description slot); empty hides it.

func (*PreferencesGroup) SetTitle

func (g *PreferencesGroup) SetTitle(t string)

SetTitle sets the header title.

type PreferencesPage

type PreferencesPage struct {
	// contains filtered or unexported fields
}

PreferencesPage is the scrolling stack of groups: a column of groups in a vertical Scroll, clamped to a readable width - the adw page.

func NewPreferencesPage

func NewPreferencesPage() *PreferencesPage

NewPreferencesPage returns an empty page.

func (*PreferencesPage) Add

func (p *PreferencesPage) Add(w Widget)

Add appends a group (or any widget) to the page.

func (*PreferencesPage) Arrange

func (p *PreferencesPage) Arrange(r render.Rect)

Arrange lays the page out, then brings a pending Reveal into view.

func (*PreferencesPage) Baseline

func (c *PreferencesPage) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*PreferencesPage) Children

func (c *PreferencesPage) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*PreferencesPage) HitTest

func (c *PreferencesPage) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*PreferencesPage) Measure

func (c *PreferencesPage) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*PreferencesPage) Paint

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

Paint draws the surface (when configured) then the root.

func (*PreferencesPage) Reveal

func (p *PreferencesPage) Reveal(w Widget)

Reveal scrolls the page so w is in view at the next layout.

func (*PreferencesPage) ScrollBy

func (p *PreferencesPage) ScrollBy(dx, dy int)

ScrollBy forwards wheel and gesture scrolling to the page's scroll.

func (*PreferencesPage) SetIconName

func (p *PreferencesPage) SetIconName(name string)

SetIconName sets the page's switcher icon by theme name.

func (*PreferencesPage) SetTitle

func (p *PreferencesPage) SetTitle(t string)

SetTitle names the page for a PreferencesView's switcher and search.

func (*PreferencesPage) Title

func (p *PreferencesPage) Title() string

Title returns the page name.

type PreferencesView

type PreferencesView struct {
	// contains filtered or unexported fields
}

PreferencesView is the body of libadwaita's AdwPreferencesDialog: PreferencesPages behind a view switcher, a search that lists the matching rows of every page (title or subtitle, case-insensitive; rows opt out with SetSearchable), and subpages pushed over the pages with a back button. Activating a search result shows its page and scrolls the row into view.

func NewPreferencesView

func NewPreferencesView(face render.Font, sizePx float64) *PreferencesView

NewPreferencesView returns an empty preferences view.

func (*PreferencesView) Add

func (v *PreferencesView) Add(p *PreferencesPage)

Add appends a page; the switcher shows once there are two.

func (*PreferencesView) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*PreferencesView) Baseline

func (c *PreferencesView) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*PreferencesView) Children

func (c *PreferencesView) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*PreferencesView) HitTest

func (c *PreferencesView) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*PreferencesView) Measure

func (c *PreferencesView) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*PreferencesView) Pages

func (v *PreferencesView) Pages() []*PreferencesPage

Pages returns the pages in order.

func (*PreferencesView) Paint

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

Paint draws the surface (when configured) then the root.

func (*PreferencesView) PopSubpage

func (v *PreferencesView) PopSubpage() bool

PopSubpage returns from the topmost subpage, reporting whether there was one.

func (*PreferencesView) PushSubpage

func (v *PreferencesView) PushSubpage(title string, content Widget)

PushSubpage pushes a page titled title over the preferences with a back button, AdwPreferencesDialog's push_subpage.

func (*PreferencesView) Search

func (v *PreferencesView) Search(text string)

Search runs a search for text, as typing in the search entry does; empty returns to the page shown before.

func (*PreferencesView) ShowPage

func (v *PreferencesView) ShowPage(p *PreferencesPage)

ShowPage shows p.

func (*PreferencesView) VisiblePage

func (v *PreferencesView) VisiblePage() *PreferencesPage

VisiblePage returns the shown page, nil while searching.

type PressAter

type PressAter interface {
	PressAt(p Point)
}

PressAter receives where a press landed, right after SetPressed(true): a slider warps its value there (gtk-primary-button-warps-slider).

type PressEnder

type PressEnder interface {
	PressEnd()
}

PressEnder receives the end of a press gesture: the release (after any click), a cancelled press (the gesture became a data-device drag), or pointer loss (the device went away mid-gesture). Widgets that accumulate gesture state across DragMove calls — a list's rubber-band selection, say — settle and flush it here, so a gesture that ends off-widget still concludes exactly once.

type PressSetter

type PressSetter interface {
	SetPressed(on bool)
}

PressSetter receives press tracking from the Router.

type ProgressBar

type ProgressBar struct {

	// Fill and Trough color the bar; zero is the theme's accent (or
	// the accent-color) and, for the trough, the fill at a fifth of
	// its opacity, under the trough and progress rules.
	Fill, Trough render.Color
	// PulseStep is how far one Pulse moves the block (GTK pulse-step).
	PulseStep float64
	// contains filtered or unexported fields
}

ProgressBar paints a read-only fill over a trough, as GTK's node tree: `progressbar > trough > progress` - the bar's box, the trough's, and the fill's, each styled by the cascade. Besides the fraction it has GTK's activity mode for work of unknown length: Pulse steps a bouncing block, SetPulsing animates it continuously, and SetValue returns to the fraction.

func NewProgressBar

func NewProgressBar(value float64) *ProgressBar

NewProgressBar returns a progress bar at value clamped to [0, 1].

func (*ProgressBar) Activity

func (p *ProgressBar) Activity() bool

Activity reports whether the bar is in activity mode.

func (*ProgressBar) Arrange

func (p *ProgressBar) Arrange(r render.Rect)

Arrange lays the bar out and syncs the pulse with visibility.

func (*ProgressBar) HitTest

func (p *ProgressBar) HitTest(pt Point) Widget

HitTest returns the bar when p is inside its bounds.

func (*ProgressBar) Measure

func (p *ProgressBar) Measure(axis Axis, forSize int) Sizes

Measure wants the 160x10 trough inside the bar's CSS box.

func (*ProgressBar) Paint

func (p *ProgressBar) Paint(cv *render.Canvas)

Paint draws the trough and the fill: the fraction, or the block.

func (*ProgressBar) Pulse

func (p *ProgressBar) Pulse()

Pulse enters activity mode and moves the block one PulseStep, bouncing off the trough's ends.

func (*ProgressBar) Pulsing

func (p *ProgressBar) Pulsing() bool

Pulsing reports whether the continuous animation is on.

func (*ProgressBar) Role

func (p *ProgressBar) Role() Role

Role implements Roleer.

func (*ProgressBar) SetPulsing

func (p *ProgressBar) SetPulsing(on bool)

SetPulsing animates the activity block continuously while the bar is on screen; off freezes it in place (SetValue leaves the mode).

func (*ProgressBar) SetValue

func (p *ProgressBar) SetValue(v float64)

SetValue sets the fraction, leaving activity mode.

func (*ProgressBar) Value

func (m *ProgressBar) Value() float64

Value returns the fill fraction in [0, 1].

type ProgressRing

type ProgressRing struct {
	// contains filtered or unexported fields
}

ProgressRing is a circular determinate progress: the fraction sweeps clockwise from twelve o'clock over a full-circle track, with an optional child centered inside, a percentage or an icon. Its node tree is ProgressBar's, `progressring > trough > progress`: the ring's min-width and min-height set the diameter, the trough's min-height the stroke, and the trough's and progress's background colors the track and the fill, the fill the accent (or the accent-color) and the track the fill at a fifth of its opacity unless set. The success, warning and error classes recolor it. A new value eases in over the theme's medium motion.

func NewProgressRing

func NewProgressRing(value float64) *ProgressRing

NewProgressRing returns a ring at value clamped to [0, 1].

func (*ProgressRing) AccessibleName

func (n *ProgressRing) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ProgressRing) AddClass

func (n *ProgressRing) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ProgressRing) Arrange

func (r *ProgressRing) Arrange(rect render.Rect)

Arrange centers the ring's square in the content box and the child at its natural size in the square.

func (*ProgressRing) AttachStylesheet

func (n *ProgressRing) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ProgressRing) Attr

func (n *ProgressRing) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ProgressRing) Bounds

func (n *ProgressRing) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ProgressRing) Child

func (r *ProgressRing) Child() Widget

Child returns the centered widget, nil when none.

func (*ProgressRing) Children

func (r *ProgressRing) Children() []Widget

Children returns the centered widget.

func (*ProgressRing) Classes

func (n *ProgressRing) Classes() []string

Classes returns a copy of the widget's classes.

func (*ProgressRing) DebugName

func (n *ProgressRing) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ProgressRing) DetachStylesheet

func (n *ProgressRing) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ProgressRing) Element

func (n *ProgressRing) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ProgressRing) Enabled

func (n *ProgressRing) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ProgressRing) HAlign

func (n *ProgressRing) HAlign() Align

HAlign returns the horizontal placement.

func (*ProgressRing) HasClass

func (n *ProgressRing) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ProgressRing) HasState

func (n *ProgressRing) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ProgressRing) HitLeaf

func (n *ProgressRing) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ProgressRing) HitTest

func (r *ProgressRing) HitTest(p Point) Widget

HitTest returns the child under p, else the ring inside its bounds.

func (*ProgressRing) HoverWithin

func (n *ProgressRing) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ProgressRing) ID

func (n *ProgressRing) ID() string

ID returns the style id, empty when none is set.

func (*ProgressRing) InlineStyle

func (n *ProgressRing) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ProgressRing) Invalidate

func (n *ProgressRing) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ProgressRing) InvalidateLayout

func (n *ProgressRing) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ProgressRing) InvalidateRect

func (n *ProgressRing) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ProgressRing) LayoutMotion

func (n *ProgressRing) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ProgressRing) Margin

func (n *ProgressRing) Margin() render.Insets

Margin returns the programmatic margin.

func (*ProgressRing) MaximumSize

func (n *ProgressRing) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ProgressRing) Measure

func (r *ProgressRing) Measure(axis Axis, forSize int) Sizes

Measure wants the diameter square inside the ring's CSS box.

func (*ProgressRing) Paint

func (r *ProgressRing) Paint(cv *render.Canvas)

Paint strokes the track and the sweep, then the child.

func (*ProgressRing) Parent

func (n *ProgressRing) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ProgressRing) RemoveAttr

func (n *ProgressRing) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ProgressRing) RemoveClass

func (n *ProgressRing) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ProgressRing) Role

func (r *ProgressRing) Role() Role

Role implements Roleer.

func (*ProgressRing) SetAccessibleName

func (n *ProgressRing) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ProgressRing) SetAttr

func (n *ProgressRing) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ProgressRing) SetChild

func (r *ProgressRing) SetChild(w Widget)

SetChild centers w inside the ring; nil removes it.

func (*ProgressRing) SetClass

func (n *ProgressRing) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ProgressRing) SetClasses

func (n *ProgressRing) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ProgressRing) SetCursorName

func (n *ProgressRing) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ProgressRing) SetDebugName

func (n *ProgressRing) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ProgressRing) SetElement

func (n *ProgressRing) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ProgressRing) SetEnabled

func (n *ProgressRing) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ProgressRing) SetFocusOnClick

func (n *ProgressRing) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ProgressRing) SetHAlign

func (n *ProgressRing) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ProgressRing) SetHExpand

func (n *ProgressRing) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ProgressRing) SetID

func (n *ProgressRing) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ProgressRing) SetInlineStyle

func (n *ProgressRing) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ProgressRing) SetInlineStylePriority

func (n *ProgressRing) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ProgressRing) SetLayoutMotion

func (n *ProgressRing) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ProgressRing) SetMargin

func (n *ProgressRing) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ProgressRing) SetMaximumSize

func (n *ProgressRing) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ProgressRing) SetOnClickWithin

func (n *ProgressRing) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ProgressRing) SetOnFocusChanged

func (n *ProgressRing) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ProgressRing) SetOnHoverWithin

func (n *ProgressRing) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ProgressRing) SetOnPointer

func (n *ProgressRing) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ProgressRing) SetOnScroll

func (n *ProgressRing) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ProgressRing) SetSharedElement

func (n *ProgressRing) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ProgressRing) SetSizeRequest

func (n *ProgressRing) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ProgressRing) SetState

func (n *ProgressRing) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ProgressRing) SetTooltip

func (n *ProgressRing) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ProgressRing) SetTooltipMarkup

func (n *ProgressRing) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ProgressRing) SetVAlign

func (n *ProgressRing) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ProgressRing) SetVExpand

func (n *ProgressRing) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ProgressRing) SetValue

func (r *ProgressRing) SetValue(v float64)

SetValue clamps v to [0, 1] and eases the sweep to it.

func (*ProgressRing) SetVisible

func (n *ProgressRing) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ProgressRing) SharedElement

func (n *ProgressRing) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ProgressRing) SizeRequest

func (n *ProgressRing) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ProgressRing) TooltipMarkup

func (n *ProgressRing) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ProgressRing) TooltipText

func (n *ProgressRing) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ProgressRing) VAlign

func (n *ProgressRing) VAlign() Align

VAlign returns the vertical placement.

func (*ProgressRing) Value

func (r *ProgressRing) Value() float64

Value returns the fraction in [0, 1].

func (*ProgressRing) Visible

func (n *ProgressRing) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type RawKeyHandler

type RawKeyHandler interface {
	// RawKey reports whether the press was consumed. code is the
	// evdev keycode, sym its keysym, mods the held modifiers.
	RawKey(code uint32, mods Mods, sym xkb.Keysym) bool
}

RawKeyHandler sees the key presses the action translation does not cover — letters and other keysyms that carry no KeyAction — while its tree holds the keyboard (a popup menu under a grab, say). Returning true consumes the press; a false return hands nothing on (the host decides what, if anything, happens next). Mnemonics and accelerators ride this path.

type RevealTransition

type RevealTransition uint8

RevealTransition is how a Revealer brings its child in and out.

const (
	// RevealNone shows and hides at once; a hidden child takes no space.
	RevealNone RevealTransition = iota
	// RevealFade fades the child's opacity.
	RevealFade
	// RevealSlideUp slides the child in from below, clipped to its slot.
	RevealSlideUp
	// RevealSlideDown slides the child in from above.
	RevealSlideDown
	// RevealSlideLeft slides the child in from the right.
	RevealSlideLeft
	// RevealSlideRight slides the child in from the left.
	RevealSlideRight
	// RevealBounce scales the child up from its center, overshooting,
	// while it fades in.
	RevealBounce
	// RevealZoom scales the child up from its center while it fades in.
	RevealZoom
	// RevealRotate spins the child half a turn while it grows from 30%
	// and fades in.
	RevealRotate
	// RevealFlip widens the child from a vertical line at its center.
	RevealFlip
	// RevealSwingUp swings the child up about its bottom edge.
	RevealSwingUp
	// RevealSwingDown swings the child down about its top edge.
	RevealSwingDown
	// RevealSwingLeft swings the child about its right edge.
	RevealSwingLeft
	// RevealSwingRight swings the child about its left edge.
	RevealSwingRight
	// RevealGenie sucks the child toward the revealer's genie edge.
	RevealGenie
)

type Revealer

type Revealer struct {
	// contains filtered or unexported fields
}

Revealer shows one child through an enter/exit transition: a fade, a slide clipped to the child's slot, or a transformed composite (zoom, bounce, rotate, flip, swing, genie) drawn through an offscreen layer with its opacity. Progress runs linearly in time toward the target; each transition shapes it with its own curve, the bounce overshooting.

Every transition but RevealNone reserves the child's full size for the whole run, hidden included, and moves the child within it, so a content-sized surface keeps its size while a card slides in over its own slot. RevealNone takes no space while hidden.

The child hit-tests at its slot whenever any of it shows; a transform moves pixels, not input.

func NewRevealer

func NewRevealer(child Widget) *Revealer

NewRevealer wraps child hidden, fading over 200ms.

func (*Revealer) AccessibleName

func (n *Revealer) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Revealer) AddClass

func (n *Revealer) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Revealer) Arrange

func (r *Revealer) Arrange(rect render.Rect)

Arrange gives the child the whole rect; a collapsing slide's child keeps its natural extent along the slide, its leading edge on the slot's growing edge.

func (*Revealer) AttachStylesheet

func (n *Revealer) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Revealer) Attr

func (n *Revealer) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Revealer) Bounds

func (n *Revealer) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Revealer) Child

func (r *Revealer) Child() Widget

Child returns the wrapped widget.

func (*Revealer) Children

func (r *Revealer) Children() []Widget

Children exposes the child for damage, focus and accessibility while any of it shows or is being revealed, so keyboard traversal and the accessibility tree skip a hidden revealer's content.

func (*Revealer) Classes

func (n *Revealer) Classes() []string

Classes returns a copy of the widget's classes.

func (*Revealer) Collapse

func (r *Revealer) Collapse() bool

Collapse reports SetCollapse.

func (*Revealer) DebugName

func (n *Revealer) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Revealer) DetachStylesheet

func (n *Revealer) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Revealer) Element

func (n *Revealer) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Revealer) Enabled

func (n *Revealer) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Revealer) Finish

func (r *Revealer) Finish()

Finish lands a running transition at once, reporting it as its end would; with none running it does nothing. It is the escape for a surface that must go now (a shutdown, a test without a clock).

func (*Revealer) HAlign

func (n *Revealer) HAlign() Align

HAlign returns the horizontal placement.

func (*Revealer) HasClass

func (n *Revealer) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Revealer) HasState

func (n *Revealer) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Revealer) HitLeaf

func (n *Revealer) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Revealer) HitTest

func (r *Revealer) HitTest(p Point) Widget

HitTest picks inside the child while any of it shows.

func (*Revealer) HoverWithin

func (n *Revealer) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Revealer) ID

func (n *Revealer) ID() string

ID returns the style id, empty when none is set.

func (*Revealer) InlineStyle

func (n *Revealer) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Revealer) Invalidate

func (n *Revealer) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Revealer) InvalidateLayout

func (n *Revealer) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Revealer) InvalidateRect

func (n *Revealer) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Revealer) LayoutMotion

func (n *Revealer) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Revealer) Margin

func (n *Revealer) Margin() render.Insets

Margin returns the programmatic margin.

func (*Revealer) MaximumSize

func (n *Revealer) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Revealer) Measure

func (r *Revealer) Measure(axis Axis, forSize int) Sizes

Measure is the child's size, nothing for a hidden RevealNone, and for a collapsing slide the child's natural extent along the slide scaled by the eased progress.

func (*Revealer) Paint

func (r *Revealer) Paint(cv *render.Canvas)

Paint draws the child through the transition at its progress.

func (*Revealer) Parent

func (n *Revealer) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Revealer) Progress

func (r *Revealer) Progress() float64

Progress is how far the child is shown, 0 hidden to 1 shown, before the transition's curve.

func (*Revealer) RemoveAttr

func (n *Revealer) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Revealer) RemoveClass

func (n *Revealer) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Revealer) Revealed

func (r *Revealer) Revealed() bool

Revealed reports the target state: true once SetRevealed(true) asked for the child, whether or not the enter has finished.

func (*Revealer) SetAccessibleName

func (n *Revealer) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Revealer) SetAttr

func (n *Revealer) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Revealer) SetClass

func (n *Revealer) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Revealer) SetClasses

func (n *Revealer) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Revealer) SetCollapse

func (r *Revealer) SetCollapse(collapse bool)

SetCollapse makes a slide take space as it shows, the way a GTK revealer does: along the slide's axis the revealer measures the child's natural size scaled by the eased progress, nothing while hidden, and the child keeps its full size, its leading edge riding the slot's growing edge, clipped to the slot. Content below a collapsing revealer moves with it. Only the four slides collapse; the other transitions reserve the child's full size whatever this says.

func (*Revealer) SetCursorName

func (n *Revealer) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Revealer) SetDebugName

func (n *Revealer) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Revealer) SetDuration

func (r *Revealer) SetDuration(d time.Duration)

SetDuration sets the full transition length; zero snaps.

func (*Revealer) SetElement

func (n *Revealer) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Revealer) SetEnabled

func (n *Revealer) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Revealer) SetFocusOnClick

func (n *Revealer) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Revealer) SetGenieEdge

func (r *Revealer) SetGenieEdge(e Edge)

SetGenieEdge picks the edge RevealGenie collapses toward.

func (*Revealer) SetHAlign

func (n *Revealer) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Revealer) SetHExpand

func (n *Revealer) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Revealer) SetID

func (n *Revealer) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Revealer) SetInlineStyle

func (n *Revealer) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Revealer) SetInlineStylePriority

func (n *Revealer) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Revealer) SetLayoutMotion

func (n *Revealer) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Revealer) SetMargin

func (n *Revealer) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Revealer) SetMaximumSize

func (n *Revealer) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Revealer) SetOnClickWithin

func (n *Revealer) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Revealer) SetOnFocusChanged

func (n *Revealer) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Revealer) SetOnHoverWithin

func (n *Revealer) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Revealer) SetOnPointer

func (n *Revealer) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Revealer) SetOnScroll

func (n *Revealer) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Revealer) SetOnTransitionDone

func (r *Revealer) SetOnTransitionDone(fn func(revealed bool))

SetOnTransitionDone runs fn whenever a transition lands, with the state it landed in: the hook for unmapping a surface or dropping a card once its exit has played.

func (*Revealer) SetRevealed

func (r *Revealer) SetRevealed(reveal bool)

SetRevealed starts the transition toward shown or hidden. A reversal mid-flight starts from where the child is and runs the full duration. Asking for the current target changes nothing.

func (*Revealer) SetSharedElement

func (n *Revealer) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Revealer) SetSizeRequest

func (n *Revealer) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Revealer) SetState

func (n *Revealer) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Revealer) SetTooltip

func (n *Revealer) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Revealer) SetTooltipMarkup

func (n *Revealer) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Revealer) SetTransition

func (r *Revealer) SetTransition(t RevealTransition)

SetTransition picks the transition the next reveal or hide plays.

func (*Revealer) SetVAlign

func (n *Revealer) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Revealer) SetVExpand

func (n *Revealer) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Revealer) SetVisible

func (n *Revealer) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Revealer) SharedElement

func (n *Revealer) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Revealer) SizeRequest

func (n *Revealer) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Revealer) TooltipMarkup

func (n *Revealer) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Revealer) TooltipText

func (n *Revealer) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Revealer) Transition

func (r *Revealer) Transition() RevealTransition

Transition returns the transition style.

func (*Revealer) VAlign

func (n *Revealer) VAlign() Align

VAlign returns the vertical placement.

func (*Revealer) Visible

func (n *Revealer) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type RichLabel

type RichLabel struct {

	// OnLinkClick fires when a press-release lands on a link run.
	OnLinkClick func(href string)
	// contains filtered or unexported fields
}

RichLabel paints a single line of styled text driven by the minimal markup subset ParseMarkup accepts; see that function for the grammar and the escaping rules. Input ParseMarkup rejects renders literally, tags and all, so malformed markup can never panic or break a layout.

Text is shaped once per run and drawn on one shared baseline; the line height is the maximum over the runs, so a taller face grows the box instead of misaligning its neighbors. Links (<a href=...>) are opt-in: they underline in the run's color, and installing OnLinkClick makes them clickable with a hand cursor.

func NewRichLabel

func NewRichLabel(face render.Font, sizePx float64, markup string, color render.Color) *RichLabel

NewRichLabel returns a rich label that paints markup with face at sizePx pixels in color. Face may be a render.Chain for mixed-script fallback; it shapes every run until SetVariants provides real variants. The argument order is the toolkit-wide constructor order: face, then sizePx, then the content, then colors. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*RichLabel) AccessibleName

func (n *RichLabel) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*RichLabel) AddClass

func (n *RichLabel) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*RichLabel) Alignment

func (l *RichLabel) Alignment() render.Alignment

Alignment returns the horizontal placement.

func (*RichLabel) Arrange

func (l *RichLabel) Arrange(r render.Rect)

Arrange records the border box inside r, the margin box, and fits the line to the content box's width.

func (*RichLabel) AttachStylesheet

func (n *RichLabel) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*RichLabel) Attr

func (n *RichLabel) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*RichLabel) Bounds

func (n *RichLabel) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*RichLabel) CharsWithin

func (l *RichLabel) CharsWithin(px int) int

CharsWithin is how many approximate character widths fit in px, the max-width-chars that holds the label's natural width to px.

func (*RichLabel) Classes

func (n *RichLabel) Classes() []string

Classes returns a copy of the widget's classes.

func (*RichLabel) ClearSelection

func (l *RichLabel) ClearSelection()

ClearSelection drops the highlight.

func (*RichLabel) ClickAt

func (l *RichLabel) ClickAt(p Point)

ClickAt fires OnLinkClick when the click lands on a link run; a selectable label's plain click drops the selection.

func (*RichLabel) CursorName

func (l *RichLabel) CursorName() string

CursorName asks for the pointing hand while the pointer sits on a link run.

func (*RichLabel) DebugName

func (n *RichLabel) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*RichLabel) DetachStylesheet

func (n *RichLabel) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*RichLabel) Direction

func (l *RichLabel) Direction() Direction

Direction returns the base paragraph direction the line resolves with.

func (*RichLabel) DragMove

func (l *RichLabel) DragMove(p Point)

DragMove extends the drag selection to the pointer.

func (*RichLabel) Element

func (n *RichLabel) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*RichLabel) Ellipsize

func (l *RichLabel) Ellipsize() EllipsizeMode

Ellipsize returns the truncation mode.

func (*RichLabel) Enabled

func (n *RichLabel) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*RichLabel) HAlign

func (n *RichLabel) HAlign() Align

HAlign returns the horizontal placement.

func (*RichLabel) HasClass

func (n *RichLabel) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*RichLabel) HasState

func (n *RichLabel) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*RichLabel) HitLeaf

func (n *RichLabel) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*RichLabel) HitTest

func (l *RichLabel) HitTest(p Point) Widget

HitTest returns the label when p is inside its bounds.

func (*RichLabel) HoverMove

func (l *RichLabel) HoverMove(p Point)

HoverMove records the pointer position for link lookups.

func (*RichLabel) HoverWithin

func (n *RichLabel) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*RichLabel) ID

func (n *RichLabel) ID() string

ID returns the style id, empty when none is set.

func (*RichLabel) InlineStyle

func (n *RichLabel) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*RichLabel) Invalidate

func (n *RichLabel) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*RichLabel) InvalidateLayout

func (n *RichLabel) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*RichLabel) InvalidateRect

func (n *RichLabel) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*RichLabel) LayoutMotion

func (n *RichLabel) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*RichLabel) Margin

func (n *RichLabel) Margin() render.Insets

Margin returns the programmatic margin.

func (*RichLabel) Markup

func (l *RichLabel) Markup() string

Markup returns the current markup string.

func (*RichLabel) MaxLines

func (l *RichLabel) MaxLines() int

MaxLines returns the row cap, 0 for none.

func (*RichLabel) MaxWidthChars

func (l *RichLabel) MaxWidthChars() int

MaxWidthChars returns the natural-width cap in characters, 0 when unset.

func (*RichLabel) MaximumSize

func (n *RichLabel) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*RichLabel) Measure

func (l *RichLabel) Measure(axis Axis, forSize int) Sizes

Measure reports the line inside the CSS box: across its total advance, needing the ellipsis when it ellipsizes, else its widest token when it wraps, else all of it, max-width-chars holding the advance of one that can narrow; down one line height - the maximum over the runs - per row it wraps into at the width given.

func (*RichLabel) Paint

func (l *RichLabel) Paint(cv *render.Canvas)

Paint draws the selection highlight, then each run: its background, its variant face off its baseline shift, its color (a span color wins over the label color, faded by its alpha), and an underline for link runs. Wrap mode lays one row per baseline.

func (*RichLabel) Parent

func (n *RichLabel) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*RichLabel) PressAt

func (l *RichLabel) PressAt(p Point)

PressAt starts a drag selection at the pressed rune. user-select none never starts one; all selects the whole text.

func (*RichLabel) RemoveAttr

func (n *RichLabel) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*RichLabel) RemoveClass

func (n *RichLabel) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*RichLabel) Role

func (l *RichLabel) Role() Role

Role implements Roleer.

func (*RichLabel) Selectable

func (l *RichLabel) Selectable() bool

Selectable reports whether the label takes drag selections.

func (*RichLabel) SelectedText

func (l *RichLabel) SelectedText() (string, bool)

SelectedText is the selected runes and whether any are selected, the copy path's source.

func (*RichLabel) SelectionBands

func (l *RichLabel) SelectionBands(start, end int) []render.Rect

SelectionBands returns the selection rectangles covering runes [start, end) of Text(), in root coordinates: one band per run the range touches, spanning the widget's full height. Rich labels have no editing caret; bands are the whole of their selection geometry.

func (*RichLabel) SetAccessibleName

func (n *RichLabel) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*RichLabel) SetAlignment

func (l *RichLabel) SetAlignment(a render.Alignment)

SetAlignment selects horizontal placement when the arranged rect is wider than the line.

func (*RichLabel) SetAttr

func (n *RichLabel) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*RichLabel) SetClass

func (n *RichLabel) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*RichLabel) SetClasses

func (n *RichLabel) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*RichLabel) SetCursorName

func (n *RichLabel) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*RichLabel) SetDebugName

func (n *RichLabel) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*RichLabel) SetDirection

func (l *RichLabel) SetDirection(d Direction)

SetDirection selects the base paragraph direction the line resolves and lays out with. DirectionAuto (the default) reads it off the line's first strong character; the resolution spans the whole line, so styled spans reorder together. Start/end alignment mirrors with the resolved direction. Changing the direction re-resolves the line and drops the measure cache.

func (*RichLabel) SetElement

func (n *RichLabel) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*RichLabel) SetEllipsize

func (l *RichLabel) SetEllipsize(mode EllipsizeMode)

SetEllipsize sets how a line wider than its box truncates: Start, Middle, or End trade runes for an ellipsis, in the style of the run it stands beside, until the line fits; None (the default) lets it overflow. The natural width stays the whole line's.

func (*RichLabel) SetEnabled

func (n *RichLabel) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*RichLabel) SetFocusOnClick

func (n *RichLabel) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*RichLabel) SetHAlign

func (n *RichLabel) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*RichLabel) SetHExpand

func (n *RichLabel) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*RichLabel) SetHovered

func (l *RichLabel) SetHovered(on bool)

SetHovered forgets the pointer position on leave.

func (*RichLabel) SetID

func (n *RichLabel) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*RichLabel) SetInlineStyle

func (n *RichLabel) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*RichLabel) SetInlineStylePriority

func (n *RichLabel) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*RichLabel) SetLayoutMotion

func (n *RichLabel) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*RichLabel) SetMargin

func (n *RichLabel) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*RichLabel) SetMarkup

func (l *RichLabel) SetMarkup(markup string)

SetMarkup replaces the label markup and invalidates its bounds. Markup ParseMarkup rejects renders literally.

func (*RichLabel) SetMaxLines

func (l *RichLabel) SetMaxLines(n int)

SetMaxLines caps a wrapping, ellipsizing label at n rows: past that the rows merge into the last and the truncation mode ellipsizes it. 0, the default, is no cap.

func (*RichLabel) SetMaxWidthChars

func (l *RichLabel) SetMaxWidthChars(n int)

SetMaxWidthChars caps the label's natural width at n approximate character widths, GTK's max-width-chars: a wrapping label lays its text out wrapped at the cap and asks for its widest row, a single line truncates by the ellipsize mode; a shorter text keeps its own width. n <= 0 removes the cap.

func (*RichLabel) SetMaximumSize

func (n *RichLabel) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*RichLabel) SetOnClickWithin

func (n *RichLabel) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*RichLabel) SetOnFocusChanged

func (n *RichLabel) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*RichLabel) SetOnHoverWithin

func (n *RichLabel) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*RichLabel) SetOnPointer

func (n *RichLabel) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*RichLabel) SetOnScroll

func (n *RichLabel) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*RichLabel) SetSelectable

func (l *RichLabel) SetSelectable(on bool)

SetSelectable lets a press drag a text selection across the label, the readout a user copies; ctrl+c copies it through SelectedText.

func (*RichLabel) SetSelection

func (l *RichLabel) SetSelection(start, end int)

SetSelection highlights the rune range [start, end) of Text(), clamped; an empty range paints nothing.

func (*RichLabel) SetSharedElement

func (n *RichLabel) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*RichLabel) SetSizeRequest

func (n *RichLabel) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*RichLabel) SetState

func (n *RichLabel) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*RichLabel) SetTooltip

func (n *RichLabel) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*RichLabel) SetTooltipMarkup

func (n *RichLabel) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*RichLabel) SetVAlign

func (n *RichLabel) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*RichLabel) SetVExpand

func (n *RichLabel) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*RichLabel) SetVariants

func (l *RichLabel) SetVariants(v VariantFunc)

SetVariants installs the face variants bold and italic runs shape with, and re-shapes the label. Plain runs always shape with the base face.

func (*RichLabel) SetVisible

func (n *RichLabel) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*RichLabel) SetWrap

func (l *RichLabel) SetWrap(on bool)

SetWrap toggles word wrapping at the arranged width: Measure reports the widest wrapped row and one line height per row, and Paint lays the rows out with the alignment. Changing it relayouts.

func (*RichLabel) SharedElement

func (n *RichLabel) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*RichLabel) SizeRequest

func (n *RichLabel) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*RichLabel) Text

func (l *RichLabel) Text() string

Text returns the label's decoded plain text: the concatenated run text, or the raw input when the markup was rejected.

func (*RichLabel) TooltipMarkup

func (n *RichLabel) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*RichLabel) TooltipText

func (n *RichLabel) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*RichLabel) VAlign

func (n *RichLabel) VAlign() Align

VAlign returns the vertical placement.

func (*RichLabel) Visible

func (n *RichLabel) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*RichLabel) Wrap

func (l *RichLabel) Wrap() bool

Wrap reports whether the label wraps at the arranged width.

type Role

type Role uint8

Role classifies a widget for assistive technology. The names follow the AT-SPI roles an out-of-process bridge would translate to, so callers can switch on them without lys-ui gaining a dbus dependency.

const (
	RoleNone Role = iota
	RoleButton
	RoleLabel
	RoleEntry
	RoleTextArea
	RoleSlider
	RoleSwitch
	RoleCheckBox
	RoleProgressBar
	RoleLevelBar
	RoleScrollArea
	RoleList
	RoleMenu
	RoleTabList
	RoleComboBox
	RoleSplitter
	RoleCalendar
	RoleColorChooser
	RoleScrollBar
	// RoleToggleButton is a button that stays pressed (GTK's
	// toggle-button role); A11yState.Pressed carries its state.
	RoleToggleButton
	// RoleAlert is an inline callout assistive technology announces
	// (an Alert).
	RoleAlert
	// RoleChart is a chart, named by a summary of its data.
	RoleChart
)

Semantic roles. RoleNone is zero: layout containers, spacers, and unclassified leaves; the rest name the interactive and text widgets, translated to their AT-SPI names by String.

func RoleOf

func RoleOf(w Widget) Role

RoleOf returns w's role, or RoleNone when w is nil or carries none (plain containers and third-party Widget implementations).

func (Role) String

func (r Role) String() string

String returns the lowercase role name.

type Roleer

type Roleer interface {
	// Role returns the widget's semantic role.
	Role() Role
}

Roleer is implemented by widgets carrying a semantic role.

type Router

type Router struct {
	// Root is the widget tree inputs route through.
	Root Widget
	// contains filtered or unexported fields
}

Router turns pointer and keyboard input into widget state changes: hover tracking, press/release with click detection, drags, scroll bubbling, and focus for keyboard text.

The Router is not safe for concurrent use; call it from the same goroutine that dispatches the wayland connection.

func (*Router) Axis

func (r *Router) Axis(dx, dy float64, mods Mods)

Axis routes vertical and horizontal scrolling to the hovered widget or the nearest ancestor that handles scrolling, mods held. A scroll hook (SetOnScroll) on the way sees the step first and consumes it only when it says so; a disabled ScrollHandler stops the walk: the wheel never scrolls through an inert viewport to an outer one.

func (*Router) AxisEnd

func (r *Router) AxisEnd()

AxisEnd ends a finger scroll: the PixelScroller that took the gesture's pixels hears it (ScrollEnder) even when the pointer has since moved off it.

func (*Router) AxisPixels

func (r *Router) AxisPixels(dx, dy float64, mods Mods)

AxisPixels routes exact scroll deltas like Axis routes steps: to the nearest scrolling widget under the pointer, which takes the pixels when it is a PixelScroller; any other, and a scroll hook on the way, gets whole steps as the pixels add up to them.

func (*Router) BeginDrop added in v0.2.5

func (r *Router) BeginDrop() func(mime string, data []byte, p Point)

BeginDrop clears the hover state and returns what hands the current drop target its payload once the bytes are in: the target stays the one under the drop, whatever drags come through while they travel.

func (*Router) CancelPress

func (r *Router) CancelPress()

CancelPress drops the active press without a click: a gesture that became a data-device drag must not fire the widget on release.

func (*Router) DragAction

func (r *Router) DragAction(offered transfer.Action) transfer.Action

DragAction is the current drop target's pick among offered (DropActionChooser), ActionNone to leave the choice to the default.

func (*Router) DragEnter

func (r *Router) DragEnter(mimes []string, p Point) string

DragEnter routes a drag entering the tree: find the drop target at p, ask it for a decision by mime, and highlight it only when it accepted. Returns the accepted mime ("" rejects).

func (*Router) DragHover

func (r *Router) DragHover(p Point) string

DragHover routes drag movement within the tree. The compositor only sends enter on surface changes, so crossing between targets inside one surface retargets here, with the mimes from the enter.

func (*Router) DragLeave

func (r *Router) DragLeave()

DragLeave clears the drop target after the drag left the surface or ended without a drop.

func (*Router) DragMime

func (r *Router) DragMime() string

DragMime returns the mime the current drop target accepted, empty while nothing is accepted; the payload is fetched for it on drop.

func (*Router) Drop

func (r *Router) Drop(mime string, data []byte, p Point)

Drop delivers the drop to the current drop target and clears the hover state. data carries the payload bytes the app fetched from the offer — or through the same-process shortcut.

func (*Router) FocusNext

func (r *Router) FocusNext()

FocusNext moves focus to the next focusable widget in paint order, wrapping around; with no focus it takes the first.

func (*Router) FocusPrev

func (r *Router) FocusPrev()

FocusPrev moves focus to the previous focusable widget.

func (*Router) Focused

func (r *Router) Focused() Widget

Focused returns the widget receiving keyboard input.

func (*Router) Forget

func (r *Router) Forget(w Widget)

Forget drops every piece of router state that points at w or into w's subtree — the widget-removal counterpart of PointerLost. Hover clears, so no hover shade or tooltip dwell outlives a removed widget; the press is cancelled without a click (its release must never click a ghost); the drop target clears, so a drop cannot land on detached content; and focus — including a focus on a descendant — moves to the next focusable widget in paint order, exactly like focusAfter, or nowhere when none follows. Containers fire this through the removal hook (SetRemovedHook); descent is decided from the parent links the last Arrange recorded, the same bookkeeping markSub walks.

func (*Router) Gesture

func (r *Router) Gesture(g Gesture) bool

Gesture routes g: a Begin (or a long press) goes to the widget under g.At and up its ancestors until one claims it; the rest of the gesture goes to the claimer. It reports whether a widget took it.

func (*Router) Hovered

func (r *Router) Hovered() Widget

Hovered returns the widget currently under the pointer.

func (*Router) KeyAction

func (r *Router) KeyAction(a KeyAction, mods Mods)

KeyAction delivers an editing or activation action to the focused widget — never to one that went disabled since it took focus; see keyboardTarget. An ancestor KeyInterceptor sees the action first (GTK's key controller on a parent), and an ancestor FocusNavigator may move focus instead.

func (*Router) Leave

func (r *Router) Leave()

Leave clears hover state when the pointer leaves the surface.

func (*Router) Move

func (r *Router) Move(p Point)

Move updates hover state and feeds drags and in-widget hover tracking. p is in root coordinates. A hit inside a disabled subtree hovers nothing: an inert control shows no hover shade.

func (*Router) PointerLost

func (r *Router) PointerLost()

PointerLost ends every pointer-derived state because the pointer stopped delivering events: the device went away (wl_seat capability loss) or the compositor ended the grab that kept it here. The active press is cancelled without a click — its release will never arrive — and hover clears, so nothing stays highlighted or half-pressed for a device that is gone.

func (*Router) Press

func (r *Router) Press(button uint32, p Point, mods Mods)

Press records a pointer button press, mods held. p is in root coordinates. A pointer hook (SetOnPointer) sees it first and may consume it. A press on a disabled widget is swallowed whole: no pressed shade, no drag, and no focus move — focus stays where it was, exactly like a press on empty space outside any control leaves a text field alone.

func (*Router) Pressed

func (r *Router) Pressed() Widget

Pressed returns the widget an implicit press is active on, or nil.

func (*Router) Rehover

func (r *Router) Rehover() bool

Rehover re-picks the hovered widget under the resting pointer after a layout moved the tree beneath it (a scroll, a reflow, a removal): hover follows what is under the pointer now, not what was there when it last moved. A press in progress keeps its target. Reports whether the hover changed.

func (*Router) Release

func (r *Router) Release(button uint32, p Point)

Release finishes a press: a release over the pressed widget clicks it — unless the widget was disabled between press and release, in which case the click dies with the gesture.

func (*Router) SelectAll

func (r *Router) SelectAll()

SelectAll asks the focused widget to select its entire content, honoring a disable-during-focus just like KeyAction.

func (*Router) SetFocus

func (r *Router) SetFocus(w Widget) error

SetFocus moves keyboard focus to w, the programmatic counterpart of clicking it: a search entry that should take typing the moment its surface maps is focused this way. A w that cannot take focus fails with ErrNotFocusable and one outside this router's tree with ErrNotInTree, leaving focus where it was; nil clears focus.

func (*Router) Stylus

func (r *Router) Stylus(s Stylus)

Stylus delivers a tablet sample: to the pressed widget's chain while a press is held (a stroke stays with the widget it began on), otherwise the hovered one's, the first StylusHandler up the tree.

func (*Router) Type

func (r *Router) Type(ch rune)

Type delivers a typed character to the focused widget, honoring a disable-during-focus just like KeyAction.

type RouterPointer

type RouterPointer struct{ R *Router }

RouterPointer is TouchPointer straight onto a router: move, left press and release, and a cancelled press. The emulated pointer leaves after a release - a finger does not hover.

func (RouterPointer) TouchCancel

func (p RouterPointer) TouchCancel()

TouchCancel implements TouchPointer.

func (RouterPointer) TouchMove

func (p RouterPointer) TouchMove(at Point)

TouchMove implements TouchPointer.

func (RouterPointer) TouchPress

func (p RouterPointer) TouchPress(at Point)

TouchPress implements TouchPointer.

func (RouterPointer) TouchRelease

func (p RouterPointer) TouchRelease(at Point)

TouchRelease implements TouchPointer.

type RuneHandler

type RuneHandler interface {
	InsertRune(r rune)
}

RuneHandler receives typed characters.

type SchemeStyle

type SchemeStyle struct {
	Color, Background render.Color
	Bold, Italic      bool
}

SchemeStyle is one style of a TextScheme. Zero colors keep what the text would paint with; Bold and Italic shape with the faces SetVariants gives.

type ScreenPick

type ScreenPick struct {

	// OnPick receives the clicked pixel's color.
	OnPick func(render.Color)
	// contains filtered or unexported fields
}

ScreenPick displays one captured screen and reports the pixel color under clicks - the eyedropper's view (#84). The capture arrives as a plain image (the app's capture pipeline grabbed it off the loop), paints scaled to fit, and a click maps back to the exact source pixel, so colors are picked from what the screen really showed. The cursor is a crosshair; the picked color lands in OnPick exactly once per click.

func NewScreenPick

func NewScreenPick(img image.Image) *ScreenPick

NewScreenPick returns a pick view over img, handed over read-only.

func (*ScreenPick) AccessibleName

func (n *ScreenPick) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ScreenPick) AddClass

func (n *ScreenPick) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ScreenPick) Arrange

func (s *ScreenPick) Arrange(r render.Rect)

Arrange records the rect; the drawn fit is computed in Paint from the mapped device rect, the same math every image draw uses.

func (*ScreenPick) AttachStylesheet

func (n *ScreenPick) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ScreenPick) Attr

func (n *ScreenPick) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ScreenPick) Bounds

func (n *ScreenPick) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ScreenPick) Classes

func (n *ScreenPick) Classes() []string

Classes returns a copy of the widget's classes.

func (*ScreenPick) ClickAt

func (s *ScreenPick) ClickAt(p Point)

ClickAt picks the source pixel under the point and hands its color to OnPick. Points in the letterbox clamp to the nearest edge pixel.

func (*ScreenPick) DebugName

func (n *ScreenPick) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ScreenPick) DetachStylesheet

func (n *ScreenPick) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ScreenPick) Element

func (n *ScreenPick) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ScreenPick) Enabled

func (n *ScreenPick) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ScreenPick) HAlign

func (n *ScreenPick) HAlign() Align

HAlign returns the horizontal placement.

func (*ScreenPick) HasClass

func (n *ScreenPick) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ScreenPick) HasState

func (n *ScreenPick) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ScreenPick) HitLeaf

func (n *ScreenPick) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ScreenPick) HitTest

func (s *ScreenPick) HitTest(p Point) Widget

HitTest resolves inside the bounds.

func (*ScreenPick) HoverWithin

func (n *ScreenPick) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ScreenPick) ID

func (n *ScreenPick) ID() string

ID returns the style id, empty when none is set.

func (*ScreenPick) InlineStyle

func (n *ScreenPick) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ScreenPick) Invalidate

func (n *ScreenPick) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ScreenPick) InvalidateLayout

func (n *ScreenPick) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ScreenPick) InvalidateRect

func (n *ScreenPick) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ScreenPick) LayoutMotion

func (n *ScreenPick) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ScreenPick) Margin

func (n *ScreenPick) Margin() render.Insets

Margin returns the programmatic margin.

func (*ScreenPick) MaximumSize

func (n *ScreenPick) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ScreenPick) Measure

func (s *ScreenPick) Measure(axis Axis, forSize int) Sizes

Measure is the image's pictureRequest: the dialog scales it down to fit.

func (*ScreenPick) Paint

func (s *ScreenPick) Paint(cv *render.Canvas)

Paint draws the image scaled to fit, letterboxed inside the bounds.

func (*ScreenPick) Parent

func (n *ScreenPick) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ScreenPick) RemoveAttr

func (n *ScreenPick) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ScreenPick) RemoveClass

func (n *ScreenPick) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ScreenPick) SetAccessibleName

func (n *ScreenPick) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ScreenPick) SetAttr

func (n *ScreenPick) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ScreenPick) SetClass

func (n *ScreenPick) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ScreenPick) SetClasses

func (n *ScreenPick) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ScreenPick) SetCursorName

func (n *ScreenPick) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ScreenPick) SetDebugName

func (n *ScreenPick) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ScreenPick) SetElement

func (n *ScreenPick) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ScreenPick) SetEnabled

func (n *ScreenPick) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ScreenPick) SetFocusOnClick

func (n *ScreenPick) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ScreenPick) SetHAlign

func (n *ScreenPick) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ScreenPick) SetHExpand

func (n *ScreenPick) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ScreenPick) SetID

func (n *ScreenPick) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ScreenPick) SetInlineStyle

func (n *ScreenPick) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ScreenPick) SetInlineStylePriority

func (n *ScreenPick) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ScreenPick) SetLayoutMotion

func (n *ScreenPick) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ScreenPick) SetMargin

func (n *ScreenPick) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ScreenPick) SetMaximumSize

func (n *ScreenPick) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ScreenPick) SetOnClickWithin

func (n *ScreenPick) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ScreenPick) SetOnFocusChanged

func (n *ScreenPick) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ScreenPick) SetOnHoverWithin

func (n *ScreenPick) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ScreenPick) SetOnPointer

func (n *ScreenPick) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ScreenPick) SetOnScroll

func (n *ScreenPick) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ScreenPick) SetSharedElement

func (n *ScreenPick) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ScreenPick) SetSizeRequest

func (n *ScreenPick) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ScreenPick) SetState

func (n *ScreenPick) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ScreenPick) SetTooltip

func (n *ScreenPick) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ScreenPick) SetTooltipMarkup

func (n *ScreenPick) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ScreenPick) SetVAlign

func (n *ScreenPick) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ScreenPick) SetVExpand

func (n *ScreenPick) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ScreenPick) SetVisible

func (n *ScreenPick) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ScreenPick) SharedElement

func (n *ScreenPick) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ScreenPick) SizeRequest

func (n *ScreenPick) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ScreenPick) TooltipMarkup

func (n *ScreenPick) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ScreenPick) TooltipText

func (n *ScreenPick) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ScreenPick) VAlign

func (n *ScreenPick) VAlign() Align

VAlign returns the vertical placement.

func (*ScreenPick) Visible

func (n *ScreenPick) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Scroll

type Scroll struct {

	// ShowBars enables the auto-hiding scrollbar indicators.
	ShowBars bool

	// OnScrolled fires when a wheel, bar drag, or keyboard scroll lands
	// at a NEW offset (same-offset scrolls stay silent). Nil means
	// nobody listens.
	OnScrolled func(x, y int)
	// FillX and FillY stretch a smaller child across the viewport
	// instead of centering it.
	FillX, FillY bool
	// VerticalOnly scrolls up and down only (GTK's hscrollbar-policy
	// never): the child is measured and laid out at the viewport's
	// width, so a wrapping label wraps there instead of at infinity.
	VerticalOnly bool
	// PropagateNaturalWidth (GTK's propagate-natural-width) makes a
	// VerticalOnly scroll ask for its child's natural width; without
	// it the scroll asks for the child's minimum, as GTK's does.
	PropagateNaturalWidth bool
	// PropagateNaturalHeight (GTK's propagate-natural-height): the
	// scroll asks for its content's height, capped by
	// SetMaxContentHeight, giving nothing up to a short parent. Without
	// it, as GTK's, the scroll asks for no height of its own: it takes
	// what its parent gives it (an expanding slot, FillY) and scrolls
	// the rest.
	PropagateNaturalHeight bool
	// contains filtered or unexported fields
}

Scroll embeds a child larger than the viewport and shifts it by an offset. With ShowBars, overflowing axes reserve a scrollbar gutter; the bars fade in on hover or scrolling and out after a dwell, drag 1:1, and gutter clicks page. A child smaller than the viewport is centered, or stretched along an axis when the matching Fill flag is set.

func NewScroll

func NewScroll(child Widget) *Scroll

NewScroll wraps child in a scrollable viewport.

func (*Scroll) AccessibleName

func (n *Scroll) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Scroll) AddClass

func (n *Scroll) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Scroll) Arrange

func (s *Scroll) Arrange(r render.Rect)

Arrange pins the viewport to r, reserving a gutter for each overflowing axis that shows a bar, and places the child at the negative offset: stretched across the viewport when Fill is set and the child is smaller, centered when it is smaller without fill, otherwise at its natural size shifted by the offset.

func (*Scroll) ArrangeRoot

func (s *Scroll) ArrangeRoot(r render.Rect)

ArrangeRoot records the viewport rect.

func (*Scroll) AttachStylesheet

func (n *Scroll) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Scroll) Attr

func (n *Scroll) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Scroll) AxisRange

func (s *Scroll) AxisRange(axis Axis) ScrollRange

AxisRange implements Adjustable: the offset, the visible extent, and the content's extent along axis.

func (*Scroll) Bounds

func (n *Scroll) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Scroll) Children

func (s *Scroll) Children() []Widget

Children exposes the wrapped child for focus traversal; an empty scroll (SetChild(nil)) exposes none.

func (*Scroll) Classes

func (n *Scroll) Classes() []string

Classes returns a copy of the widget's classes.

func (*Scroll) ClickAt

func (s *Scroll) ClickAt(p Point)

ClickAt implements Clicker: a gutter press above or below (or left or right of) a handle pages by one viewport; the first DragMove of such a press would have grabbed the handle instead. A click on a handle without motion does nothing. Disabled scrolls ignore clicks.

func (*Scroll) DebugName

func (n *Scroll) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Scroll) DetachStylesheet

func (n *Scroll) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Scroll) DragMove

func (s *Scroll) DragMove(p Point)

DragMove implements DragMover. The first call inside a scrollbar track grabs that handle (recording the press position and offset); later calls map pointer motion 1:1 onto content motion through the viewport-to-track ratio. Outside the tracks this is content drugging of the wrapped child, which the child handles. Disabled scrolls ignore drags.

func (*Scroll) Element

func (n *Scroll) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Scroll) Enabled

func (n *Scroll) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Scroll) HAlign

func (n *Scroll) HAlign() Align

HAlign returns the horizontal placement.

func (*Scroll) HasClass

func (n *Scroll) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Scroll) HasState

func (n *Scroll) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Scroll) HitLeaf

func (n *Scroll) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Scroll) HitTest

func (s *Scroll) HitTest(p Point) Widget

HitTest returns the widget under p: the shown scrollbars belong to the scroll itself (a press there drags or pages, never hits content), the child's bounds already carry the scroll offset so hit-testing through a scrolled viewport lands on the right content, and anything else inside the bounds is the scroll.

func (*Scroll) HoverWithin

func (n *Scroll) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Scroll) ID

func (n *Scroll) ID() string

ID returns the style id, empty when none is set.

func (*Scroll) InlineStyle

func (n *Scroll) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Scroll) Invalidate

func (n *Scroll) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Scroll) InvalidateLayout

func (n *Scroll) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Scroll) InvalidateRect

func (n *Scroll) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Scroll) LayoutMotion

func (n *Scroll) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Scroll) Margin

func (n *Scroll) Margin() render.Insets

Margin returns the programmatic margin.

func (*Scroll) MaxContentHeight

func (s *Scroll) MaxContentHeight() int

MaxContentHeight is the cap SetMaxContentHeight set, 0 for none.

func (*Scroll) MaximumSize

func (n *Scroll) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Scroll) Measure

func (s *Scroll) Measure(axis Axis, forSize int) Sizes

Measure reports the scroll's request inside its CSS box. Across, a scroll that pans sideways asks for its child's natural width and needs none; a VerticalOnly one needs its child's minimum and asks for it too, or for the natural width under PropagateNaturalWidth (GTK's never policy). Down, it asks for nothing of its own unless PropagateNaturalHeight, then for its child's height up to the SetMaxContentHeight cap, needing only scrollFloor: a short parent gets the rest back and the scroll scrolls it.

func (*Scroll) Offset

func (s *Scroll) Offset() (int, int)

Offset returns the current scroll offset.

func (*Scroll) Paint

func (s *Scroll) Paint(cv *render.Canvas)

Paint clips to the viewport, paints the shifted child, and draws the auto-hiding bars in their gutters at the current fade alpha.

func (*Scroll) Parent

func (n *Scroll) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Scroll) RemoveAttr

func (n *Scroll) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Scroll) RemoveClass

func (n *Scroll) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Scroll) Role

func (s *Scroll) Role() Role

Role implements Roleer.

func (*Scroll) ScrollBy

func (s *Scroll) ScrollBy(dx, dy int)

ScrollBy shifts the offset by dx, dy wheel steps and shows the bars. A step is GTK's wheel scroll: the visible extent raised to 2/3 (a taller page scrolls further per notch), at least one pixel. A disabled scroll does not scroll.

func (*Scroll) ScrollEnd

func (s *Scroll) ScrollEnd()

ScrollEnd implements ScrollEnder: the fingers lifted, so the content glides on from the gesture's velocity, and the glow fades once the motion is over.

func (*Scroll) ScrollPixels

func (s *Scroll) ScrollPixels(dx, dy float64)

ScrollPixels implements PixelScroller: exact deltas, the fraction kept for the next one so slow finger motion still moves. The deltas feed the kinetic glide, and pushing past an end builds the edge glow.

func (*Scroll) SetAccessibleName

func (n *Scroll) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Scroll) SetAttr

func (n *Scroll) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Scroll) SetAxisOffset

func (s *Scroll) SetAxisOffset(axis Axis, offset int)

SetAxisOffset implements Adjustable.

func (*Scroll) SetChild

func (s *Scroll) SetChild(child Widget)

SetChild replaces the wrapped child. The old child detaches like any removal — parent link cleared, removal hook fired — and the scroll forgets the old content's position: offsets reset to the top-left (new content keeps no memory of the old scroll) and any bar drag ends. Re-setting the current child is a no-op. nil clears the content: an empty scroll measures empty, paints nothing, and hit tests as itself.

func (*Scroll) SetClass

func (n *Scroll) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Scroll) SetClasses

func (n *Scroll) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Scroll) SetCursorName

func (n *Scroll) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Scroll) SetDebugName

func (n *Scroll) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Scroll) SetElement

func (n *Scroll) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Scroll) SetEnabled

func (s *Scroll) SetEnabled(enabled bool)

SetEnabled turns the viewport and everything inside it on or off through the per-query enable walk, like Box. A disabled scroll ignores wheel, bar drags, and gutter clicks; its child is disabled with it.

func (*Scroll) SetFocusOnClick

func (n *Scroll) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Scroll) SetHAlign

func (n *Scroll) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Scroll) SetHExpand

func (n *Scroll) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Scroll) SetHovered

func (s *Scroll) SetHovered(on bool)

SetHovered implements HoverSetter: entering shows the bars, leaving starts the dwell before they fade. Hovering itself paints nothing; the fade tweens invalidate the gutter strips as alpha moves.

func (*Scroll) SetID

func (n *Scroll) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Scroll) SetInlineStyle

func (n *Scroll) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Scroll) SetInlineStylePriority

func (n *Scroll) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Scroll) SetLayoutMotion

func (n *Scroll) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Scroll) SetMargin

func (n *Scroll) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Scroll) SetMaxContentHeight

func (s *Scroll) SetMaxContentHeight(h int)

SetMaxContentHeight caps the height the scroll asks for (GTK's max-content-height) and turns PropagateNaturalHeight on, the only height a cap applies to: up to h it is as tall as its content, past it h tall and scrolling. 0 is no cap; a negative h is 0.

func (*Scroll) SetMaximumSize

func (n *Scroll) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Scroll) SetOffset

func (s *Scroll) SetOffset(x, y int)

SetOffset scrolls to x, y, clamped so the child never leaves the viewport (overshoot clamps). A child smaller than the viewport stays pinned at 0. The next Arrange moves the content and owes the damage.

func (*Scroll) SetOnClickWithin

func (n *Scroll) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Scroll) SetOnFocusChanged

func (n *Scroll) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Scroll) SetOnHoverWithin

func (n *Scroll) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Scroll) SetOnPointer

func (n *Scroll) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Scroll) SetOnScroll

func (n *Scroll) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Scroll) SetPressed

func (s *Scroll) SetPressed(on bool)

SetPressed implements PressSetter: ending the press ends any drag.

func (*Scroll) SetSharedElement

func (n *Scroll) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Scroll) SetSizeRequest

func (n *Scroll) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Scroll) SetState

func (n *Scroll) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Scroll) SetTooltip

func (n *Scroll) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Scroll) SetTooltipMarkup

func (n *Scroll) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Scroll) SetVAlign

func (n *Scroll) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Scroll) SetVExpand

func (n *Scroll) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Scroll) SetVisible

func (n *Scroll) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Scroll) SharedElement

func (n *Scroll) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Scroll) SizeRequest

func (n *Scroll) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Scroll) TooltipMarkup

func (n *Scroll) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Scroll) TooltipText

func (n *Scroll) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Scroll) VAlign

func (n *Scroll) VAlign() Align

VAlign returns the vertical placement.

func (*Scroll) Visible

func (n *Scroll) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*Scroll) WatchRange

func (s *Scroll) WatchRange(fn func())

WatchRange implements Adjustable.

type ScrollEnder

type ScrollEnder interface {
	ScrollEnd()
}

ScrollEnder is a PixelScroller told when a finger scroll ends (the fingers lifted): Scroll glides on from the gesture's velocity.

type ScrollEvent

type ScrollEvent struct {
	DX, DY int
	// Mods are the keyboard modifiers held.
	Mods Mods
	// At is where the pointer rests, in root coordinates.
	At Point
}

ScrollEvent is a wheel step as a hook sees it, in ScrollBy's steps: DY positive downward, DX positive rightward.

type ScrollHandler

type ScrollHandler interface {
	ScrollBy(dx, dy int)
}

ScrollHandler receives scroll deltas in 40px steps: dx from the horizontal axis (tilt wheels, trackpads), dy from the vertical.

type ScrollMove added in v0.2.5

type ScrollMove struct {
	View   render.Rect
	DX, DY int
}

ScrollMove is a viewport whose pixels moved by DX, DY as they stand: a frame can copy them there instead of painting them, and owes only what the move exposed, which the damage holds. All in logical pixels.

func CollectFrameDamageInto added in v0.2.5

func CollectFrameDamageInto(buf []render.Rect, moves []ScrollMove, root Widget) (rects []render.Rect, outMoves []ScrollMove, any bool)

CollectFrameDamageInto is CollectDamageInto for a frame that can copy pixels: a viewport that only scrolled reports a ScrollMove, reusing moves' storage, and owes only what the move exposed.

type ScrollRange

type ScrollRange struct{ Offset, Page, Total int }

ScrollRange is one axis of a scroll position (GTK Adjustment's numbers): Offset into a Total extent, of which Page is visible. The bar geometry and the drag and page arithmetic live here once, for Scroll's own bars and the standalone Scrollbar alike.

func (ScrollRange) Max

func (r ScrollRange) Max() int

Max is the largest offset.

func (ScrollRange) Overflows

func (r ScrollRange) Overflows() bool

Overflows reports whether there is anything to scroll.

type Scrollbar

type Scrollbar struct {
	// contains filtered or unexported fields
}

Scrollbar is a standalone, always-visible bar bound to an Adjustable (GTK Scrollbar): the thumb tracks the target's range, dragging it scrolls 1:1, and a track click pages. It draws nothing while the target does not overflow. Place it beside the scrolled widget; the target's own auto-hiding bars are independent of it.

func NewScrollbar

func NewScrollbar(target Adjustable, axis Axis) *Scrollbar

NewScrollbar returns a bar driving target along axis (Row for a horizontal bar, Column for a vertical one).

func (*Scrollbar) AccessibleName

func (n *Scrollbar) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Scrollbar) AddClass

func (n *Scrollbar) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Scrollbar) Arrange

func (n *Scrollbar) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Scrollbar) AttachStylesheet

func (n *Scrollbar) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Scrollbar) Attr

func (n *Scrollbar) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Scrollbar) Axis

func (b *Scrollbar) Axis() Axis

Axis reports the bar's orientation.

func (*Scrollbar) Bounds

func (n *Scrollbar) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Scrollbar) Classes

func (n *Scrollbar) Classes() []string

Classes returns a copy of the widget's classes.

func (*Scrollbar) ClickAt

func (b *Scrollbar) ClickAt(p Point)

ClickAt pages toward a track click; the release ending a thumb drag is not a click.

func (*Scrollbar) DebugName

func (n *Scrollbar) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Scrollbar) DetachStylesheet

func (n *Scrollbar) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Scrollbar) DragMove

func (b *Scrollbar) DragMove(p Point)

DragMove scrolls the grabbed thumb with the pointer.

func (*Scrollbar) Element

func (n *Scrollbar) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Scrollbar) Enabled

func (n *Scrollbar) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Scrollbar) HAlign

func (n *Scrollbar) HAlign() Align

HAlign returns the horizontal placement.

func (*Scrollbar) HasClass

func (n *Scrollbar) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Scrollbar) HasState

func (n *Scrollbar) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Scrollbar) HitLeaf

func (n *Scrollbar) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Scrollbar) HitTest

func (b *Scrollbar) HitTest(p Point) Widget

HitTest implements Widget: the whole strip is the bar.

func (*Scrollbar) HoverWithin

func (n *Scrollbar) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Scrollbar) ID

func (n *Scrollbar) ID() string

ID returns the style id, empty when none is set.

func (*Scrollbar) InlineStyle

func (n *Scrollbar) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Scrollbar) Invalidate

func (n *Scrollbar) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Scrollbar) InvalidateLayout

func (n *Scrollbar) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Scrollbar) InvalidateRect

func (n *Scrollbar) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Scrollbar) LayoutMotion

func (n *Scrollbar) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Scrollbar) Margin

func (n *Scrollbar) Margin() render.Insets

Margin returns the programmatic margin.

func (*Scrollbar) MaximumSize

func (n *Scrollbar) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Scrollbar) Measure

func (b *Scrollbar) Measure(axis Axis, forSize int) Sizes

Measure is the bar's thickness across its axis; along it the bar takes what its parent stretches it to. scrollbar-width: none collapses it, thin keeps the slot and paints slimmer.

func (*Scrollbar) Paint

func (b *Scrollbar) Paint(cv *render.Canvas)

Paint draws the track and thumb while the target overflows.

func (*Scrollbar) Parent

func (n *Scrollbar) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Scrollbar) PressAt

func (b *Scrollbar) PressAt(p Point)

PressAt grabs the thumb under p.

func (*Scrollbar) PressEnd

func (b *Scrollbar) PressEnd()

PressEnd releases the thumb.

func (*Scrollbar) RemoveAttr

func (n *Scrollbar) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Scrollbar) RemoveClass

func (n *Scrollbar) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Scrollbar) Role

func (b *Scrollbar) Role() Role

Role implements Roleer.

func (*Scrollbar) SetAccessibleName

func (n *Scrollbar) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Scrollbar) SetAttr

func (n *Scrollbar) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Scrollbar) SetClass

func (n *Scrollbar) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Scrollbar) SetClasses

func (n *Scrollbar) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Scrollbar) SetCursorName

func (n *Scrollbar) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Scrollbar) SetDebugName

func (n *Scrollbar) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Scrollbar) SetElement

func (n *Scrollbar) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Scrollbar) SetEnabled

func (n *Scrollbar) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Scrollbar) SetFocusOnClick

func (n *Scrollbar) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Scrollbar) SetHAlign

func (n *Scrollbar) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Scrollbar) SetHExpand

func (n *Scrollbar) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Scrollbar) SetID

func (n *Scrollbar) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Scrollbar) SetInlineStyle

func (n *Scrollbar) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Scrollbar) SetInlineStylePriority

func (n *Scrollbar) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Scrollbar) SetLayoutMotion

func (n *Scrollbar) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Scrollbar) SetMargin

func (n *Scrollbar) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Scrollbar) SetMaximumSize

func (n *Scrollbar) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Scrollbar) SetOnClickWithin

func (n *Scrollbar) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Scrollbar) SetOnFocusChanged

func (n *Scrollbar) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Scrollbar) SetOnHoverWithin

func (n *Scrollbar) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Scrollbar) SetOnPointer

func (n *Scrollbar) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Scrollbar) SetOnScroll

func (n *Scrollbar) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Scrollbar) SetSharedElement

func (n *Scrollbar) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Scrollbar) SetSizeRequest

func (n *Scrollbar) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Scrollbar) SetState

func (n *Scrollbar) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Scrollbar) SetTooltip

func (n *Scrollbar) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Scrollbar) SetTooltipMarkup

func (n *Scrollbar) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Scrollbar) SetVAlign

func (n *Scrollbar) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Scrollbar) SetVExpand

func (n *Scrollbar) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Scrollbar) SetVisible

func (n *Scrollbar) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Scrollbar) SharedElement

func (n *Scrollbar) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Scrollbar) SizeRequest

func (n *Scrollbar) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Scrollbar) TooltipMarkup

func (n *Scrollbar) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Scrollbar) TooltipText

func (n *Scrollbar) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Scrollbar) VAlign

func (n *Scrollbar) VAlign() Align

VAlign returns the vertical placement.

func (*Scrollbar) Visible

func (n *Scrollbar) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SearchBar struct {
	// contains filtered or unexported fields
}

SearchBar is the slide-down search container: a SearchEntry (the accessor returns it wired for focus) inside a Revealer that slides in from the top, keyed by SetSearchMode - the state an accel or the app's shortcut handling flips. The key capture itself stays the app's (accel groups, OnKey); the bar owns only the reveal.

func NewSearchBar

func NewSearchBar(face render.Font, sizePx float64) *SearchBar

NewSearchBar returns a hidden bar with an empty search field; call Entry().SetPlaceholder on it for hint text.

func (*SearchBar) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*SearchBar) Baseline

func (c *SearchBar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*SearchBar) Children

func (c *SearchBar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*SearchBar) Entry

func (b *SearchBar) Entry() *SearchEntry

Entry returns the bar's search field.

func (*SearchBar) HitTest

func (c *SearchBar) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*SearchBar) Measure

func (c *SearchBar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*SearchBar) Paint

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

Paint draws the surface (when configured) then the root.

func (*SearchBar) SearchMode

func (b *SearchBar) SearchMode() bool

SearchMode reports whether the bar is showing.

func (*SearchBar) SetSearchMode

func (b *SearchBar) SetSearchMode(on bool)

SetSearchMode reveals or hides the bar; revealing keeps whatever text the field held.

type SearchEntry

type SearchEntry struct {
	*Entry

	// OnSearchChanged fires with the settled text - the delayed signal
	// a search wants, so a fast typist triggers one search, not one
	// per keystroke.
	OnSearchChanged func(text string)
	// contains filtered or unexported fields
}

SearchEntry is the search preset over Entry: a leading search icon, a clear button while text exists, Esc clearing (an empty field passes Esc on), and OnSearchChanged - the delayed search-changed signal, fired once typing settles for the delay (SetDelay tunes it, zero fires synchronously). The entry's whole public surface rides along through the embedded field; wire the app's search to OnSearchChanged, not OnChanged.

func NewSearchEntry

func NewSearchEntry(face render.Font, sizePx float64, placeholder string) *SearchEntry

NewSearchEntry returns a search field with an optional placeholder.

func (SearchEntry) AccessibleName

func (n SearchEntry) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (SearchEntry) AddClass

func (n SearchEntry) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (SearchEntry) AttachStylesheet

func (n SearchEntry) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (SearchEntry) Attr

func (n SearchEntry) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (SearchEntry) Bounds

func (n SearchEntry) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (SearchEntry) Classes

func (n SearchEntry) Classes() []string

Classes returns a copy of the widget's classes.

func (SearchEntry) DebugName

func (n SearchEntry) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (SearchEntry) DetachStylesheet

func (n SearchEntry) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (SearchEntry) Element

func (n SearchEntry) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (SearchEntry) Enabled

func (n SearchEntry) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (SearchEntry) HAlign

func (n SearchEntry) HAlign() Align

HAlign returns the horizontal placement.

func (SearchEntry) HasClass

func (n SearchEntry) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (SearchEntry) HasState

func (n SearchEntry) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (SearchEntry) HitLeaf

func (n SearchEntry) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (SearchEntry) HoverWithin

func (n SearchEntry) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (SearchEntry) ID

func (n SearchEntry) ID() string

ID returns the style id, empty when none is set.

func (SearchEntry) InlineStyle

func (n SearchEntry) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (SearchEntry) Invalidate

func (n SearchEntry) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (SearchEntry) InvalidateLayout

func (n SearchEntry) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (SearchEntry) InvalidateRect

func (n SearchEntry) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (SearchEntry) LayoutMotion

func (n SearchEntry) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (SearchEntry) Margin

func (n SearchEntry) Margin() render.Insets

Margin returns the programmatic margin.

func (SearchEntry) MaximumSize

func (n SearchEntry) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (SearchEntry) Parent

func (n SearchEntry) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (SearchEntry) RemoveAttr

func (n SearchEntry) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (SearchEntry) RemoveClass

func (n SearchEntry) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (SearchEntry) SetAccessibleName

func (n SearchEntry) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (SearchEntry) SetAttr

func (n SearchEntry) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (SearchEntry) SetClass

func (n SearchEntry) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (SearchEntry) SetClasses

func (n SearchEntry) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (SearchEntry) SetCursorName

func (n SearchEntry) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (SearchEntry) SetDebugName

func (n SearchEntry) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*SearchEntry) SetDelay

func (s *SearchEntry) SetDelay(d time.Duration)

SetDelay tunes the search-changed settle time; zero fires synchronously with every change.

func (SearchEntry) SetElement

func (n SearchEntry) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (SearchEntry) SetEnabled

func (n SearchEntry) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (SearchEntry) SetFocusOnClick

func (n SearchEntry) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (SearchEntry) SetHAlign

func (n SearchEntry) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (SearchEntry) SetHExpand

func (n SearchEntry) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (SearchEntry) SetID

func (n SearchEntry) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (SearchEntry) SetInlineStyle

func (n SearchEntry) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (SearchEntry) SetInlineStylePriority

func (n SearchEntry) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (SearchEntry) SetLayoutMotion

func (n SearchEntry) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (SearchEntry) SetMargin

func (n SearchEntry) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (SearchEntry) SetMaximumSize

func (n SearchEntry) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (SearchEntry) SetOnClickWithin

func (n SearchEntry) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (SearchEntry) SetOnFocusChanged

func (n SearchEntry) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (SearchEntry) SetOnHoverWithin

func (n SearchEntry) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (SearchEntry) SetOnPointer

func (n SearchEntry) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (SearchEntry) SetOnScroll

func (n SearchEntry) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (SearchEntry) SetSharedElement

func (n SearchEntry) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (SearchEntry) SetSizeRequest

func (n SearchEntry) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (SearchEntry) SetState

func (n SearchEntry) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (SearchEntry) SetTooltip

func (n SearchEntry) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (SearchEntry) SetTooltipMarkup

func (n SearchEntry) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (SearchEntry) SetVAlign

func (n SearchEntry) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (SearchEntry) SetVExpand

func (n SearchEntry) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (SearchEntry) SetVisible

func (n SearchEntry) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (SearchEntry) SharedElement

func (n SearchEntry) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (SearchEntry) SizeRequest

func (n SearchEntry) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (SearchEntry) TooltipMarkup

func (n SearchEntry) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (SearchEntry) TooltipText

func (n SearchEntry) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (SearchEntry) VAlign

func (n SearchEntry) VAlign() Align

VAlign returns the vertical placement.

func (SearchEntry) Visible

func (n SearchEntry) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SegmentDrop added in v0.2.3

type SegmentDrop struct {
	// contains filtered or unexported fields
}

SegmentDrop is a SegmentIndicator's one travelling indicator, painted behind the segments as the indicator element under segments. It rests on the active segment's box. On a switch its leading edges spring ahead and its trailing edges follow, so it stretches towards the target, travels there and settles as one shape, along whichever axis the segments stack. It shows nothing while no segment is active, and it appears and goes at once, without travelling. Under reduced motion or a theme without animations it lands on the target at once.

func (*SegmentDrop) HitTest added in v0.2.3

func (*SegmentDrop) HitTest(Point) Widget

func (*SegmentDrop) Measure added in v0.2.3

func (*SegmentDrop) Measure(axis Axis, forSize int) Sizes

func (*SegmentDrop) Moving added in v0.2.3

func (d *SegmentDrop) Moving() bool

Moving reports whether the indicator is in flight. A settled or hidden indicator is not, and schedules no frame.

func (*SegmentDrop) Paint added in v0.2.3

func (*SegmentDrop) Paint(*render.Canvas)

type SegmentIndicator

type SegmentIndicator struct {

	// OnSelect hears a clicked segment's index.
	OnSelect func(i int)
	// contains filtered or unexported fields
}

SegmentIndicator is a row of segments, one per workspace or page: the active one drawn long and filled, occupied and urgent ones in their theme colours. A segment can hold content (SetSegmentContent), centred in it, and Segment reaches its button. A click on a segment reports it through OnSelect. In a vertical bar the segments stack. It styles as the segments element, each segment a button.segment with the active, occupied and urgent classes. EnableDrop adds one indicator that travels between the segments behind them.

func NewSegmentIndicator

func NewSegmentIndicator(n int) *SegmentIndicator

NewSegmentIndicator returns n empty segments, none active.

func (*SegmentIndicator) Active

func (s *SegmentIndicator) Active() int

Active is the active segment, -1 for none.

func (*SegmentIndicator) Arrange

func (s *SegmentIndicator) Arrange(r render.Rect)

Arrange lays the segments out, then settles an enabled drop on what their boxes now are.

func (*SegmentIndicator) Baseline

func (c *SegmentIndicator) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*SegmentIndicator) Children

func (c *SegmentIndicator) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*SegmentIndicator) Count

func (s *SegmentIndicator) Count() int

Count is the number of segments.

func (*SegmentIndicator) EnableDrop added in v0.2.3

func (s *SegmentIndicator) EnableDrop() *SegmentDrop

EnableDrop gives the row its one travelling indicator and returns it, for its classes and inline style. The stylesheet draws it: the indicator element takes any box the segments would, and without a rule it paints nothing. A row that never calls this keeps no animation state.

func (*SegmentIndicator) HitTest

func (c *SegmentIndicator) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*SegmentIndicator) Measure

func (s *SegmentIndicator) Measure(axis Axis, forSize int) Sizes

Measure stacks the segments in a vertical bar, then measures them.

func (*SegmentIndicator) Paint

func (s *SegmentIndicator) Paint(cv *render.Canvas)

Paint draws the row's box, an enabled drop on it, and the segments over the drop.

func (*SegmentIndicator) Segment

func (s *SegmentIndicator) Segment(i int) *Button

Segment is segment i's button, nil out of range: for its classes, inline style, tooltip, and its SetOnPointer and SetOnScroll for the other buttons and the wheel.

func (*SegmentIndicator) SetActive

func (s *SegmentIndicator) SetActive(i int)

SetActive makes segment i the active one; out of range, none is. An enabled drop travels there from where it is.

func (*SegmentIndicator) SetCount

func (s *SegmentIndicator) SetCount(n int)

SetCount keeps n segments, the states of those kept.

func (*SegmentIndicator) SetSegmentContent

func (s *SegmentIndicator) SetSegmentContent(i int, w Widget)

SetSegmentContent shows w inside segment i (a label, app icons), nil for none; out of range does nothing.

func (*SegmentIndicator) SetSegmentState

func (s *SegmentIndicator) SetSegmentState(i int, st SegmentState)

SetSegmentState marks segment i empty or occupied; out of range does nothing.

func (*SegmentIndicator) SetSegmentUrgent

func (s *SegmentIndicator) SetSegmentUrgent(i int, urgent bool)

SetSegmentUrgent marks segment i as asking for attention or not, whatever its state; out of range does nothing.

func (*SegmentIndicator) ShiftActive added in v0.2.3

func (s *SegmentIndicator) ShiftActive(i int)

ShiftActive is SetActive for the same item at a new index, after segments before it came or went: it starts no travel for an enabled drop, which stays on the item, and it leaves one already under way or still owed to the next frame alone.

type SegmentState

type SegmentState uint8

SegmentState marks a segment of a SegmentIndicator.

const (
	SegmentEmpty SegmentState = iota
	// SegmentOccupied is a segment with something in it, a workspace
	// with windows.
	SegmentOccupied
)

The segment states.

type SelectAller

type SelectAller interface {
	SelectAll()
}

SelectAller clears or sets a full selection on the focused widget.

type SelectedTexter

type SelectedTexter interface {
	// SelectedText returns the selected text and whether a non-empty
	// selection exists.
	SelectedText() (string, bool)
}

SelectedTexter exposes the widget's active selection.

type SelectionMode

type SelectionMode uint8

SelectionMode is how pointer and keyboard gestures turn into a selected row set on a List.

const (
	// SelectionSingle keeps zero or one selected row: a click or a
	// plain motion key selects exactly that row, Enter activates it.
	// The zero value, so a List is single-select unless told otherwise.
	SelectionSingle SelectionMode = iota
	// SelectionNone ignores every selection gesture and Select call;
	// rows keep only their own widget behavior. Keyboard selection
	// keys do nothing.
	SelectionNone
	// SelectionBrowse is single-select that never sits empty once it
	// has selected: pointer motion over a row selects it (focus
	// follows the pointer, GTK's browse mode) and gestures cannot
	// clear the selection, only move it.
	SelectionBrowse
	// SelectionMultiple keeps any set of rows. Clicks toggle rows,
	// drags rubber-band select, shift+arrows extend from the anchor,
	// ctrl+arrows move the keyboard cursor without selecting,
	// ctrl+space toggles the cursor row, ctrl+a selects everything.
	SelectionMultiple
)

type Separator

type Separator struct {
	// contains filtered or unexported fields
}

Separator is the standalone one-pixel theme rule: horizontal between stacked rows, vertical between side-by-side panes. Menus paint the same rule inline for their ItemSeparator rows; layouts reach for this widget. The natural size is one pixel square along both axes — boxes stretch the cross axis, and expand stretches the main axis — and the rule paints through whatever it was allocated.

func NewSeparator

func NewSeparator(orientation Orientation) *Separator

NewSeparator returns a separator along orientation.

func (*Separator) AccessibleName

func (n *Separator) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Separator) AddClass

func (n *Separator) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Separator) Arrange

func (n *Separator) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Separator) AttachStylesheet

func (n *Separator) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Separator) Attr

func (n *Separator) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Separator) Bounds

func (n *Separator) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Separator) Classes

func (n *Separator) Classes() []string

Classes returns a copy of the widget's classes.

func (*Separator) DebugName

func (n *Separator) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Separator) DetachStylesheet

func (n *Separator) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Separator) Element

func (n *Separator) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Separator) Enabled

func (n *Separator) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Separator) HAlign

func (n *Separator) HAlign() Align

HAlign returns the horizontal placement.

func (*Separator) HasClass

func (n *Separator) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Separator) HasState

func (n *Separator) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Separator) HitLeaf

func (n *Separator) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Separator) HitTest

func (s *Separator) HitTest(p Point) Widget

HitTest returns the separator when p is inside its bounds.

func (*Separator) HoverWithin

func (n *Separator) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Separator) ID

func (n *Separator) ID() string

ID returns the style id, empty when none is set.

func (*Separator) InlineStyle

func (n *Separator) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Separator) Invalidate

func (n *Separator) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Separator) InvalidateLayout

func (n *Separator) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Separator) InvalidateRect

func (n *Separator) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Separator) LayoutMotion

func (n *Separator) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Separator) Margin

func (n *Separator) Margin() render.Insets

Margin returns the programmatic margin.

func (*Separator) MaximumSize

func (n *Separator) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Separator) Measure

func (s *Separator) Measure(axis Axis, forSize int) Sizes

Measure wants one pixel; allocation decides the rest.

func (*Separator) Orientation

func (s *Separator) Orientation() Orientation

Orientation returns the axis the rule runs along.

func (*Separator) Paint

func (s *Separator) Paint(cv *render.Canvas)

Paint draws the rule centered in the allocated rect, in the theme border color menus use for their inline separators.

func (*Separator) Parent

func (n *Separator) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Separator) RemoveAttr

func (n *Separator) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Separator) RemoveClass

func (n *Separator) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Separator) SetAccessibleName

func (n *Separator) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Separator) SetAttr

func (n *Separator) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Separator) SetClass

func (n *Separator) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Separator) SetClasses

func (n *Separator) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Separator) SetCursorName

func (n *Separator) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Separator) SetDebugName

func (n *Separator) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Separator) SetElement

func (n *Separator) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Separator) SetEnabled

func (n *Separator) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Separator) SetFocusOnClick

func (n *Separator) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Separator) SetHAlign

func (n *Separator) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Separator) SetHExpand

func (n *Separator) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Separator) SetID

func (n *Separator) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Separator) SetInlineStyle

func (n *Separator) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Separator) SetInlineStylePriority

func (n *Separator) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Separator) SetLayoutMotion

func (n *Separator) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Separator) SetMargin

func (n *Separator) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Separator) SetMaximumSize

func (n *Separator) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Separator) SetOnClickWithin

func (n *Separator) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Separator) SetOnFocusChanged

func (n *Separator) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Separator) SetOnHoverWithin

func (n *Separator) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Separator) SetOnPointer

func (n *Separator) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Separator) SetOnScroll

func (n *Separator) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Separator) SetSharedElement

func (n *Separator) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Separator) SetSizeRequest

func (n *Separator) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Separator) SetState

func (n *Separator) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Separator) SetTooltip

func (n *Separator) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Separator) SetTooltipMarkup

func (n *Separator) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Separator) SetVAlign

func (n *Separator) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Separator) SetVExpand

func (n *Separator) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Separator) SetVisible

func (n *Separator) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Separator) SharedElement

func (n *Separator) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Separator) SizeRequest

func (n *Separator) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Separator) TooltipMarkup

func (n *Separator) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Separator) TooltipText

func (n *Separator) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Separator) VAlign

func (n *Separator) VAlign() Align

VAlign returns the vertical placement.

func (*Separator) Visible

func (n *Separator) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Sheet

type Sheet struct {

	// OnClosed fires when a close finished sliding out, whatever
	// caused it.
	OnClosed func()
	// contains filtered or unexported fields
}

Sheet is a panel over content (and adw's BottomSheet as NewBottomSheet): SetOpen slides the panel in from its side over a dimmed backdrop. A click on the backdrop and Escape close it, and while it is open Tab stays inside the panel. A bottom sheet carries a grab handle: dragging it down past a third of the sheet dismisses it, a shorter drag springs back. Side and top sheets take an optional header (SetHeader), footer (SetFooter) and a close button. It styles as the `sheet` element; the panel as `.sheet-panel`, its header's .title and .description.

func NewBottomSheet

func NewBottomSheet(content, sheet Widget) *Sheet

NewBottomSheet returns a closed sheet sliding sheet up from the bottom over content, with the grab handle (adw BottomSheet).

func NewSheet

func NewSheet(content, body Widget, side SheetSide) *Sheet

NewSheet returns a closed sheet sliding body in from side over content.

func (*Sheet) Arrange

func (s *Sheet) Arrange(r render.Rect)

Arrange lays the content over the whole rect and the panel where the slide and the drag put it: each animation frame relayouts the sheet.

func (*Sheet) Baseline

func (c *Sheet) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Sheet) Children

func (s *Sheet) Children() []Widget

Children is the content and, while showing, the panel: focus traversal, damage and the accessibility tree reach the panel's widgets.

func (*Sheet) ClickAt

func (s *Sheet) ClickAt(p Point)

ClickAt closes on a click on the backdrop.

func (*Sheet) Content

func (s *Sheet) Content() Widget

Content returns the widget the sheet slides over.

func (*Sheet) DragMove

func (s *Sheet) DragMove(p Point)

DragMove follows a downward drag.

func (*Sheet) FocusTrap

func (s *Sheet) FocusTrap() Widget

FocusTrap implements FocusTrapper: while open, Tab stays in the panel.

func (*Sheet) HitTest

func (s *Sheet) HitTest(p Point) Widget

HitTest resolves into the panel while the sheet shows (the backdrop and a bottom sheet's handle are the sheet itself), else into the content.

func (*Sheet) InterceptKey

func (s *Sheet) InterceptKey(_ Widget, a KeyAction, _ Mods) bool

InterceptKey implements KeyInterceptor: Escape anywhere in the open sheet closes it.

func (*Sheet) KeyAction

func (s *Sheet) KeyAction(a KeyAction, _ Mods)

KeyAction closes on Escape while the sheet itself has the focus.

func (*Sheet) Measure

func (c *Sheet) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Sheet) Open

func (s *Sheet) Open() bool

Open reports whether the sheet is open (or opening).

func (*Sheet) Paint

func (s *Sheet) Paint(cv *render.Canvas)

Paint draws the content, then - while showing - the dimmed backdrop, the panel's surface (a bottom sheet's with its handle) and the panel.

func (*Sheet) PressAt

func (s *Sheet) PressAt(p Point)

PressAt begins a drag on a bottom sheet's handle strip.

func (*Sheet) PressEnd

func (s *Sheet) PressEnd()

PressEnd dismisses past a third of the sheet's height, else springs back.

func (*Sheet) SetFooter

func (s *Sheet) SetFooter(w Widget)

SetFooter puts w (the actions, typically) under the body.

func (*Sheet) SetHeader

func (s *Sheet) SetHeader(face render.Font, title, description string)

SetHeader puts a title and a description above the body, with a close button at the panel's corner.

func (*Sheet) SetOpen

func (s *Sheet) SetOpen(on bool)

SetOpen slides the sheet in or out.

func (*Sheet) SetWidth

func (s *Sheet) SetWidth(w int)

SetWidth sets a side sheet's widest, still at most three quarters of the widget.

func (*Sheet) Side

func (s *Sheet) Side() SheetSide

Side returns the edge the sheet slides in from.

type SheetSide

type SheetSide uint8

SheetSide is the edge a Sheet slides in from.

const (
	// SheetRight slides in from the right edge.
	SheetRight SheetSide = iota
	// SheetLeft slides in from the left edge.
	SheetLeft
	// SheetTop slides down from the top edge.
	SheetTop
	// SheetBottom slides up from the bottom edge.
	SheetBottom
)

The sheet sides.

type ShortcutItem

type ShortcutItem struct {
	Title string
	Keys  string
}

ShortcutItem is one shortcut: what it does, and its keys in the accelerator label form ("Ctrl+Shift+P", a chord "Ctrl+X Ctrl+S").

type ShortcutSection

type ShortcutSection struct {
	Title string
	Items []ShortcutItem
}

ShortcutSection is one titled group of a shortcuts overview.

type ShortcutsView

type ShortcutsView struct {
	*PreferencesPage
}

ShortcutsView is the shortcuts overview (GTK ShortcutsWindow, adw ShortcutsDialog's content): a scrolling page of boxed groups, one per section, each shortcut a row with its title and keycaps. Fill it from the application's accelerator registry (app.Application.ShortcutsDialog does) or from any data.

func NewShortcutsView

func NewShortcutsView(face render.Font, sections []ShortcutSection) *ShortcutsView

NewShortcutsView builds the overview of sections.

func (ShortcutsView) Baseline

func (c ShortcutsView) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (ShortcutsView) Children

func (c ShortcutsView) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (ShortcutsView) HitTest

func (c ShortcutsView) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (ShortcutsView) Measure

func (c ShortcutsView) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (ShortcutsView) Paint

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

Paint draws the surface (when configured) then the root.

type Sidebar struct {

	// OnWidthChanged fires with the expanded width after a drag
	// resized it, for the app to keep.
	OnWidthChanged func(width int)
	// contains filtered or unexported fields
}

Sidebar is an application sidebar beside content: a header, groups of items with icons, badges and submenus, and a footer. On a wide window it docks beside the content and Toggle collapses it - off canvas or to an icon rail - with a slide; below its narrow width it hides and Toggle opens it as a sheet over the content. Picking an item makes it the active one. Bind ToggleAction to Ctrl+B with an accelerator; the Trigger button toggles it too. It styles as the `sidebar` element: the .panel, .group-label labels, button.item rows (:checked while active), .badge labels and .sub submenus.

func NewSidebar

func NewSidebar(face render.Font, content Widget) *Sidebar

NewSidebar returns an expanded sidebar beside content, collapsing off canvas.

func (*Sidebar) AddCollapsibleGroup

func (s *Sidebar) AddCollapsibleGroup(label string, open bool, items ...SidebarItem)

AddCollapsibleGroup appends a group whose label folds its items (a collapsible group): clicking the label, or its chevron, shows and hides them, open to start with when open.

func (*Sidebar) AddGroup

func (s *Sidebar) AddGroup(label string, items ...SidebarItem)

AddGroup appends a group of items under label ("" for none).

func (*Sidebar) Arrange

func (s *Sidebar) Arrange(r render.Rect)

Arrange evaluates the narrow breakpoint against the width, then lays the sidebar out.

func (*Sidebar) Baseline

func (c *Sidebar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Sidebar) Children

func (c *Sidebar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Sidebar) CursorName

func (s *Sidebar) CursorName() string

CursorName is the resize cursor over the handle.

func (*Sidebar) DragMove

func (s *Sidebar) DragMove(p Point)

DragMove resizes the panel with the pointer, within the bounds.

func (*Sidebar) Expanded

func (s *Sidebar) Expanded() bool

Expanded reports whether the docked sidebar is expanded.

func (*Sidebar) HitTest

func (s *Sidebar) HitTest(p Point) Widget

HitTest takes the resize handle itself, and otherwise the panel and content as laid out.

func (*Sidebar) Measure

func (c *Sidebar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Sidebar) Narrow

func (s *Sidebar) Narrow() bool

Narrow reports the sidebar off canvas below the narrow width.

func (*Sidebar) Paint

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

Paint draws the surface (when configured) then the root.

func (*Sidebar) PressAt

func (s *Sidebar) PressAt(p Point)

PressAt starts a resize on the handle.

func (*Sidebar) PressEnd

func (s *Sidebar) PressEnd()

PressEnd ends a resize, reporting the new width.

func (*Sidebar) SetActive

func (s *Sidebar) SetActive(id string) bool

SetActive makes the item called id (its ID, else its Label) the active one, as a click would without running it, and shows it: its submenu and its collapsed group open. It reports whether an item has that id.

func (*Sidebar) SetCollapse

func (s *Sidebar) SetCollapse(c SidebarCollapse)

SetCollapse picks how a wide sidebar collapses.

func (*Sidebar) SetExpanded

func (s *Sidebar) SetExpanded(on bool)

SetExpanded expands or collapses the docked sidebar with a slide; a SidebarNone sidebar stays expanded.

func (*Sidebar) SetFooter

func (s *Sidebar) SetFooter(w Widget)

SetFooter puts w at the panel's bottom.

func (*Sidebar) SetHeader

func (s *Sidebar) SetHeader(w Widget)

SetHeader puts w at the panel's top.

func (*Sidebar) SetNarrowWidth

func (s *Sidebar) SetNarrowWidth(w int)

SetNarrowWidth moves the breakpoint below which the sidebar is off canvas (768px by default): the sidebar measures its own width, so one inside a narrower region of a wide window wants a lower one.

func (*Sidebar) SetResizable

func (s *Sidebar) SetResizable(min, max int)

SetResizable lets the user drag the docked panel's edge to resize it between min and max pixels (OnWidthChanged reports the result); a zero max turns it off.

func (*Sidebar) SetWidth

func (s *Sidebar) SetWidth(px int)

SetWidth sets the expanded width, 256px by default.

func (*Sidebar) Toggle

func (s *Sidebar) Toggle()

Toggle collapses or expands the docked sidebar, or below the narrow width opens or closes it over the content.

func (*Sidebar) ToggleAction

func (s *Sidebar) ToggleAction() Activatable

ToggleAction is Toggle as an action, for an accelerator (Ctrl+B, say).

func (*Sidebar) Trigger

func (s *Sidebar) Trigger() *Button

Trigger returns the button that toggles the sidebar, for the content's header.

func (*Sidebar) Width

func (s *Sidebar) Width() int

Width returns the expanded width.

type SidebarCollapse

type SidebarCollapse uint8

SidebarCollapse is how a Sidebar collapses on a wide window.

const (
	// SidebarOffcanvas slides the sidebar away entirely.
	SidebarOffcanvas SidebarCollapse = iota
	// SidebarIcon narrows it to a rail of the items' icons.
	SidebarIcon
	// SidebarNone keeps it expanded.
	SidebarNone
)

The collapse modes.

type SidebarItem

type SidebarItem struct {
	Label string
	// ID names the item for SetActive; empty uses its Label.
	ID string
	// Icon leads the row and is what the icon rail shows; nil shows
	// none.
	Icon Widget
	// Badge is a count or a note at the row's end; "" shows none.
	Badge string
	// Active marks the item as the current page.
	Active bool
	// OnActivate runs when the item is picked.
	OnActivate func()
	// Items are a submenu, shown under the item as it is toggled open.
	Items []SidebarItem
}

SidebarItem is one entry of a Sidebar group.

type Size

type Size struct {
	W, H int
}

Size is a width and height in pixels.

func LayoutShownSize

func LayoutShownSize(w Widget) (Size, bool)

LayoutShownSize is the size w is shown at and whether it animates its layout: mid-motion the size its spring paints it at, else its laid-out size. A surface sized from its content (a popover shrinking) keeps its size until that is the content's new size, so the content springs down inside it before the surface follows.

func SizeWithin

func SizeWithin(w Widget, avail Size) Size

SizeWithin is the size w takes in a host that offers at most avail: its natural width capped to avail.W, then its natural height for that width capped to avail.H, neither below its minimum. A window sizes its root with it, a popover its content. The result exceeds avail where the widget's minimum does: w overflows rather than squeezing below what it needs.

func SizeWithinAsChild

func SizeWithinAsChild(w Widget, avail Size) Size

SizeWithinAsChild is SizeWithin for w measured as a child: a host sizing a tree's top by MeasureAsChild.

func (Size) Along

func (s Size) Along(a Axis) int

Along is s's extent along a: its width along a Row, its height down a Column.

type SizeGroup

type SizeGroup struct {
	// contains filtered or unexported fields
}

SizeGroup makes widgets in different containers measure alike (GTK SizeGroup): every member requests the largest natural size of the group along the mode's axes - labels in separate rows line up. Add returns the wrapper to place in the tree in the member's stead; a member's size change relayouts every peer.

func NewSizeGroup

func NewSizeGroup(mode SizeGroupMode) *SizeGroup

NewSizeGroup returns an empty group equalizing mode's axes.

func (*SizeGroup) Add

func (g *SizeGroup) Add(w Widget) Widget

Add joins w and returns the wrapper to place in the tree.

type SizeGroupMode

type SizeGroupMode uint8

SizeGroupMode picks the axes a SizeGroup equalizes.

const (
	// SizeGroupHorizontal equalizes widths.
	SizeGroupHorizontal SizeGroupMode = 1 << iota
	// SizeGroupVertical equalizes heights.
	SizeGroupVertical
	// SizeGroupBoth equalizes both.
	SizeGroupBoth = SizeGroupHorizontal | SizeGroupVertical
)

type Sizes

type Sizes struct {
	Min, Nat int
}

Sizes is a widget's size request along one axis, GTK's minimum and natural size: Min is the least it lays out at without clipping or overflowing what it shows, Nat the size it wants. 0 <= Min <= Nat.

func FixedSizes

func FixedSizes(n int) Sizes

FixedSizes is a request that wants exactly n: a widget of one size along an axis.

func MeasureAsChild

func MeasureAsChild(w Widget, axis Axis, forSize int) Sizes

MeasureAsChild measures w as a container measures its child: its size request, programmatic margin and CSS sizes apply. A host that owns a tree's top (a popover around its content) measures through it so the top's own size request counts, as GTK honors a popover's.

func (Sizes) Within

func (s Sizes) Within(n int) int

Within is n held to the request: never below Min, never above Nat.

type SliceModel

type SliceModel[T any] []T

SliceModel adapts a slice as a ColumnModel.

func (SliceModel[T]) Len

func (s SliceModel[T]) Len() int

Len implements ColumnModel.

func (SliceModel[T]) Row

func (s SliceModel[T]) Row(i int) T

Row implements ColumnModel.

type Slider

type Slider struct {

	// Pressed reports whether a drag is in progress.
	Pressed bool

	// OnChanged fires after every value change, including programmatic
	// ones.
	OnChanged func(v float64)
	// contains filtered or unexported fields
}

Slider is a slider over [min, max] with an optional step, horizontal by default; SetAxis(Column) stands it up (GTK's orientation), the minimum at the top unless inverted (GTK's inverted, the volume-style minimum at the bottom). Pressing warps the value to the pointer and a drag follows it.

It is GtkScale's node tree: `scale` (its box, opacity, outline, and :hover while the pointer is over it) holding `trough` (background, radius, min-height, and min-width as the natural width) holding `highlight` (the filled part) and `slider` (the knob: background, radius, min size, opacity, box-shadow). Unstyled it keeps the theme's 4px trough and 14px knob. The scale carries .horizontal or .vertical; across a vertical scale the trough's min-width is its thickness and min-height its length.

func NewSlider

func NewSlider(min, max, step, value float64) *Slider

NewSlider returns a horizontal slider over [min, max] at value, with changes snapped to step (0 disables snapping). The pointer turns to the hand over it, the way wayle's slider primitives ask.

func (*Slider) AccessibleName

func (n *Slider) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Slider) AddClass

func (n *Slider) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Slider) Arrange

func (n *Slider) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Slider) AttachStylesheet

func (n *Slider) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Slider) Attr

func (n *Slider) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Slider) Axis

func (s *Slider) Axis() Axis

Axis reports the orientation.

func (*Slider) BindValue

func (s *Slider) BindValue(b *Binding[float64]) (unbind func())

BindValue wires the binding two-way to the slider's value. SetValue clamps and snaps, and fires OnChanged only when the shown value moved, so a binding value off-grid settles on the snapped one without looping.

func (*Slider) Bounds

func (n *Slider) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Slider) Classes

func (n *Slider) Classes() []string

Classes returns a copy of the widget's classes.

func (*Slider) DebugName

func (n *Slider) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Slider) DetachStylesheet

func (n *Slider) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Slider) DragMove

func (s *Slider) DragMove(p Point)

DragMove sets the value from the pointer position while pressed. Disabled sliders ignore the drag.

func (*Slider) Element

func (n *Slider) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Slider) Enabled

func (n *Slider) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Slider) HAlign

func (n *Slider) HAlign() Align

HAlign returns the horizontal placement.

func (*Slider) HasClass

func (n *Slider) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Slider) HasState

func (n *Slider) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Slider) HitLeaf

func (n *Slider) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Slider) HitTest

func (s *Slider) HitTest(p Point) Widget

HitTest returns the slider when p is inside its bounds.

func (*Slider) HoverWithin

func (n *Slider) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Slider) ID

func (n *Slider) ID() string

ID returns the style id, empty when none is set.

func (*Slider) InlineStyle

func (n *Slider) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Slider) Invalidate

func (n *Slider) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Slider) InvalidateLayout

func (n *Slider) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Slider) InvalidateRect

func (n *Slider) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Slider) Inverted

func (s *Slider) Inverted() bool

Inverted reports whether the minimum is at the far end.

func (*Slider) KeyAction

func (s *Slider) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler: arrows nudge the value by one step (or a tenth of the range without one), Home and End jump. Disabled sliders ignore keys.

func (*Slider) LayoutMotion

func (n *Slider) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Slider) Margin

func (n *Slider) Margin() render.Insets

Margin returns the programmatic margin.

func (*Slider) MaximumSize

func (n *Slider) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Slider) Measure

func (s *Slider) Measure(axis Axis, forSize int) Sizes

Measure wants the trough's length (200px unstyled) by the thicker of the trough and the knob, at least 18px, inside the scale's box.

func (*Slider) Paint

func (s *Slider) Paint(cv *render.Canvas)

Paint draws the trough, its highlight, and the knob, each from its node's style over the theme's colors. Disabled, the theme colors fade through the derived disabled colors (a stylesheet fades with its own :disabled rules).

func (*Slider) Parent

func (n *Slider) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Slider) PressAt

func (s *Slider) PressAt(p Point)

PressAt implements PressAter: the value warps to the press, and a drag carries on from there (GTK's primary-button warp). Disabled sliders ignore it.

func (*Slider) RemoveAttr

func (n *Slider) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Slider) RemoveClass

func (n *Slider) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Slider) Role

func (s *Slider) Role() Role

Role implements Roleer.

func (*Slider) SetAccessibleName

func (n *Slider) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Slider) SetAttr

func (n *Slider) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Slider) SetAxis

func (s *Slider) SetAxis(axis Axis)

SetAxis orients the slider: Row horizontal, Column vertical.

func (*Slider) SetClass

func (n *Slider) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Slider) SetClasses

func (n *Slider) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Slider) SetCursorName

func (n *Slider) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Slider) SetDebugName

func (n *Slider) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Slider) SetElement

func (n *Slider) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Slider) SetEnabled

func (n *Slider) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Slider) SetFocusOnClick

func (n *Slider) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Slider) SetHAlign

func (n *Slider) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Slider) SetHExpand

func (n *Slider) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Slider) SetHovered

func (s *Slider) SetHovered(on bool)

SetHovered implements HoverSetter: `scale:hover` restyles the trough and knob (a knob shown only on hover).

func (*Slider) SetID

func (n *Slider) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Slider) SetInlineStyle

func (n *Slider) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Slider) SetInlineStylePriority

func (n *Slider) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Slider) SetInverted

func (s *Slider) SetInverted(on bool)

SetInverted puts the minimum at the far end: the right of a horizontal slider, the bottom of a vertical one.

func (*Slider) SetLayoutMotion

func (n *Slider) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Slider) SetMargin

func (n *Slider) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Slider) SetMaximumSize

func (n *Slider) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Slider) SetOnClickWithin

func (n *Slider) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Slider) SetOnFocusChanged

func (n *Slider) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Slider) SetOnHoverWithin

func (n *Slider) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Slider) SetOnPointer

func (n *Slider) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Slider) SetOnScroll

func (n *Slider) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Slider) SetPressed

func (s *Slider) SetPressed(on bool)

SetPressed implements PressSetter; the trough brightens while dragging.

func (*Slider) SetSharedElement

func (n *Slider) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Slider) SetSizeRequest

func (n *Slider) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Slider) SetState

func (n *Slider) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Slider) SetTooltip

func (n *Slider) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Slider) SetTooltipMarkup

func (n *Slider) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Slider) SetVAlign

func (n *Slider) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Slider) SetVExpand

func (n *Slider) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Slider) SetValue

func (s *Slider) SetValue(v float64)

SetValue clamps v to [min, max], snaps it to step, and fires OnChanged when it moved.

func (*Slider) SetVisible

func (n *Slider) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Slider) SharedElement

func (n *Slider) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Slider) SizeRequest

func (n *Slider) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Slider) TooltipMarkup

func (n *Slider) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Slider) TooltipText

func (n *Slider) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Slider) VAlign

func (n *Slider) VAlign() Align

VAlign returns the vertical placement.

func (*Slider) Value

func (s *Slider) Value() float64

Value returns the current value.

func (*Slider) ValueAt

func (s *Slider) ValueAt(p Point) float64

ValueAt maps a point across the trough to a value (an unstyled trough is inset 4px each end so the extremes are reachable).

func (*Slider) Visible

func (n *Slider) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Spacer

type Spacer struct {
	// contains filtered or unexported fields
}

Spacer is empty layout space of a fixed size.

func NewSpacer

func NewSpacer(w, h int) *Spacer

NewSpacer returns a spacer wanting w x h.

func (*Spacer) AccessibleName

func (n *Spacer) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Spacer) AddClass

func (n *Spacer) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Spacer) Arrange

func (n *Spacer) Arrange(r render.Rect)

Arrange records the widget's rect. A rect that moved or resized from the previous frame also invalidates the old pixels, so partial damage does not leave the widget's old paint behind.

func (*Spacer) AttachStylesheet

func (n *Spacer) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Spacer) Attr

func (n *Spacer) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Spacer) Bounds

func (n *Spacer) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Spacer) Classes

func (n *Spacer) Classes() []string

Classes returns a copy of the widget's classes.

func (*Spacer) DebugName

func (n *Spacer) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Spacer) DetachStylesheet

func (n *Spacer) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Spacer) Element

func (n *Spacer) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Spacer) Enabled

func (n *Spacer) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Spacer) HAlign

func (n *Spacer) HAlign() Align

HAlign returns the horizontal placement.

func (*Spacer) HasClass

func (n *Spacer) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Spacer) HasState

func (n *Spacer) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Spacer) HitLeaf

func (n *Spacer) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Spacer) HitTest

func (s *Spacer) HitTest(Point) Widget

HitTest returns nil: empty space is not interactive.

func (*Spacer) HoverWithin

func (n *Spacer) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Spacer) ID

func (n *Spacer) ID() string

ID returns the style id, empty when none is set.

func (*Spacer) InlineStyle

func (n *Spacer) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Spacer) Invalidate

func (n *Spacer) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Spacer) InvalidateLayout

func (n *Spacer) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Spacer) InvalidateRect

func (n *Spacer) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Spacer) LayoutMotion

func (n *Spacer) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Spacer) Margin

func (n *Spacer) Margin() render.Insets

Margin returns the programmatic margin.

func (*Spacer) MaximumSize

func (n *Spacer) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Spacer) Measure

func (s *Spacer) Measure(axis Axis, forSize int) Sizes

Measure returns the spacer's size.

func (*Spacer) Paint

func (s *Spacer) Paint(*render.Canvas)

Paint paints nothing.

func (*Spacer) Parent

func (n *Spacer) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Spacer) RemoveAttr

func (n *Spacer) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Spacer) RemoveClass

func (n *Spacer) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Spacer) SetAccessibleName

func (n *Spacer) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Spacer) SetAttr

func (n *Spacer) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Spacer) SetClass

func (n *Spacer) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Spacer) SetClasses

func (n *Spacer) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Spacer) SetCursorName

func (n *Spacer) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Spacer) SetDebugName

func (n *Spacer) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Spacer) SetElement

func (n *Spacer) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Spacer) SetEnabled

func (n *Spacer) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Spacer) SetFocusOnClick

func (n *Spacer) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Spacer) SetHAlign

func (n *Spacer) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Spacer) SetHExpand

func (n *Spacer) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Spacer) SetID

func (n *Spacer) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Spacer) SetInlineStyle

func (n *Spacer) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Spacer) SetInlineStylePriority

func (n *Spacer) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Spacer) SetLayoutMotion

func (n *Spacer) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Spacer) SetMargin

func (n *Spacer) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Spacer) SetMaximumSize

func (n *Spacer) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Spacer) SetOnClickWithin

func (n *Spacer) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Spacer) SetOnFocusChanged

func (n *Spacer) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Spacer) SetOnHoverWithin

func (n *Spacer) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Spacer) SetOnPointer

func (n *Spacer) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Spacer) SetOnScroll

func (n *Spacer) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Spacer) SetSharedElement

func (n *Spacer) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Spacer) SetSizeRequest

func (n *Spacer) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Spacer) SetState

func (n *Spacer) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Spacer) SetTooltip

func (n *Spacer) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Spacer) SetTooltipMarkup

func (n *Spacer) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Spacer) SetVAlign

func (n *Spacer) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Spacer) SetVExpand

func (n *Spacer) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Spacer) SetVisible

func (n *Spacer) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Spacer) SharedElement

func (n *Spacer) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Spacer) SizeRequest

func (n *Spacer) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Spacer) TooltipMarkup

func (n *Spacer) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Spacer) TooltipText

func (n *Spacer) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Spacer) VAlign

func (n *Spacer) VAlign() Align

VAlign returns the vertical placement.

func (*Spacer) Visible

func (n *Spacer) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SpinButton

type SpinButton struct {
	*Entry

	// OnValueChanged fires when the user changed the value: a step
	// or a commit that moved it. SetValue does not fire it, so a
	// caller mirroring an external value never echoes it back.
	OnValueChanged func(v float64)
	// contains filtered or unexported fields
}

SpinButton is a numeric entry, GtkSpinButton: the text shows the value at Digits decimals; the drawn up/down steppers at its end and the Up and Down keys step it by Step, PageUp and PageDown by ten steps; Enter, or focus leaving the entry, commits the typed text. A commit clamps into [Min, Max] and rounds to Digits; text that does not parse as a number reverts to the value.

The value changes only through those paths and SetValue; the text between commits is the entry's own.

func NewSpinButton

func NewSpinButton(face render.Font, sizePx float64, color render.Color, min, max, step float64, digits int) *SpinButton

NewSpinButton returns a spin button over [min, max] stepping by step (a step ≤ 0 is 1), showing digits decimals, starting at min.

func (SpinButton) AccessibleName

func (n SpinButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (SpinButton) AddClass

func (n SpinButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (SpinButton) AttachStylesheet

func (n SpinButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (SpinButton) Attr

func (n SpinButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*SpinButton) BindValue

func (s *SpinButton) BindValue(b *Binding[float64]) (unbind func())

BindValue wires the binding two-way to the spin button's value. SetValue is silent - only user edits fire OnValueChanged - so the programmatic apply never echoes.

func (SpinButton) Bounds

func (n SpinButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (SpinButton) Classes

func (n SpinButton) Classes() []string

Classes returns a copy of the widget's classes.

func (SpinButton) DebugName

func (n SpinButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (SpinButton) DetachStylesheet

func (n SpinButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (SpinButton) Element

func (n SpinButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (SpinButton) Enabled

func (n SpinButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (SpinButton) HAlign

func (n SpinButton) HAlign() Align

HAlign returns the horizontal placement.

func (SpinButton) HasClass

func (n SpinButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (SpinButton) HasState

func (n SpinButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (SpinButton) HitLeaf

func (n SpinButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (SpinButton) HoverWithin

func (n SpinButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (SpinButton) ID

func (n SpinButton) ID() string

ID returns the style id, empty when none is set.

func (SpinButton) InlineStyle

func (n SpinButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (SpinButton) Invalidate

func (n SpinButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (SpinButton) InvalidateLayout

func (n SpinButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (SpinButton) InvalidateRect

func (n SpinButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*SpinButton) KeyAction

func (s *SpinButton) KeyAction(a KeyAction, mods Mods)

KeyAction steps on Up/Down and PageUp/PageDown; every other key edits the text.

func (SpinButton) LayoutMotion

func (n SpinButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (SpinButton) Margin

func (n SpinButton) Margin() render.Insets

Margin returns the programmatic margin.

func (SpinButton) MaximumSize

func (n SpinButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (SpinButton) Parent

func (n SpinButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*SpinButton) Range

func (s *SpinButton) Range() (min, max float64)

Range reports the bounds.

func (SpinButton) RemoveAttr

func (n SpinButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (SpinButton) RemoveClass

func (n SpinButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (SpinButton) SetAccessibleName

func (n SpinButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (SpinButton) SetAttr

func (n SpinButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (SpinButton) SetClass

func (n SpinButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (SpinButton) SetClasses

func (n SpinButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (SpinButton) SetCursorName

func (n SpinButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (SpinButton) SetDebugName

func (n SpinButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*SpinButton) SetDigits

func (s *SpinButton) SetDigits(digits int)

SetDigits changes the shown decimals, re-rounding the value (silently, like SetValue).

func (SpinButton) SetElement

func (n SpinButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (SpinButton) SetEnabled

func (n SpinButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (SpinButton) SetFocusOnClick

func (n SpinButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (SpinButton) SetHAlign

func (n SpinButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (SpinButton) SetHExpand

func (n SpinButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (SpinButton) SetID

func (n SpinButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (SpinButton) SetInlineStyle

func (n SpinButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (SpinButton) SetInlineStylePriority

func (n SpinButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (SpinButton) SetLayoutMotion

func (n SpinButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (SpinButton) SetMargin

func (n SpinButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (SpinButton) SetMaximumSize

func (n SpinButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (SpinButton) SetOnClickWithin

func (n SpinButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (SpinButton) SetOnFocusChanged

func (n SpinButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (SpinButton) SetOnHoverWithin

func (n SpinButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (SpinButton) SetOnPointer

func (n SpinButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (SpinButton) SetOnScroll

func (n SpinButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*SpinButton) SetRange

func (s *SpinButton) SetRange(min, max float64)

SetRange changes the bounds, re-clamping the value (silently, like SetValue).

func (SpinButton) SetSharedElement

func (n SpinButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (SpinButton) SetSizeRequest

func (n SpinButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (SpinButton) SetState

func (n SpinButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*SpinButton) SetStep

func (s *SpinButton) SetStep(step float64)

SetStep changes how far a key steps (a step ≤ 0 is 1).

func (SpinButton) SetTooltip

func (n SpinButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (SpinButton) SetTooltipMarkup

func (n SpinButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (SpinButton) SetVAlign

func (n SpinButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (SpinButton) SetVExpand

func (n SpinButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*SpinButton) SetValue

func (s *SpinButton) SetValue(v float64)

SetValue sets the value (clamped, rounded) and shows it, discarding uncommitted text; it does not fire OnValueChanged.

func (SpinButton) SetVisible

func (n SpinButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (SpinButton) SharedElement

func (n SpinButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (SpinButton) SizeRequest

func (n SpinButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (SpinButton) TooltipMarkup

func (n SpinButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (SpinButton) TooltipText

func (n SpinButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (SpinButton) VAlign

func (n SpinButton) VAlign() Align

VAlign returns the vertical placement.

func (*SpinButton) Value

func (s *SpinButton) Value() float64

Value reports the committed value.

func (SpinButton) Visible

func (n SpinButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SpinRow

type SpinRow struct {
	*ActionRow
	// contains filtered or unexported fields
}

SpinRow is an ActionRow with a SpinButton in its end slot.

func NewSpinRow

func NewSpinRow(face render.Font, sizePx float64, title, subtitle string, min, max, step float64, digits int, on func(v float64)) *SpinRow

NewSpinRow returns the row over [min, max] stepping by step with digits decimals; on, when set, receives user-committed changes.

func (SpinRow) Arrange

func (c SpinRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (SpinRow) Baseline

func (c SpinRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (SpinRow) Children

func (c SpinRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (SpinRow) HitTest

func (c SpinRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (SpinRow) Measure

func (c SpinRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (SpinRow) PackEnd

func (p SpinRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (SpinRow) PackStart

func (p SpinRow) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*SpinRow) SetValue

func (r *SpinRow) SetValue(v float64)

SetValue sets it silently - mirroring an external value never echoes back as a user change.

func (*SpinRow) SpinButton

func (r *SpinRow) SpinButton() *SpinButton

SpinButton returns the embedded control.

func (*SpinRow) Value

func (r *SpinRow) Value() float64

Value reports the committed value.

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner is an indeterminate activity indicator (lucide's Loader2): a rotating open ring in the text color, the `spinner` element's color. The rotation is animation-clock driven — one frame invalidation per step, and no timer at all unless the spinner is both spinning and visible. A hidden or stopped spinner schedules no wake, so an idle app with a parked spinner costs nothing.

func NewSpinner

func NewSpinner(size int) *Spinner

NewSpinner returns a spinner sized size×size pixels.

func (*Spinner) AccessibleName

func (n *Spinner) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Spinner) AddClass

func (n *Spinner) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Spinner) Arrange

func (s *Spinner) Arrange(r render.Rect)

Arrange records the rect and syncs the rotation with visibility.

func (*Spinner) AttachStylesheet

func (n *Spinner) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Spinner) Attr

func (n *Spinner) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Spinner) Bounds

func (n *Spinner) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Spinner) Classes

func (n *Spinner) Classes() []string

Classes returns a copy of the widget's classes.

func (*Spinner) DebugName

func (n *Spinner) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Spinner) DetachStylesheet

func (n *Spinner) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Spinner) Element

func (n *Spinner) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Spinner) Enabled

func (n *Spinner) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Spinner) HAlign

func (n *Spinner) HAlign() Align

HAlign returns the horizontal placement.

func (*Spinner) HasClass

func (n *Spinner) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Spinner) HasState

func (n *Spinner) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Spinner) HitLeaf

func (n *Spinner) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Spinner) HitTest

func (s *Spinner) HitTest(p Point) Widget

HitTest returns the spinner when p is inside its bounds.

func (*Spinner) HoverWithin

func (n *Spinner) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Spinner) ID

func (n *Spinner) ID() string

ID returns the style id, empty when none is set.

func (*Spinner) InlineStyle

func (n *Spinner) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Spinner) Invalidate

func (n *Spinner) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Spinner) InvalidateLayout

func (n *Spinner) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Spinner) InvalidateRect

func (n *Spinner) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Spinner) LayoutMotion

func (n *Spinner) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Spinner) Margin

func (n *Spinner) Margin() render.Insets

Margin returns the programmatic margin.

func (*Spinner) MaximumSize

func (n *Spinner) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Spinner) Measure

func (s *Spinner) Measure(axis Axis, forSize int) Sizes

Measure wants a size×size square.

func (*Spinner) Paint

func (s *Spinner) Paint(cv *render.Canvas)

Paint draws the open ring at the current angle.

func (*Spinner) Parent

func (n *Spinner) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Spinner) RemoveAttr

func (n *Spinner) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Spinner) RemoveClass

func (n *Spinner) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Spinner) SetAccessibleName

func (n *Spinner) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Spinner) SetAttr

func (n *Spinner) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Spinner) SetClass

func (n *Spinner) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Spinner) SetClasses

func (n *Spinner) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Spinner) SetCursorName

func (n *Spinner) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Spinner) SetDebugName

func (n *Spinner) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Spinner) SetElement

func (n *Spinner) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Spinner) SetEnabled

func (n *Spinner) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Spinner) SetFocusOnClick

func (n *Spinner) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Spinner) SetHAlign

func (n *Spinner) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Spinner) SetHExpand

func (n *Spinner) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Spinner) SetID

func (n *Spinner) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Spinner) SetInlineStyle

func (n *Spinner) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Spinner) SetInlineStylePriority

func (n *Spinner) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Spinner) SetLayoutMotion

func (n *Spinner) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Spinner) SetMargin

func (n *Spinner) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Spinner) SetMaximumSize

func (n *Spinner) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Spinner) SetOnClickWithin

func (n *Spinner) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Spinner) SetOnFocusChanged

func (n *Spinner) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Spinner) SetOnHoverWithin

func (n *Spinner) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Spinner) SetOnPointer

func (n *Spinner) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Spinner) SetOnScroll

func (n *Spinner) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Spinner) SetSharedElement

func (n *Spinner) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Spinner) SetSizeRequest

func (n *Spinner) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Spinner) SetSpinning

func (s *Spinner) SetSpinning(on bool)

SetSpinning turns the rotation on or off. Stopping cancels the tween at once — the frozen angle stays where it stopped and no wake remains scheduled. Starting takes effect once the spinner is on screen; until then nothing is scheduled.

func (*Spinner) SetState

func (n *Spinner) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Spinner) SetTooltip

func (n *Spinner) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Spinner) SetTooltipMarkup

func (n *Spinner) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Spinner) SetVAlign

func (n *Spinner) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Spinner) SetVExpand

func (n *Spinner) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Spinner) SetVisible

func (n *Spinner) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Spinner) SharedElement

func (n *Spinner) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Spinner) SizeRequest

func (n *Spinner) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Spinner) Spinning

func (s *Spinner) Spinning() bool

Spinning reports whether the rotation is on.

func (*Spinner) TooltipMarkup

func (n *Spinner) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Spinner) TooltipText

func (n *Spinner) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Spinner) VAlign

func (n *Spinner) VAlign() Align

VAlign returns the vertical placement.

func (*Spinner) Visible

func (n *Spinner) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SplitButton

type SplitButton struct {

	// OnClick fires for the main half; OnMenu for the arrow, with the
	// arrow as the popover anchor.
	OnClick func()
	OnMenu  func(anchor Boundser)
	// contains filtered or unexported fields
}

SplitButton is a button with a menu side (adw SplitButton): the main half fires OnClick, the arrow half reports its anchor through OnMenu - the app opens the menu popover there (app.AttachSplitButton), the same reporting shape a MenuBar's roots use.

func NewSplitButton

func NewSplitButton(content Widget, sizePx float64) *SplitButton

NewSplitButton returns the pair over content (a label or ButtonContent).

func (*SplitButton) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*SplitButton) Arrow

func (s *SplitButton) Arrow() Boundser

Arrow returns the menu half, the popover anchor.

func (*SplitButton) Baseline

func (c *SplitButton) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*SplitButton) Children

func (c *SplitButton) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*SplitButton) HitTest

func (c *SplitButton) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*SplitButton) Measure

func (c *SplitButton) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*SplitButton) Paint

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

Paint draws the surface (when configured) then the root.

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack holds named children and shows exactly one at a time, switching through its transition (none by default).

func NewStack

func NewStack() *Stack

NewStack returns an empty stack.

func (*Stack) AccessibleName

func (n *Stack) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Stack) Add

func (s *Stack) Add(name string, w Widget) *Stack

Add puts a child under name; adding an existing name replaces it. The replaced widget detaches like Stack.Remove — parent link cleared, removal hook fired — instead of staying parented to a stack it no longer belongs to.

func (*Stack) AddClass

func (n *Stack) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Stack) Arrange

func (s *Stack) Arrange(r render.Rect)

Arrange assigns the content box to every child.

func (*Stack) ArrangeRoot

func (s *Stack) ArrangeRoot(r render.Rect)

ArrangeRoot records the stack's own rect.

func (*Stack) AttachStylesheet

func (n *Stack) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Stack) Attr

func (n *Stack) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Stack) Bounds

func (n *Stack) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Stack) Children

func (s *Stack) Children() []Widget

Children exposes the visible child for focus traversal.

func (*Stack) Classes

func (n *Stack) Classes() []string

Classes returns a copy of the widget's classes.

func (*Stack) DebugName

func (n *Stack) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Stack) DetachStylesheet

func (n *Stack) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Stack) Element

func (n *Stack) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Stack) Enabled

func (n *Stack) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Stack) HAlign

func (n *Stack) HAlign() Align

HAlign returns the horizontal placement.

func (*Stack) HasClass

func (n *Stack) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Stack) HasState

func (n *Stack) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Stack) HitLeaf

func (n *Stack) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Stack) HitTest

func (s *Stack) HitTest(p Point) Widget

HitTest returns the visible child under p, or the stack inside its bounds.

func (*Stack) Homogeneous

func (s *Stack) Homogeneous() bool

Homogeneous reports whether the stack is as large as its largest page (SetHomogeneous).

func (*Stack) HoverWithin

func (n *Stack) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Stack) ID

func (n *Stack) ID() string

ID returns the style id, empty when none is set.

func (*Stack) InlineStyle

func (n *Stack) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Stack) Insert

func (s *Stack) Insert(i int, name string, w Widget) *Stack

Insert puts a child under name at position i of the page order (clamped), with Add's replacement rule for an existing name.

func (*Stack) InterpolateSize

func (s *Stack) InterpolateSize() bool

InterpolateSize reports whether a switch tweens the stack's size (SetInterpolateSize).

func (*Stack) Invalidate

func (n *Stack) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Stack) InvalidateLayout

func (n *Stack) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Stack) InvalidateRect

func (n *Stack) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Stack) LayoutMotion

func (n *Stack) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Stack) Margin

func (n *Stack) Margin() render.Insets

Margin returns the programmatic margin.

func (*Stack) MaximumSize

func (n *Stack) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Stack) Measure

func (s *Stack) Measure(axis Axis, forSize int) Sizes

Measure reports the widest request of its children - or, sized to its visible page, that page's, tweened from the page leaving while an interpolating switch runs - inside the stack's CSS box (GtkStack's padding, border and min sizes).

func (*Stack) Move

func (s *Stack) Move(name string, i int)

Move moves the page under name to position i of the page order (clamped); the page stays attached. An unknown name is a no-op.

func (*Stack) Order

func (s *Stack) Order() []string

Order returns the page names in add order.

func (*Stack) Page

func (s *Stack) Page(name string) Widget

Page is the child added under name, visible or not (GtkStack's get_child_by_name); nil for an unknown name.

func (*Stack) Paint

func (s *Stack) Paint(cv *render.Canvas)

Paint draws the stack's own CSS layers, then the visible child, or both pages mid-switch.

func (*Stack) Parent

func (n *Stack) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Stack) Remove

func (s *Stack) Remove(name string) bool

Remove deletes the child under name and reports whether there was one. Removing the visible child leaves the stack showing nothing — Visible reads "" until the next Show or Add names a child; removal never silently promotes a sibling (pinned). The removed widget's parent link clears and the removal hook fires, so routers drop it; an unknown name is a no-op.

func (*Stack) RemoveAttr

func (n *Stack) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Stack) RemoveClass

func (n *Stack) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Stack) SetAccessibleName

func (n *Stack) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Stack) SetAttr

func (n *Stack) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Stack) SetClass

func (n *Stack) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Stack) SetClasses

func (n *Stack) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Stack) SetCursorName

func (n *Stack) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Stack) SetDebugName

func (n *Stack) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Stack) SetElement

func (n *Stack) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Stack) SetEnabled

func (s *Stack) SetEnabled(enabled bool)

SetEnabled turns the visible child on or off through the per-query enable walk, like Box (hidden children stay untouched; they paint nothing, so they need no repaint either).

func (*Stack) SetFocusOnClick

func (n *Stack) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Stack) SetHAlign

func (n *Stack) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Stack) SetHExpand

func (n *Stack) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Stack) SetHomogeneous

func (s *Stack) SetHomogeneous(h bool)

SetHomogeneous picks whether the stack is as large as its largest page (true, the default) or as its visible one (GTK's hhomogeneous and vhomogeneous off), so pages of different sizes resize what holds the stack.

func (*Stack) SetID

func (n *Stack) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Stack) SetInlineStyle

func (n *Stack) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Stack) SetInlineStylePriority

func (n *Stack) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Stack) SetInterpolateSize

func (s *Stack) SetInterpolateSize(on bool)

SetInterpolateSize makes a stack sized to its visible page tween between the two pages' sizes through a switch, on the switch's own easing (GTK's interpolate-size); off, the size jumps.

func (*Stack) SetLayoutMotion

func (n *Stack) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Stack) SetMargin

func (n *Stack) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Stack) SetMaximumSize

func (n *Stack) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Stack) SetOnClickWithin

func (n *Stack) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Stack) SetOnFocusChanged

func (n *Stack) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Stack) SetOnHoverWithin

func (n *Stack) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Stack) SetOnPointer

func (n *Stack) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Stack) SetOnScroll

func (n *Stack) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Stack) SetSharedElement

func (n *Stack) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Stack) SetSizeRequest

func (n *Stack) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Stack) SetState

func (n *Stack) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Stack) SetTooltip

func (n *Stack) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Stack) SetTooltipMarkup

func (n *Stack) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Stack) SetTransition

func (s *Stack) SetTransition(t StackTransition, d time.Duration)

SetTransition picks how later Show calls switch pages and how long a switch takes (GTK's stack transition type and duration); a zero duration switches at once.

func (*Stack) SetVAlign

func (n *Stack) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Stack) SetVExpand

func (n *Stack) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Stack) SetVisible

func (n *Stack) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Stack) SharedElement

func (n *Stack) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Stack) Show

func (s *Stack) Show(name string)

Show makes the child under name the visible one through the stack's transition; unknown names are ignored. A switch during a running one starts from the page then showing.

func (*Stack) SizeRequest

func (n *Stack) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Stack) Switching

func (s *Stack) Switching() bool

Switching reports whether a page transition is running.

func (*Stack) TooltipMarkup

func (n *Stack) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Stack) TooltipText

func (n *Stack) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Stack) VAlign

func (n *Stack) VAlign() Align

VAlign returns the vertical placement.

func (*Stack) Visible

func (s *Stack) Visible() string

Visible returns the visible child's name.

type StackSwitcher

type StackSwitcher struct {
	*ViewSwitcher
}

StackSwitcher is GTK's classic stack switcher: a text-only ViewSwitcher, the variant for windows that title pages in words.

func NewStackSwitcher

func NewStackSwitcher(face render.Font, sizePx float64, stack *Stack, titles map[string]string) *StackSwitcher

NewStackSwitcher returns a tab strip driving stack.

func (StackSwitcher) Arrange

func (c StackSwitcher) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (StackSwitcher) Baseline

func (c StackSwitcher) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (StackSwitcher) Children

func (c StackSwitcher) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (StackSwitcher) HitTest

func (c StackSwitcher) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (StackSwitcher) Measure

func (c StackSwitcher) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (StackSwitcher) Paint

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

Paint draws the surface (when configured) then the root.

type StackSwitcherPolicy

type StackSwitcherPolicy uint8

StackSwitcherPolicy decides what switcher toggles show.

const (
	// SwitcherAll shows icon and title where both exist.
	SwitcherAll StackSwitcherPolicy = iota
	// SwitcherText titles only (no icons), the narrow variant.
	SwitcherText
	// SwitcherIcons icons only, the bottom-bar variant.
	SwitcherIcons
)

Switcher policies.

type StackTransition

type StackTransition uint8

StackTransition is how a Stack moves between pages.

const (
	// StackNone switches at once.
	StackNone StackTransition = iota
	// StackCrossfade cross-fades the old page into the new one.
	StackCrossfade
	// StackSlideLeftRight slides the pages sideways: a page added
	// later comes in from the right, an earlier one from the left.
	StackSlideLeftRight
)

type StateAction

type StateAction[S comparable] struct {
	// contains filtered or unexported fields
}

StateAction is a named action holding a state, relm4's stateful RelmAction: activating one of its targets sets the state, and every proxy shows the state it holds. A bool state is a toggle (Toggle); any comparable state can drive a radio group (Target).

func NewStateAction

func NewStateAction[S comparable](name string, initial S, onChange func(S)) *StateAction[S]

NewStateAction returns an enabled action at initial; onChange, when not nil, hears every change of state.

func (*StateAction) Enabled

func (c *StateAction) Enabled() bool

Enabled reports whether the action may be activated.

func (*StateAction) Name

func (c *StateAction) Name() string

Name returns the action's name.

func (*StateAction) SetEnabled

func (c *StateAction) SetEnabled(on bool)

SetEnabled enables or disables the action and every proxy bound to it.

func (*StateAction[S]) SetState

func (a *StateAction[S]) SetState(s S)

SetState changes the state, notifying onChange and every proxy; an equal state does nothing. It applies even while the action is disabled, since disabling gates the user, not the program.

func (*StateAction[S]) State

func (a *StateAction[S]) State() S

State returns the current state.

func (*StateAction) Subscribe

func (c *StateAction) Subscribe(fn func()) (cancel func())

Subscribe registers fn for every enabled or state change; the returned cancel removes it.

func (*StateAction[S]) Target

func (a *StateAction[S]) Target(v S) Checkable

Target is the Checkable that sets the state to v: one radio item of the group the action's states form.

type StateFlags

type StateFlags uint8

StateFlags are the widget states a stylesheet matches that no router drives: an application sets them to reflect its own model.

const (
	// StateChecked matches :checked — a toggled-on control, or a menu
	// button whose popup is open.
	StateChecked StateFlags = 1 << iota
	// StateSelected matches :selected.
	StateSelected
	// StateIndeterminate matches :indeterminate.
	StateIndeterminate
	// StateBackdrop matches :backdrop — the widget's window is inactive.
	StateBackdrop
	// StateTarget matches :target — the widget an in-app navigation
	// points at, the role a URL fragment's element plays on the web.
	StateTarget
)

The application-driven states.

type StatusPage

type StatusPage struct {
	// contains filtered or unexported fields
}

StatusPage is the empty/error state page (adw StatusPage): an icon on a muted tile, a title, a wrapped description, and an optional content area (a call-to-action button), centered in whatever space it gets. It styles as the `statuspage` element with .icon, .title and .description parts.

func NewStatusPage

func NewStatusPage(face render.Font, iconName, title, description string) *StatusPage

NewStatusPage returns the page; empty icon or description drops it.

func (*StatusPage) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*StatusPage) Baseline

func (c *StatusPage) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*StatusPage) Children

func (c *StatusPage) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*StatusPage) HitTest

func (c *StatusPage) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*StatusPage) Measure

func (p *StatusPage) Measure(axis Axis, forSize int) Sizes

Measure is the page's content request, wanting the column's full width: a page fills the space it gets up to statusPageWidth, its content centered in it, aligned or not.

func (*StatusPage) Paint

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

Paint draws the surface (when configured) then the root.

func (*StatusPage) SetChild

func (p *StatusPage) SetChild(w Widget)

SetChild adds w (a call-to-action button, typically) to the content area under the description; successive children stack.

func (*StatusPage) SetIcon

func (p *StatusPage) SetIcon(w Widget)

SetIcon shows w (an icon, typically 24px) centered on the muted tile above the title; nil drops the tile.

type Stylesheet

type Stylesheet struct {
	// contains filtered or unexported fields
}

Stylesheet is one parsed stylesheet at a priority, reloadable in place. Installed with AddStylesheet it applies to every widget; created with NewStylesheet and attached to widgets (AttachStylesheet) it applies to those subtrees only — one surface's styling that must not reach another's. The zero value is not usable.

func AddStylesheet

func AddStylesheet(css string, priority int) *Stylesheet

AddStylesheet parses css and installs it at priority, above or below the other stylesheets by priority and, at equal priority, after every earlier one. The next frame repaints with it; call it from the event-loop goroutine, like SetTheme. Malformed rules are skipped with a warning on the library logger — the valid remainder still applies.

func AddStylesheetFile

func AddStylesheetFile(path string, priority int) (*Stylesheet, error)

AddStylesheetFile loads a stylesheet from path and installs it at priority as its own Stylesheet, with hot reload on it: a change to the file reloads it off the loop, and Remove stops that. A file that cannot be read or whose parse reports a problem fails with an error naming the path, instead of half-loading.

func NewStylesheet

func NewStylesheet(css string, priority int) *Stylesheet

NewStylesheet parses css into a stylesheet at priority without installing it: attach it to the widgets whose subtrees it styles.

func NewStylesheetFile

func NewStylesheetFile(path string, priority int) (*Stylesheet, error)

NewStylesheetFile reads the stylesheet at path into a scoped sheet at priority, like NewStylesheet: attach it to the widgets whose subtrees it styles. Its @import rules resolve relative to path, and the hot reload AddStylesheetFile starts reloads it on change until Remove. A file that cannot be read or whose parse reports a problem fails with an error naming the path.

func (*Stylesheet) Load

func (s *Stylesheet) Load(css string)

Load replaces the stylesheet's rules with css, keeping its priority and position, and stops its hot reload: the sheet is string-backed from here on. Loading into an installed stylesheet that was removed (and is attached nowhere) reinstalls it; a NewStylesheet sheet stays scoped, styling only the subtrees it is attached to. It parses on the calling goroutine; LoadParsed takes a sheet ParseStylesheet parsed elsewhere.

func (*Stylesheet) LoadParsed added in v0.2.5

func (s *Stylesheet) LoadParsed(p *ParsedStylesheet)

LoadParsed is Load with the parse already done: installing p costs no parse, and restyles exactly what Load of the same text would.

func (*Stylesheet) Priority

func (s *Stylesheet) Priority() int

Priority returns the priority the stylesheet was installed at.

func (*Stylesheet) Remove

func (s *Stylesheet) Remove()

Remove uninstalls the stylesheet and stops its hot reload (a scoped NewStylesheetFile sheet keeps styling where it is attached, but no longer reloads); removing twice is a no-op.

type StylesheetWatcher added in v0.2.5

type StylesheetWatcher func(dirs []string, changed func()) (stop func(), err error)

StylesheetWatcher reports changes in dirs: changed runs on the event-loop goroutine after anything in them changed, until stop.

type Stylus

type Stylus struct {
	Tool               StylusTool
	At                 Point
	Pressure, Distance float64
	TiltX, TiltY       float64
	Rotation           float64
	Down               bool
	Button             uint32
	Pressed            bool
}

Stylus is one tablet tool sample: where the tool is, its axes, and whether its tip is down. Pressure and Distance are 0..1; tilt and rotation are degrees. Button reports a stylus button that changed with this sample (0: none) and Pressed its state.

type StylusHandler

type StylusHandler interface {
	Stylus(s Stylus)
}

StylusHandler takes tablet samples - a canvas drawing with pressure, a slider dragging finer with a light touch. The tool also drives the pointer (hover, press, drag), so widgets that ignore pressure just work under a pen.

type StylusTool

type StylusTool uint8

StylusTool is a tablet tool's kind.

const (
	StylusPen StylusTool = iota
	StylusEraser
	StylusBrush
	StylusPencil
	StylusAirbrush
	StylusFinger
	StylusMouse
	StylusLens
)

Stylus tools.

type SurfaceHost

type SurfaceHost interface {
	// OpenMenu opens items as a popup menu beside anchor, whose bounds
	// are in the tree's coordinates, painted with face at sizePx.
	OpenMenu(anchor Boundser, face render.Font, sizePx float64, items []MenuItem, opts MenuOptions)
	// OpenPopover opens content in a popover beside anchor, and returns
	// what closes it.
	OpenPopover(anchor Boundser, content Widget, opts PopoverOptions) (close func())
	// Focus moves the surface's keyboard focus to w, failing as
	// Router.SetFocus does.
	Focus(w Widget) error
}

SurfaceHost is what a widget tree's surface does for its widgets: the application attaches one to every surface's root (SetSurfaceHost), and the widgets reach it through OpenMenu, OpenPopover and GrabFocus. The host owns the surface plumbing and reports its own failures.

type SwatchPicker

type SwatchPicker struct {

	// OnPicked runs when a swatch is clicked.
	OnPicked func(c render.Color)
	// OnEdited runs on every change in the expanded chooser.
	OnEdited func(c render.Color)
	// contains filtered or unexported fields
}

SwatchPicker picks a color from a grid of preset swatches, one click each, the current one ringed; an optional custom row lists the user's own colors under the presets, and a Custom entry opens the full ColorChooser in place. OnPicked hears a swatch pick, OnEdited every change the chooser makes.

func NewSwatchPicker

func NewSwatchPicker(face render.Font, sizePx float64, presets []render.Color, current render.Color) *SwatchPicker

NewSwatchPicker returns a picker over presets with current ringed.

func (*SwatchPicker) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*SwatchPicker) Baseline

func (c *SwatchPicker) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*SwatchPicker) Children

func (c *SwatchPicker) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*SwatchPicker) Color

func (p *SwatchPicker) Color() render.Color

Color returns the current color.

func (*SwatchPicker) Expanded

func (p *SwatchPicker) Expanded() bool

Expanded reports whether the full chooser is open.

func (*SwatchPicker) HitTest

func (c *SwatchPicker) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*SwatchPicker) Measure

func (c *SwatchPicker) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*SwatchPicker) Paint

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

Paint draws the surface (when configured) then the root.

func (*SwatchPicker) SetColor

func (p *SwatchPicker) SetColor(c render.Color)

SetColor makes c current, ringing its swatch.

func (*SwatchPicker) SetCustom

func (p *SwatchPicker) SetCustom(colors []render.Color)

SetCustom shows colors as a row under the presets; none hides it.

type SwipeDismiss

type SwipeDismiss struct {

	// OnDismiss fires once, as the child leaves: dir is -1 out to the
	// left, 1 to the right.
	OnDismiss func(dir int)
	// contains filtered or unexported fields
}

SwipeDismiss lets its child be swiped away sideways, as a notification is: a press that travels sideways past a small slop takes the gesture from whatever it landed on (a button under it does not click), and the child follows the pointer, fading as it goes. A release past 40% of the width, or a fling, sends it out on a spring and fires OnDismiss once; any shorter swipe springs it back. A release inside the slop is an ordinary click for the child. A sideways two-finger touchpad scroll drags it the same way, its end settling it.

func NewSwipeDismiss

func NewSwipeDismiss(child Widget) *SwipeDismiss

NewSwipeDismiss wraps child.

func (*SwipeDismiss) AccessibleName

func (n *SwipeDismiss) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*SwipeDismiss) AddClass

func (n *SwipeDismiss) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*SwipeDismiss) Arrange

func (s *SwipeDismiss) Arrange(r render.Rect)

Arrange places the child at r, shifted by the swipe.

func (*SwipeDismiss) AttachStylesheet

func (n *SwipeDismiss) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*SwipeDismiss) Attr

func (n *SwipeDismiss) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*SwipeDismiss) Bounds

func (n *SwipeDismiss) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*SwipeDismiss) Child

func (s *SwipeDismiss) Child() Widget

Child is the wrapped widget.

func (*SwipeDismiss) Children

func (s *SwipeDismiss) Children() []Widget

Children is the child.

func (*SwipeDismiss) ClaimPixels

func (s *SwipeDismiss) ClaimPixels(dx, dy float64) bool

ClaimPixels implements PixelClaimer: a sideways finger scroll drags the child as the pointer does.

func (*SwipeDismiss) Classes

func (n *SwipeDismiss) Classes() []string

Classes returns a copy of the widget's classes.

func (*SwipeDismiss) DebugName

func (n *SwipeDismiss) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*SwipeDismiss) DetachStylesheet

func (n *SwipeDismiss) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*SwipeDismiss) DragMove

func (s *SwipeDismiss) DragMove(p Point)

DragMove implements DragMover: the child follows the pointer.

func (*SwipeDismiss) Element

func (n *SwipeDismiss) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*SwipeDismiss) Enabled

func (n *SwipeDismiss) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*SwipeDismiss) HAlign

func (n *SwipeDismiss) HAlign() Align

HAlign returns the horizontal placement.

func (*SwipeDismiss) HasClass

func (n *SwipeDismiss) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*SwipeDismiss) HasState

func (n *SwipeDismiss) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*SwipeDismiss) HitLeaf

func (n *SwipeDismiss) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*SwipeDismiss) HitTest

func (s *SwipeDismiss) HitTest(p Point) Widget

HitTest is the child, else the wrapper within its bounds.

func (*SwipeDismiss) HoverWithin

func (n *SwipeDismiss) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*SwipeDismiss) ID

func (n *SwipeDismiss) ID() string

ID returns the style id, empty when none is set.

func (*SwipeDismiss) InlineStyle

func (n *SwipeDismiss) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*SwipeDismiss) InterceptDrag

func (s *SwipeDismiss) InterceptDrag(from, at Point) bool

InterceptDrag implements DragInterceptor: a press that travelled past the slop, more sideways than up or down, becomes a swipe.

func (*SwipeDismiss) Invalidate

func (n *SwipeDismiss) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*SwipeDismiss) InvalidateLayout

func (n *SwipeDismiss) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*SwipeDismiss) InvalidateRect

func (n *SwipeDismiss) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*SwipeDismiss) LayoutMotion

func (n *SwipeDismiss) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*SwipeDismiss) Margin

func (n *SwipeDismiss) Margin() render.Insets

Margin returns the programmatic margin.

func (*SwipeDismiss) MaximumSize

func (n *SwipeDismiss) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*SwipeDismiss) Measure

func (s *SwipeDismiss) Measure(axis Axis, forSize int) Sizes

Measure is the child's size.

func (*SwipeDismiss) Offset

func (s *SwipeDismiss) Offset() float64

Offset is how far, in logical pixels, the child sits off its place.

func (*SwipeDismiss) Paint

func (s *SwipeDismiss) Paint(cv *render.Canvas)

Paint draws the child, fading with its offset.

func (*SwipeDismiss) Parent

func (n *SwipeDismiss) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*SwipeDismiss) PressEnd

func (s *SwipeDismiss) PressEnd()

PressEnd implements PressEnder: the release settles the swipe.

func (*SwipeDismiss) RemoveAttr

func (n *SwipeDismiss) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*SwipeDismiss) RemoveClass

func (n *SwipeDismiss) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*SwipeDismiss) ScrollEnd

func (s *SwipeDismiss) ScrollEnd()

ScrollEnd implements ScrollEnder: lifting the fingers settles it.

func (*SwipeDismiss) SetAccessibleName

func (n *SwipeDismiss) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*SwipeDismiss) SetAttr

func (n *SwipeDismiss) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*SwipeDismiss) SetClass

func (n *SwipeDismiss) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*SwipeDismiss) SetClasses

func (n *SwipeDismiss) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*SwipeDismiss) SetCursorName

func (n *SwipeDismiss) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*SwipeDismiss) SetDebugName

func (n *SwipeDismiss) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*SwipeDismiss) SetElement

func (n *SwipeDismiss) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*SwipeDismiss) SetEnabled

func (n *SwipeDismiss) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*SwipeDismiss) SetFocusOnClick

func (n *SwipeDismiss) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*SwipeDismiss) SetHAlign

func (n *SwipeDismiss) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*SwipeDismiss) SetHExpand

func (n *SwipeDismiss) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*SwipeDismiss) SetID

func (n *SwipeDismiss) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*SwipeDismiss) SetInlineStyle

func (n *SwipeDismiss) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*SwipeDismiss) SetInlineStylePriority

func (n *SwipeDismiss) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*SwipeDismiss) SetLayoutMotion

func (n *SwipeDismiss) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*SwipeDismiss) SetMargin

func (n *SwipeDismiss) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*SwipeDismiss) SetMaximumSize

func (n *SwipeDismiss) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*SwipeDismiss) SetOnClickWithin

func (n *SwipeDismiss) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*SwipeDismiss) SetOnFocusChanged

func (n *SwipeDismiss) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*SwipeDismiss) SetOnHoverWithin

func (n *SwipeDismiss) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*SwipeDismiss) SetOnPointer

func (n *SwipeDismiss) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*SwipeDismiss) SetOnScroll

func (n *SwipeDismiss) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*SwipeDismiss) SetSharedElement

func (n *SwipeDismiss) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*SwipeDismiss) SetSizeRequest

func (n *SwipeDismiss) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*SwipeDismiss) SetState

func (n *SwipeDismiss) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*SwipeDismiss) SetTooltip

func (n *SwipeDismiss) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*SwipeDismiss) SetTooltipMarkup

func (n *SwipeDismiss) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*SwipeDismiss) SetVAlign

func (n *SwipeDismiss) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*SwipeDismiss) SetVExpand

func (n *SwipeDismiss) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*SwipeDismiss) SetVisible

func (n *SwipeDismiss) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*SwipeDismiss) SharedElement

func (n *SwipeDismiss) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*SwipeDismiss) SizeRequest

func (n *SwipeDismiss) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*SwipeDismiss) TooltipMarkup

func (n *SwipeDismiss) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*SwipeDismiss) TooltipText

func (n *SwipeDismiss) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*SwipeDismiss) VAlign

func (n *SwipeDismiss) VAlign() Align

VAlign returns the vertical placement.

func (*SwipeDismiss) Visible

func (n *SwipeDismiss) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Switch

type Switch struct {

	// OnChanged fires after every state change, including programmatic
	// ones.
	OnChanged func(on bool)
	// contains filtered or unexported fields
}

Switch is a boolean toggle painted as a pill with a sliding knob. A stylesheet restyles it the GTK way: `switch` is the track (background, border-radius, min-width/min-height, the box layers; `:checked` while on) and `switch slider` the knob (min size, margin, background, radius, shadow). Unstyled, it is the theme's 40x22 pill. A flip slides the knob and blends the colors over the theme's medium motion.

func NewSwitch

func NewSwitch(on bool) *Switch

NewSwitch returns a switch in the given state. The pointer turns to the hand over it, the way wayle's switch primitive asks.

func (*Switch) AccessibleName

func (n *Switch) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Switch) AddClass

func (n *Switch) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Switch) Arrange

func (s *Switch) Arrange(r render.Rect)

Arrange keeps the border box inside the margins, at the track's natural size: a taller or wider slot (a row's cross stretch) centers the pill across and keeps it at the start, the way a checkbox keeps its indicator, instead of stretching the knob with it. The knob takes its place here, not in Paint, so a first paint leaves nothing for the next frame to repaint.

func (*Switch) AttachStylesheet

func (n *Switch) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Switch) Attr

func (n *Switch) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Switch) BindAction

func (s *Switch) BindAction(c Checkable) (unbind func())

BindAction makes the switch a proxy of c, like ToggleButton.BindAction.

func (*Switch) BindOn

func (s *Switch) BindOn(b *Binding[bool]) (unbind func())

BindOn wires the binding two-way to the switch's state.

func (*Switch) Bounds

func (n *Switch) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Switch) Classes

func (n *Switch) Classes() []string

Classes returns a copy of the widget's classes.

func (*Switch) ClickAt

func (s *Switch) ClickAt(Point)

ClickAt toggles the switch; the Router invokes it on press+release. Disabled switches ignore clicks.

func (*Switch) DebugName

func (n *Switch) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Switch) DetachStylesheet

func (n *Switch) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Switch) Element

func (n *Switch) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Switch) Enabled

func (n *Switch) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Switch) HAlign

func (n *Switch) HAlign() Align

HAlign returns the horizontal placement.

func (*Switch) HasClass

func (n *Switch) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Switch) HasState

func (n *Switch) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Switch) HitLeaf

func (n *Switch) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Switch) HitTest

func (s *Switch) HitTest(p Point) Widget

HitTest returns the switch when p is inside its bounds.

func (*Switch) HoverWithin

func (n *Switch) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Switch) ID

func (n *Switch) ID() string

ID returns the style id, empty when none is set.

func (*Switch) InlineStyle

func (n *Switch) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Switch) InsertRune

func (s *Switch) InsertRune(r rune)

InsertRune implements RuneHandler: Space toggles, the other half of the GTK activation pair. Disabled switches ignore it.

func (*Switch) Invalidate

func (n *Switch) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Switch) InvalidateLayout

func (n *Switch) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Switch) InvalidateRect

func (n *Switch) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Switch) KeyAction

func (s *Switch) KeyAction(a KeyAction, _ Mods)

KeyAction implements KeyActionHandler: Enter toggles when focused, which makes the switch reachable and activatable by keyboard only. Disabled switches ignore keys.

func (*Switch) LayoutMotion

func (n *Switch) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Switch) Margin

func (n *Switch) Margin() render.Insets

Margin returns the programmatic margin.

func (*Switch) MaximumSize

func (n *Switch) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Switch) Measure

func (s *Switch) Measure(axis Axis, forSize int) Sizes

Measure wants the 32x18 pill, floored by the stylesheet's min size, inside its CSS box.

func (*Switch) On

func (s *Switch) On() bool

On reports the switch state.

func (*Switch) Paint

func (s *Switch) Paint(cv *render.Canvas)

Paint draws the track and knob. The knob sits at the right when on, in the accent's foreground over the accent track; off, the track is the input color under a knob that contrasts it (the window background on a light palette, the text color on a dark one). A flip blends the two by progress. Disabled, the theme's on-track and knob fade through the derived disabled colors (a stylesheet fades with its own :disabled rules).

func (*Switch) Parent

func (n *Switch) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Switch) RemoveAttr

func (n *Switch) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Switch) RemoveClass

func (n *Switch) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Switch) Role

func (s *Switch) Role() Role

Role implements Roleer.

func (*Switch) SetAccessibleName

func (n *Switch) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Switch) SetAttr

func (n *Switch) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Switch) SetClass

func (n *Switch) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Switch) SetClasses

func (n *Switch) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Switch) SetCursorName

func (n *Switch) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Switch) SetDebugName

func (n *Switch) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Switch) SetElement

func (n *Switch) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Switch) SetEnabled

func (n *Switch) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Switch) SetFocusOnClick

func (n *Switch) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Switch) SetHAlign

func (n *Switch) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Switch) SetHExpand

func (n *Switch) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Switch) SetID

func (n *Switch) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Switch) SetInlineStyle

func (n *Switch) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Switch) SetInlineStylePriority

func (n *Switch) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Switch) SetLayoutMotion

func (n *Switch) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Switch) SetMargin

func (n *Switch) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Switch) SetMaximumSize

func (n *Switch) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Switch) SetOn

func (s *Switch) SetOn(on bool)

SetOn changes the state and fires OnChanged when it flipped.

func (*Switch) SetOnClickWithin

func (n *Switch) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Switch) SetOnFocusChanged

func (n *Switch) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Switch) SetOnHoverWithin

func (n *Switch) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Switch) SetOnPointer

func (n *Switch) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Switch) SetOnScroll

func (n *Switch) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Switch) SetPressed

func (s *Switch) SetPressed(bool)

SetPressed is a no-op: the switch has no pressed visual.

func (*Switch) SetSharedElement

func (n *Switch) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Switch) SetSizeRequest

func (n *Switch) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Switch) SetState

func (n *Switch) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Switch) SetTooltip

func (n *Switch) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Switch) SetTooltipMarkup

func (n *Switch) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Switch) SetVAlign

func (n *Switch) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Switch) SetVExpand

func (n *Switch) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Switch) SetVisible

func (n *Switch) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Switch) SharedElement

func (n *Switch) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Switch) SizeRequest

func (n *Switch) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Switch) Toggle

func (s *Switch) Toggle()

Toggle flips the state and fires OnChanged.

func (*Switch) TooltipMarkup

func (n *Switch) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Switch) TooltipText

func (n *Switch) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Switch) VAlign

func (n *Switch) VAlign() Align

VAlign returns the vertical placement.

func (*Switch) Visible

func (n *Switch) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SwitchRow

type SwitchRow struct {
	*ActionRow
	// contains filtered or unexported fields
}

SwitchRow is an ActionRow with a Switch in its end slot: the subtitle typically explains the consequence of flipping.

func NewSwitchRow

func NewSwitchRow(face render.Font, sizePx float64, title, subtitle string, on func(on bool)) *SwitchRow

NewSwitchRow returns the row; on, when set, fires after flips, whatever the source (GTK toggled).

func (SwitchRow) Arrange

func (c SwitchRow) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (SwitchRow) Baseline

func (c SwitchRow) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (SwitchRow) Children

func (c SwitchRow) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (SwitchRow) HitTest

func (c SwitchRow) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (SwitchRow) Measure

func (c SwitchRow) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*SwitchRow) On

func (r *SwitchRow) On() bool

On reports the state.

func (SwitchRow) PackEnd

func (p SwitchRow) PackEnd(w Widget)

PackEnd adds w to the trailing slot.

func (SwitchRow) PackStart

func (p SwitchRow) PackStart(w Widget)

PackStart adds w to the leading slot.

func (*SwitchRow) Set

func (r *SwitchRow) Set(on bool)

Set flips the switch programmatically (fires the same hook).

func (*SwitchRow) Switch

func (r *SwitchRow) Switch() *Switch

Switch returns the embedded control, for BindOn.

type Symbol

type Symbol struct {
	// contains filtered or unexported fields
}

Symbol paints one SymbolKind in a size x size box, stroked in the cascade's color over the theme's muted text. Styled as `image`.

func NewSymbol

func NewSymbol(kind SymbolKind, size int) *Symbol

NewSymbol returns a symbol of kind in a size-pixel box.

func (*Symbol) AccessibleName

func (n *Symbol) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Symbol) AddClass

func (n *Symbol) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Symbol) Arrange

func (s *Symbol) Arrange(r render.Rect)

Arrange records the rect.

func (*Symbol) AttachStylesheet

func (n *Symbol) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Symbol) Attr

func (n *Symbol) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Symbol) Bounds

func (n *Symbol) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Symbol) Classes

func (n *Symbol) Classes() []string

Classes returns a copy of the widget's classes.

func (*Symbol) DebugName

func (n *Symbol) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Symbol) DetachStylesheet

func (n *Symbol) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Symbol) Element

func (n *Symbol) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Symbol) Enabled

func (n *Symbol) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Symbol) HAlign

func (n *Symbol) HAlign() Align

HAlign returns the horizontal placement.

func (*Symbol) HasClass

func (n *Symbol) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Symbol) HasState

func (n *Symbol) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Symbol) HitLeaf

func (n *Symbol) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Symbol) HitTest

func (s *Symbol) HitTest(p Point) Widget

HitTest resolves inside the bounds.

func (*Symbol) HoverWithin

func (n *Symbol) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Symbol) ID

func (n *Symbol) ID() string

ID returns the style id, empty when none is set.

func (*Symbol) InlineStyle

func (n *Symbol) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Symbol) Invalidate

func (n *Symbol) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Symbol) InvalidateLayout

func (n *Symbol) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Symbol) InvalidateRect

func (n *Symbol) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Symbol) Kind

func (s *Symbol) Kind() SymbolKind

Kind reports the glyph.

func (*Symbol) LayoutMotion

func (n *Symbol) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Symbol) Margin

func (n *Symbol) Margin() render.Insets

Margin returns the programmatic margin.

func (*Symbol) MaximumSize

func (n *Symbol) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Symbol) Measure

func (s *Symbol) Measure(axis Axis, forSize int) Sizes

Measure wants the symbol's box.

func (*Symbol) Paint

func (s *Symbol) Paint(cv *render.Canvas)

Paint strokes the glyph centered in the bounds.

func (*Symbol) Parent

func (n *Symbol) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Symbol) RemoveAttr

func (n *Symbol) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Symbol) RemoveClass

func (n *Symbol) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Symbol) SetAccessibleName

func (n *Symbol) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Symbol) SetAttr

func (n *Symbol) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Symbol) SetClass

func (n *Symbol) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Symbol) SetClasses

func (n *Symbol) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Symbol) SetCursorName

func (n *Symbol) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Symbol) SetDebugName

func (n *Symbol) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Symbol) SetElement

func (n *Symbol) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Symbol) SetEnabled

func (n *Symbol) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Symbol) SetFocusOnClick

func (n *Symbol) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Symbol) SetHAlign

func (n *Symbol) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Symbol) SetHExpand

func (n *Symbol) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Symbol) SetID

func (n *Symbol) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Symbol) SetInlineStyle

func (n *Symbol) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Symbol) SetInlineStylePriority

func (n *Symbol) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Symbol) SetKind

func (s *Symbol) SetKind(kind SymbolKind)

SetKind changes the glyph (a disclosure turning, a sort flipping).

func (*Symbol) SetLayoutMotion

func (n *Symbol) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Symbol) SetMargin

func (n *Symbol) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Symbol) SetMaximumSize

func (n *Symbol) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Symbol) SetOnClickWithin

func (n *Symbol) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Symbol) SetOnFocusChanged

func (n *Symbol) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Symbol) SetOnHoverWithin

func (n *Symbol) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Symbol) SetOnPointer

func (n *Symbol) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Symbol) SetOnScroll

func (n *Symbol) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Symbol) SetSharedElement

func (n *Symbol) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Symbol) SetSizeRequest

func (n *Symbol) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Symbol) SetState

func (n *Symbol) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Symbol) SetTooltip

func (n *Symbol) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Symbol) SetTooltipMarkup

func (n *Symbol) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Symbol) SetVAlign

func (n *Symbol) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Symbol) SetVExpand

func (n *Symbol) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Symbol) SetVisible

func (n *Symbol) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Symbol) SharedElement

func (n *Symbol) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Symbol) SizeRequest

func (n *Symbol) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Symbol) TooltipMarkup

func (n *Symbol) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Symbol) TooltipText

func (n *Symbol) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Symbol) VAlign

func (n *Symbol) VAlign() Align

VAlign returns the vertical placement.

func (*Symbol) Visible

func (n *Symbol) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type SymbolKind

type SymbolKind uint8

SymbolKind names one of the vector glyphs the toolkit draws for its own chrome - disclosure arrows, sort indicators, window controls - instead of text glyphs, which fonts (the bundled fixture face among them) often lack and which then render as missing-glyph boxes.

const (
	// SymbolChevronRight is a right-pointing chevron (collapsed, next).
	SymbolChevronRight SymbolKind = iota
	// SymbolChevronDown is a down-pointing chevron (expanded, descending).
	SymbolChevronDown
	// SymbolChevronLeft is a left-pointing chevron (back).
	SymbolChevronLeft
	// SymbolChevronUp is an up-pointing chevron (ascending).
	SymbolChevronUp
	// SymbolClose is a diagonal cross.
	SymbolClose
	// SymbolMinimize is a low horizontal bar.
	SymbolMinimize
	// SymbolMaximize is an outlined square.
	SymbolMaximize
	// SymbolCrosshair is a picker's crosshair.
	SymbolCrosshair
	// SymbolDoubleLeft is two left chevrons (a bigger step back).
	SymbolDoubleLeft
	// SymbolDoubleRight is two right chevrons (a bigger step forward).
	SymbolDoubleRight
	// SymbolEllipsis is three dots in a row (more, collapsed items).
	SymbolEllipsis
	// SymbolMinus is a centered horizontal bar (a separator, less).
	SymbolMinus
	// SymbolCheck is a check mark (selected, done).
	SymbolCheck
	// SymbolChevronsUpDown is an up chevron over a down one (a picker
	// that opens a list).
	SymbolChevronsUpDown
	// SymbolSearch is a magnifying glass.
	SymbolSearch
	// SymbolCalendar is a calendar page (a date field).
	SymbolCalendar
	// SymbolPanelLeft is a window with a left pane (a sidebar toggle).
	SymbolPanelLeft
	// SymbolArrowLeft is a left-pointing arrow (previous).
	SymbolArrowLeft
	// SymbolArrowRight is a right-pointing arrow (next).
	SymbolArrowRight
	// SymbolUser is a head over shoulders (a person, an account).
	SymbolUser
	// SymbolFolder is a folder with its tab (a project, a directory).
	SymbolFolder
)

Symbol kinds.

type TabBar

type TabBar struct {
	// contains filtered or unexported fields
}

TabBar is libadwaita's AdwTabBar: the tabs of a TabView in a row. Clicking a tab selects it, its close button closes it (pinned tabs have none), and dragging a tab drops it at a position in this bar or in another window's, which moves the page there. Tabs show an icon (or a spinner while loading), the title, an attention mark, and the page's indicator. It styles as `tabbar` with `tab` children.

func NewTabBar

func NewTabBar(face render.Font, sizePx float64, view *TabView) *TabBar

NewTabBar returns a bar presenting view's tabs.

func (*TabBar) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*TabBar) Baseline

func (c *TabBar) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*TabBar) Children

func (c *TabBar) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*TabBar) Detach

func (b *TabBar) Detach()

Detach stops following the view; the bar keeps its last tabs.

func (*TabBar) DragEnter

func (b *TabBar) DragEnter(mimes []string, _ Point) string

DragEnter accepts dragged tabs.

func (*TabBar) Drop

func (b *TabBar) Drop(mime string, data []byte, p Point)

Drop moves the dropped tab's page to the position under p: a reorder within this bar's view, a transfer from another.

func (*TabBar) DropAction

func (b *TabBar) DropAction(transfer.Action) transfer.Action

DropAction moves.

func (*TabBar) HitTest

func (c *TabBar) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*TabBar) Measure

func (c *TabBar) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*TabBar) Paint

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

Paint draws the surface (when configured) then the root.

func (*TabBar) Tabs

func (b *TabBar) Tabs() []Widget

Tabs returns the tab widgets in order (tests, styling).

func (*TabBar) View

func (b *TabBar) View() *TabView

View returns the presented TabView.

type TabOverview

type TabOverview struct {

	// OnOpenChanged runs when the overview opens or closes.
	OnOpenChanged func(open bool)
	// contains filtered or unexported fields
}

TabOverview is libadwaita's AdwTabOverview: while open it replaces its child with a grid of the view's pages as thumbnails; clicking one selects it and closes the overview.

func NewTabOverview

func NewTabOverview(face render.Font, sizePx float64, view *TabView, child Widget) *TabOverview

NewTabOverview returns an overview of view around child (usually the window content holding the TabView).

func (*TabOverview) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*TabOverview) Baseline

func (c *TabOverview) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*TabOverview) Children

func (c *TabOverview) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*TabOverview) HitTest

func (c *TabOverview) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*TabOverview) Measure

func (c *TabOverview) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*TabOverview) Open

func (o *TabOverview) Open() bool

Open reports whether the overview shows.

func (*TabOverview) Paint

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

Paint draws the surface (when configured) then the root.

func (*TabOverview) SetOpen

func (o *TabOverview) SetOpen(on bool)

SetOpen opens or closes the overview. Opening snapshots every page at the view's current size.

type TabPage

type TabPage struct {

	// OnIndicator runs when the tab's indicator icon is clicked (a mute
	// button on a playing tab).
	OnIndicator func()
	// contains filtered or unexported fields
}

TabPage is one page of a TabView: its child and what its tab shows.

func (*TabPage) Child

func (p *TabPage) Child() Widget

Child returns the page's content.

func (*TabPage) Loading

func (p *TabPage) Loading() bool

Loading reports the loading state.

func (*TabPage) NeedsAttention

func (p *TabPage) NeedsAttention() bool

NeedsAttention reports the attention mark.

func (*TabPage) Pinned

func (p *TabPage) Pinned() bool

Pinned reports whether the page is pinned.

func (*TabPage) SetIcon

func (p *TabPage) SetIcon(name string)

SetIcon sets the tab's icon by theme name; "" shows none.

func (*TabPage) SetIndicator

func (p *TabPage) SetIndicator(name string)

SetIndicator sets the indicator icon shown beside the title by theme name; "" shows none. OnIndicator hears clicks on it.

func (*TabPage) SetLoading

func (p *TabPage) SetLoading(on bool)

SetLoading shows a spinner in place of the icon while on.

func (*TabPage) SetNeedsAttention

func (p *TabPage) SetNeedsAttention(on bool)

SetNeedsAttention marks the tab until it is selected.

func (*TabPage) SetTitle

func (p *TabPage) SetTitle(s string)

SetTitle sets the tab title.

func (*TabPage) SetTooltip

func (p *TabPage) SetTooltip(s string)

SetTooltip sets the tab's tooltip.

func (*TabPage) Title

func (p *TabPage) Title() string

Title returns the tab title.

func (*TabPage) View

func (p *TabPage) View() *TabView

View returns the TabView holding the page, nil once closed.

type TabTrapper

type TabTrapper interface {
	// TrapTab inserts the widget's tab or indent and reports true.
	TrapTab(ctrl bool) bool
}

TabTrapper lets a focused widget absorb a plain Tab press as indentation. When the focused widget implements it and TrapTab returns true, focus stays; ctrl+Tab and shift+Tab always move focus regardless of this interface.

type TabView

type TabView struct {

	// OnSelect runs when the selected page changes.
	OnSelect func(p *TabPage)
	// OnClosePage, when set, decides whether p closes: return false to
	// keep it (an unsaved-changes prompt).
	OnClosePage func(p *TabPage) bool
	// OnPageAttached and OnPageDetached run when a page joins or leaves
	// this view, by insertion, close or a transfer between views.
	OnPageAttached func(p *TabPage)
	OnPageDetached func(p *TabPage)
	// contains filtered or unexported fields
}

TabView is libadwaita's AdwTabView: a stack of pages, one visible, whose tabs a TabBar (and a TabOverview) present. Pinned pages sit first. Closing asks OnClosePage, which may veto.

func NewTabView

func NewTabView() *TabView

NewTabView returns an empty tab view.

func (*TabView) AccessibleName

func (n *TabView) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*TabView) AddClass

func (n *TabView) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*TabView) Append

func (v *TabView) Append(child Widget, title string) *TabPage

Append adds child as a new last unpinned page titled title.

func (*TabView) Arrange

func (v *TabView) Arrange(r render.Rect)

Arrange gives the visible page the whole rect.

func (*TabView) AttachStylesheet

func (n *TabView) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*TabView) Attr

func (n *TabView) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*TabView) Bounds

func (n *TabView) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*TabView) Children

func (v *TabView) Children() []Widget

Children exposes the visible page for traversal.

func (*TabView) Classes

func (n *TabView) Classes() []string

Classes returns a copy of the widget's classes.

func (*TabView) ClosePage

func (v *TabView) ClosePage(p *TabPage) bool

ClosePage closes p unless OnClosePage vetoes, and reports whether it closed. The page after it, else before it, becomes visible.

func (*TabView) DebugName

func (n *TabView) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*TabView) DetachStylesheet

func (n *TabView) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*TabView) Element

func (n *TabView) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*TabView) Enabled

func (n *TabView) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*TabView) HAlign

func (n *TabView) HAlign() Align

HAlign returns the horizontal placement.

func (*TabView) HasClass

func (n *TabView) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*TabView) HasState

func (n *TabView) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*TabView) HitLeaf

func (n *TabView) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*TabView) HitTest

func (v *TabView) HitTest(p Point) Widget

HitTest routes into the visible page.

func (*TabView) HoverWithin

func (n *TabView) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*TabView) ID

func (n *TabView) ID() string

ID returns the style id, empty when none is set.

func (*TabView) Index

func (v *TabView) Index(p *TabPage) int

Index returns p's position, -1 when p is not in this view.

func (*TabView) InlineStyle

func (n *TabView) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*TabView) Insert

func (v *TabView) Insert(i int, child Widget, title string) *TabPage

Insert adds child at position i, kept among the unpinned pages.

func (*TabView) Invalidate

func (n *TabView) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*TabView) InvalidateLayout

func (n *TabView) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*TabView) InvalidateRect

func (n *TabView) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*TabView) LayoutMotion

func (n *TabView) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*TabView) Margin

func (n *TabView) Margin() render.Insets

Margin returns the programmatic margin.

func (*TabView) MaximumSize

func (n *TabView) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*TabView) Measure

func (v *TabView) Measure(axis Axis, forSize int) Sizes

Measure is the widest page's request, so switching tabs does not resize the window.

func (*TabView) NPages

func (v *TabView) NPages() int

NPages returns the page count.

func (*TabView) NPinned

func (v *TabView) NPinned() int

NPinned returns how many pages are pinned.

func (*TabView) Pages

func (v *TabView) Pages() []*TabPage

Pages returns the pages in tab order.

func (*TabView) Paint

func (v *TabView) Paint(cv *render.Canvas)

Paint paints the visible page.

func (*TabView) Parent

func (n *TabView) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*TabView) Prepend

func (v *TabView) Prepend(child Widget, title string) *TabPage

Prepend adds child as the first unpinned page.

func (*TabView) RemoveAttr

func (n *TabView) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*TabView) RemoveClass

func (n *TabView) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*TabView) Reorder

func (v *TabView) Reorder(p *TabPage, i int)

Reorder moves p to position i, kept within its pinned or unpinned run.

func (*TabView) Select

func (v *TabView) Select(p *TabPage)

Select shows p.

func (*TabView) SelectIndex

func (v *TabView) SelectIndex(i int)

SelectIndex shows the page at i; out of range does nothing.

func (*TabView) SelectNext

func (v *TabView) SelectNext()

SelectNext shows the next page, wrapping to the first.

func (*TabView) SelectPrevious

func (v *TabView) SelectPrevious()

SelectPrevious shows the previous page, wrapping to the last.

func (*TabView) Selected

func (v *TabView) Selected() *TabPage

Selected returns the visible page, nil when empty.

func (*TabView) SetAccessibleName

func (n *TabView) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*TabView) SetAttr

func (n *TabView) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*TabView) SetClass

func (n *TabView) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*TabView) SetClasses

func (n *TabView) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*TabView) SetCursorName

func (n *TabView) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*TabView) SetDebugName

func (n *TabView) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*TabView) SetElement

func (n *TabView) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*TabView) SetEnabled

func (n *TabView) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*TabView) SetFocusOnClick

func (n *TabView) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*TabView) SetHAlign

func (n *TabView) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*TabView) SetHExpand

func (n *TabView) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*TabView) SetID

func (n *TabView) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*TabView) SetInlineStyle

func (n *TabView) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*TabView) SetInlineStylePriority

func (n *TabView) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*TabView) SetLayoutMotion

func (n *TabView) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*TabView) SetMargin

func (n *TabView) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*TabView) SetMaximumSize

func (n *TabView) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*TabView) SetOnClickWithin

func (n *TabView) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*TabView) SetOnFocusChanged

func (n *TabView) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*TabView) SetOnHoverWithin

func (n *TabView) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*TabView) SetOnPointer

func (n *TabView) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*TabView) SetOnScroll

func (n *TabView) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*TabView) SetPinned

func (v *TabView) SetPinned(p *TabPage, on bool)

SetPinned pins or unpins p: pinned pages move to the end of the pinned run, unpinned ones to the start of the rest.

func (*TabView) SetSharedElement

func (n *TabView) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*TabView) SetSizeRequest

func (n *TabView) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*TabView) SetState

func (n *TabView) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*TabView) SetTooltip

func (n *TabView) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*TabView) SetTooltipMarkup

func (n *TabView) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*TabView) SetVAlign

func (n *TabView) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*TabView) SetVExpand

func (n *TabView) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*TabView) SetVisible

func (n *TabView) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*TabView) SharedElement

func (n *TabView) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*TabView) SizeRequest

func (n *TabView) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*TabView) Subscribe

func (v *TabView) Subscribe(fn func()) (cancel func())

Subscribe registers fn for every change of pages, order, selection or page state: what a TabBar redraws from.

func (*TabView) TooltipMarkup

func (n *TabView) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*TabView) TooltipText

func (n *TabView) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*TabView) TransferPage

func (v *TabView) TransferPage(p *TabPage, i int)

TransferPage moves p from its view into this one at position i, keeping its child, as a tab dragged between windows. The page is selected in its new view.

func (*TabView) VAlign

func (n *TabView) VAlign() Align

VAlign returns the vertical placement.

func (*TabView) Visible

func (n *TabView) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type TableColumn

type TableColumn[T any] struct {
	Title string
	// Width is the cell's minimum width (the header's too, so columns
	// line up); Expand shares leftover table width across the
	// expanding columns, Box-style.
	Width  int
	Expand bool
	// Cell builds the cell's widget for one row value; nil renders the
	// zero label.
	Cell func(T) Widget
	// Sort, when non-nil, makes the header clickable and orders rows:
	// negative puts a first. Equal values keep source order (stable).
	Sort func(a, b T) int
	// Head, when set, is the header cell instead of Title's button: a
	// select-all check.
	Head Widget
}

TableColumn is one typed table column: how a cell renders, how wide it sits, and whether the header sorts by it.

type TextArea

type TextArea struct {

	// MaxWidth caps the natural width Measure reports when not
	// wrapping: a long line stops growing the layout at the cap and
	// pans inside it instead — the text widgets' counterpart of
	// Scroll's bounded natural size. Zero (the default) reports the
	// content-hugging width. Set it before the first Measure, or
	// follow with InvalidateLayout.
	MaxWidth int

	// OnChanged fires after the contents change, whatever the source:
	// typing, editing keys, paste, undo and redo, or SetText (GTK's
	// TextBuffer changed). Text reads the new contents.
	OnChanged func()
	// contains filtered or unexported fields
}

TextArea is a multi-line editor: logical lines split on newlines, per-line cursor motion with a sticky preferred column, and a selection model shared with Entry. With wrap enabled (the default) long logical lines flow across visual rows built from shaped advance widths; editing and Text stay logical regardless.

Example
package main

import (
	"fmt"
	"log"

	"github.com/stubbedev/lys-lib/render"
	"golang.org/x/image/font/gofont/goregular"

	"github.com/stubbedev/lys-ui/widget"
)

func face() *render.Typeface {
	tf, err := render.LoadFont(goregular.TTF)
	if err != nil {
		log.Fatal(err)
	}
	return tf
}

func main() {
	// A text area holds logical lines and soft-wraps them at the
	// offered width by default (SetWrap(false) restores one row per
	// line). Editing stays in logical coordinates; Text reports them.
	notes := widget.NewTextArea(face(), 14, widget.Current().Text)
	notes.SetText("wrap me softly\nline two")

	fmt.Println(notes.Text())
	fmt.Println("--")

	// Place the caret on the second line, after "two", and type.
	notes.SetCursor(1, 8)
	notes.InsertRune('!')
	fmt.Println(notes.Text())
}
Output:
wrap me softly
line two
--
wrap me softly
line two!

func NewTextArea

func NewTextArea(face render.Font, sizePx float64, color render.Color) *TextArea

NewTextArea returns an empty area painted with face at sizePx. Face may be a render.Chain for mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*TextArea) AccessibleName

func (n *TextArea) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*TextArea) AddClass

func (n *TextArea) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*TextArea) Arrange

func (t *TextArea) Arrange(r render.Rect)

Arrange pins the rect and re-pans the caret's line: a resize changes the visible width, so the caret may need pulling back into view. Stale pans on other lines re-clamp when read.

func (*TextArea) AttachStylesheet

func (n *TextArea) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*TextArea) Attr

func (n *TextArea) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*TextArea) AutoIndent

func (t *TextArea) AutoIndent() bool

AutoIndent reports SetAutoIndent.

func (*TextArea) Backspace

func (t *TextArea) Backspace()

Backspace removes the selection, or one grapheme cluster/line break backward — an emoji family, a flag, a base rune with its marks go as one whole (#57); one undo entry per call. Blocked while disabled or read-only.

func (*TextArea) BindText

func (t *TextArea) BindText(b *Binding[string]) (unbind func())

BindText wires the binding two-way to the text area's contents.

func (*TextArea) Bounds

func (n *TextArea) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*TextArea) CharExtents

func (t *TextArea) CharExtents(offset int) (render.Rect, bool)

CharExtents implements TextGeometry. A line's newline reports a zero-width box at the line's end.

func (*TextArea) Classes

func (n *TextArea) Classes() []string

Classes returns a copy of the widget's classes.

func (*TextArea) ClickAt

func (t *TextArea) ClickAt(p Point)

ClickAt places the cursor (and anchor) at the clicked position, dropping the composing display.

func (*TextArea) Composing

func (t *TextArea) Composing() bool

Composing reports whether composing (input-method preedit) text is on show.

func (*TextArea) CursorName

func (t *TextArea) CursorName() string

CursorName reports the text caret shape while hovered.

func (*TextArea) CursorPos

func (t *TextArea) CursorPos() (line, col int)

CursorPos returns the cursor as line/column.

func (*TextArea) DebugName

func (n *TextArea) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*TextArea) Delete

func (t *TextArea) Delete()

Delete removes the selection, or one grapheme cluster/line break forward (#57); one undo entry per call. Blocked while disabled or read-only.

func (*TextArea) DeleteWordBackward

func (t *TextArea) DeleteWordBackward()

DeleteWordBackward removes the word before the cursor — ctrl+ backspace, with alt+backspace as the macOS alias — or the selection when one is active; the whole word is one undo entry. At a line start it is a no-op: word deletion stays inside the line, it never joins the previous one. Blocked while disabled or read-only.

func (*TextArea) DeleteWordForward

func (t *TextArea) DeleteWordForward()

DeleteWordForward removes the word after the cursor — ctrl+delete — or the selection when one is active; the whole word is one undo entry. At a line end it is a no-op, the mirror of DeleteWordBackward at a line start. Blocked while disabled or read-only.

func (*TextArea) DetachStylesheet

func (n *TextArea) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*TextArea) Direction

func (t *TextArea) Direction() Direction

Direction returns the base paragraph direction the area resolves with.

func (*TextArea) DoubleClickAt

func (t *TextArea) DoubleClickAt(p Point)

DoubleClickAt selects the same-class run under the pointer, over the shared word segmentation — the same words the ctrl+arrows steps land on.

func (*TextArea) DragMove

func (t *TextArea) DragMove(p Point)

DragMove extends the selection to the dragged position, dropping the composing display. A motion past the field's left or right edge auto-pans the clicked line one step so the drag can reach text outside the viewport.

func (*TextArea) Element

func (n *TextArea) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*TextArea) Enabled

func (n *TextArea) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*TextArea) HAlign

func (n *TextArea) HAlign() Align

HAlign returns the horizontal placement.

func (*TextArea) HasClass

func (n *TextArea) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*TextArea) HasState

func (n *TextArea) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*TextArea) HitLeaf

func (n *TextArea) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*TextArea) HitTest

func (t *TextArea) HitTest(p Point) Widget

HitTest returns the area when p is inside its bounds.

func (*TextArea) HoverWithin

func (n *TextArea) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*TextArea) ID

func (n *TextArea) ID() string

ID returns the style id, empty when none is set.

func (*TextArea) IMECommit

func (t *TextArea) IMECommit(text string)

IMECommit implements IMEClient.

func (*TextArea) IMECursorRect

func (t *TextArea) IMECursorRect() render.Rect

IMECursorRect implements IMETracker: the caret rectangle in root coordinates, for the input method's candidate window. Pan-aware so the window tracks the caret on a panned unwrapped line, on either direction's reading edge.

func (*TextArea) IMEDelete

func (t *TextArea) IMEDelete(before, after int)

IMEDelete implements IMEClient: input-method deletion of up to before bytes before and after bytes after the caret, possibly across line breaks. Blocked while disabled or read-only.

func (*TextArea) IMEMultiline

func (t *TextArea) IMEMultiline() bool

IMEMultiline implements IMETracker.

func (*TextArea) IMEPreedit

func (t *TextArea) IMEPreedit(text string, cursorBegin, cursorEnd int)

IMEPreedit implements IMEClient. A disabled or read-only area never enters composing (see Entry.IMEPreedit).

func (*TextArea) IMERevision added in v0.2.5

func (t *TextArea) IMERevision() IMERevision

IMERevision implements IMETracker.

func (*TextArea) IMESurrounding

func (t *TextArea) IMESurrounding(limit int) (string, int, int)

IMESurrounding implements IMETracker.

func (*TextArea) Indent

func (t *TextArea) Indent() int

Indent returns how many spaces Tab inserts; zero means a tab character.

func (*TextArea) InlineStyle

func (n *TextArea) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*TextArea) Insert

func (t *TextArea) Insert(s string)

Insert inserts s at the cursor; an active selection is replaced, and the whole insertion — a paste, a drop, a committed composition — is one undo entry. Blocked while disabled or read-only.

func (*TextArea) InsertRune

func (t *TextArea) InsertRune(r rune)

InsertRune implements RuneHandler. Typed runes coalesce into one undo entry until a word boundary, an idle gap, or a different edit breaks the run. Blocked while disabled or read-only.

func (*TextArea) Invalidate

func (n *TextArea) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*TextArea) InvalidateLayout

func (n *TextArea) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*TextArea) InvalidateRect

func (n *TextArea) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*TextArea) KeyAction

func (t *TextArea) KeyAction(a KeyAction, mods Mods)

KeyAction implements KeyActionHandler. Shift-extended motion grows the selection from its anchor; ctrl turns arrows and backspace/delete word-wise, alt+backspace aliasing ctrl+backspace. The bare keys edit one grapheme cluster per press (#57), so emoji and accented pairs edit whole. Interaction order: while composing, the input method owns the text and the bare backspace unwinds the composing display one rune first — that is compose state (#54), orthogonal to committed text; after it, ctrl/alt make backspace and delete word-wise over the cluster-refined words (#56); the bare keys apply to the contents one cluster at a time. A disabled area ignores keys outright; a read-only one keeps the motion and selection keys and drops only the mutating ones.

func (*TextArea) LayoutMotion

func (n *TextArea) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*TextArea) LineNumbers

func (t *TextArea) LineNumbers() bool

LineNumbers reports SetLineNumbers.

func (*TextArea) Margin

func (n *TextArea) Margin() render.Insets

Margin returns the programmatic margin.

func (*TextArea) MaximumSize

func (n *TextArea) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*TextArea) Measure

func (t *TextArea) Measure(axis Axis, forSize int) Sizes

Measure reports the widest line by the line count, or, when wrapping at the width given, the wrapped row count, the text insets (CSS box, text node, gutter) around it and the stylesheet's min-* floors under it. Composing text counts toward the widest line and the row count. MaxWidth caps the wanted width — a long line then stops widening the layout at the cap and pans inside it. A wrapping area needs no width of its text's: it wraps into what it gets.

func (*TextArea) MoveWord

func (t *TextArea) MoveWord(delta int)

MoveWord moves the cursor one visual word within its line: the word edge the direction points at, gaps (whitespace, punctuation runs) skipped whole. An active selection collapses to the visually- directed edge first, without moving; the line boundaries are no-ops.

func (*TextArea) MoveWordExtending

func (t *TextArea) MoveWordExtending(delta int)

MoveWordExtending is MoveWord with shift held: the selection extends from its anchor to the word edge.

func (*TextArea) OffsetAt

func (t *TextArea) OffsetAt(p Point) int

OffsetAt implements TextGeometry.

func (*TextArea) Paint

func (t *TextArea) Paint(cv *render.Canvas)

Paint draws the wrapped rows, the selection highlight, the composing text with its underline, and the cursor. An unwrapped line wider than the viewport pans: its content draws at -panX[line], clipped to the inner rect, per logical line. The placeholder only shows on an empty area and never pans. State colors follow Entry: disabled fills with the derived disabled surface and fades the text; read-only keeps the text and fades only the caret. The stylesheet's background-color, color, and border-radius override the theme's.

func (*TextArea) Parent

func (n *TextArea) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*TextArea) Placeholder

func (t *TextArea) Placeholder() string

Placeholder returns the text shown when the area is empty.

func (*TextArea) ReadOnly

func (t *TextArea) ReadOnly() bool

ReadOnly reports whether the area is in the read-only mode.

func (*TextArea) Redo

func (t *TextArea) Redo() bool

Redo reapplies the most recently undone edit, reporting whether there was one. Like Undo it is a user edit and no-ops while disabled or read-only.

func (*TextArea) RemoveAttr

func (n *TextArea) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*TextArea) RemoveClass

func (n *TextArea) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*TextArea) Role

func (t *TextArea) Role() Role

Role implements Roleer.

func (*TextArea) Select

func (t *TextArea) Select(start, end int)

Select implements TextSelector.

func (*TextArea) SelectAll

func (t *TextArea) SelectAll()

SelectAll selects the entire document; the pan follows the caret to the end of the last line.

func (*TextArea) SelectedText

func (t *TextArea) SelectedText() (string, bool)

SelectedText implements SelectedTexter.

func (*TextArea) Selection

func (t *TextArea) Selection() (start, end pos, active bool)

Selection reports the selected rune range in line/col pairs.

func (*TextArea) SetAccessibleName

func (n *TextArea) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*TextArea) SetAttr

func (n *TextArea) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*TextArea) SetAutoIndent

func (t *TextArea) SetAutoIndent(on bool)

SetAutoIndent makes Enter start the new line with the current line's leading whitespace (GtkSourceView's auto-indent).

func (*TextArea) SetCaret

func (t *TextArea) SetCaret(offset int)

SetCaret implements TextSelector.

func (*TextArea) SetClass

func (n *TextArea) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*TextArea) SetClasses

func (n *TextArea) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*TextArea) SetCursor

func (t *TextArea) SetCursor(line, col int)

SetCursor places the cursor and anchor at a line/column, clearing any selection. Columns beyond the line clamp.

func (*TextArea) SetCursorName

func (n *TextArea) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*TextArea) SetDebugName

func (n *TextArea) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*TextArea) SetDirection

func (t *TextArea) SetDirection(d Direction)

SetDirection selects the base paragraph direction every line resolves and lays out with — each line is one paragraph. DirectionAuto (the default) reads it off the line's first strong character; DirectionRTL additionally starts short lines at the right edge and mirrors the pan. Arrow and word motion always move visually, through the same resolution the paint uses, while cursor, anchor, and selection stay logical line/column positions. Changing the direction drops the row cache and re-pans.

func (*TextArea) SetElement

func (n *TextArea) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*TextArea) SetEnabled

func (n *TextArea) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*TextArea) SetFocusOnClick

func (n *TextArea) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*TextArea) SetHAlign

func (n *TextArea) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*TextArea) SetHExpand

func (n *TextArea) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*TextArea) SetHighlighter

func (t *TextArea) SetHighlighter(h Highlighter, scheme TextScheme)

SetHighlighter styles the text with h through scheme; a nil h paints it plain.

func (*TextArea) SetID

func (n *TextArea) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*TextArea) SetIndent

func (t *TextArea) SetIndent(n int)

SetIndent sets how many spaces Tab inserts while focused; zero (the default) inserts a tab character.

func (*TextArea) SetInlineStyle

func (n *TextArea) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*TextArea) SetInlineStylePriority

func (n *TextArea) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*TextArea) SetLayoutMotion

func (n *TextArea) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*TextArea) SetLineNumbers

func (t *TextArea) SetLineNumbers(on bool)

SetLineNumbers shows the line-number gutter at the text's left.

func (*TextArea) SetMargin

func (n *TextArea) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*TextArea) SetMaximumSize

func (n *TextArea) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*TextArea) SetOnClickWithin

func (n *TextArea) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*TextArea) SetOnFocusChanged

func (n *TextArea) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*TextArea) SetOnHoverWithin

func (n *TextArea) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*TextArea) SetOnPointer

func (n *TextArea) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*TextArea) SetOnScroll

func (n *TextArea) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*TextArea) SetPlaceholder

func (t *TextArea) SetPlaceholder(s string)

SetPlaceholder sets the text shown when the area is empty.

func (*TextArea) SetReadOnly

func (t *TextArea) SetReadOnly(ro bool)

SetReadOnly toggles the read-only mode — the same contract as Entry.SetReadOnly: user edits (typing, paste, composition, delete, undo/redo, and Tab indentation through TrapTab) no-op, while selection, copy, caret motion, and pan keep working. A history built before the flip waits untouched. The visual distinguishes itself from disabled the same way: normal text, muted caret.

func (*TextArea) SetScheme

func (t *TextArea) SetScheme(scheme TextScheme)

SetScheme replaces the scheme, keeping the highlighter (a palette change).

func (*TextArea) SetSharedElement

func (n *TextArea) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*TextArea) SetSizeRequest

func (n *TextArea) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*TextArea) SetState

func (n *TextArea) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*TextArea) SetText

func (t *TextArea) SetText(s string)

SetText replaces the contents, splitting on newlines, and clears the selection and composing display. An app-driven replacement is not an edit to back out of: the undo history starts fresh.

func (*TextArea) SetTooltip

func (n *TextArea) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*TextArea) SetTooltipMarkup

func (n *TextArea) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*TextArea) SetVAlign

func (n *TextArea) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*TextArea) SetVExpand

func (n *TextArea) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*TextArea) SetVariants

func (t *TextArea) SetVariants(v VariantFunc)

SetVariants installs the faces bold and italic styles shape with (RichLabel's VariantFunc); without, they draw with the regular face.

func (*TextArea) SetVisible

func (n *TextArea) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*TextArea) SetWrap

func (t *TextArea) SetWrap(on bool)

SetWrap toggles soft wrapping; the default is on.

func (*TextArea) SharedElement

func (n *TextArea) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*TextArea) SizeRequest

func (n *TextArea) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*TextArea) Text

func (t *TextArea) Text() string

Text returns the contents, lines joined with newlines.

func (*TextArea) TextLen

func (t *TextArea) TextLen() int

TextLen returns the number of logical lines, for tests and callers.

func (*TextArea) TooltipMarkup

func (n *TextArea) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*TextArea) TooltipText

func (n *TextArea) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*TextArea) TrapTab

func (t *TextArea) TrapTab(bool) bool

TrapTab implements the tab-trap rule: a plain Tab inside the area inserts indentation instead of moving focus. Ctrl and shift variants are routed to focus movement before this is asked. Read-only and disabled areas decline the trap, so Tab moves focus instead.

func (*TextArea) Undo

func (t *TextArea) Undo() bool

Undo restores the state before the most recent edit — contents, caret, and selection included — reporting whether there was anything to undo. Composing text drops first, like before any other edit. Undo is a user edit: disabled or read-only, it no-ops and returns false while the history waits untouched.

func (*TextArea) VAlign

func (n *TextArea) VAlign() Align

VAlign returns the vertical placement.

func (*TextArea) Visible

func (n *TextArea) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

func (*TextArea) Wrap

func (t *TextArea) Wrap() bool

Wrap reports whether soft wrapping is on.

type TextGeometry

type TextGeometry interface {
	// CharExtents is the box of the character at offset; false outside
	// the text or when nothing is drawn (a hidden password).
	CharExtents(offset int) (render.Rect, bool)
	// OffsetAt is the offset of the character under p, -1 outside the
	// text area.
	OffsetAt(p Point) int
}

TextGeometry reports where a text widget draws each character, in root coordinates: what a screen reader's review cursor and magnifiers follow.

type TextInserter

type TextInserter interface {
	// Insert inserts s at the caret, replacing the selection.
	Insert(s string)
}

TextInserter is an editable text widget that accepts pasted text: Insert places s at the caret, replacing any active selection, and reports the change through OnChanged. Entry and TextArea implement it; primary-selection pastes (middle click) target it.

type TextScheme

type TextScheme map[string]SchemeStyle

TextScheme maps style ids to styles: the highlighter's span classes, and "text", "cursor", "selection" and "line-numbers" for the view itself (a GtkSourceView style scheme).

func (TextScheme) Style

func (s TextScheme) Style(class string) (SchemeStyle, bool)

Style is class's style, following the def.lang map to the nearest style the scheme has; false when none is styled.

type TextSelector

type TextSelector interface {
	// SetCaret moves the caret to offset, collapsing any selection.
	SetCaret(offset int)
	// Select selects start..end, the caret at end.
	Select(start, end int)
}

TextSelector is a text widget whose caret and selection code - and assistive technologies, through the AT-SPI bridge - can set, in rune offsets into its Text (the offsets A11yState reports). Positions snap to grapheme-cluster starts, composing text is dropped, and the view pans to the caret.

type TextSpan

type TextSpan struct {
	Start, End int
	Class      string
}

TextSpan styles runes [Start, End) of a line with the scheme's style for Class (a GtkSourceView style id, such as def:string).

type TextStyle

type TextStyle struct {
	// Bold and Italic select the face variant a run shapes with.
	Bold, Italic bool
	// Weight is the numeric weight (100 to 1000) a variable face shapes
	// the run at, zero the label's; markup keeps Bold in step with it
	// (600 and up), so a static family picks its bold variant.
	Weight int
	// Family is the font family the run shapes in, "" the label's.
	Family string
	// SizePx is the run's absolute size in pixels, zero the label's;
	// Scale multiplies it, zero meaning 1: Pango's absolute and
	// relative sizes, relative ones compounding as they nest.
	SizePx, Scale float64
	// Shift lifts the run off the baseline by that fraction of its size
	// (superscript up, subscript down).
	Shift float64
	// Underline and Strikethrough draw the decoration lines over the
	// run (Pango's <u> and <s>), in the run's color; UnderlineStyle is
	// the underline's line (double, or wavy for Pango's error).
	Underline, Strikethrough bool
	UnderlineStyle           render.DecorationStyle
	// Color overrides the label color while non-zero. Premultiplied,
	// like every render.Color.
	Color render.Color
	// Alpha scales the run's opacity, in (0, 1]; zero leaves it.
	Alpha float64
	// Background fills behind the run while non-zero.
	Background render.Color
	// LetterSpacing adds pixels after each of the run's characters.
	LetterSpacing float64
	// Features are the OpenType features the run shapes with, in the
	// canonical tag=value;tag=value form.
	Features string
	// Href is the link target of a run; empty for plain text.
	Href string
}

TextStyle is the style state markup tags accumulate over a run of text. The zero value is the plain label style.

type Theme

type Theme struct {
	// Bg is the window background; Surface fills controls at rest.
	Bg, Surface Color
	// SurfaceHover and SurfacePressed restyle controls under the
	// pointer or while pressed. Leave them unset and HoverSurface
	// and PressedSurface derive them from Surface.
	SurfaceHover, SurfacePressed Color
	// Text paints primary labels; TextMuted groups and hints. Leave
	// TextMuted unset and DisabledText derives it from Text.
	Text, TextMuted Color
	// SurfaceDisabled fills disabled controls. Leave it unset and
	// DisabledSurface derives it from Surface and Bg.
	SurfaceDisabled Color
	// Accent drives fills that express state: progress, switches on,
	// sliders. HoverAccent derives the translucent hover wash from it.
	Accent Color
	// OnAccent paints glyphs and knobs on top of Accent.
	OnAccent Color
	// Border strokes control outlines.
	Border Color
	// Card fills cards and Popover floating surfaces (menus,
	// popovers, dropdown lists). Leave them unset and CardColor and
	// PopoverColor derive them from Surface.
	Card, Popover Color
	// Muted fills quiet regions: tab lists, skeletons, table headers,
	// code spans. Leave it unset and MutedColor derives it from
	// Surface.
	Muted Color
	// Secondary fills the secondary button and badge: a fill of its
	// own, so an app that paints panels in Surface can keep the
	// button visible on them. Leave it unset and SecondaryColor
	// derives it from MutedColor.
	Secondary Color
	// Sidebar fills an application sidebar. Leave it unset and
	// SidebarColor derives it from Surface.
	Sidebar Color
	// Chart colors a chart's series, chart-1 to chart-5; an
	// unset one is ChartColor's fallback (Accent).
	Chart [5]Color
	// Input strokes the borders of text fields and other inputs.
	// Leave it unset and InputColor derives it from Border.
	Input Color
	// Ring paints the focus ring around the focused control. Leave it
	// unset and RingColor derives it from Accent.
	Ring Color
	// Destructive, Success, Warning, and Error are the status fills
	// (destructive-action buttons, banners, the @*_bg_color names).
	// Leave them unset to derive the Adwaita defaults for the
	// palette's polarity - the zero-falls-back-to-derived rule.
	Destructive, Success, Warning, Error Color
	// ShadowColor paints floating surfaces' box shadows (menus,
	// popovers, tooltips, toasts, dialogs). Leave it unset to derive
	// the default (neutral black at 110 alpha), the usual zero-falls-
	// back-to-derived rule.
	ShadowColor Color
	// ShadowBlur is the shadow's falloff radius in pixels around every
	// floating surface, and the on/off switch: zero disables client
	// shadows entirely — for compositors that already blur under
	// translucent surfaces, where a client shadow would double up.
	ShadowBlur int
	// Radius is the default corner rounding; Spacing and Padding are
	// layout defaults.
	Radius  int
	Spacing int
	Padding int
	// TextSize is the default label size in pixels.
	TextSize float64
	// MotionShort, MotionMedium and MotionLong are the motion tokens:
	// the durations of a state change (hover, press), a surface opening
	// or closing, and a large move. Stylesheets read them as
	// var(--lys-duration-short) and friends. Leave them unset for the
	// toolkit's (anim.DurationShort and friends).
	MotionShort, MotionMedium, MotionLong time.Duration
	// Animations gates the animated enter/exit (and open/reveal) motion:
	// surface tweens, toast slides, dropdown lists. False collapses the
	// durations to zero — the reduced-motion switch beside
	// LYS_UI_NO_ANIM=1 and surfx.SetEnabled(false); state machines run
	// unchanged, only the motion goes away.
	Animations bool
}

Theme holds the palette and metrics widgets paint with. Colors left at zero on a widget fall back to the theme at paint time, so replacing the theme restyles everything on the next frame.

A Theme is an immutable value: the With* methods return a fresh copy and never touch the receiver, so chains compose from any preset —

widget.SetTheme(widget.DarkTheme().WithAccent(green).WithPadding(10))

Colors arrive from config files as hex strings; parse them with ParseColor or set them with WithAccentHex, which errors on malformed input instead of defaulting silently.

func Current

func Current() *Theme

Current returns the active theme.

func DarkTheme

func DarkTheme() *Theme

DarkTheme returns the default dark palette: a neutral one, a light primary on near-black, translucent hairlines.

func HighContrastTheme

func HighContrastTheme() *Theme

HighContrastTheme returns the high-contrast preset (#88): pure black on pure white, no muted tones, hairline chrome replaced by a solid border - the palette the desktop's contrast preference asks for. The WCAG guard in SetTheme is its acceptance test by construction: every pair passes AA with room to spare. Shadows and animations stay off; the point is legibility, not depth.

func LightTheme

func LightTheme() *Theme

LightTheme returns the default light palette: a neutral one, a near-black primary on white.

func (*Theme) CardColor

func (t *Theme) CardColor() Color

CardColor returns the card fill: Card when set, otherwise Surface.

func (*Theme) ChartColor

func (t *Theme) ChartColor(i int) Color

ChartColor returns series i's color, cycling through the five chart colors; an unset one is Accent.

func (*Theme) DestructiveColor

func (t *Theme) DestructiveColor() Color

DestructiveColor returns the destructive fill (Destructive when set).

func (*Theme) DisabledAccent

func (t *Theme) DisabledAccent() Color

DisabledAccent returns the accent fill (a switch's on-track, a slider's fill, a checkbox's tick) while the control ignores input: Accent faded to disabledFade, the same fade DisabledText applies to Text.

func (*Theme) DisabledSurface

func (t *Theme) DisabledSurface() Color

DisabledSurface returns the fill of a control that ignores input: the explicit SurfaceDisabled when set, otherwise Surface mixed halfway toward Bg — the control recedes into the window on any palette, the inert counterpart of PressedSurface.

func (*Theme) DisabledText

func (t *Theme) DisabledText() Color

DisabledText returns the color for rows and labels that ignore input: the explicit TextMuted when set, otherwise Text faded to disabledFade alpha.

func (*Theme) DrawShadow

func (t *Theme) DrawShadow(cv *render.Canvas, r render.Rect, radius int)

DrawShadow paints the theme's box shadow around r — a widget's arranged bounds — rounding at the given corner radius. It is the one elevation helper every floating surface paints through; disabled or fully transparent shadows paint nothing.

func (*Theme) ErrorColor

func (t *Theme) ErrorColor() Color

ErrorColor returns the error fill (Error when set).

func (*Theme) HoverAccent

func (t *Theme) HoverAccent() Color

HoverAccent returns the translucent accent wash rows and items paint under the pointer: Accent at alpha 70, the same derivation every highlighter uses.

func (*Theme) HoverSurface

func (t *Theme) HoverSurface() Color

HoverSurface returns the control fill under the pointer: the explicit SurfaceHover when set, otherwise Surface mixed 8% toward Text. The text pole carries the palette's polarity, so the shift lightens dark palettes and darkens light ones.

func (*Theme) InputColor

func (t *Theme) InputColor() Color

InputColor returns the input border color: Input when set, otherwise Border.

func (*Theme) IsDark

func (t *Theme) IsDark() bool

IsDark reports the palette's polarity: a background darker than mid-grey luminance.

func (*Theme) MotionDurations

func (t *Theme) MotionDurations() (short, medium, long time.Duration)

MotionDurations returns the motion tokens in effect: the theme's, the toolkit's where unset, and zero throughout when Moves is false.

func (*Theme) Moves added in v0.2.1

func (t *Theme) Moves() bool

Moves reports whether this theme's motion runs: Animations, unless the desktop asks for reduced motion (SetReducedMotion).

func (*Theme) MutedColor

func (t *Theme) MutedColor() Color

MutedColor returns the quiet-region fill: Muted when set, otherwise Surface.

func (*Theme) PopoverColor

func (t *Theme) PopoverColor() Color

PopoverColor returns the floating-surface fill: Popover when set, otherwise Surface.

func (*Theme) PressedSurface

func (t *Theme) PressedSurface() Color

PressedSurface returns the control fill while pressed: the explicit SurfacePressed when set, otherwise Surface mixed 20% toward black — the surface recedes under a press on any palette.

func (*Theme) RingColor

func (t *Theme) RingColor() Color

RingColor returns the focus ring color: Ring when set, otherwise Accent.

func (*Theme) SecondaryColor

func (t *Theme) SecondaryColor() Color

SecondaryColor returns the secondary variant's fill: Secondary when set, otherwise MutedColor.

func (*Theme) ShadowGutter

func (t *Theme) ShadowGutter() int

ShadowGutter reports how much room a surface must reserve around its content for the theme's shadow: the blur when shadows paint, else zero. Popups grow their surface by it on every side and dialogs inset their card by it; content size, placement, and hit-testing stay on the un-guttered logical rect.

func (*Theme) ShadowRing

func (t *Theme) ShadowRing(r render.Rect) render.Rect

ShadowRing returns the rect the shadow around r covers: the damage ring a floating widget owes beyond its bounds (the blur plus the anti-aliasing rim, matching the raster's box). Empty when the shadow is disabled, which callers treat as "no extra pixels owed".

func (*Theme) SidebarColor

func (t *Theme) SidebarColor() Color

SidebarColor returns the sidebar fill: Sidebar when set, otherwise Surface.

func (*Theme) SuccessColor

func (t *Theme) SuccessColor() Color

SuccessColor returns the success fill (Success when set).

func (*Theme) TitleSize

func (t *Theme) TitleSize() float64

TitleSize is the size of a title over text at TextSize: a card's, a dialog's or a window's heading.

func (*Theme) WarningColor

func (t *Theme) WarningColor() Color

WarningColor returns the warning fill (Warning when set).

func (*Theme) WithAccent

func (t *Theme) WithAccent(c Color) *Theme

WithAccent returns a copy with the accent color set.

func (*Theme) WithAccentHex

func (t *Theme) WithAccentHex(s string) (*Theme, error)

WithAccentHex returns a copy with the accent parsed from a hex string (#rgb, #rrggbb, #rrggbbaa). A malformed string is an error, never a silent default — theme construction is where a config mistake must surface.

func (*Theme) WithAnimations

func (t *Theme) WithAnimations(on bool) *Theme

WithAnimations returns a copy with the animated-motion gate set; false is the theme-level reduced-motion switch (see Animations).

func (*Theme) WithBg

func (t *Theme) WithBg(c Color) *Theme

WithBg returns a copy with the window background set.

func (*Theme) WithBorder

func (t *Theme) WithBorder(c Color) *Theme

WithBorder returns a copy with the outline color set.

func (*Theme) WithCard

func (t *Theme) WithCard(c Color) *Theme

WithCard returns a copy with the card fill set.

func (*Theme) WithInput

func (t *Theme) WithInput(c Color) *Theme

WithInput returns a copy with the input border color set.

func (*Theme) WithMotion

func (t *Theme) WithMotion(short, medium, long time.Duration) *Theme

WithMotion returns a copy with the motion tokens set; zero keeps a token at the toolkit's duration.

func (*Theme) WithMuted

func (t *Theme) WithMuted(c Color) *Theme

WithMuted returns a copy with the quiet-region fill set.

func (*Theme) WithOnAccent

func (t *Theme) WithOnAccent(c Color) *Theme

WithOnAccent returns a copy with the on-accent glyph color set.

func (*Theme) WithPadding

func (t *Theme) WithPadding(px int) *Theme

WithPadding returns a copy with the default control padding set.

func (*Theme) WithPopover

func (t *Theme) WithPopover(c Color) *Theme

WithPopover returns a copy with the floating-surface fill set.

func (*Theme) WithRadius

func (t *Theme) WithRadius(px int) *Theme

WithRadius returns a copy with the default corner rounding set.

func (*Theme) WithRing

func (t *Theme) WithRing(c Color) *Theme

WithRing returns a copy with the focus ring color set.

func (*Theme) WithSecondary

func (t *Theme) WithSecondary(c Color) *Theme

WithSecondary returns a copy with the secondary variant's fill set.

func (*Theme) WithShadowBlur

func (t *Theme) WithShadowBlur(px int) *Theme

WithShadowBlur returns a copy with the shadow falloff radius set; zero disables client shadows (see ShadowBlur).

func (*Theme) WithShadowColor

func (t *Theme) WithShadowColor(c Color) *Theme

WithShadowColor returns a copy with the box-shadow color set. The zero color means unset (derive the default), the theme-wide convention.

func (*Theme) WithSidebar

func (t *Theme) WithSidebar(c Color) *Theme

WithSidebar returns a copy with the sidebar fill set.

func (*Theme) WithSpacing

func (t *Theme) WithSpacing(px int) *Theme

WithSpacing returns a copy with the default layout gap set.

func (*Theme) WithSurface

func (t *Theme) WithSurface(c Color) *Theme

WithSurface returns a copy with the control fill set.

func (*Theme) WithSurfaceDisabled

func (t *Theme) WithSurfaceDisabled(c Color) *Theme

WithSurfaceDisabled returns a copy with the disabled-control fill set; unset, the copy derives one (DisabledSurface).

func (*Theme) WithSurfaceHover

func (t *Theme) WithSurfaceHover(c Color) *Theme

WithSurfaceHover returns a copy with the hover shade set; unset, the copy derives one (HoverSurface).

func (*Theme) WithSurfacePressed

func (t *Theme) WithSurfacePressed(c Color) *Theme

WithSurfacePressed returns a copy with the pressed shade set; unset, the copy derives one (PressedSurface).

func (*Theme) WithText

func (t *Theme) WithText(c Color) *Theme

WithText returns a copy with the primary text color set.

func (*Theme) WithTextMuted

func (t *Theme) WithTextMuted(c Color) *Theme

WithTextMuted returns a copy with the secondary text color set.

func (*Theme) WithTextSize

func (t *Theme) WithTextSize(px float64) *Theme

WithTextSize returns a copy with the default label size set.

type TimeOfDay

type TimeOfDay struct {
	Hour, Minute int
}

TimeOfDay is a wall-clock time: an hour 0-23 and a minute 0-59.

func (TimeOfDay) String

func (t TimeOfDay) String() string

String is the 24-hour time, 14:05.

type Toast

type Toast struct {
	OnAction func()

	// OnDismissed fires once when the toast finished going away — the
	// exit fade landed, or Dismiss hit a toast that was out of the
	// tree. The host detaches it inside.
	OnDismissed func()
	// contains filtered or unexported fields
}

Toast is a transient feedback card: a line of text, an optional muted description under it, an optional action button, an auto-dismiss timer that hover pauses (hovering cancels the pending dismissal — even a mid-exit toast snaps back — and leaving arms a fresh full timeout), and a slide-and-fade entrance plus fade-out exit, all on the animation clock. A toast out of the tree is inert: it holds no timer, so a detached toast costs no wakeups.

The host learns the toast is gone from OnDismissed, which fires exactly once when the exit fade lands, and detaches it there.

func NewToast

func NewToast(face render.Font, text string, timeout time.Duration) *Toast

NewToast returns a toast showing text. A positive timeout auto-dismisses the card once it is on screen; zero or negative keeps it until Dismiss. Face may be a render.Chain for mixed-script fallback. A nil face panics here (see requireFace) instead of failing later, in shaping.

func (*Toast) AccessibleName

func (n *Toast) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*Toast) Action

func (t *Toast) Action() string

Action returns the action label, empty when there is none.

func (*Toast) AddClass

func (n *Toast) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*Toast) Arrange

func (t *Toast) Arrange(r render.Rect)

Arrange records the rect. The first visible arrangement starts the entrance and arms the auto-dismiss timer; going off screen stops both — nothing animates while hidden.

func (*Toast) AttachStylesheet

func (n *Toast) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*Toast) Attr

func (n *Toast) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*Toast) Bounds

func (n *Toast) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*Toast) Classes

func (n *Toast) Classes() []string

Classes returns a copy of the widget's classes.

func (*Toast) ClickAt

func (t *Toast) ClickAt(p Point)

ClickAt fires the action when the release landed on it, dismissing the toast; clicks elsewhere are inert.

func (*Toast) Close

func (t *Toast) Close()

Close tears the toast down without a fade and without firing OnDismissed — the host calling this is already detaching it.

func (*Toast) Closed

func (t *Toast) Closed() bool

Closed reports whether the toast is permanently gone.

func (*Toast) DebugName

func (n *Toast) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*Toast) Description

func (t *Toast) Description() string

Description returns the line under the text, empty when there is none.

func (*Toast) DetachStylesheet

func (n *Toast) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*Toast) Dismiss

func (t *Toast) Dismiss()

Dismiss starts the exit fade now. A toast out of the tree has no pixels to fade, so it finishes on the spot.

func (*Toast) Element

func (n *Toast) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*Toast) Enabled

func (n *Toast) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*Toast) HAlign

func (n *Toast) HAlign() Align

HAlign returns the horizontal placement.

func (*Toast) HasClass

func (n *Toast) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*Toast) HasState

func (n *Toast) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*Toast) HitLeaf

func (n *Toast) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*Toast) HitTest

func (t *Toast) HitTest(p Point) Widget

HitTest returns the toast when p is inside its bounds; the toast handles its own action clicks.

func (*Toast) HoverMove

func (t *Toast) HoverMove(p Point)

HoverMove tracks the pointer for the action button's hover shade.

func (*Toast) HoverWithin

func (n *Toast) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*Toast) ID

func (n *Toast) ID() string

ID returns the style id, empty when none is set.

func (*Toast) InlineStyle

func (n *Toast) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*Toast) Invalidate

func (n *Toast) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*Toast) InvalidateLayout

func (n *Toast) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*Toast) InvalidateRect

func (n *Toast) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*Toast) LayoutMotion

func (n *Toast) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*Toast) Margin

func (n *Toast) Margin() render.Insets

Margin returns the programmatic margin.

func (*Toast) MaximumSize

func (n *Toast) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*Toast) Measure

func (t *Toast) Measure(axis Axis, forSize int) Sizes

Measure wants the text plus the action at the theme text size, padded to a card, and needs only the action and the padding: the host clamps the width and the text clips.

func (*Toast) Paint

func (t *Toast) Paint(cv *render.Canvas)

Paint draws the card, its text, and the action button at the current reveal: alpha fades with progress, and the entrance rise is masked to the paint extent — the card's bounds, widened by the theme shadow ring plus the slide when one is owed — so the animation never paints outside its damage rect. The shadow rides the card (it shifts with the same dy), which is why it clips to the extent, not the bounds. The stylesheet's box-shadow, background-color, border, border-radius, and color override the theme's; the action is Sonner's small button on the primary fill.

func (*Toast) Parent

func (n *Toast) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*Toast) RemoveAttr

func (n *Toast) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*Toast) RemoveClass

func (n *Toast) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*Toast) SetAccessibleName

func (n *Toast) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*Toast) SetAction

func (t *Toast) SetAction(label string, fn func())

SetAction attaches the optional action button; an empty label removes it. Firing the action dismisses the toast, the standard toast contract.

func (*Toast) SetAttr

func (n *Toast) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*Toast) SetClass

func (n *Toast) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*Toast) SetClasses

func (n *Toast) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*Toast) SetCursorName

func (n *Toast) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*Toast) SetDebugName

func (n *Toast) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*Toast) SetDescription

func (t *Toast) SetDescription(desc string)

SetDescription sets the muted line under the text; empty removes it.

func (*Toast) SetElement

func (n *Toast) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*Toast) SetEnabled

func (n *Toast) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*Toast) SetFocusOnClick

func (n *Toast) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*Toast) SetHAlign

func (n *Toast) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*Toast) SetHExpand

func (n *Toast) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*Toast) SetHovered

func (t *Toast) SetHovered(on bool)

SetHovered implements HoverSetter: hover cancels the pending dismissal — the timer goes away and a mid-exit toast snaps back — and leaving arms a fresh full timeout.

func (*Toast) SetID

func (n *Toast) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*Toast) SetInlineStyle

func (n *Toast) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*Toast) SetInlineStylePriority

func (n *Toast) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*Toast) SetLayoutMotion

func (n *Toast) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*Toast) SetMargin

func (n *Toast) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*Toast) SetMaximumSize

func (n *Toast) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*Toast) SetOnClickWithin

func (n *Toast) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*Toast) SetOnFocusChanged

func (n *Toast) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*Toast) SetOnHoverWithin

func (n *Toast) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*Toast) SetOnPointer

func (n *Toast) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*Toast) SetOnScroll

func (n *Toast) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*Toast) SetSharedElement

func (n *Toast) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*Toast) SetSizeRequest

func (n *Toast) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*Toast) SetState

func (n *Toast) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*Toast) SetText

func (t *Toast) SetText(text string)

SetText replaces the card's text.

func (*Toast) SetTooltip

func (n *Toast) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*Toast) SetTooltipMarkup

func (n *Toast) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*Toast) SetVAlign

func (n *Toast) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*Toast) SetVExpand

func (n *Toast) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*Toast) SetVisible

func (n *Toast) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*Toast) SharedElement

func (n *Toast) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*Toast) SizeRequest

func (n *Toast) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*Toast) Text

func (t *Toast) Text() string

Text returns the card's text.

func (*Toast) TooltipMarkup

func (n *Toast) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*Toast) TooltipText

func (n *Toast) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*Toast) VAlign

func (n *Toast) VAlign() Align

VAlign returns the vertical placement.

func (*Toast) Visible

func (n *Toast) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ToggleButton

type ToggleButton struct {
	Button

	// OnToggled fires after every change of the active state, from a
	// click, a key, SetActive, or a group peer taking over.
	OnToggled func(active bool)
	// contains filtered or unexported fields
}

ToggleButton is a button that stays pressed (GTK ToggleButton): clicking flips its active state, painted with the selected fill and :checked. In a group (SetGroup) it behaves as a radio: activating it releases the others and a click on the active one keeps it active. The embedded Button's OnClick drives the toggle; observe OnToggled. Assistive technology reads it as a toggle button, pressed while active.

func NewToggleButton

func NewToggleButton(child Widget, padding, radius int) *ToggleButton

NewToggleButton returns an inactive toggle around child. It styles as GTK's toggle, button.toggle.

func (*ToggleButton) AccessibleName

func (n *ToggleButton) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*ToggleButton) Active

func (t *ToggleButton) Active() bool

Active reports the state.

func (*ToggleButton) AddClass

func (n *ToggleButton) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*ToggleButton) AttachStylesheet

func (n *ToggleButton) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*ToggleButton) Attr

func (n *ToggleButton) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*ToggleButton) BindAction

func (t *ToggleButton) BindAction(c Checkable) (unbind func())

BindAction makes the toggle a proxy of c: it shows c's checked state, a click activates c, and it is enabled exactly while c is.

func (*ToggleButton) Bounds

func (n *ToggleButton) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*ToggleButton) Classes

func (n *ToggleButton) Classes() []string

Classes returns a copy of the widget's classes.

func (*ToggleButton) DebugName

func (n *ToggleButton) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*ToggleButton) DetachStylesheet

func (n *ToggleButton) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*ToggleButton) Element

func (n *ToggleButton) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*ToggleButton) Enabled

func (n *ToggleButton) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*ToggleButton) HAlign

func (n *ToggleButton) HAlign() Align

HAlign returns the horizontal placement.

func (*ToggleButton) HasClass

func (n *ToggleButton) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*ToggleButton) HasState

func (n *ToggleButton) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*ToggleButton) HitLeaf

func (n *ToggleButton) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*ToggleButton) HoverWithin

func (n *ToggleButton) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*ToggleButton) ID

func (n *ToggleButton) ID() string

ID returns the style id, empty when none is set.

func (*ToggleButton) InlineStyle

func (n *ToggleButton) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*ToggleButton) Invalidate

func (n *ToggleButton) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*ToggleButton) InvalidateLayout

func (n *ToggleButton) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*ToggleButton) InvalidateRect

func (n *ToggleButton) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*ToggleButton) LayoutMotion

func (n *ToggleButton) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*ToggleButton) Margin

func (n *ToggleButton) Margin() render.Insets

Margin returns the programmatic margin.

func (*ToggleButton) MaximumSize

func (n *ToggleButton) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*ToggleButton) Parent

func (n *ToggleButton) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*ToggleButton) RemoveAttr

func (n *ToggleButton) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*ToggleButton) RemoveClass

func (n *ToggleButton) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*ToggleButton) Role

func (t *ToggleButton) Role() Role

Role implements Roleer.

func (*ToggleButton) SetAccessibleName

func (n *ToggleButton) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*ToggleButton) SetActive

func (t *ToggleButton) SetActive(on bool)

SetActive changes the state, firing OnToggled when it flipped.

func (*ToggleButton) SetAttr

func (n *ToggleButton) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*ToggleButton) SetClass

func (n *ToggleButton) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*ToggleButton) SetClasses

func (n *ToggleButton) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*ToggleButton) SetCursorName

func (n *ToggleButton) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*ToggleButton) SetDebugName

func (n *ToggleButton) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*ToggleButton) SetElement

func (n *ToggleButton) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*ToggleButton) SetEnabled

func (n *ToggleButton) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*ToggleButton) SetFocusOnClick

func (n *ToggleButton) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*ToggleButton) SetGroup

func (t *ToggleButton) SetGroup(other *ToggleButton)

SetGroup makes t a radio peer of other (joining other's group).

func (*ToggleButton) SetHAlign

func (n *ToggleButton) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*ToggleButton) SetHExpand

func (n *ToggleButton) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*ToggleButton) SetID

func (n *ToggleButton) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*ToggleButton) SetInlineStyle

func (n *ToggleButton) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*ToggleButton) SetInlineStylePriority

func (n *ToggleButton) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*ToggleButton) SetLayoutMotion

func (n *ToggleButton) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*ToggleButton) SetMargin

func (n *ToggleButton) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*ToggleButton) SetMaximumSize

func (n *ToggleButton) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*ToggleButton) SetOnClickWithin

func (n *ToggleButton) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*ToggleButton) SetOnFocusChanged

func (n *ToggleButton) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*ToggleButton) SetOnHoverWithin

func (n *ToggleButton) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*ToggleButton) SetOnPointer

func (n *ToggleButton) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*ToggleButton) SetOnScroll

func (n *ToggleButton) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*ToggleButton) SetSharedElement

func (n *ToggleButton) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*ToggleButton) SetSizeRequest

func (n *ToggleButton) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*ToggleButton) SetState

func (n *ToggleButton) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*ToggleButton) SetTooltip

func (n *ToggleButton) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*ToggleButton) SetTooltipMarkup

func (n *ToggleButton) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*ToggleButton) SetVAlign

func (n *ToggleButton) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*ToggleButton) SetVExpand

func (n *ToggleButton) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*ToggleButton) SetVisible

func (n *ToggleButton) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*ToggleButton) SharedElement

func (n *ToggleButton) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*ToggleButton) SizeRequest

func (n *ToggleButton) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*ToggleButton) TooltipMarkup

func (n *ToggleButton) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*ToggleButton) TooltipText

func (n *ToggleButton) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*ToggleButton) VAlign

func (n *ToggleButton) VAlign() Align

VAlign returns the vertical placement.

func (*ToggleButton) Visible

func (n *ToggleButton) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type ToggleGroup

type ToggleGroup struct {

	// OnChanged fires after every change of the active toggle, from a
	// click, a key, or SetActive.
	OnChanged func(i int)
	// contains filtered or unexported fields
}

ToggleGroup is the segmented control (adw 1.7): a pill of ToggleButtons in one radio group, exactly one active. Clicks and Left/Right activate; SetActive drives it from code. ViewSwitcher is a ToggleGroup bound to a Stack.

func NewToggleGroup

func NewToggleGroup(items ...Widget) *ToggleGroup

NewToggleGroup returns a group over items (labels, ButtonContents, icons), the first active.

func (*ToggleGroup) Active

func (g *ToggleGroup) Active() int

Active reports the active toggle (-1 when empty).

func (*ToggleGroup) Append

func (g *ToggleGroup) Append(content Widget)

Append adds a toggle; the first one appended is active. Appending never announces: OnChanged reports user and SetActive changes only.

func (*ToggleGroup) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ToggleGroup) Baseline

func (c *ToggleGroup) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ToggleGroup) Children

func (c *ToggleGroup) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ToggleGroup) Clear

func (g *ToggleGroup) Clear()

Clear removes every toggle.

func (*ToggleGroup) HitTest

func (c *ToggleGroup) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ToggleGroup) KeyAction

func (g *ToggleGroup) KeyAction(a KeyAction, _ Mods)

KeyAction moves the active toggle with Left/Right.

func (*ToggleGroup) Len

func (g *ToggleGroup) Len() int

Len reports the toggle count.

func (*ToggleGroup) Measure

func (c *ToggleGroup) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ToggleGroup) Paint

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

Paint draws the surface (when configured) then the root.

func (*ToggleGroup) SetActive

func (g *ToggleGroup) SetActive(i int)

SetActive activates toggle i (clamped); OnChanged fires when it moved.

type ToolbarStyle

type ToolbarStyle uint8

ToolbarStyle is how a ToolbarView's bars sit against the content.

const (
	// ToolbarFlat draws the bars flush with the content.
	ToolbarFlat ToolbarStyle = iota
	// ToolbarRaised raises the bars with a shadow.
	ToolbarRaised
	// ToolbarRaisedBorder raises the bars and draws a border.
	ToolbarRaisedBorder
)

type ToolbarView

type ToolbarView struct {
	// contains filtered or unexported fields
}

ToolbarView is libadwaita's AdwToolbarView: top and bottom bars around a content widget. The bars reveal and hide with a slide, take a flat, raised or raised-with-border style, and the content can extend under them (under translucent bars, scrolling beneath them). It styles as `toolbarview` with `.top-bar` and `.bottom-bar` parts carrying the style as a class.

func NewToolbarView

func NewToolbarView(content Widget) *ToolbarView

NewToolbarView returns a toolbar view around content.

func (*ToolbarView) AddBottomBar

func (t *ToolbarView) AddBottomBar(bar Widget)

AddBottomBar appends a bar to the bottom stack.

func (*ToolbarView) AddTopBar

func (t *ToolbarView) AddTopBar(bar Widget)

AddTopBar appends a bar to the top stack.

func (*ToolbarView) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*ToolbarView) Baseline

func (c *ToolbarView) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*ToolbarView) Children

func (c *ToolbarView) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*ToolbarView) Content

func (t *ToolbarView) Content() Widget

Content returns the content.

func (*ToolbarView) HitTest

func (c *ToolbarView) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*ToolbarView) Measure

func (c *ToolbarView) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*ToolbarView) Paint

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

Paint draws the surface (when configured) then the root.

func (*ToolbarView) RevealBottomBars

func (t *ToolbarView) RevealBottomBars() bool

RevealBottomBars reports whether the bottom bars are shown.

func (*ToolbarView) RevealTopBars

func (t *ToolbarView) RevealTopBars() bool

RevealTopBars reports whether the top bars are shown.

func (*ToolbarView) SetBottomBarStyle

func (t *ToolbarView) SetBottomBarStyle(s ToolbarStyle)

SetBottomBarStyle sets the bottom bars' style.

func (*ToolbarView) SetContent

func (t *ToolbarView) SetContent(w Widget)

SetContent replaces the content.

func (*ToolbarView) SetExtendContentToBottomEdge

func (t *ToolbarView) SetExtendContentToBottomEdge(on bool)

SetExtendContentToBottomEdge lets the content run under the bottom bars.

func (*ToolbarView) SetExtendContentToTopEdge

func (t *ToolbarView) SetExtendContentToTopEdge(on bool)

SetExtendContentToTopEdge lets the content run under the top bars.

func (*ToolbarView) SetRevealBottomBars

func (t *ToolbarView) SetRevealBottomBars(on bool)

SetRevealBottomBars shows or hides the bottom bars with a slide.

func (*ToolbarView) SetRevealTopBars

func (t *ToolbarView) SetRevealTopBars(on bool)

SetRevealTopBars shows or hides the top bars with a slide.

func (*ToolbarView) SetTopBarStyle

func (t *ToolbarView) SetTopBarStyle(s ToolbarStyle)

SetTopBarStyle sets the top bars' style.

type TooltipAnchorer

type TooltipAnchorer interface {
	TooltipAnchor() render.Rect
}

TooltipAnchorer is a widget whose tooltip belongs to a part of it, a calendar's hovered day: the tooltip centers under that rect, in the tree's coordinates, rather than under the widget's bounds.

type TooltipMarkupper

type TooltipMarkupper interface {
	TooltipMarkup() (markup string, ok bool)
}

TooltipMarkupper is a widget whose tooltip may be RichLabel markup; every node is one (SetTooltipMarkup).

type TooltipTexter

type TooltipTexter interface {
	// TooltipText returns the tooltip, empty when none is set.
	TooltipText() string
}

TooltipTexter exposes a widget's hover tooltip text.

type TouchPointer

type TouchPointer interface {
	TouchMove(p Point)
	TouchPress(p Point)
	TouchRelease(p Point)
	// TouchCancel ends the emulated press without a click: a gesture
	// took the contact over.
	TouchCancel()
}

TouchPointer receives a touch contact's pointer emulation: the host routes it through its own pointer path (window-frame grabs and drag sources included), or RouterPointer drives the router directly.

type TouchTracker

type TouchTracker struct {
	Router  *Router
	Pointer TouchPointer
	// contains filtered or unexported fields
}

TouchTracker turns touch contacts into input the rest of the toolkit already speaks. One contact emulates the pointer - a tap clicks, a drag drags, a hold past the long-press delay offers GestureLongPress - through Pointer. A second contact cancels that and makes the pair a gesture: a pinch (scale and rotation) for a widget that claims GesturePinch, otherwise a two-finger scroll down the precise-axis path, ending in a kinetic glide when the fingers lift.

func (*TouchTracker) Cancel

func (t *TouchTracker) Cancel()

Cancel drops every contact: the compositor took the sequence.

func (*TouchTracker) Down

func (t *TouchTracker) Down(id int32, p Point)

Down adds a contact at p.

func (*TouchTracker) Motion

func (t *TouchTracker) Motion(id int32, p Point)

Motion moves contact id to p.

func (*TouchTracker) Up

func (t *TouchTracker) Up(id int32)

Up lifts contact id.

type TreeRow

type TreeRow[T any] struct {
	Value    T
	Children []TreeRow[T]
}

TreeRow is one node of a static tree: a value and its children.

type TypedFactory

type TypedFactory[T any] struct {
	Setup func() Widget
	Bind  func(item T, row Widget)
	// Unbind, when set, runs when a row's item scrolls out; the row
	// goes back to the pool and is Bound to whatever scrolls in next.
	Unbind func(item T, row Widget)
}

TypedFactory is how a typed view materializes rows, relm4's RelmListItem/RelmGridItem: Setup builds a row once, Bind fills it for one item every time it scrolls into view, Unbind releases it when it scrolls out. Rows recycle: only the visible ones exist, and Setup runs about as often as the viewport holds rows.

type TypedGrid

type TypedGrid[T any] struct {
	TypedList[T]
}

TypedGrid is a virtualized grid over typed items, relm4's TypedGridView: a TypedList flowing left to right in as many columns of the cell width as the width fits, recycling, sorting, filters and typed selection all inherited. It styles as `gridview` with `child` cells.

func NewTypedGrid

func NewTypedGrid[T any](model ColumnModel[T], factory TypedFactory[T], cellWidth, cellHeight int) *TypedGrid[T]

NewTypedGrid returns a grid over model with cells of at least cellWidth by cellHeight pixels, between 1 and 7 columns (GTK's defaults).

func (*TypedGrid) AccessibleName

func (n *TypedGrid) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*TypedGrid) AddClass

func (n *TypedGrid) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*TypedGrid) AttachStylesheet

func (n *TypedGrid) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*TypedGrid) Attr

func (n *TypedGrid) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*TypedGrid) Bounds

func (n *TypedGrid) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*TypedGrid) Classes

func (n *TypedGrid) Classes() []string

Classes returns a copy of the widget's classes.

func (*TypedGrid[T]) Columns

func (g *TypedGrid[T]) Columns() int

Columns returns the column count of the last layout.

func (*TypedGrid) DebugName

func (n *TypedGrid) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*TypedGrid) DetachStylesheet

func (n *TypedGrid) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*TypedGrid) Element

func (n *TypedGrid) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*TypedGrid) Enabled

func (n *TypedGrid) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*TypedGrid) HAlign

func (n *TypedGrid) HAlign() Align

HAlign returns the horizontal placement.

func (*TypedGrid) HasClass

func (n *TypedGrid) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*TypedGrid) HasState

func (n *TypedGrid) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*TypedGrid) HitLeaf

func (n *TypedGrid) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*TypedGrid) HoverWithin

func (n *TypedGrid) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*TypedGrid) ID

func (n *TypedGrid) ID() string

ID returns the style id, empty when none is set.

func (*TypedGrid) InlineStyle

func (n *TypedGrid) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*TypedGrid) Invalidate

func (n *TypedGrid) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*TypedGrid) InvalidateLayout

func (n *TypedGrid) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*TypedGrid) InvalidateRect

func (n *TypedGrid) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*TypedGrid) LayoutMotion

func (n *TypedGrid) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*TypedGrid) Margin

func (n *TypedGrid) Margin() render.Insets

Margin returns the programmatic margin.

func (*TypedGrid[T]) MaxColumns

func (g *TypedGrid[T]) MaxColumns() int

MaxColumns returns the column cap, zero for none.

func (*TypedGrid) MaximumSize

func (n *TypedGrid) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*TypedGrid[T]) MinColumns

func (g *TypedGrid[T]) MinColumns() int

MinColumns returns the column floor.

func (*TypedGrid) Parent

func (n *TypedGrid) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*TypedGrid) RemoveAttr

func (n *TypedGrid) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*TypedGrid) RemoveClass

func (n *TypedGrid) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*TypedGrid) Select

func (s *TypedGrid) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*TypedGrid) SelectAll

func (s *TypedGrid) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*TypedGrid) SelectRows

func (s *TypedGrid) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*TypedGrid) Selected

func (s *TypedGrid) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*TypedGrid) Selection

func (s *TypedGrid) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*TypedGrid) SelectionMode

func (s *TypedGrid) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*TypedGrid) SetAccessibleName

func (n *TypedGrid) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*TypedGrid) SetAttr

func (n *TypedGrid) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*TypedGrid) SetClass

func (n *TypedGrid) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*TypedGrid) SetClasses

func (n *TypedGrid) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*TypedGrid) SetCursorName

func (n *TypedGrid) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*TypedGrid) SetDebugName

func (n *TypedGrid) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*TypedGrid) SetElement

func (n *TypedGrid) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*TypedGrid) SetEnabled

func (n *TypedGrid) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*TypedGrid) SetFocusOnClick

func (n *TypedGrid) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*TypedGrid) SetHAlign

func (n *TypedGrid) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*TypedGrid) SetHExpand

func (n *TypedGrid) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*TypedGrid) SetID

func (n *TypedGrid) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*TypedGrid) SetInlineStyle

func (n *TypedGrid) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*TypedGrid) SetInlineStylePriority

func (n *TypedGrid) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*TypedGrid) SetLayoutMotion

func (n *TypedGrid) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*TypedGrid) SetMargin

func (n *TypedGrid) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*TypedGrid[T]) SetMaxColumns

func (g *TypedGrid[T]) SetMaxColumns(n int)

SetMaxColumns sets the most columns the grid lays out; zero lifts the cap.

func (*TypedGrid) SetMaximumSize

func (n *TypedGrid) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*TypedGrid[T]) SetMinColumns

func (g *TypedGrid[T]) SetMinColumns(n int)

SetMinColumns sets the fewest columns the grid lays out, even when cells end up narrower than their width.

func (*TypedGrid) SetOnClickWithin

func (n *TypedGrid) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*TypedGrid) SetOnFocusChanged

func (n *TypedGrid) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*TypedGrid) SetOnHoverWithin

func (n *TypedGrid) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*TypedGrid) SetOnPointer

func (n *TypedGrid) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*TypedGrid) SetOnScroll

func (n *TypedGrid) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*TypedGrid) SetSelectionMode

func (s *TypedGrid) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*TypedGrid) SetSharedElement

func (n *TypedGrid) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*TypedGrid) SetSizeRequest

func (n *TypedGrid) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*TypedGrid) SetState

func (n *TypedGrid) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*TypedGrid) SetTooltip

func (n *TypedGrid) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*TypedGrid) SetTooltipMarkup

func (n *TypedGrid) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*TypedGrid) SetVAlign

func (n *TypedGrid) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*TypedGrid) SetVExpand

func (n *TypedGrid) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*TypedGrid) SetVisible

func (n *TypedGrid) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*TypedGrid) SharedElement

func (n *TypedGrid) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*TypedGrid) SizeRequest

func (n *TypedGrid) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*TypedGrid) TooltipMarkup

func (n *TypedGrid) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*TypedGrid) TooltipText

func (n *TypedGrid) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*TypedGrid) VAlign

func (n *TypedGrid) VAlign() Align

VAlign returns the vertical placement.

func (*TypedGrid) Visible

func (n *TypedGrid) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type TypedItems

type TypedItems[T any] struct {
	// contains filtered or unexported fields
}

TypedItems is the typed item model the typed views sit on, relm4's DynamicIndex analog: a slice of T with CRUD, insertion in sort order, and change notification - wholesale through SetRefresh/Notify, one edited item in place through SetItemRefresh/NotifyItem. It is a ColumnModel, so it feeds TypedList, TypedGrid and ColumnView alike.

func NewTypedItems

func NewTypedItems[T any](items ...T) *TypedItems[T]

NewTypedItems returns a model over items.

func (*TypedItems[T]) Append

func (m *TypedItems[T]) Append(item T)

Append adds item at the end.

func (*TypedItems[T]) Clear

func (m *TypedItems[T]) Clear()

Clear drops every item and notifies the refresh.

func (*TypedItems[T]) Get

func (m *TypedItems[T]) Get(i int) T

Get returns item i.

func (*TypedItems[T]) Insert

func (m *TypedItems[T]) Insert(i int, item T)

Insert adds item at i and notifies the refresh.

func (*TypedItems[T]) InsertSorted

func (m *TypedItems[T]) InsertSorted(item T, cmp func(a, b T) int) int

InsertSorted adds item at the position cmp keeps the slice sorted at (the first among equals) and returns where it landed.

func (*TypedItems[T]) Len

func (m *TypedItems[T]) Len() int

Len implements ColumnModel.

func (*TypedItems[T]) Notify

func (m *TypedItems[T]) Notify()

Notify reports the model changed; the view recomputes - resorting, refiltering and rebinding in the process.

func (*TypedItems[T]) NotifyItem

func (m *TypedItems[T]) NotifyItem(i int)

NotifyItem reports item i was edited in place; a visible row rebinds to the new value, and nothing else moves.

func (*TypedItems[T]) RemoveAt

func (m *TypedItems[T]) RemoveAt(i int)

RemoveAt drops item i and notifies the refresh.

func (*TypedItems[T]) Row

func (m *TypedItems[T]) Row(i int) T

Row implements ColumnModel.

func (*TypedItems[T]) Set

func (m *TypedItems[T]) Set(i int, item T)

Set replaces item i in place and notifies the item refresh, so a visible row rebinds to the new value without rebuilding the view.

func (*TypedItems[T]) SetItemRefresh

func (m *TypedItems[T]) SetItemRefresh(fn func(i int))

SetItemRefresh installs the per-item hook NotifyItem runs.

func (*TypedItems[T]) SetRefresh

func (m *TypedItems[T]) SetRefresh(fn func())

SetRefresh installs the wholesale-change hook Notify runs.

type TypedList

type TypedList[T any] struct {
	List

	// OnSelectionChanged fires with the selected items, in visible
	// order, once per gesture.
	OnSelectionChanged func(items []T)
	// OnActivate fires with the activated row's item.
	OnActivate func(item T)
	// contains filtered or unexported fields
}

TypedList is a virtualized list over typed items, relm4's TypedListView: the model layer sorts and filters without touching the source, rows are built once by the factory's Setup and filled per item by Bind (Unbind on the way out), so only the visible rows exist, and selection is typed - it reports items and follows them through sorting and filtering. List underneath does what List is for: SetSelectionMode, Select, keyboard and scrolling come from it and act on visible rows.

func NewTypedList

func NewTypedList[T any](model ColumnModel[T], factory TypedFactory[T], rowHeight int) *TypedList[T]

NewTypedList returns a list over model whose rows the factory builds and fills; rowHeight is the uniform row height in pixels, zero to derive it from the first row.

func (*TypedList) AccessibleName

func (n *TypedList) AccessibleName() string

AccessibleName returns the name SetAccessibleName set.

func (*TypedList) AddClass

func (n *TypedList) AddClass(names ...string)

AddClass adds style classes; a widget matches `.class` selectors naming any of them. Adding a class already present is a no-op. The change restyles the widget (and, when a selector tests the class on an ancestor or sibling, the widgets that depend on it) on the next read.

func (*TypedList[T]) AddFilter

func (l *TypedList[T]) AddFilter(keep func(T) bool) *ViewFilter[T]

AddFilter appends a filter to the stack and returns its handle; every enabled filter must accept an item for it to show.

func (*TypedList) AttachStylesheet

func (n *TypedList) AttachStylesheet(s *Stylesheet)

AttachStylesheet applies s to this widget and its descendants, on top of the installed stylesheets (a tie at equal priority and specificity goes to the attached one). Attaching the same stylesheet twice is a no-op; one stylesheet can style many subtrees, and a Load restyles them all.

func (*TypedList) Attr

func (n *TypedList) Attr(name string) (string, bool)

Attr returns one data attribute's value and whether it is set.

func (*TypedList) Bounds

func (n *TypedList) Bounds() render.Rect

Bounds returns the last arranged rect. Before the first Arrange — and that includes a widget built but never put in a tree — it is the zero rect, a defined value, never a panic and never stale geometry.

func (*TypedList) Classes

func (n *TypedList) Classes() []string

Classes returns a copy of the widget's classes.

func (*TypedList[T]) ClearFilters

func (l *TypedList[T]) ClearFilters()

ClearFilters drops every filter.

func (*TypedList) DebugName

func (n *TypedList) DebugName() string

DebugName returns the widget's debug name, empty when none is set.

func (*TypedList) DetachStylesheet

func (n *TypedList) DetachStylesheet(s *Stylesheet)

DetachStylesheet stops s from styling this subtree; detaching one that is not attached is a no-op.

func (*TypedList) Element

func (n *TypedList) Element() string

Element returns the element name the widget matches: the override set with SetElement, else the lowercased Go type name.

func (*TypedList) Enabled

func (n *TypedList) Enabled() bool

Enabled reports the widget's own flag, NOT the effective state: a widget inside a disabled container still reads true here. Input paths and Paint must consult widget.IsEnabled, which folds the ancestors in.

func (*TypedList) HAlign

func (n *TypedList) HAlign() Align

HAlign returns the horizontal placement.

func (*TypedList) HasClass

func (n *TypedList) HasClass(name string) bool

HasClass reports whether the widget carries the style class.

func (*TypedList) HasState

func (n *TypedList) HasState(flags StateFlags) bool

HasState reports whether every flag in flags is on.

func (*TypedList) HitLeaf

func (n *TypedList) HitLeaf(self Widget, p Point) Widget

HitLeaf is the leaf hit test every widget without children routes through: the widget itself inside its bounds, unless it is hidden or the pointer passes through it (pointer-events: none on it or an ancestor).

func (*TypedList) HoverWithin

func (n *TypedList) HoverWithin() bool

HoverWithin reports whether the pointer is over the widget or a descendant.

func (*TypedList) ID

func (n *TypedList) ID() string

ID returns the style id, empty when none is set.

func (*TypedList) InlineStyle

func (n *TypedList) InlineStyle() string

InlineStyle returns the inline declarations as set.

func (*TypedList) Invalidate

func (n *TypedList) Invalidate()

Invalidate schedules a repaint of the widget's arranged bounds. Call it after any state change that alters what Paint draws. Layout is untouched; mutations that change the wanted size need InvalidateLayout.

func (*TypedList) InvalidateLayout

func (n *TypedList) InvalidateLayout()

InvalidateLayout drops the cached Measure result here and in every ancestor, so the next frame remeasures the affected branch only, and schedules a repaint of the bounds (a size change usually alters the painting too).

func (*TypedList) InvalidateRect

func (n *TypedList) InvalidateRect(r render.Rect)

InvalidateRect schedules a repaint of r, an arbitrary rect in root coordinates - for widgets that owe pixels outside their arranged bounds, such as a scrollbar strip beside a viewport. Unlike Invalidate it does not mark the arranged bounds themselves.

func (*TypedList[T]) ItemChanged

func (l *TypedList[T]) ItemChanged(i int)

ItemChanged rebinds the row showing source item i, when one is showing. The hook a TypedItems model reports an in-place edit through.

func (*TypedList) LayoutMotion

func (n *TypedList) LayoutMotion() LayoutMotion

LayoutMotion returns the programmatic layout motion.

func (*TypedList) Margin

func (n *TypedList) Margin() render.Insets

Margin returns the programmatic margin.

func (*TypedList) MaximumSize

func (n *TypedList) MaximumSize() Size

MaximumSize returns the size cap (zero axes unbounded).

func (*TypedList) Parent

func (n *TypedList) Parent() Widget

Parent returns the container that arranged this widget, or nil for the tree root.

func (*TypedList[T]) PopFilter

func (l *TypedList[T]) PopFilter()

PopFilter drops the most recently added filter.

func (*TypedList[T]) Refresh

func (l *TypedList[T]) Refresh()

Refresh re-reads the model: the order is rebuilt under the current sort and filters and the visible rows rebind. The hook a TypedItems model reports wholesale changes through.

func (*TypedList) RemoveAttr

func (n *TypedList) RemoveAttr(name string)

RemoveAttr drops one data attribute; dropping one the widget does not carry is a no-op.

func (*TypedList) RemoveClass

func (n *TypedList) RemoveClass(names ...string)

RemoveClass drops style classes; dropping one the widget does not carry is a no-op.

func (*TypedList[T]) Row

func (l *TypedList[T]) Row(i int) T

Row returns the data of visible row i, post sort/filter.

func (*TypedList[T]) Rows

func (l *TypedList[T]) Rows() int

Rows reports the visible item count, post sort/filter.

func (*TypedList) Select

func (s *TypedList) Select(i int)

Select moves the selection to item i (clamped, -1 clears). In multiple mode it collapses the set to the one item (-1 clears it); in none mode it does nothing.

func (*TypedList) SelectAll

func (s *TypedList) SelectAll()

SelectAll selects every item. It is the ctrl+a target through Router.SelectAll and does nothing outside multiple mode, where "all" is not a representable selection.

func (*TypedList) SelectRows

func (s *TypedList) SelectRows(rows ...int)

SelectRows makes rows the multiple-mode selection (out-of-range rows are dropped) and notifies; outside multiple mode it does nothing.

func (*TypedList) Selected

func (s *TypedList) Selected() int

Selected returns the selected item in single and browse mode; in multiple mode the anchor the last gesture or Select settled on, -1 when the set is empty. Selection reports the whole set.

func (*TypedList[T]) SelectedItem

func (l *TypedList[T]) SelectedItem() (item T, ok bool)

SelectedItem returns the selected item; in multiple mode the anchor the last gesture settled on, false when nothing is selected.

func (*TypedList[T]) SelectedItems

func (l *TypedList[T]) SelectedItems() []T

SelectedItems returns the selection as items, in visible order.

func (*TypedList) Selection

func (s *TypedList) Selection() []int

Selection returns the whole selected set, ascending; empty when nothing is selected.

func (*TypedList) SelectionMode

func (s *TypedList) SelectionMode() SelectionMode

SelectionMode returns the current selection model.

func (*TypedList) SetAccessibleName

func (n *TypedList) SetAccessibleName(name string)

SetAccessibleName names the widget for assistive technology, over its tooltip and the name its content gives it: an icon button's "Close", a page link's "Go to page 3". Empty restores those.

func (*TypedList) SetAttr

func (n *TypedList) SetAttr(name, value string)

SetAttr sets one data attribute, the `[attr]` and `[attr=value]` selectors' subject — app-attached metadata, GTK has no analog. An empty name is a no-op; an empty value sets a present-but-empty attribute. The change restyles the widget and, conservatively, its subtree.

func (*TypedList) SetClass

func (n *TypedList) SetClass(name string, on bool)

SetClass adds the class name when on and removes it otherwise.

func (*TypedList) SetClasses

func (n *TypedList) SetClasses(names ...string)

SetClasses replaces the class list wholesale — the GTK set_css_classes idiom for widgets whose modifiers are recomputed at once. Order is irrelevant to matching.

func (*TypedList) SetCursorName

func (n *TypedList) SetCursorName(s string)

SetCursorName requests the pointer shape while hovered, an xcursor name ("pointer", "text" — what set_cursor_from_name takes); empty falls back to the widget default. A widget's own CursorName implementation outranks it.

func (*TypedList) SetDebugName

func (n *TypedList) SetDebugName(name string)

SetDebugName labels the widget for the inspector: the tree dump and the overlay show it, so bug reports can point at "the save button" instead of "*widget.Button #3". Names are plain data: nothing in the toolkit reads them, and text or state updates never touch them.

func (*TypedList) SetElement

func (n *TypedList) SetElement(name string)

SetElement overrides the element name the widget matches in stylesheets. The default is the widget's own type name lowercased; the app-level surfaces (dialog, popover, tooltip, toast) name themselves with this in their constructors.

func (*TypedList) SetEnabled

func (n *TypedList) SetEnabled(enabled bool)

SetEnabled turns the widget's own interactivity on or off; every node-embedding widget inherits it. The zero state is enabled.

Propagation model (pinned): a container's flag does NOT rewrite its children's. Disable a Box and the whole subtree reads as disabled through widget.IsEnabled, the per-query ancestor walk — the same shape as IsInteractive. Per-query beats a recursive flag because it keeps every widget's own decision intact: re-enabling the container never resurrects a child the app disabled on purpose, and a child disabled after its container keeps its state when the container comes back. Each widget's own flag only ever changes through its own SetEnabled.

The flip invalidates self and — for containers that expose Children, which override this with invalidateTree — every descendant, so the muted paint lands on the next frame without a relayout: enabled state changes what Paint draws, never what Measure wants. The style marks go stale with the flags: :disabled rules may match now.

func (*TypedList[T]) SetFilterStatus

func (l *TypedList[T]) SetFilterStatus(f *ViewFilter[T], on bool)

SetFilterStatus turns a filter AddFilter returned on or off without dropping it.

func (*TypedList) SetFocusOnClick

func (n *TypedList) SetFocusOnClick(on bool)

SetFocusOnClick decides whether a press on the widget moves the keyboard focus to it (GTK's focus-on-click, on by default): a command palette's rows leave it in the search entry.

func (*TypedList) SetHAlign

func (n *TypedList) SetHAlign(a Align)

SetHAlign places the widget horizontally inside the space its parent gives it, GTK's halign: AlignFill (the default) stretches it, the others keep its natural width at the start, center or end.

func (*TypedList) SetHExpand

func (n *TypedList) SetHExpand(on bool)

SetHExpand says whether the widget wants extra horizontal space, GTK's hexpand: a row Box gives it a share of its leftover width. Unset, a widget wants it when a visible child does.

func (*TypedList) SetID

func (n *TypedList) SetID(id string)

SetID sets the widget's style id, which `#id` selectors match. It is distinct from the accessible name: a11y names stay semantic text, not style hooks. Empty clears.

func (*TypedList) SetInlineStyle

func (n *TypedList) SetInlineStyle(css string)

SetInlineStyle sets the widget's inline declarations — `color: red; --accent: #f80` — the widget-scoped provider GTK attaches per widget. They apply to this widget alone (custom properties then inherit into its subtree) at StylePriorityUser, with no specificity. Empty clears. Malformed declarations are skipped with a warning.

func (*TypedList) SetInlineStylePriority

func (n *TypedList) SetInlineStylePriority(css string, priority int)

SetInlineStylePriority is SetInlineStyle at an explicit priority.

func (*TypedList) SetLayoutMotion

func (n *TypedList) SetLayoutMotion(m LayoutMotion)

SetLayoutMotion animates the widget's moves and resizes on m: when layout puts it somewhere new, it springs there from where it was shown. Layout itself runs once, at the destination; the frames in between paint the laid-out widget translated to the spring's position and clipped to its size, so text never stretches. A widget inserted into an already shown parent grows in from no height.

func (*TypedList) SetMargin

func (n *TypedList) SetMargin(m render.Insets)

SetMargin sets the space kept clear around the widget inside its parent's allocation, GTK's margin-*. It adds to a stylesheet margin.

func (*TypedList) SetMaximumSize

func (n *TypedList) SetMaximumSize(w, h int)

SetMaximumSize caps the widget's size, the typed max-width and max-height: a container never measures it larger than w x h (its border box) and holds a wider slot to it by its alignment, fill reading as start. What the content paints past the cap is clipped. A zero axis is unbounded; negative values are zero. The size request wins where the two cross, so equal values pin an exact size.

func (*TypedList[T]) SetModel

func (l *TypedList[T]) SetModel(m ColumnModel[T])

SetModel replaces the data source, keeping the sort and the filters.

func (*TypedList) SetOnClickWithin

func (n *TypedList) SetOnClickWithin(fn func())

SetOnClickWithin registers fn to hear a click (press and release on the same widget) anywhere in the widget that nothing nearer takes: GTK's GestureClick on a container. A button, entry or other clicking widget inside keeps its own clicks, so a card can open on a click and still hold a working close button. The nearest registered ancestor of the clicked widget hears it; nil unregisters.

func (*TypedList) SetOnFocusChanged

func (n *TypedList) SetOnFocusChanged(fn func(focused bool))

SetOnFocusChanged registers fn to hear the widget gain or lose keyboard focus, however focus moved (a click elsewhere, Tab, a programmatic SetFocus, the window losing the focused widget): an entry that commits its text when the user leaves it. nil unregisters.

func (*TypedList) SetOnHoverWithin

func (n *TypedList) SetOnHoverWithin(fn func(on bool))

SetOnHoverWithin registers fn to hear the pointer enter or leave the widget or any descendant (the :hover chain; GTK's motion controller on a container): a row that reveals its actions on hover whichever child the pointer is over. nil unregisters.

func (*TypedList) SetOnPointer

func (n *TypedList) SetOnPointer(fn func(e PointerEvent) bool)

SetOnPointer registers fn to see every button press on the widget or a descendant that is not a control of its own (a button inside keeps its presses), any button with its click count and modifiers. A true return consumes the press: no click, focus move, context menu or drag follows. The nearest registered widget sees it first. nil unregisters.

func (*TypedList) SetOnScroll

func (n *TypedList) SetOnScroll(fn func(e ScrollEvent) bool)

SetOnScroll registers fn to see the wheel steps over the widget or a descendant before any scroller between them; a true return consumes the step, false lets it scroll on. nil unregisters.

func (*TypedList) SetSelectionMode

func (s *TypedList) SetSelectionMode(mode SelectionMode)

SetSelectionMode switches the selection model. Leaving multiple mode keeps the lowest selected item as the single selection (or clears it when the set was empty); entering it seeds the set with the current selection and anchors there. The change notification fires when the switch changes the set.

func (*TypedList) SetSharedElement

func (n *TypedList) SetSharedElement(tag string)

SetSharedElement tags the widget as one end of a shared-element transition. A tag names one widget shown at a time: when a widget paints after another widget with its tag was shown in its stead - a stack page switch, a card opening into its detail view - it morphs out of the other: its bounds and corner radius travel from the other's to its own on a spring while the other's last rendering fades out and its own fades in, both scaled into the moving rounded shape, so fill, border and content blend across. Reduced motion cross-fades in place. An empty tag removes it.

func (*TypedList) SetSizeRequest

func (n *TypedList) SetSizeRequest(w, h int)

SetSizeRequest sets the widget's minimum size, GTK's set_size_request: a container never measures it smaller than w x h (its border box: padding and border inside, margin outside). A zero axis leaves that axis to the widget; negative values are zero.

func (*TypedList[T]) SetSort

func (l *TypedList[T]) SetSort(cmp func(a, b T) int)

SetSort orders the view by cmp (nil returns to the source order); equal items keep source order. The sort applies now and to every later rebuild, so items appended or inserted land where cmp puts them.

func (*TypedList) SetState

func (n *TypedList) SetState(flags StateFlags, on bool)

SetState turns application-driven state flags on or off. The widget restyles when the set changed.

func (*TypedList) SetTooltip

func (n *TypedList) SetTooltip(s string)

SetTooltip sets hover text shown after a dwell; empty clears it.

func (*TypedList) SetTooltipMarkup

func (n *TypedList) SetTooltipMarkup(markup string)

SetTooltipMarkup sets a tooltip in RichLabel markup (bold, italic, links' look): the card renders it rich, while TooltipText - the accessible name - is its plain text. Markup ParseMarkup rejects shows literally.

func (*TypedList) SetVAlign

func (n *TypedList) SetVAlign(a Align)

SetVAlign is SetHAlign for the vertical axis.

func (*TypedList) SetVExpand

func (n *TypedList) SetVExpand(on bool)

SetVExpand is SetHExpand for vertical space.

func (*TypedList) SetVisible

func (n *TypedList) SetVisible(visible bool)

SetVisible hides or shows the widget in its container's layout. An invisible widget measures and arranges to zero, paints nothing, and drops out of hit testing - the container's other children reclaim the space. State changes what the container does with the widget, so the parent relayouts.

func (*TypedList) SharedElement

func (n *TypedList) SharedElement() string

SharedElement returns the widget's shared-element tag.

func (*TypedList) SizeRequest

func (n *TypedList) SizeRequest() Size

SizeRequest returns the size request (zero axes unset).

func (*TypedList) TooltipMarkup

func (n *TypedList) TooltipMarkup() (string, bool)

TooltipMarkup returns the tooltip's markup and whether it was set as markup (TooltipMarkupper).

func (*TypedList) TooltipText

func (n *TypedList) TooltipText() string

TooltipText returns the hover text, empty when none is set.

func (*TypedList) VAlign

func (n *TypedList) VAlign() Align

VAlign returns the vertical placement.

func (*TypedList) Visible

func (n *TypedList) Visible() bool

Visible reports the widget's own visibility flag, not the effective state: a widget inside an invisible container still reads true. Layout, Paint, and HitTest paths consult widget.IsVisible, which folds the ancestors in.

type Undoer

type Undoer interface {
	Undo() bool
	Redo() bool
}

Undoer is an editable widget with an undo history. Undo restores the state before the most recent edit, Redo reapplies the most recently undone one; both report whether anything changed.

type VariantFunc

type VariantFunc func(bold, italic bool) *render.Typeface

VariantFunc returns the face a bold or italic run shapes with. It must never return nil; returning the base face for a variant the platform lacks is the expected downgrade and renders fine.

func BaseVariants

func BaseVariants(base *render.Typeface) VariantFunc

BaseVariants serves base for every style. Use it when only one face is loaded: markup bold and italic then render with the base face. lys-ui never synthesizes faux bold or italic outlines. Apps that load real variants wire them here, e.g. via internal/sysfont's Variant.

type Video

type Video struct {
	// contains filtered or unexported fields
}

Video is GTK's GtkVideo: a media.Stream's frames fitted into the bounds by the scale policy (ImageFit by default), with MediaControls along the bottom that show while the pointer is over the video or the stream is not playing. The Video does not own the stream; whoever made it closes it. It styles as `video`.

func NewVideo

func NewVideo(face render.Font, sizePx float64, stream *media.Stream) *Video

NewVideo returns a video showing stream (nil for none), its controls in face at sizePx.

func (*Video) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*Video) Autoplay

func (v *Video) Autoplay() bool

Autoplay reports whether streams play as soon as they are shown.

func (*Video) Baseline

func (c *Video) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*Video) Children

func (c *Video) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*Video) Controls

func (v *Video) Controls() *MediaControls

Controls returns the video's MediaControls.

func (*Video) HitTest

func (c *Video) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*Video) Measure

func (c *Video) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*Video) Paint

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

Paint draws the surface (when configured) then the root.

func (*Video) Scale

func (v *Video) Scale() ImageScale

Scale returns the fit policy.

func (*Video) SetAutoplay

func (v *Video) SetAutoplay(on bool)

SetAutoplay plays every stream as soon as it is shown, the current one included.

func (*Video) SetScale

func (v *Video) SetScale(s ImageScale)

SetScale selects how frames fill the bounds: ImageFit (the default), ImageCover, ImageStretch, ImageScaleDown or ImageNone.

func (*Video) SetStream

func (v *Video) SetStream(stream *media.Stream)

SetStream shows stream instead, playing it at once under autoplay.

func (*Video) Stream

func (v *Video) Stream() *media.Stream

Stream returns the stream shown.

type ViewFilter

type ViewFilter[T any] struct {
	// contains filtered or unexported fields
}

ViewFilter is one filter in a viewModel's stack: a predicate over items, on or off. AddFilter hands one out; SetFilterStatus toggles it without dropping it.

func (*ViewFilter[T]) Enabled

func (f *ViewFilter[T]) Enabled() bool

Enabled reports whether the filter currently applies.

type ViewSwitcher

type ViewSwitcher struct {
	*ToggleGroup
	// contains filtered or unexported fields
}

ViewSwitcher is a ToggleGroup bound to a Stack: one toggle per page (title, and an icon when given), the visible page's toggle active, activating a toggle showing its page - the adw pill for bottom bars and headers alike.

func NewViewSwitcher

func NewViewSwitcher(face render.Font, sizePx float64, stack *Stack, titles, icons map[string]string) *ViewSwitcher

NewViewSwitcher returns a strip driving stack; titles names the pages (missing names fall back to the page names), icons is optional.

func (ViewSwitcher) Arrange

func (c ViewSwitcher) Arrange(r render.Rect)

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (ViewSwitcher) Baseline

func (c ViewSwitcher) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (ViewSwitcher) Children

func (c ViewSwitcher) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (ViewSwitcher) HitTest

func (c ViewSwitcher) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (ViewSwitcher) Measure

func (c ViewSwitcher) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (ViewSwitcher) Paint

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

Paint draws the surface (when configured) then the root.

func (*ViewSwitcher) ReflectVisible

func (v *ViewSwitcher) ReflectVisible()

ReflectVisible activates the visible page's toggle after a programmatic stack.Show (the app drives, the switcher shows).

func (*ViewSwitcher) SetPolicy

func (v *ViewSwitcher) SetPolicy(p StackSwitcherPolicy)

SetPolicy changes what the toggles show and rebuilds.

func (*ViewSwitcher) Sync

func (v *ViewSwitcher) Sync()

Sync rebuilds the toggles over the stack's pages (the stack has no signal: the app calls this after adding pages).

type Widget

type Widget interface {
	// Measure reports the widget's request along axis - its width for
	// Row, its height for Column - given forSize, its extent across
	// that axis, or Unknown: GTK's height-for-width measure. The
	// request never depends on the room a parent will offer; the
	// parent decides at Arrange (docs/architecture.md).
	Measure(axis Axis, forSize int) Sizes
	// Arrange assigns the widget's final pixel rect and recurses into
	// children.
	Arrange(r render.Rect)
	// Paint draws the widget, honoring any clip already set on the
	// canvas.
	Paint(cv *render.Canvas)
	// HitTest returns the deepest widget whose area contains p, or nil
	// when p misses the tree below this widget.
	HitTest(p Point) Widget
}

Widget is one node in the retained widget tree. Measure reports what a widget asks for, Arrange gives it its final rect, Paint draws it. A container measures its children where it arranges them, so a root needs only Arrange.

func AnchorWidget

func AnchorWidget(anchor Boundser) Widget

AnchorWidget is the widget a popup opened against anchor styles under, nil for a bare rect: the anchor itself, or the item a menubar's menu opens beneath.

func FocusRingOwner

func FocusRingOwner(w Widget) Widget

FocusRingOwner is the widget the focus ring of a focused w goes around: what w or its nearest claiming ancestor names, else w.

func HitChild

func HitChild(w Widget, p Point) Widget

HitChild hit-tests a container's child at p, PaintChild's counterpart: nil for a child hidden by SetVisible or display: none, whoever its container is, else the child's own HitTest. Containers defined outside the kit call it for their children too.

func RootOf

func RootOf(w Widget) Widget

RootOf is the top of w's tree: the widget with no parent above it.

func StyleAnchor

func StyleAnchor(w Widget) Widget

StyleAnchor is the widget w's tree is anchored to (SetStyleAnchor), nil when none.

type WindowControls

type WindowControls struct {

	// OnClose, OnMinimize, and OnMaximize fire for the corresponding
	// button; the app wires them to its window.
	OnClose    func()
	OnMinimize func()
	OnMaximize func()
	// contains filtered or unexported fields
}

WindowControls are the CSD frame buttons: close, minimize, maximize. Each is shown only when asked - the compositor's capabilities decide which an app offers - and each fires its hook on click.

func NewWindowControls

func NewWindowControls(face render.Font, sizePx float64) *WindowControls

NewWindowControls returns a controls cluster with every button hidden; Show* turns them on.

func (*WindowControls) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*WindowControls) Baseline

func (c *WindowControls) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*WindowControls) Children

func (c *WindowControls) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*WindowControls) HitTest

func (c *WindowControls) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*WindowControls) Measure

func (c *WindowControls) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*WindowControls) Paint

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

Paint draws the surface (when configured) then the root.

func (*WindowControls) ShowClose

func (c *WindowControls) ShowClose(on bool)

ShowClose shows the close button (a cross), wired to OnClose.

func (*WindowControls) ShowMaximize

func (c *WindowControls) ShowMaximize(on bool)

ShowMaximize shows the maximize button (a square), wired to OnMaximize.

func (*WindowControls) ShowMinimize

func (c *WindowControls) ShowMinimize(on bool)

ShowMinimize shows the minimize button (an underscore), wired to OnMinimize.

func (*WindowControls) Shown

func (c *WindowControls) Shown() (closeBtn, minimize, maximize bool)

Shown reports which buttons are shown.

type WindowDoubleClickable

type WindowDoubleClickable interface {
	// WindowDoubleClick fires on the second press inside the grab
	// interval; the widget routes it where it wants (HeaderBar's
	// OnDoubleClick hook).
	WindowDoubleClick()
}

WindowDoubleClickable is the optional second half of WindowMover: a double press inside the grab area maximizes, GTK header style.

type WindowMover

type WindowMover interface {
	// WindowMoveGrab reports whether a press on the widget itself (not
	// its children) should move the window.
	WindowMoveGrab() bool
}

WindowMover is implemented by widgets whose background area is a drag handle for moving the window: a press that resolves into the widget (not a deeper control) starts the compositor's move grab. HeaderBar carries it; a stylesheet's custom header can too.

type WindowTitle

type WindowTitle struct {
	// contains filtered or unexported fields
}

WindowTitle is libadwaita's AdwWindowTitle: a title over a smaller, muted subtitle, centered in a header bar, each ellipsized; an empty subtitle takes no space. It styles as `windowtitle` with `.title` and `.subtitle` labels.

func NewWindowTitle

func NewWindowTitle(face render.Font, sizePx float64, title, subtitle string) *WindowTitle

NewWindowTitle returns the title pair in face at sizePx, the subtitle a step smaller.

func (*WindowTitle) Arrange

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

Arrange lays the root over the content box, as its parent: inside its margins and held to its CSS sizes, matching Measure.

func (*WindowTitle) Baseline

func (c *WindowTitle) Baseline() (int, bool)

Baseline implements Baseliner: the root's, laid over the whole rect.

func (*WindowTitle) Children

func (c *WindowTitle) Children() []Widget

Children is the root, so focus traversal, the damage walk and the accessibility tree reach the widgets a composite is built from.

func (*WindowTitle) HitTest

func (c *WindowTitle) HitTest(p Point) Widget

HitTest resolves into the root; bare background is the embedder.

func (*WindowTitle) Measure

func (c *WindowTitle) Measure(axis Axis, forSize int) Sizes

Measure is the root's request inside the insets, its width pinned under fixedWidth and its height floored at minHeight.

func (*WindowTitle) Paint

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

Paint draws the surface (when configured) then the root.

func (*WindowTitle) SetSubtitle

func (w *WindowTitle) SetSubtitle(s string)

SetSubtitle sets the subtitle; empty hides it.

func (*WindowTitle) SetTitle

func (w *WindowTitle) SetTitle(s string)

SetTitle sets the title.

func (*WindowTitle) Subtitle

func (w *WindowTitle) Subtitle() string

Subtitle returns the subtitle.

func (*WindowTitle) Title

func (w *WindowTitle) Title() string

Title returns the title.

Source Files

Directories

Path Synopsis
Package css names libadwaita's style classes and named colors - the relm4-css analog (#95) - so application code spells them as constants and stylesheets written for GTK port over verbatim:
Package css names libadwaita's style classes and named colors - the relm4-css analog (#95) - so application code spells them as constants and stylesheets written for GTK port over verbatim:

Jump to

Keyboard shortcuts

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