elements

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 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

Overview

Package elements provides the stateless building blocks of Giode: box, flex, text and raw. They are cheap to build and are meant to be created inside the view function on every frame. Stateful components (see components/) hold the persistent state interactive widgets need.

The building blocks live in per-element subpackages (box, text, ...) on top of the shared runtime in elements/internal/base; this package re-exports them so callers keep using elements.Box, elements.Text and so on.

Index

Constants

View Source
const (
	SemanticText         = base.SemanticText
	SemanticButton       = base.SemanticButton
	SemanticInput        = base.SemanticInput
	SemanticCheckbox     = base.SemanticCheckbox
	SemanticSlider       = base.SemanticSlider
	SemanticSelect       = base.SemanticSelect
	SemanticTab          = base.SemanticTab
	SemanticMenuItem     = base.SemanticMenuItem
	SemanticLink         = base.SemanticLink
	SemanticImage        = base.SemanticImage
	SemanticScroll       = base.SemanticScroll
	SemanticCustom       = base.SemanticCustom
	SemanticHeading      = base.SemanticHeading
	SemanticSwitch       = base.SemanticSwitch
	SemanticRadio        = base.SemanticRadio
	SemanticProgress     = base.SemanticProgress
	SemanticGroup        = base.SemanticGroup
	SemanticList         = base.SemanticList
	SemanticListItem     = base.SemanticListItem
	SemanticTable        = base.SemanticTable
	SemanticRow          = base.SemanticRow
	SemanticCell         = base.SemanticCell
	SemanticColumnHeader = base.SemanticColumnHeader
	SemanticDialog       = base.SemanticDialog
	SemanticAlert        = base.SemanticAlert
	SemanticStatus       = base.SemanticStatus
	SemanticMenu         = base.SemanticMenu
	SemanticMenuBar      = base.SemanticMenuBar
	SemanticTabList      = base.SemanticTabList
	SemanticTabPanel     = base.SemanticTabPanel
	SemanticTree         = base.SemanticTree
	SemanticTreeItem     = base.SemanticTreeItem
	SemanticComboBox     = base.SemanticComboBox
	SemanticToolbar      = base.SemanticToolbar
	SemanticRegion       = base.SemanticRegion
)

Semantic kinds.

View Source
const (
	NotCheckable  = base.NotCheckable
	Unchecked     = base.Unchecked
	Checked       = base.Checked
	Mixed         = base.Mixed
	NotExpandable = base.NotExpandable
	Collapsed     = base.Collapsed
	Expanded      = base.Expanded
	LiveOff       = base.LiveOff
	LivePolite    = base.LivePolite
	LiveAssertive = base.LiveAssertive
)

Accessibility states (SemanticNode.Checked, Expanded, Live).

View Source
const (
	PlaceAuto  = base.PlaceAuto
	PlaceBelow = base.PlaceBelow
	PlaceAbove = base.PlaceAbove
)

Portal placements.

View Source
const (
	// DefaultRetainFrames is how many frames an entry may go
	// unrequested before it's dropped.
	DefaultRetainFrames = base.DefaultRetainFrames
	// CompactWidth is the window width, in dp, under which Compact
	// reports true outside any Responsive.
	CompactWidth = base.CompactWidth
)

Keyed state.

View Source
const (
	// LongPressDuration is how long a touch must be held still for
	// OnLongPress.
	LongPressDuration = box.LongPressDuration

	MousePrimary   = box.MousePrimary
	MouseSecondary = box.MouseSecondary
	MouseMiddle    = box.MouseMiddle

	// ClickPointer is a mouse, pen or touch click.
	ClickPointer = box.ClickPointer
	// ClickKeyboard is Enter or Space on a focused Pressable.
	ClickKeyboard = box.ClickKeyboard
	// ClickProgrammatic is a call to Pressable.Click (or automation).
	ClickProgrammatic = box.ClickProgrammatic
)
View Source
const (
	TextAnchorTopLeft     = canvas.TextAnchorTopLeft
	TextAnchorTop         = canvas.TextAnchorTop
	TextAnchorTopRight    = canvas.TextAnchorTopRight
	TextAnchorLeft        = canvas.TextAnchorLeft
	TextAnchorCenter      = canvas.TextAnchorCenter
	TextAnchorRight       = canvas.TextAnchorRight
	TextAnchorBottomLeft  = canvas.TextAnchorBottomLeft
	TextAnchorBottom      = canvas.TextAnchorBottom
	TextAnchorBottomRight = canvas.TextAnchorBottomRight
)

