Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

scene

Pan/zoom 2D viewport. Wraps egui::containers::Scene (added 0.34). Children render inside a transformed coordinate space — mouse-wheel zooms, primary-drag pans (right-click stays free for context menus). Transform state persists in egui's per-id temp data, so pan/zoom carries across frames without caller plumbing.

Exports

  • scene(opts: SceneOpts?) -> any — build a pan/zoom 2D viewport widget. The module returns this function directly.

Types:

  • SceneOpts = { id: string?, props: { [string]: any }?, style: { [string]: any }?, children: { any }?, zoomRange: { number }?, initialPan: { x: number, y: number }?, initialZoom: number?, onTransformChange: string?, focusable: boolean? }

Usage

local scene = require("@builtin::modules.zui.widget.scene")

scene({
    zoomRange         = { 0.25, 4.0 },
    onTransformChange = "graph:moved",
    children = {
        Z.canvas({ commands = drawNodes(state) }),
        Z.area({ id = "node-1", pos = nodePos[1] }, { ... }),
    },
})

Notes

  • zoomRange defaults to [0.25, 4.0] (overriding egui's default of 0.0..=1.0 so wheel-zoom works in both directions).
  • initialPan and initialZoom only apply on the first frame; once the user pans or zooms the persisted rect takes over.
  • onTransformChange payload is a comma-separated string "panX,panY,zoom" — UiValue is scalar-only. Parse with string.split(value, ","). Falls back to <id>-transform when not set.
  • Pan is primary-button only — right-click stays free for Z.contextMenu handlers on inner widgets.