view

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 11 Imported by: ? 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

Package view is the behaviour layer for a QML view.

QML in this toolkit is a builder, not a language: there are no expressions and no signal-handler bodies, so every behaviour is attached from Go by id. That is the agreed model ("still wired on golang behaviour"), and this package is the part that keeps a view's Go short and honest:

scene, _ := view.Load("page.qml", "web-light", 1280, 900)
scene.OnClick("ctaPrimary", func() { ... })
scene.OnHover("cardPricing", func(inside bool) { ... })
scene.Shot(1280, 900, "landing.png")

Every lookup reports a MISS. A scene that silently does nothing because an id was misspelled is the failure mode this tree keeps finding ("a capability nobody switched on"), so a missing id is a log line, not a shrug.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentRect

func ContentRect(w, h int32, in platform.Insets) graphics.Rect

ContentRect returns the window rectangle that remains inside the platform's safe-area insets. A phone scene positions its page here and measures its breakpoints against the resulting width, not the raw window width: a 320px screen with 30px side insets has 260px of usable content.

The keyboard inset is deliberately not applied. A scene normally keeps its content behind the keyboard and scrolls the focused field into view; a caller that wants to reserve the keyboard reads Insets.Keyboard itself.

func Shot

func Shot(root meui.Widget, w, h int, out string) error

Shot rasterises any widget tree to a PNG through the software device. The tree is laid out through the same Paint path the window uses, so radius, shadow, gradient, clip and text are the toolkit's, not a second renderer's.

Types

type Breakpoint

type Breakpoint struct {
	MinWidth int32
	Apply    func(scene *Scene, width, height int32)
}

Breakpoint applies a layout when the scene's width falls in its range. The highest MinWidth that the width reaches wins; the width can change with every resize, so an Apply receives the exact size and may compute continuous sizes (a cover that spans the page) as well as discrete ones (a sidebar that disappears).

type Scene

type Scene struct {
	Root meui.Widget
	Reg  *qml.BoundWidgetRegistry
	Ctx  *qml.BindingContext
	Path string
}

Scene is a parsed QML document plus its id registry.

func Load

func Load(path, preset string, w, h int) (*Scene, error)

Load installs the preset, parses path and returns the scene. The preset is applied BEFORE parsing because scene colours may be resolved at parse time.

func LoadBundle

func LoadBundle(bundle *resources.Bundle, uri, preset string, w, h int) (*Scene, error)

LoadBundle is Load with the scene and its assets coming from a resources bundle. The URI uses a scheme mounted on the bundle, e.g. res://scenes/main.qml.

func Parse

func Parse(src, preset string, w, h int) (*Scene, error)

Parse is Load for an in-memory document (tests, small probes).

func (*Scene) Breakpoints

func (s *Scene) Breakpoints(bps []Breakpoint)

Breakpoints wires the scene's window resize hook. It exists because a page is a layout that RESPONDS: the same scene has to survive a 900px window and a 1600px one.

func (*Scene) Get

func (s *Scene) Get(id string) meui.Widget

Get resolves an id, logging a miss with the scene path so a typo is visible.

func (*Scene) OnClick

func (s *Scene) OnClick(id string, fn func()) bool

OnClick wires a click handler onto the id. It accepts the two shapes this tree has for a clickable surface — a *meui.Panel (Rectangle with clickable: true) and a *meui.MouseArea — and reports an error for anything else, because silently ignoring it is how a scene ends up looking interactive and not being it.

func (*Scene) OnHover

func (s *Scene) OnHover(id string, fn func(inside bool)) bool

OnHover wires hover enter/leave. A clickable Panel tracks hover itself (it paints the theme wash); the callback is for scene-specific behaviour.

func (*Scene) OnPaint

func (s *Scene) OnPaint(id string, fn func(*graphics.Canvas, graphics.Rect)) bool

OnPaint installs a custom painter on a Rectangle — the escape hatch for a scene that needs chrome the widget set does not have (a chart, a gradient orb, a decorative rule). The callback receives the box's local rect.

func (*Scene) ScrollTo

func (s *Scene) ScrollTo(id string, y float32) bool

ScrollTo scrolls a ScrollView to a content y. Pair it with SetFrame / Select to reveal a chosen row without the scene keeping its own scroll state.

func (*Scene) Select

func (s *Scene) Select(id string, selected bool) bool

Select marks a box as the chosen one in its group (a nav item, a list row, a day cell). It is the declarative counterpart of the per-scene colour swaps the first demos did by hand.

func (*Scene) SetFrame

func (s *Scene) SetFrame(id string, x, y, w, h float32) bool

SetFrame places a widget by id: the responsive twin of x/y in QML. It is how a breakpoint moves one element without a second scene.

func (*Scene) SetText

func (s *Scene) SetText(id, text string) bool

SetText updates a label-ish widget's text through the toolkit's bound-property hook, which every text widget implements.

func (*Scene) Shot

func (s *Scene) Shot(w, h int, out string) error

Shot rasterises the scene at w×h through the software device and writes a PNG. It is the fast review loop: no display, no GL, no window.

func (*Scene) Show

func (s *Scene) Show(id string, visible bool) bool

Show hides or shows a widget by id.

Jump to

Keyboard shortcuts

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