driver

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0 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

Index

Constants

This section is empty.

Variables

NoClipBounds is the open clip rectangle walkObjectTree starts with: an object reached with this clip size has crossed no clipping ancestor.

Functions

func AbsolutePositionForObject

func AbsolutePositionForObject(object core.CanvasObject, trees []core.CanvasObject) geo.Position

AbsolutePositionForObject returns the absolute position of an object in a set of object trees. If the object is not part of any of the trees, the position (0,0) is returned.

func ClipBoundsForObject

func ClipBoundsForObject(object core.CanvasObject, trees []core.CanvasObject) (geo.Rectangle, bool)

ClipBoundsForObject returns the region object's clipping ancestors leave visible, within the given trees, in absolute canvas coordinates: the bounds of the nearest one, intersected with those of the ones above it (#566), and empty when they do not overlap. ok is false when object is not found, or when no ancestor clips it (it is drawn against the full canvas). A clipping ancestor is one IsClip reports — a event.Scrollable, a bellui.Container with ClipToBounds, or a widget whose renderer clips. It reuses the same clip tracking the hit-test walk uses, so a caller can size content (e.g. a popover) to the region that will actually be visible rather than overflowing into a clipped area.

func FindObjectAtPositionMatching

func FindObjectAtPositionMatching(mouse geo.Position, matches func(object core.CanvasObject) bool, overlays []core.CanvasObject, roots ...core.CanvasObject) (core.CanvasObject, geo.Position, int)

FindObjectAtPositionMatching is used to find an object in a canvas at the specified position. The matches function determines of the type of object that is found at this position is of a suitable type. The various canvas roots and overlays that can be searched are also passed in.

func HandleEscape

func HandleEscape(c core.Canvas) bool

HandleEscape gives the Escape key its default meaning — close the innermost pop-up, menu or dialog — and reports whether it consumed the key. Drivers call it before delivering the key press, so a canvas-hosted dialog dismisses even though nothing inside it is focused.

The focused widget gets first refusal through event.EscapeHandler: while a text field is composing, or a cell is being edited in place, Escape belongs to that widget and no overlay closes. Everything else falls through, which is why a focused text field inside a dialog does not trap the user in it.

func IsClip

func IsClip(o core.CanvasObject) bool

func IsPathClip

func IsPathClip(o core.CanvasObject) (any, bool)

IsPathClip checks if a canvas object's renderer implements path-based stencil clipping. Returns the clip path (as any to avoid import cycles) and true if the renderer supports path clipping.

func IsRepaintBoundary

func IsRepaintBoundary(o core.CanvasObject) bool

IsRepaintBoundary checks if a canvas object's renderer implements the RepaintBoundary marker interface, indicating its subtree should be rendered into a cached FBO for dirty-region isolation.

func IsRoundedClip

func IsRoundedClip(o core.CanvasObject) (bool, float32)

IsRoundedClip checks if a canvas object's renderer implements rounded-corner stencil clipping. Returns the corner radius if so.

func MoveTabFocus added in v1.1.0

func MoveTabFocus(c TabFocuser, mods event.KeyModifier) bool

MoveTabFocus moves c's focus as TabDirection says for a Tab press with mods, and reports whether it did. A press it reports false for belongs to the focused widget or the shortcut path.

func PopDirectionScope

func PopDirectionScope(obj core.CanvasObject)

PopDirectionScope balances PushDirectionScope for obj. A non-scope obj is a no-op.

func PushDirectionScope

func PushDirectionScope(obj core.CanvasObject)

PushDirectionScope pushes obj's ambient layout direction onto the per-goroutine uidir stack when obj is a direction scope, so paint-time text base direction and leading/trailing alignment inside the subtree resolve against the scope rather than the process-global direction. It is the paint-time mirror of the layout hook in common.Canvas.EnsureMinSize and must be balanced by PopDirectionScope in the matching after-children callback. A non-scope obj is a no-op.

func RepaintBoundaryStatus added in v1.2.0

func RepaintBoundaryStatus(o core.CanvasObject) (boundary, settled bool)

