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
- Variables
- func InSelectionArea() bool
- func Keyed[T any](scope, key any, init func() T) T
- func SetKeyboardOwner(o KeyboardOwner)
- type BoxElement
- type Breakpoint
- type CacheSafe
- type CheckState
- type ChildTracker
- type ClickEvent
- type ClickSource
- type ContextMenu
- type Contextual
- type Describer
- type DividerElement
- type DragEvent
- type Element
- type ExpandState
- type KeyboardOwner
- type KeyedCache
- type Keyframe
- type KeyframeAnimation
- type LiveMode
- type MemoCache
- type MouseButton
- type NamedKey
- type OutOfFlow
- type Painter
- type Path
- type Placement
- type PressState
- type Pressable
- type RawFunc
- type RichTextElement
- type SemanticContainer
- type SemanticKind
- type SemanticNode
- type Span
- type StickyItem
- type StickyScope
- type TextAnchor
- type TextElement
- type VisibleClip
- type Watch
Constants ¶
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.
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).
const ( PlaceAuto = base.PlaceAuto PlaceBelow = base.PlaceBelow PlaceAbove = base.PlaceAbove )
Portal placements.
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.
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 )
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 ¶
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.
var ( AbsolutePosition = base.AbsolutePosition PushOffset = base.PushOffset TrackPosition = base.TrackPosition TrackChild = base.TrackChild ReorderTracked = base.ReorderTracked )
Absolute position and tracking.
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.
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.
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.
var ( TouchInput = base.TouchInput SetTouchInput = base.SetTouchInput MinTouchTarget = base.MinTouchTarget SetDebugLogger = base.SetDebugLogger )
Touch input and diagnostics.
var ( ActiveBreakpoint = base.ActiveBreakpoint Compact = base.Compact )
Responsive breakpoints.
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.
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 )
var ( Text = text.Text RichText = text.RichText SpanText = text.SpanText SpanElement = text.SpanElement Link = text.Link SetLinkOpener = text.SetLinkOpener SelectionArea = text.SelectionArea )
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 ¶
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 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 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 DividerElement ¶
type DividerElement = divider.DividerElement
DividerElement is a thin horizontal line.
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 KeyframeAnimation ¶
type KeyframeAnimation = box.KeyframeAnimation
KeyframeAnimation plays styles through keyframes on a Box; Keyframe is one of its steps.
type MouseButton ¶
type MouseButton = box.MouseButton
MouseButton identifies which button produced a click.
type NamedKey ¶
NamedKey is a key, with its modifiers, that an OnKey handler asks Gio for by name (Tab).
type OutOfFlow ¶
OutOfFlow is implemented by elements that paint over the window and take no space where they're placed: Dialog, Sheet and Drawer.
type PressState ¶
type PressState = box.PressState
PressState is the interaction state a Pressable's content is built with.
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 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.
Source Files
¶
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: |