Documentation
¶
Overview ¶
Package render turns the shell package's composition/model values into a live go-widgets widget tree and captures it to an image. It is the raw rendering layer: it imports the toolkit, the icon theme and the notification toast bridge, so it is exercised by the runtime smoke rather than the model coverage gate.
Index ¶
- Constants
- type Config
- type IconLoader
- type Scene
- func (s *Scene) AppCount() int
- func (s *Scene) DockCount() int
- func (s *Scene) FileCount() int
- func (s *Scene) HostRoot() *scene.HostRoot
- func (s *Scene) MenuCategoryCount() int
- func (s *Scene) Render() (*image.RGBA, error)
- func (s *Scene) Root() toolkit.Widget
- func (s *Scene) SetQuery(q string)
- func (s *Scene) SetToasts(ts []*toolkit.Toast)
- func (s *Scene) ShowToast(t *toolkit.Toast)
- func (s *Scene) Theme() *toolkit.Theme
- func (s *Scene) ToastCount() int
- func (s *Scene) Widget() toolkit.Widget
Constants ¶
const DefaultIconSize = 48
DefaultIconSize is the nominal pixel size requested from the icon theme.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Apps *shell.AppIndex
Menu *shell.MenuModel
Dir *shell.Dir
Thumbnailer *shell.Thumbnailer
Icons *IconLoader
Theme *toolkit.Theme
Width int
Height int
// DockMax caps how many app icons appear in the dock (0 -> a sane default).
DockMax int
}
Config bundles the shell models and rendering resources a Scene composes.
type IconLoader ¶
type IconLoader struct {
// contains filtered or unexported fields
}
IconLoader resolves icon names (or absolute paths) to go-widgets Image widgets through an XDG icon theme, rasterizing PNG/JPEG/GIF icons and falling back to a solid placeholder when an icon is missing or cannot be decoded (e.g. an SVG-only icon). Results are cached per name.
func NewIconLoader ¶
func NewIconLoader(themeName string, size int) *IconLoader
NewIconLoader builds a loader for the named icon theme (defaulting to hicolor) at the given nominal size.
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
Scene is the composed desktop shell: a Border(menubar / dock / launcher / file-grid) plus a floating toast stack. All mutable state (the launcher search query and its results, the file model) flows through go-widgets/mvvm.
func (*Scene) AppCount ¶
AppCount is the number of launchable apps currently listed in the launcher.
func (*Scene) HostRoot ¶ added in v0.3.0
HostRoot builds a damage-aware root over the shell's widget tree for the windowed backend's incremental-present path (github.com/go-widgets/window v0.4.0 presents only the rectangles a scene.HostRoot reports, instead of the whole surface, every frame).
The returned *scene.HostRoot is a drop-in toolkit.Widget: handed to window.Backend.Run it drives RenderDamaged (small-rect present); handed to a damage-unaware host it still full-repaints correctly through Draw. It owns a Scene mirroring a hostShell — a thin composite of the shell's five border regions plus the floating toast stack — and repaints a widget's VACATED background as scene chrome, so an incremental frame is pixel-identical to the full composite by construction.
HostRoot also installs the Scene's incremental hooks: a launcher result-list change invalidates just the launcher (west) region, and any toast-stack mutation re-anchors and (conservatively) full-damages the surface. Pointer hover/scroll invalidate the region under the pointer; every other input event (click, key, drag) full-damages, because the region it affects is uncertain (a click may open a menu popup that spans regions). Correctness first: an uncertain region is always over-invalidated, never under-invalidated, so no frame can leave a stale pixel — the win is that the common high-frequency interactions (hover, a launcher keystroke, a grid scroll) present a small rect instead of the whole window.
func (*Scene) MenuCategoryCount ¶
MenuCategoryCount is the number of application-menu categories.
func (*Scene) Render ¶
Render paints the whole shell (root widget then the toast stack) into a fresh image of the configured size.
func (*Scene) SetQuery ¶
SetQuery updates the launcher search query, driving the results + launcher.
func (*Scene) SetToasts ¶
SetToasts replaces the floating toast stack (e.g. from a notification daemon) and fires the toast-changed hook.
func (*Scene) ShowToast ¶
ShowToast adds a toast to the floating stack (used to present notifications), then fires the toast-changed hook so the incremental path repaints the toast overlay. A nil toast is ignored (and never fires the hook).
func (*Scene) Theme ¶
Theme returns the theme the scene paints with, so a windowing backend paints its background and widgets with the same palette the -capture path uses.
func (*Scene) ToastCount ¶
ToastCount is the number of visible toasts.
func (*Scene) Widget ¶
Widget returns the whole shell — the Border root plus its floating toast overlay — as a single toolkit.Widget. A windowing backend such as github.com/go-widgets/window drives exactly one root widget through its Run loop, so wrapping the overlay here lets the live window show the same composition (dock, launcher, menu, file grid AND notification toasts) that Render paints to a PNG. It is backend-agnostic: it only touches toolkit primitives and reads the scene's live toast slice at Draw time, so a toast pushed by the notifications daemon appears on the next repaint.