The points of a text Painter.Text can put at (x, y).

Variables

View Source
var (
	AfterLayout    = base.AfterLayout
	RunAfterLayout = base.RunAfterLayout
	SetMetric      = base.SetMetric
	DisplayScale   = base.DisplayScale
	DpToPx         = base.DpToPx
	PxToDp         = base.PxToDp
	PushColor      = base.PushColor
	CurrentColor   = base.CurrentColor
	ResolveColor   = base.ResolveColor
	// PushStickyScope collects the sticky elements a scrolling
	// container's content lays out; see base.StickyItem.
	PushStickyScope = base.PushStickyScope
	// PaintSticky paints a scrolling container's sticky elements over
	// its content, held at its edges.
	PaintSticky = base.PaintSticky
	// PushVisibleClip makes a scrolling container's viewport the
	// visible area of its content (drop targets use it).
	PushVisibleClip = base.PushVisibleClip
	Measure         = base.Measure
)

Frames and layout helpers.

View Source
var (
	AbsolutePosition = base.AbsolutePosition
	PushOffset       = base.PushOffset
	TrackPosition    = base.TrackPosition
	TrackChild       = base.TrackChild
	ReorderTracked   = base.ReorderTracked
)

Absolute position and tracking.

View Source
var (
	BeginSemantics     = base.BeginSemantics
	EndSemantics       = base.EndSemantics
	SemanticsEnabled   = base.SemanticsEnabled
	RecordSemantic     = base.RecordSemantic
	PushSemanticScroll = base.PushSemanticScroll
	// BeginSemanticGroup starts a container node (a list, a table, a
	// dialog) whose children are the nodes laid out until End.
	BeginSemanticGroup = base.BeginSemanticGroup
	// Accessible lays an element out and adjusts the nodes it records
	// (a text as a heading); AccessibleGroup makes it a container node.
	Accessible      = base.Accessible
	AccessibleGroup = base.AccessibleGroup
	// SetSemanticsWanted records the semantic tree every frame, for
	// accessibility bridges; SemanticsWanted reports it.
	SetSemanticsWanted = base.SetSemanticsWanted
	SemanticsWanted    = base.SemanticsWanted
)

Semantic tree.

View Source
var (
	SetWindowSize        = base.SetWindowSize
	RegisterPortal       = base.RegisterPortal
	RegisterPortalAt     = base.RegisterPortalAt
	RegisterPortalAround = base.RegisterPortalAround
	RegisterPortalEnd    = base.RegisterPortalEnd
	RegisterOverlay      = base.RegisterOverlay
	WindowSize           = base.WindowSize
	DrainPortals         = base.DrainPortals
)

Portals and overlays.

View Source
var (
	HandleBack    = base.HandleBack
	HandleDismiss = base.HandleDismiss
	DispatchBack  = base.DispatchBack
	OnKey         = base.OnKey
	// DrainContextMenus lays out the context menus elements opened;
	// the app calls it every frame.
	DrainContextMenus = base.DrainContextMenus
	// ShowMenu lays a menu out every frame while it's open, wherever
	// it was opened from.
	ShowMenu = base.ShowMenu
	// FrameNumber is the number of the frame being laid out.
	FrameNumber = base.FrameNumber
	// ContextClaimed reports whether an element opened its context
	// menu for a press.
	ContextClaimed = base.ContextClaimed
	DispatchKeys   = base.DispatchKeys
	// MarkTyping records that a focused text field takes typing this
	// frame, so typed keys don't run OnKey shortcuts; see base.
	MarkTyping = base.MarkTyping
	// WatchKeys registers, for this frame, a watcher of every key the
	// app gets; see base.WatchKeys.
	WatchKeys = base.WatchKeys
	// SeenKey reports a key a component took to the watchers;
	// ForwardKey passes one it didn't use on to the OnKey handlers.
	SeenKey    = base.SeenKey
	ForwardKey = base.ForwardKey
)

Back and keyboard input.

View Source
var (
	TouchInput     = base.TouchInput
	SetTouchInput  = base.SetTouchInput
	MinTouchTarget = base.MinTouchTarget
	SetDebugLogger = base.SetDebugLogger
)