RepaintBoundaryStatus is IsRepaintBoundary, and also reports whether the answer is settled: false for a widget whose renderer does not exist yet, which may turn out to be a boundary once it does. A walk can keep a settled answer rather than look the renderer up again on every visit (#487).

func ReverseWalkVisibleObjectTree

func ReverseWalkVisibleObjectTree(
	obj core.CanvasObject,
	beforeChildren func(core.CanvasObject, geo.Position, geo.Position, geo.Size) bool,
	afterChildren func(core.CanvasObject, geo.Position, core.CanvasObject),
) bool

ReverseWalkVisibleObjectTree will walk an object tree in reverse order for all visible objects executing the passed functions following the following rules: - beforeChildren is called for the start obj before traversing its children - the obj's children are traversed by calling walkObjects on each of the visible items - afterChildren is called for the obj after traversing the obj's children The walk can be aborted by returning true in one of the functions:

  • if beforeChildren returns true, further traversing is stopped immediately, the after function will not be called for the obj where the walk stopped, however, it will be called for all its parents

func TabDirection added in v1.1.0

func TabDirection(focused event.Focusable, mods event.KeyModifier) int

TabDirection reports how a Tab key press moves window focus: 1 to the next focusable object, -1 to the previous one, or 0 to leave focus alone so the key reaches the focused widget or the shortcut path.

Plain Tab and Shift+Tab move focus, unless the focused object keeps Tab for itself (an event.Tabbable whose AcceptsTab reports true, such as a multi-line Entry or a DAG canvas). Such an object would otherwise trap a keyboard user, so for it Ctrl+Tab and Ctrl+Shift+Tab move focus instead. On any other object Ctrl+Tab is left alone, so an app can still bind it as a shortcut. Alt and Super never move focus.

func WalkCompleteObjectTree

func WalkCompleteObjectTree(
	obj core.CanvasObject,
	beforeChildren func(core.CanvasObject, geo.Position, geo.Position, geo.Size) bool,
	afterChildren func(core.CanvasObject, geo.Position, core.CanvasObject),
) bool

WalkCompleteObjectTree will walk an object tree for all objects (ignoring visible state) executing the passed functions following the following rules: - beforeChildren is called for the start obj before traversing its children - the obj's children are traversed by calling walkObjects on each of the items - afterChildren is called for the obj after traversing the obj's children The walk can be aborted by returning true in one of the functions:

  • if beforeChildren returns true, further traversing is stopped immediately, the after function will not be called for the obj where the walk stopped, however, it will be called for all its parents

func WalkVisibleObjectTree

func WalkVisibleObjectTree(
	obj core.CanvasObject,
	beforeChildren func(core.CanvasObject, geo.Position, geo.Position, geo.Size) bool,
	afterChildren func(core.CanvasObject, geo.Position, core.CanvasObject),
) bool

WalkVisibleObjectTree will walk an object tree for all visible objects executing the passed functions following the following rules: - beforeChildren is called for the start obj before traversing its children - the obj's children are traversed by calling walkObjects on each of the visible items - afterChildren is called for the obj after traversing the obj's children The walk can be aborted by returning true in one of the functions:

  • if beforeChildren returns true, further traversing is stopped immediately, the after function will not be called for the obj where the walk stopped, however, it will be called for all its parents

func WalkVisibleObjectTreeCulled added in v1.2.0

func WalkVisibleObjectTreeCulled(
	obj core.CanvasObject,
	cull CullFunc,
	beforeChildren func(core.CanvasObject, geo.Position, geo.Position, geo.Size) bool,
	afterChildren func(core.CanvasObject, geo.Position, core.CanvasObject),
) bool

WalkVisibleObjectTreeCulled walks as WalkVisibleObjectTree does, except that an object cull reports as drawing nothing visible is visited without its children: beforeChildren and afterChildren run for it, so a caller that mirrors the tree stays in step, but its children are neither built nor walked (#464). Culling stops below an object with a transform, whose children's positions no longer match the clip's.

func WalkVisibleSubtreeCulled added in v1.2.0

func WalkVisibleSubtreeCulled(
	obj, parent core.CanvasObject,
	offset, clipPos geo.Position,
	clipSize geo.Size,
	cull CullFunc,
	hidden func(obj, parent core.CanvasObject),
	beforeChildren func(core.CanvasObject, geo.Position, geo.Position, geo.Size) bool,
	afterChildren func(core.CanvasObject, geo.Position, core.CanvasObject),
) bool

WalkVisibleSubtreeCulled walks as WalkVisibleObjectTreeCulled does, from obj inside a tree rather than from the tree's root: parent is obj's parent, offset its position on the canvas and (clipPos, clipSize) the clip obj sits in, as a walk from the root would have passed them. cull is nil below an object with a transform, as the walk from the root would have it; the caller passes nil when an ancestor of obj has one. hidden, if set, is called for each hidden object the walk skips, with the object it belongs to.

Types

type Clips added in v1.2.0

type Clips struct {
	Rect    bool    // clips to its bounds, as IsClip
	Rounded bool    // stencil-clips to rounded corners of Radius, as IsRoundedClip
	Radius  float32 // the rounded clip's corner radius
	Path    any     // the clip path, as IsPathClip, when non-nil
}

Clips is what an object establishes to clip its children. IsClip, IsRoundedClip and IsPathClip each look the renderer up; a paint walk asks all three for every object, twice, so ClipsOf answers them from one lookup (#492).

func ClipsOf added in v1.2.0

func ClipsOf(o core.CanvasObject) Clips

ClipsOf reports the clips an object establishes for its children.

type CullFunc added in v1.2.0

type CullFunc func(obj core.CanvasObject, pos, clipPos geo.Position, clipSize geo.Size) bool

CullFunc reports whether obj, at the absolute position pos, draws nothing inside the clip (clipPos, clipSize) its parent applies.

type InputPassThrough

type InputPassThrough interface {
	PassesInputThrough() bool
}

InputPassThrough is implemented by overlay roots that must not block input to the content beneath them — a tooltip, not a dialog. When the top overlay reports true, hit-testing falls through to the lower roots wherever the overlay itself has no match at the position.

type ObjectAtPosition

type ObjectAtPosition struct {
	Object   core.CanvasObject
	Position geo.Position
}

ObjectAtPosition holds an object found at a position along with the mouse position relative to it.

func FindAllObjectsAtPositionMatching

func FindAllObjectsAtPositionMatching(mouse geo.Position, matches func(object core.CanvasObject) bool, overlay core.CanvasObject, roots ...core.CanvasObject) []ObjectAtPosition

FindAllObjectsAtPositionMatching is like FindObjectAtPositionMatching but returns ALL matching objects at the position, ordered from deepest (innermost) to shallowest (outermost). This is used for scroll event propagation where the deepest scrollable gets first chance to handle the event, and if it doesn't consume it, the next parent scrollable tries.

type ScrollConsumer

type ScrollConsumer interface {
	event.Scrollable
	TryScrolled(ev *event.ScrollEvent) bool
}

ScrollConsumer is an optional interface for Scrollable objects that can report whether a scroll event was consumed. If TryScrolled returns false, the scroll event may propagate to a parent scrollable.

type TabEscape added in v1.2.0

type TabEscape struct {
	// contains filtered or unexported fields
}

TabEscape is a window's second way out of a widget that keeps Tab: Escape, then Tab or Shift+Tab, as in CodeMirror and Monaco. Ctrl+Tab is the first way, but browsers keep Ctrl+Tab for switching their own tabs and never deliver it to the page, so on the web it cannot work (#357).

An Escape arms it only when the Escape had nothing else to do: no pop-up or dialog closed (HandleEscape reported false) and the focused widget is not using the key for a state of its own (an event.EscapeHandler that handles it). So the first Escape still closes the dropdown, and a second one arms the way out. Any key other than a modifier disarms it, and so does any typed character (Disarm): some drivers give letter keys no name, so the character is the only sign of them. It is also armed for the widget focused at the Escape alone, so a focus change by pointer or by code cancels it.

The zero value is ready to use; a driver keeps one per window.

func (*TabEscape) Disarm added in v1.2.0

func (e *TabEscape) Disarm()

Disarm cancels the way out. Drivers call it for every typed character and when their window loses focus.

func (*TabEscape) EscapeNotConsumed added in v1.2.0

func (e *TabEscape) EscapeNotConsumed(focused event.Focusable)

EscapeNotConsumed arms the way out after an Escape that HandleEscape did not consume, when the focused widget keeps Tab and is not using Escape itself.

func (*TabEscape) MoveTabFocus added in v1.2.0

func (e *TabEscape) MoveTabFocus(c TabFocuser, key event.KeyName, mods event.KeyModifier) bool

MoveTabFocus is MoveTabFocus for a driver that offers the Escape way out. Call it for every key press: a key other than Tab only updates the state.

type TabFocuser added in v1.1.0

type TabFocuser interface {
	Focused() event.Focusable
	FocusNext()
	FocusPrevious()
}

TabFocuser is the part of a canvas MoveTabFocus needs.

type WithContext

type WithContext interface {
	RunWithContext(f func())
	RescaleContext()
	Context() any
}

WithContext allows drivers to execute within another context. Mostly this helps GLFW code execute within the painter's GL context.

Directories

Path Synopsis
Package glfw provides a full Bellui desktop driver that uses the system OpenGL libraries.
Package glfw provides a full Bellui desktop driver that uses the system OpenGL libraries.
app
Package app lets you write portable all-Go apps for Android and iOS.
Package app lets you write portable all-Go apps for Android and iOS.
event/composition
Package composition defines the IME composition (preedit) event used by the mobile driver to carry input-method composition state from the native platform layer to the focused widget.
Package composition defines the IME composition (preedit) event used by the mobile driver to carry input-method composition state from the native platform layer to the focused widget.
event/config
Package config defines the event that reports an in-place configuration change to the mobile driver.
Package config defines the event that reports an in-place configuration change to the mobile driver.
event/key
Package key defines an event for physical keyboard keys.
Package key defines an event for physical keyboard keys.
event/lifecycle
Package lifecycle defines an event for an app's lifecycle.
Package lifecycle defines an event for an app's lifecycle.
event/paint
Package paint defines an event for the app being ready to paint.
Package paint defines an event for the app being ready to paint.
event/size
Package size defines an event for the dimensions, physical resolution and orientation of the app's window.
Package size defines an event for the dimensions, physical resolution and orientation of the app's window.
event/textedit
Package textedit defines the committed text-edit event used by the mobile driver to carry a native IME/keyboard edit — a range replacement — from the platform layer to the focused editor through the text-input mirror seam (pre-rebrand tracker #771).
Package textedit defines the committed text-edit event used by the mobile driver to carry a native IME/keyboard edit — a range replacement — from the platform layer to the focused editor through the text-input mirror seam (pre-rebrand tracker #771).
event/touch
Package touch defines an event for touch input.
Package touch defines an event for touch input.
event/undoredo
Package undoredo defines the native undo/redo invocation event used by the mobile driver to carry a platform-initiated undo or redo — the iPad soft keyboard's undo/redo bar keys, the three-finger swipe gestures or shake-to-undo, all of which drive the first responder's NSUndoManager — from the platform layer to the focused editor (pre-rebrand tracker #1134).
Package undoredo defines the native undo/redo invocation event used by the mobile driver to carry a platform-initiated undo or redo — the iPad soft keyboard's undo/redo bar keys, the three-finger swipe gestures or shake-to-undo, all of which drive the first responder's NSUndoManager — from the platform layer to the focused editor (pre-rebrand tracker #1134).
gl
Package gl implements Go bindings for OpenGL ES 2.0 and ES 3.0.
Package gl implements Go bindings for OpenGL ES 2.0 and ES 3.0.
mobileinit
Package mobileinit contains common initialization logic for mobile platforms that is relevant to both all-Go apps and gobind-based apps.
Package mobileinit contains common initialization logic for mobile platforms that is relevant to both all-Go apps and gobind-based apps.

Jump to

Keyboard shortcuts

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