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 ¶
- func Dark() *toolkit.Theme
- func Light() *toolkit.Theme
- func StateColor(state string, exitCode int, exited bool) (toolkit.RGBA, bool)
- type Box
- type Probe
- type Scene
- func (s *Scene) Char(c string) bool
- func (s *Scene) Click(x, y int) bool
- func (s *Scene) Context(x, y int) bool
- func (s *Scene) Dirty() bool
- func (s *Scene) Draw(buf []byte)
- func (s *Scene) KeyCode(code string)
- func (s *Scene) KeyDown(key string) bool
- func (s *Scene) KeyUp(key string) bool
- func (s *Scene) Layers() []webcanvas.Layer
- func (s *Scene) Modifiers(m webcanvas.Modifiers)
- func (s *Scene) Move(x, y int) bool
- func (s *Scene) Probe() Probe
- func (s *Scene) Release(x, y int) bool
- func (s *Scene) RepaintWith(request func())
- func (s *Scene) Resize(w, h int) (int, int)
- func (s *Scene) Scroll(x, y, dx, dy int) bool
- func (s *Scene) SetPixelRatio(r float64)
- func (s *Scene) SetSurfaceCanvas(c SurfaceCanvas)
- func (s *Scene) Size() (int, int)
- func (s *Scene) Wake()
- type SurfaceCanvas
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dark ¶
Dark is the dark theme: the light end of the gradient as accent, and a border light enough for the same 3:1.
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 ¶
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) Click ¶
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) Draw ¶
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
KeyCode implements webcanvas.KeyCodeAware: the physical key of the keyboard event about to be delivered.
func (*Scene) KeyDown ¶
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
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
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) Move ¶
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) Release ¶
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 ¶
Resize implements webcanvas.Resizer: the scene fills the canvas (device pixels), at least minW x minH logical pixels.
func (*Scene) SetPixelRatio ¶ added in v0.4.0
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).
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).