Documentation
¶
Index ¶
- func AncestorsOfObject(c core.Canvas, obj core.CanvasObject) ([]core.CanvasObject, bool)
- func ClipBoundsForObject(c core.Canvas, obj core.CanvasObject) (geo.Rectangle, bool)
- func GeometryForObject(c core.Canvas, obj core.CanvasObject) (pos geo.Position, clip geo.Rectangle, clipped, ok bool)
- func ObjectAtPosition(c core.Canvas, pos geo.Position) (core.CanvasObject, geo.Rectangle, bool)
- func ObjectAtPositionMatching(c core.Canvas, pos geo.Position, matches func(core.CanvasObject) bool) (core.CanvasObject, geo.Rectangle, bool)
- func RunNative(fn func(any) error) error
- type AndroidContext
- type AndroidWindowContext
- type MacWindowContext
- type NativeWindow
- type UnknownContext
- type WaylandWindowContext
- type WindowsWindowContext
- type X11WindowContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AncestorsOfObject ¶
func AncestorsOfObject(c core.Canvas, obj core.CanvasObject) ([]core.CanvasObject, bool)
AncestorsOfObject returns the chain of visible objects from a canvas root down to obj (inclusive): the first element is the canvas root that contains obj (its content or an overlay), the last element is obj itself, and every element in between is a nesting container or widget between them. ok is false when obj is not found in the canvas tree (not present, or not visible).
It is the top-down companion to ObjectAtPosition (a click → object), letting tooling answer "what encloses this object?" — e.g. testing whether any ancestor is an opt-out wrapper — reusing the same visible-tree walk the painter and hit-test use, so it descends both containers and widget-renderer internals.
Since: 1.0
func ClipBoundsForObject ¶
ClipBoundsForObject returns the bounds of the nearest clipping ancestor of obj within canvas c, in absolute canvas coordinates, with ok=true when obj is clipped. When obj is drawn against the full canvas (no clipping ancestor) ok is false.
A clipping ancestor is one a scroll container (or any [event.Scrollable]), a [bellui.Container] with ClipToBounds, or a clipping widget introduces. It is useful for sizing floating content — a popover, completion list or tooltip — to the region that will actually be visible, instead of overflowing into an area an ancestor scroll then clips.
Since: 1.0
func GeometryForObject ¶
func GeometryForObject(c core.Canvas, obj core.CanvasObject) (pos geo.Position, clip geo.Rectangle, clipped, ok bool)
GeometryForObject answers, in one walk of the visible object tree, the three questions a caller that positions something over obj has to ask together: is obj in the visible tree at all, where is it, and what clips it.
ok is false when obj is not found — it is absent from the canvas, hidden, or has a hidden ancestor — and the other results are then meaningless. pos is obj's absolute position in canvas-tree coordinates. clip is the bounds of obj's nearest clipping ancestor, in the same coordinates, with clipped true only when there is one; an unclipped obj is drawn against the whole canvas.
It is the combined form of AncestorsOfObject (used for its ok alone), ClipBoundsForObject and an absolute-position lookup, which each re-derive the same root→obj path. Prefer it on a per-frame path — the visible-tree walk already carries position and clip, so answering all three at once costs one traversal and no path bookkeeping. Those helpers remain the right choice when only one answer is wanted.
Coordinate space ¶
pos is the raw walked position, matching ClipBoundsForObject. It is deliberately *not* [bellui.Driver.AbsolutePositionForObject], which additionally subtracts the canvas core.Canvas.InteractiveArea inset and so reports a position relative to the interactive area rather than the canvas tree — the space ObjectAtPosition also lives in (#235). The two differ only where that inset is non-zero (mobile, and the test canvas). Reporting position and clip in one space is the point: a caller that intersects them — as [widget.NativeViewHost] does to place an OS view — gets a meaningless rectangle if they come from different origins.
Like AncestorsOfObject, the walk covers the canvas content and its overlays; objects inside a window's menu bar are not reached.
Since: 1.0
func ObjectAtPosition ¶
ObjectAtPosition returns the deepest visible object at pos within canvas c, together with its absolute bounds. ok is false when no object is hit.
It uses the same hit-test the toolkit uses for tap dispatch: overlays are searched top-down first, then the canvas's remaining dispatch roots — on canvases that have them, the desktop menu bar and the mobile window head or open menu (#245) — then the content; an input-pass-through overlay (a tooltip, Toast or Snackbar) does not block objects beneath it. This is the "pick" primitive behind the #540 widget inspector, exposed for tooling that maps a click back to the object that produced it (e.g. a design tool's pick-to-source).
Coordinate space ¶
pos and the returned bounds are both in the space of [bellui.Driver.AbsolutePositionForObject]: relative to the canvas's interactive area (core.Canvas.InteractiveArea), not to the raw canvas tree. To go the other way — highlight a known object — compose [bellui.Driver.AbsolutePositionForObject] with the object's size; the result matches the bounds returned here (#235). The raw-tree helpers GeometryForObject and ClipBoundsForObject report the other space; the two differ by the interactive-area inset, which is non-zero only on mobile and the test canvas.
Event positions are in the raw-tree space as well: the tap dispatcher feeds this same hit-walk the position it later delivers as [event.PointEvent].AbsolutePosition, so a probe taken from an event must subtract the core.Canvas.InteractiveArea inset before calling here — a no-op on desktop, where the inset is zero.
Since: 1.0
func ObjectAtPositionMatching ¶
func ObjectAtPositionMatching(c core.Canvas, pos geo.Position, matches func(core.CanvasObject) bool) (core.CanvasObject, geo.Rectangle, bool)
ObjectAtPositionMatching is like ObjectAtPosition but returns the deepest object for which matches reports true, descending past objects the predicate rejects. Use it to skip renderer-internal primitives and resolve, say, the deepest object that is one of your own source-mapped widgets.
Since: 1.0
func RunNative ¶
RunNative provides a way to execute code within the platform-specific runtime context for various runtimes. This is mostly useful for Android where the JVM provides functionality that is not accessible directly in CGo. The call for most platforms will just execute passing an `UnknownContext` and returning any error reported.
Since: 2.3
Types ¶
type AndroidContext ¶
type AndroidContext struct {
VM, Env, Ctx uintptr
}
AndroidContext is passed to the RunNative callback when it is executed on an Android device. The VM, Env and Ctx pointers are required to make various calls into JVM methods.
Since: 2.3
type AndroidWindowContext ¶
type AndroidWindowContext struct {
AndroidContext
NativeWindow uintptr
}
AndroidWindowContext is passed to the NativeWindow.RunNative callback when it is executed on an Android device. The NativeWindow field is of type `*C.ANativeWindow`. The VM, Env and Ctx pointers are required to make various calls into JVM methods.
Since: 2.5
type MacWindowContext ¶
type MacWindowContext struct {
// NSWindow is the window handle for the native window.
NSWindow uintptr
}
MacWindowContext is passed to the NativeWindow.RunNative callback when it is executed on a macOS device.
Since: 2.5
type NativeWindow ¶
type NativeWindow interface {
// RunNative provides a way to execute code within the platform-specific runtime context for a window.
// The context types are defined in the `driver` package and the specific context passed will differ by platform.
RunNative(func(context any))
}
NativeWindow is an extension interface for `bellui.Window` that gives access to platform-native features of application windows.
Since: 2.5
type UnknownContext ¶
type UnknownContext struct{}
UnknownContext is passed to the RunNative callback when it is executed on devices or windows without special native context.
Since: 2.3
type WaylandWindowContext ¶
type WaylandWindowContext struct {
// WaylandSurface is the handle to the native Wayland surface.
WaylandSurface uintptr
// ExportedHandle is an xdg-foreign export handle for the window's toplevel
// (empty when the compositor does not support xdg-foreign). It is suitable as
// an xdg-foreign parent reference, e.g. an XDG portal parent_window of the
// form "wayland:<ExportedHandle>". Computing it exports the toplevel and is
// cached for the window's lifetime.
//
// Since: 1.0
ExportedHandle string
}
WaylandWindowContext is passed to the NativeWindow.RunNative callback when it is executed on a device with the Wayland windowing system.
Since: 2.5
type WindowsWindowContext ¶
type WindowsWindowContext struct {
// HWND is the window handle for the native window.
HWND uintptr
}
WindowsWindowContext is passed to the NativeWindow.RunNative callback when it is executed on a Microsoft Windows device.
Since: 2.5
type X11WindowContext ¶
type X11WindowContext struct {
// WindowHandle is the window handle for the native X11 window.
WindowHandle uintptr
}
X11WindowContext is passed to the NativeWindow.RunNative callback when it is executed on a device with the X11 windowing system.
Since: 2.5
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package desktop provides desktop specific driver functionality.
|
Package desktop provides desktop specific driver functionality. |
|
Package mobile provides mobile specific driver functionality.
|
Package mobile provides mobile specific driver functionality. |