Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package ui is the dashboard's view: go-widgets bound to the viewmodels of package vm. It implements go-widgets/webcanvas's App (and its Resizer, Scroller, RepaintAware and ModifierAware companions), so the same scene runs in a browser canvas and in a native test against a pixel buffer.

The view holds no state of its own beyond widget placement and focus: what it shows comes from the viewmodels' observables, what the user does goes to the viewmodels' actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dark

func Dark() *toolkit.Theme

Dark is the dark theme: the light end of the gradient as accent, and a border light enough for the same 3:1.

func Light

func Light() *toolkit.Theme

Light is the light theme: the deep end of the brand gradient as accent (4.9:1 on white, for focus rings and selection). Border is dark enough to delimit panels and tables: at least 3:1 against every ground it sits on (WCAG 2.2 SC 1.4.11, non-text contrast; asserted in theme_test.go).

func StateColor

func StateColor(state string, exitCode int, exited bool) (toolkit.RGBA, bool)

StateColor is the badge colour of a container state.

Types

type Box

type Box struct{ X, Y, W, H int }

Box is a widget's place on the canvas, in canvas pixels.

type Probe

type Probe struct {
	View        string
	Focus       string
	Boxes       map[string]Box
	Containers  []string
	Images      []string
	Selected    string
	LastCommand string
	Hint        string
	Error       string
	Live        string
	Status      []string
	Pending     int
	Running     bool
	Terminal    string
	Logs        string
	Volumes     string
	VolumeNames []string
	Mounts      []string
	Networks    []string
	// ContainerNetworks is the shown container's Networks tab.
	ContainerNetworks []string
	// Class is the class status line, ClassOpen the dialog, ClassError its
	// message, CodeLength how many characters the code field holds (never
	// the code itself).
	Class      string
	ClassOpen  bool
	ClassError string
	CodeLength int
	// Surfaces are the GPU surface panes, "title | status", and SurfaceBoxes
	// where each one's frame is drawn (canvas pixels; zero before a frame).
	Surfaces     []string
	SurfaceBoxes []Box
	// Shell is the screen of the shell inside a container, ShellLine its
	// command line, ShellStatus how it goes ("exited with status 3").
	Shell       string
	ShellLine   string
	ShellStatus string
	Memory      float64
	CPU         string
	Dark        bool
}

Probe is the scene's state for interaction tests (the page exposes it as window.__dashboard.state()): what is shown, where each control is, and what the terminal and the log pane hold — never pixels.

type Scene

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

Scene is the dashboard's widget tree.

func New

func New(app *vm.App, q *mvvm.Queue, w, h int) *Scene

New builds the scene over app, sized w x h, posting UI work through q. Text is the toolkit's anti-aliased OpenType face (Atkinson Hyperlegible), not its 5x7 bitmap default.

func (*Scene) Char

func (s *Scene) Char(c string) bool

Char implements webcanvas.App.

func (*Scene) Click

func (s *Scene) Click(x, y int) bool

Click implements webcanvas.App. A press on a surface pane's frame area gives that pane the focus and goes to its guest (pointer-down).

func (*Scene) Context

func (s *Scene) Context(x, y int) bool

Context implements webcanvas.App: a right click selects like a click.

func (*Scene) Dirty

func (s *Scene) Dirty() bool

Dirty reports whether something changed since the last Draw.

func (*Scene) Draw

func (s *Scene) Draw(buf []byte)

Draw implements webcanvas.App: it first runs the work the viewmodels posted (results from the engine), then paints the whole scene.

func (*Scene) KeyCode added in v0.8.0

func (s *Scene) KeyCode(code string)

KeyCode implements webcanvas.KeyCodeAware: the physical key of the keyboard event about to be delivered.

func (*Scene) KeyDown

func (s *Scene) KeyDown(key string) bool

KeyDown implements webcanvas.App. The terminal, when it has focus, gets every key it claims (Ctrl-C/D/L/R/W/U, arrows, Tab, ...) before any global shortcut; the shortcuts are F6 (next region), Tab / Shift-Tab (next / previous control) and Alt+1..6 (views). The shell's terminal, on the detail's Shell tab, counts as focused when the detail is. A surface pane with the focus is like a terminal: its guest gets every key but F6, which leaves it.

func (*Scene) KeyUp added in v0.8.0

func (s *Scene) KeyUp(key string) bool

KeyUp implements webcanvas.KeyUpper: a release goes to the focused pane's guest, with the text the key produces when it is one character.

func (*Scene) Layers added in v0.6.0

func (s *Scene) Layers() []webcanvas.Layer

Layers implements webcanvas.Layered. Every frame waiting is presented first -- drawn into its surface's backing image, closed, acknowledged -- whether or not the Surfaces view is shown, so the engine never waits on a pane nobody looks at. Then, in the Surfaces view, each pane's backing image is drawn over its frame area, scaled to fit with its aspect kept, greyed when the surface is closed.

func (*Scene) Modifiers

func (s *Scene) Modifiers(m webcanvas.Modifiers)

Modifiers implements webcanvas.ModifierAware.

func (*Scene) Move

func (s *Scene) Move(x, y int) bool

Move implements webcanvas.App: a drag while a button is held, else hover (which shows a hovered action's command line). Over a surface pane the move goes to its guest, coalesced to one per frame: it asks for a frame (RepaintWith coalesces) whose Layers sends the last one.

func (*Scene) Probe

func (s *Scene) Probe() Probe

Probe reports the scene's state.

func (*Scene) Release

func (s *Scene) Release(x, y int) bool

Release implements webcanvas.App. A press that began on a surface pane ends there (pointer-up, dropped outside the frame).

func (*Scene) RepaintWith

func (s *Scene) RepaintWith(request func())

RepaintWith implements webcanvas.RepaintAware.

func (*Scene) Resize

func (s *Scene) Resize(w, h int) (int, int)

Resize implements webcanvas.Resizer: the scene fills the canvas (device pixels), at least minW x minH logical pixels.

func (*Scene) Scroll

func (s *Scene) Scroll(x, y, dx, dy int) bool

Scroll implements webcanvas.Scroller.

func (*Scene) SetPixelRatio added in v0.4.0

func (s *Scene) SetPixelRatio(r float64)

SetPixelRatio implements webcanvas.PixelRatioAware: the scene renders at the display's device pixels. Every toolkit metric and the OpenType text scale with the ratio (toolkit.SetMetricScale), and the terminals' monospace face is re-rendered at its size × ratio.

func (*Scene) SetSurfaceCanvas added in v0.6.0

func (s *Scene) SetSurfaceCanvas(c SurfaceCanvas)

SetSurfaceCanvas connects the page's backing images (nil: frames are dropped as they come, and acknowledged).

func (*Scene) Size

func (s *Scene) Size() (int, int)

Size implements webcanvas.App.

func (*Scene) Wake

func (s *Scene) Wake()

Wake asks for a frame (safe from any goroutine): the hosts call it when the viewmodels post work, which the next Draw runs.

type SurfaceCanvas added in v0.6.0

type SurfaceCanvas interface {
	Present(id uint32, f vm.Frame, w, h int)
	Image(id uint32) (webcanvas.Image, bool)
	Forget(id uint32)
}

SurfaceCanvas keeps one backing image per GPU surface: the page's side of the surface panes. Present draws a frame into the surface's backing image and closes the frame, whatever happens; Image is that backing image (false before the first frame); Forget releases it. In the browser the backing image is a canvas and a frame an ImageBitmap (cmd/dashboard).

Jump to

Keyboard shortcuts

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