render

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

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

View Source
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.

func (*IconLoader) Image

func (l *IconLoader) Image(name string) *toolkit.Image

Image returns a cached Image for an icon name or absolute path. It never returns nil: an unresolved / undecodable icon yields a placeholder swatch.

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 New

func New(cfg Config) *Scene

New composes a Scene from cfg, wiring the mvvm bindings immediately.

func (*Scene) AppCount

func (s *Scene) AppCount() int

AppCount is the number of launchable apps currently listed in the launcher.

func (*Scene) DockCount

func (s *Scene) DockCount() int

DockCount is the number of icons in the dock.

func (*Scene) FileCount

func (s *Scene) FileCount() int

FileCount is the number of items in the file grid model.

func (*Scene) MenuCategoryCount

func (s *Scene) MenuCategoryCount() int

MenuCategoryCount is the number of application-menu categories.

func (*Scene) Render

func (s *Scene) Render() (*image.RGBA, error)

Render paints the whole shell (root widget then the toast stack) into a fresh image of the configured size.

func (*Scene) Root

func (s *Scene) Root() toolkit.Widget

Root returns the composed root widget.

func (*Scene) SetQuery

func (s *Scene) SetQuery(q string)

SetQuery updates the launcher search query, driving the results + launcher.

func (*Scene) SetToasts

func (s *Scene) SetToasts(ts []*toolkit.Toast)

SetToasts replaces the floating toast stack (e.g. from a notification daemon).

func (*Scene) ShowToast

func (s *Scene) ShowToast(t *toolkit.Toast)

ShowToast adds a toast to the floating stack (used to present notifications).

func (*Scene) Theme

func (s *Scene) Theme() *toolkit.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

func (s *Scene) ToastCount() int

ToastCount is the number of visible toasts.

func (*Scene) Widget

func (s *Scene) Widget() toolkit.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.

Jump to

Keyboard shortcuts

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