uidir

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package uidir holds an ambient, per-goroutine user-interface direction override. It is the layout-direction analogue of the per-goroutine theme stack in internal/theme: a github.com/belluikit/bellui/container.DirectionScope (or a direction-scoped window canvas) pushes its direction while it lays out and paints its subtree, so the canvas-free layout, measurement and shaping code that resolves direction through lang.IsRTLDirection picks up the scoped value instead of the process-global one.

Callers push only concrete directions (LTR or RTL); a DirectionAuto scope is a no-op that defers to the enclosing scope or the global setting, so the stack never contains DirectionAuto and Current is a single read of the top.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Current

func Current() (bellui.Direction, bool)

Current returns the ambient direction override in effect on the calling goroutine, if any. The bool is false when no scope is active, in which case callers fall back to the process-global direction. The returned direction is always concrete (LTR or RTL); see the package comment.

func Mark

func Mark() int

Mark returns the calling goroutine's current direction-stack depth. Pair it with Restore (typically via defer) around a tree walk that does per-node Push/Pop in separate visitor callbacks: if a draw or layout panic unwinds past the matching Pops, Restore discards the orphaned entries so the per-goroutine stack does not leak and corrupt later direction resolution.

func Pop

func Pop(d bellui.Direction)

Pop removes the direction installed by the matching Push. A Pop balancing a bellui.DirectionAuto Push (which pushed nothing) is a no-op.

func Push

func Push(d bellui.Direction)

Push installs d as the ambient direction for the calling goroutine until the matching Pop. It is called by a direction scope around the layout and paint of its subtree. Pushing bellui.DirectionAuto is a no-op so that an automatic scope transparently inherits the enclosing direction.

func Restore

func Restore(depth int)

Restore truncates the calling goroutine's direction stack back to the depth returned by an earlier Mark. On the normal balanced-Pop path the stack is already at that depth, so Restore is a no-op; it only acts when a panic left entries pushed after the Mark.

Types

This section is empty.

Jump to

Keyboard shortcuts

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