Touch input and diagnostics.

View Source
var (
	ActiveBreakpoint = base.ActiveBreakpoint
	Compact          = base.Compact
)

Responsive breakpoints.

View Source
var (
	ForgetKeyed       = base.ForgetKeyed
	SetKeyedRetention = base.SetKeyedRetention
	InvalidateCaches  = base.InvalidateCaches
	BeginFrame        = base.BeginFrame
	EndFrame          = base.EndFrame
	Memo              = base.Memo
	NewMemoCache      = base.NewMemoCache
	IsCacheSafe       = base.IsCacheSafe
)

Keyed and memo caches.

View Source
var (
	Box = box.Box
	// Keyframes returns a keyframe animation for BoxElement.Animation.
	Keyframes            = box.Keyframes
	Row                  = box.Row
	Stack                = box.Stack
	Grid                 = box.Grid
	NewPressable         = box.NewPressable
	SetLongPressFeedback = box.SetLongPressFeedback
)
View Source
var (
	Text          = text.Text
	RichText      = text.RichText
	SpanText      = text.SpanText
	SpanElement   = text.SpanElement
	Link          = text.Link
	SetLinkOpener = text.SetLinkOpener
	SelectionArea = text.SelectionArea
)
View Source
var (
	Raw         = raw.Raw
	Divider     = divider.Divider
	Glyph       = glyph.Glyph
	SizedPx     = glyph.SizedPx
	OffsetPx    = glyph.OffsetPx
	Canvas      = canvas.Canvas
	Responsive  = responsive.Responsive
	Table       = table.Table
	TableRow    = table.TableRow
	TableHeader = table.TableHeader
	TableCell   = table.TableCell
)

Functions

func InSelectionArea

func InSelectionArea() bool

InSelectionArea reports whether a SelectionArea is being laid out around the caller: its text is part of that area's selection.

func Keyed

func Keyed[T any](scope, key any, init func() T) T

Keyed returns the state stored under (scope, key), creating it with init the first time it's asked for.

func SetKeyboardOwner

func SetKeyboardOwner(o KeyboardOwner)

SetKeyboardOwner records the focused text field for this frame. A focused field calls it every frame it's laid out.

Types

type BoxElement

type BoxElement = box.BoxElement

BoxElement is a container element: a flex container and a containing block for absolutely positioned children.

type Breakpoint

type Breakpoint = responsive.Breakpoint

Breakpoint is a simplified media query.

type CacheSafe

type CacheSafe = base.CacheSafe

CacheSafe is implemented by elements whose output a cache may keep: it depends only on their own fields and what caches watch.

type CheckState

type CheckState = base.CheckState

CheckState, ExpandState and LiveMode are accessibility states of a SemanticNode.

type ChildTracker

type ChildTracker = base.ChildTracker

ChildTracker records what a child registers while it's laid out.

type ClickEvent

type ClickEvent = box.ClickEvent

ClickEvent describes a click.

type ClickSource

type ClickSource = box.ClickSource

ClickSource says how a click was produced.

type ContextMenu

type ContextMenu = base.ContextMenu

ContextMenu is a menu an element opens at the pointer when it's right-clicked or long-pressed.

type Contextual

type Contextual = base.Contextual

Contextual gives an element a context menu (Context); every element and component embeds it.

type Describer

type Describer = base.Describer

Describer names an element for layout diagnostics.

type DividerElement

type DividerElement = divider.DividerElement

DividerElement is a thin horizontal line.

type DragEvent

type DragEvent = box.DragEvent

DragEvent describes a drag on a Pressable.

type Element

type Element = base.Element

Element is anything that can lay itself out in a frame.

type ExpandState

type ExpandState = base.ExpandState

Element, semantics and the shared runtime, re-exported from elements/internal/base.

type KeyboardOwner

type KeyboardOwner interface {
	// KeepsKeyboard reports whether a tap at p, in window coordinates,
	// lands on the field or its own overlays (its edit menu and
	// selection handles).
	KeepsKeyboard(p image.Point) bool
}

KeyboardOwner is the focused text field, for dismissing the software keyboard with a tap outside it: the window asks it whether a tap belongs to it.

func TakeKeyboardOwner

func TakeKeyboardOwner() KeyboardOwner

