struct Canvas
Swift
struct Canvas
Custom-drawn control: Yoga sizes the box; the app emits draw commands.
Use this for product-specific widgets (meters, charts, diagram chrome) that
should not live in LavaUI. The paint closure runs every emit with the
absolute frame; call DrawList primitives freely. No Yoga children.
continuousRedraw: register withAnimationDriverso the frame loop keeps painting while true (e.g. a live equalizer). Flip false when idle.onGesture: down/move/up with local + window coordinates, for a synchronized inspection cursor, drag-to-zoom, or range selection. Store paint-only interaction values in@DrawState; ordinary@Stateintentionally recomputes the owning body on every change.onWheel: deltas plus the pointer's position local to this canvas, for zooming around the cursor rather than the center.onHover: enter/leave, for a canvas whose paint changes under the pointer. A hover fill would come free from a.hoverBackground(); this is for the ones that draw the difference themselves, and it is also what makes the canvas resolvable as a hover target at all.
Sources/LavaUI/Canvas.swift:85
Constructors
init(label: String = "Canvas", width: Dimension = .auto, height: Dimension = .auto, flexGrow: Float = 0, minWidth: Float = 0, minHeight: Float = 0, continuousRedraw: Bool = false, onTap: (() -> Void)? = nil, onGesture: ((CanvasGesture) -> Void)? = nil, onWheel: ((_ dx: Float, _ dy: Float, _ localX: Float, _ localY: Float) -> Void)? = nil, onHover: ((Bool) -> Void)? = nil, paint: @escaping (DrawList, CanvasFrame) -> Void)
Not documented.
Sources/LavaUI/Canvas.swift:100
Properties
var continuousRedraw: Bool
When true, this leaf asks for ~60fps redraws via AnimationDriver.
Sources/LavaUI/Canvas.swift:93
var dumpDetail: String { get }
Not documented.
Sources/LavaUI/Canvas.swift:128
var flexGrow: Float
Not documented.
Sources/LavaUI/Canvas.swift:89
var height: Dimension
Not documented.
Sources/LavaUI/Canvas.swift:88
var label: String
Not documented.
Sources/LavaUI/Canvas.swift:86
var minHeight: Float
Not documented.
Sources/LavaUI/Canvas.swift:91
var minWidth: Float
Not documented.
Sources/LavaUI/Canvas.swift:90
var onGesture: ((CanvasGesture) -> Void)?
Not documented.
Sources/LavaUI/Canvas.swift:95
var onHover: ((Bool) -> Void)?
Not documented.
Sources/LavaUI/Canvas.swift:97
var onTap: (() -> Void)?
Not documented.
Sources/LavaUI/Canvas.swift:94
var onWheel: ((_ dx: Float, _ dy: Float, _ localX: Float, _ localY: Float) -> Void)?
Not documented.
Sources/LavaUI/Canvas.swift:96
var paint: (DrawList, CanvasFrame) -> Void
Not documented.
Sources/LavaUI/Canvas.swift:98
var width: Dimension
Not documented.
Sources/LavaUI/Canvas.swift:87
Methods
func mountPrimitive() -> any AnyViewNode
Not documented.
Sources/LavaUI/Canvas.swift:135
func reconcilePrimitive(_ node: any AnyViewNode) -> any AnyViewNode
Not documented.
Sources/LavaUI/Canvas.swift:149