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 ¶
- func ContentRect(w, h int32, in platform.Insets) graphics.Rect
- func Shot(root meui.Widget, w, h int, out string) error
- type Breakpoint
- type Scene
- func (s *Scene) Breakpoints(bps []Breakpoint)
- func (s *Scene) Get(id string) meui.Widget
- func (s *Scene) OnClick(id string, fn func()) bool
- func (s *Scene) OnHover(id string, fn func(inside bool)) bool
- func (s *Scene) OnPaint(id string, fn func(*graphics.Canvas, graphics.Rect)) bool
- func (s *Scene) ScrollTo(id string, y float32) bool
- func (s *Scene) Select(id string, selected bool) bool
- func (s *Scene) SetFrame(id string, x, y, w, h float32) bool
- func (s *Scene) SetText(id, text string) bool
- func (s *Scene) Shot(w, h int, out string) error
- func (s *Scene) Show(id string, visible bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentRect ¶
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.
Types ¶
type Breakpoint ¶
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 ¶
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 ¶
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 (*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) OnClick ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SetText updates a label-ish widget's text through the toolkit's bound-property hook, which every text widget implements.