TakeKeyboardOwner returns the field recorded this frame, if any, and clears it for the next.

type KeyedCache

type KeyedCache[K comparable, V any] = base.KeyedCache[K, V]

KeyedCache is a typed, self-contained version of Keyed.

func NewKeyedCache

func NewKeyedCache[K comparable, V any]() *KeyedCache[K, V]

NewKeyedCache returns an empty cache that keeps entries for DefaultRetainFrames unrequested frames.

type Keyframe

type Keyframe = box.Keyframe

Box and Pressable, re-exported from elements/box.

type KeyframeAnimation

type KeyframeAnimation = box.KeyframeAnimation

KeyframeAnimation plays styles through keyframes on a Box; Keyframe is one of its steps.

type LiveMode

type LiveMode = base.LiveMode

Element, semantics and the shared runtime, re-exported from elements/internal/base.

type MemoCache

type MemoCache = base.MemoCache

MemoCache caches the painted output of a subtree across frames.

type MouseButton

type MouseButton = box.MouseButton

MouseButton identifies which button produced a click.

type NamedKey

type NamedKey = base.NamedKey

NamedKey is a key, with its modifiers, that an OnKey handler asks Gio for by name (Tab).

type OutOfFlow

type OutOfFlow = base.OutOfFlow

OutOfFlow is implemented by elements that paint over the window and take no space where they're placed: Dialog, Sheet and Drawer.

type Painter

type Painter = canvas.Painter

Canvas's Painter draws on a Canvas, in dp.

type Path

type Path = canvas.Path

Path is a shape built from lines and curves, in dp.

type Placement

type Placement = base.Placement

Placement says on which side of its trigger a portal goes.

type PressState

type PressState = box.PressState

PressState is the interaction state a Pressable's content is built with.

type Pressable

type Pressable = box.Pressable

Pressable makes any content clickable.

type RawFunc

type RawFunc = raw.RawFunc

RawFunc adapts a function to the Element interface.

type RichTextElement

type RichTextElement = text.RichTextElement

RichTextElement is a wrapping paragraph of differently styled spans.

type SemanticContainer

type SemanticContainer = base.SemanticContainer

SemanticContainer is a container node being laid out (BeginSemanticGroup).

type SemanticKind

type SemanticKind = base.SemanticKind

SemanticKind classifies a node of the semantic tree.

type SemanticNode

type SemanticNode = base.SemanticNode

SemanticNode describes one meaningful piece of the UI.

type Span

type Span = text.Span

Span is one run of text in a RichText paragraph.

type StickyItem

type StickyItem = base.StickyItem

Element, semantics and the shared runtime, re-exported from elements/internal/base.

type StickyScope

type StickyScope = base.StickyScope

StickyScope and StickyItem are a scrolling container's sticky elements; see base.StickyItem.

type TextAnchor

type TextAnchor = canvas.TextAnchor

TextAnchor is the point of a text Painter.Text puts at (x, y).

type TextElement

type TextElement = text.TextElement

TextElement renders a single string with its styles.

type VisibleClip

type VisibleClip = base.VisibleClip

VisibleClip is the part of the window a scrolling container shows; see base.VisibleClip.

type Watch

type Watch[T comparable] = base.Watch[T]

Watch tracks the fields a component caching its own output draws from; see MemoCache.LayoutOwn.

Directories

Path Synopsis
Package dnd is in-app drag and drop: Draggable sources, DropTarget areas that accept them, insertion slots in lists (ListItem), a preview that follows the pointer or finger, auto-scrolling of the scroll containers under it, and a keyboard way to do the same.
Package dnd is in-app drag and drop: Draggable sources, DropTarget areas that accept them, insertion slots in lists (ListItem), a preview that follows the pointer or finger, auto-scrolling of the scroll containers under it, and a keyboard way to do the same.
internal
base
Package base provides the shared runtime every element package is built on: the Element interface, the frame and color helpers, the absolute-position, portal, semantic and Back/OnKey registries, and the keyed and memo caches.
Package base provides the shared runtime every element package is built on: the Element interface, the frame and color helpers, the absolute-position, portal, semantic and Back/OnKey registries, and the keyed and memo caches.
Package platform shows elements only on some platforms:
Package platform shows elements only on some platforms:

Jump to

Keyboard shortcuts

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