kit

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 58 Imported by: 0

README

ui/kit

English | 简体中文

Ready-made component layer, based on el to organize appearance and interaction, base provides keyboard navigation, first letter jump and multi-selection behavior.

Directly dependent on core, theme, locale, el, base, not window. SVG parsing and rasterization use oksvg, rasterx. For the support range, see Icon and Image.

One component corresponds to one <name>.go, the shared field frame is in field.go, and the shared surface and overlay styles are provided by surface() and floating(). conventions_test.go Check out supporting documentation, examples, Agent tests, and public API conventions.

Atomic input references access ui/internal/inputcontent via el.InputDocument; the kit does not directly depend on this internal package.

Documentation

Overview

Package kit provides components built on ui/el. Views render element trees and resolve theme colors each frame.

Index

Constants

View Source
const (
	HoverCardOpenDelay  = 700 * time.Millisecond
	HoverCardCloseDelay = 300 * time.Millisecond
)
View Source
const CopiedFeedback = 1500 * time.Millisecond

CopiedFeedback is how long a CopyButton shows 已复制.

View Source
const DisclosureDuration = 180 * time.Millisecond

DisclosureDuration is the duration of an expand/collapse transition.

View Source
const MaxNotifications = 5

MaxNotifications is how many notices show at each placement; later ones wait.

View Source
const NotificationTimeout = 5 * time.Second

NotificationTimeout is the default time a notice stays on screen.

View Source
const ProgressDuration = 200 * time.Millisecond

ProgressDuration is the duration of a determinate progress value transition.

View Source
const SheetSlide = 200 * time.Millisecond

SheetSlide is how long a sheet takes to slide in; reduced motion skips it.

View Source
const SwitchDuration = 180 * time.Millisecond

SwitchDuration is the duration of a thumb position transition.

View Source
const TitleBarHeight = 38

TitleBarHeight is the height of a TitleBar in dp.

View Source
const TooltipDelay = 500 * time.Millisecond

TooltipDelay is how long the pointer rests on a view before its tooltip shows.

Variables

View Source
var ErrNoticeSystemUnavailable = errors.New("kit: no system notification backend")

Functions

func ClearCodeLanguageRules

func ClearCodeLanguageRules(language string)

func FileSize

func FileSize(n int64) string

FileSize formats a byte count as B, KB, MB or GB.

func FormatColor

func FormatColor(c color.NRGBA, f ColorFormat, alpha bool) string

FormatColor writes c in a format, with alpha when alpha is set: #2563EBCC, rgba(37, 99, 235, 0.8), hsla(221, 83%, 53%, 0.8).

func Required

func Required(s, msg string) string

Required returns msg when s is empty or blank, else "".

func SetCodeLanguageRules

func SetCodeLanguageRules(language string, rules CodeLanguageRules) error

SetCodeLanguageRules replaces language defaults. Existing editors see it on their next edit. Chroma-recognized language names share their canonical key; custom names retain their spelling. Invalid input preserves the old rules.

func StaticTable

func StaticTable() *el.DivEl

StaticTable creates a non-virtualized table container. Build its elements during Render; retain stateful child views in the application.

func TableBody

func TableBody() *el.DivEl

TableBody groups any number of rows, including custom row compositions.

func TableCaption

func TableCaption() *el.DivEl

TableCaption creates supporting content below the rows. It remains a child of the table; pass any text or richer elements through Child.

func TableDataCell

func TableDataCell() *el.DivEl

TableDataCell creates a flexible data cell. Use Flex(0).W(Dp(width)).NoShrink() with a fixed width, or retain W(0)/Grow for equal flexible widths.

func TableFooter

func TableFooter() *el.DivEl

TableFooter groups summary rows and draws a top rule.

func TableHead

func TableHead() *el.DivEl

TableHead creates a flexible heading cell. Use Flex(0).W(Dp(width)) for a fixed width, matching the corresponding data cells.

func TableHeader

func TableHeader() *el.DivEl

TableHeader groups heading rows. Column widths are configured on each cell.

func TableRow

func TableRow() *el.DivEl

TableRow lays cells out horizontally and draws a bottom rule. Interactive children own their events; rows do not select or activate automatically.

Types

type AccordionSize

type AccordionSize uint8
const (
	AccordionSizeMedium AccordionSize = iota
	AccordionSizeXSmall
	AccordionSizeSmall
	AccordionSizeLarge
)

type AccordionView

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

AccordionView stacks sections that expand and collapse. One section is open at a time unless Multiple. Headers take focus: ↑ ↓ Home End move between them, Enter or Space toggles.

func Accordion

func Accordion() *AccordionView

func (*AccordionView) Add

func (v *AccordionView) Add(title string, body el.View) *AccordionView

func (*AccordionView) Bordered

func (v *AccordionView) Bordered(on bool) *AccordionView

Bordered controls the outer border and section separators, on by default.

func (*AccordionView) Content

func (v *AccordionView) Content(i int) el.View

Content renders an item's body with an interruptible expand/collapse animation.

func (*AccordionView) Heading

func (v *AccordionView) Heading(i int, heading el.View) *AccordionView

Heading replaces an item's visual heading while keeping its title as the accessible name. The view should contain display content, not nested controls.

func (*AccordionView) Multiple

func (v *AccordionView) Multiple() *AccordionView

func (*AccordionView) OnChange

func (v *AccordionView) OnChange(fn func(open []int)) *AccordionView

func (*AccordionView) Render

func (v *AccordionView) Render(cx *el.Context) el.Element

func (*AccordionView) SetDisabled

func (v *AccordionView) SetDisabled(on bool)

func (*AccordionView) SetItemDisabled

func (v *AccordionView) SetItemDisabled(i int, on bool)

func (*AccordionView) SetValue

func (v *AccordionView) SetValue(open ...int)

SetValue opens exactly these sections without calling OnChange; a single accordion keeps only the first.

func (*AccordionView) Size

func (v *AccordionView) Size(size AccordionSize) *AccordionView

Size sets the title, chevron, spacing and inherited body text scale.

func (*AccordionView) Trigger

func (v *AccordionView) Trigger(i int) el.View

Trigger renders just one header, for composition with Content.

func (*AccordionView) Value

func (v *AccordionView) Value() []int

Value returns the open sections' indexes in order (a copy).

type AlertSize

type AlertSize uint8
const (
	AlertSizeMedium AlertSize = iota
	AlertSizeXSmall
	AlertSizeSmall
	AlertSizeLarge
)

type AlertView

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

AlertView is a dismissible inline status message.

func Alert

func Alert(title string) *AlertView

Alert creates an inline message with an ToneInfo tone.

func (*AlertView) Banner

func (v *AlertView) Banner(on bool) *AlertView

Banner renders an edge-to-edge strip without a separate title row. If no body is supplied, the title becomes the banner message.

func (*AlertView) Content

func (v *AlertView) Content(content el.View) *AlertView

Content replaces the description, allowing rich text and application actions. Nil restores Description. The title remains the accessible name.

func (*AlertView) Description

func (v *AlertView) Description(s string) *AlertView

func (*AlertView) Icon

func (v *AlertView) Icon(name IconName) *AlertView

Icon overrides the tone's icon. IconNone hides the icon and its spacing.

func (*AlertView) OnClose

func (v *AlertView) OnClose(fn func()) *AlertView

func (*AlertView) Render

func (v *AlertView) Render(cx *el.Context) el.Element

func (*AlertView) SetDescription

func (v *AlertView) SetDescription(s string)

func (*AlertView) SetDisabled

func (v *AlertView) SetDisabled(b bool)

func (*AlertView) SetTitle

func (v *AlertView) SetTitle(s string)

func (*AlertView) SetTone

func (v *AlertView) SetTone(t Tone)

func (*AlertView) SetVisible

func (v *AlertView) SetVisible(b bool)

func (*AlertView) Size

func (v *AlertView) Size(size AlertSize) *AlertView

Size controls text, icon and padding scales; Medium preserves the default.

func (*AlertView) Tone

func (v *AlertView) Tone(t Tone) *AlertView

func (*AlertView) Visible

func (v *AlertView) Visible() bool

type Answer

type Answer struct {
	Text     string   // Single, Text, LongText
	Choices  []string // Multiple, in option order
	Rating   int      // Rating; 0 means not rated
	Freeform string   // Additional active text for choice questions.
	Skipped  bool
}

Answer holds a typed answer, optional active freeform text, or an intentional skip.

func (Answer) Empty

func (a Answer) Empty() bool

Empty reports whether the question was left unanswered.

type AttachmentGroupView

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

AttachmentGroupView arranges attachments in a horizontally scrollable row. Upload state, selection, opening and removal remain owned by the application.

func AttachmentGroup

func AttachmentGroup(items ...el.View) *AttachmentGroupView

AttachmentGroup copies the items; individual view instances remain shared. Nil entries are ignored. Each view instance should occur only once in the group.

func (*AttachmentGroupView) ClearEdgeFade

func (v *AttachmentGroupView) ClearEdgeFade() *AttachmentGroupView

func (*AttachmentGroupView) EdgeFade

func (v *AttachmentGroupView) EdgeFade(surface color.NRGBA) *AttachmentGroupView

EdgeFade blends overflowing edges into the supplied surrounding surface. The 24dp overlays do not intercept input or cover the bottom scrollbar.

func (*AttachmentGroupView) Gap

Gap sets the nonnegative spacing in dp; invalid values are ignored.

func (*AttachmentGroupView) Items

func (v *AttachmentGroupView) Items() []el.View

func (*AttachmentGroupView) Name

func (*AttachmentGroupView) Render

func (v *AttachmentGroupView) Render(cx *el.Context) el.Element

func (*AttachmentGroupView) ScrollState

func (v *AttachmentGroupView) ScrollState(cx *el.Context) (offset, viewport, content float32)

ScrollState reports offset, viewport width and content width in dp for this root. Before first paint the values are zero. Programmatic scrolling does not select items.

func (*AttachmentGroupView) ScrollTo

func (v *AttachmentGroupView) ScrollTo(dp float32)

ScrollTo requests an absolute horizontal offset in dp. It also works before first paint; the next painted content clamps it to the available range. Negative offsets mean the start. Non-finite values are ignored.

func (*AttachmentGroupView) SetDisabled

func (v *AttachmentGroupView) SetDisabled(on bool)

func (*AttachmentGroupView) SetItems

func (v *AttachmentGroupView) SetItems(items ...el.View)

type AttachmentPart

type AttachmentPart uint8

AttachmentPart identifies a styleable attachment region.

const (
	AttachmentPartRoot AttachmentPart = iota
	AttachmentPartMedia
	AttachmentPartContent
	AttachmentPartTitle
	AttachmentPartDescription
	AttachmentPartActions
)

type AttachmentSize

type AttachmentSize uint8

AttachmentSize selects a coordinated card, media, text and control scale.

const (
	AttachmentSizeMedium AttachmentSize = iota
	AttachmentSizeXSmall
	AttachmentSizeSmall
	AttachmentSizeLarge
)

type AttachmentStatus

type AttachmentStatus uint8

AttachmentStatus describes an attachment's application-controlled lifecycle. Canceled is Keel's additional state, retained for the cancel/retry workflow.

const (
	AttachmentStatusComplete AttachmentStatus = iota
	AttachmentStatusPending
	AttachmentStatusUploading
	AttachmentStatusProcessing
	AttachmentStatusFailed
	AttachmentStatusCanceled
)

func (AttachmentStatus) IsComplete

func (s AttachmentStatus) IsComplete() bool

func (AttachmentStatus) IsFailed

func (s AttachmentStatus) IsFailed() bool

func (AttachmentStatus) IsInProgress

func (s AttachmentStatus) IsInProgress() bool

func (AttachmentStatus) IsPending

func (s AttachmentStatus) IsPending() bool

func (AttachmentStatus) IsProcessing

func (s AttachmentStatus) IsProcessing() bool

func (AttachmentStatus) IsUploading

func (s AttachmentStatus) IsUploading() bool

type AttachmentView

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

AttachmentView is a file card: name, size, upload progress or an error, and optional open and remove actions.

func Attachment

func Attachment(name string, size int64) *AttachmentView

Attachment shows a file of size bytes.

func (*AttachmentView) Actions

func (v *AttachmentView) Actions(views ...el.View) *AttachmentView

Actions adds custom controls before the built-in cancel/retry controls. The remove control is a separate corner button. The slice is copied; nil entries are ignored. Empty arguments clear custom controls.

func (*AttachmentView) ClearDescription

func (v *AttachmentView) ClearDescription() *AttachmentView

ClearDescription restores the automatic localized status/size text.

func (*AttachmentView) ClearPartStatus

func (v *AttachmentView) ClearPartStatus(part AttachmentPart) *AttachmentView

ClearPartStatus restores inheritance from the attachment's effective status.

func (*AttachmentView) Content

func (v *AttachmentView) Content(view el.View) *AttachmentView

Content replaces the default metadata and progress bar. Nil restores them. With OnOpen configured, use display content here and interactive controls in Actions.

func (*AttachmentView) Description

func (v *AttachmentView) Description(text string) *AttachmentView

Description replaces automatic status/size text, retaining the description's effective status color. An empty string displays no description text.

func (*AttachmentView) Media

func (v *AttachmentView) Media(view el.View) *AttachmentView

Media replaces the file icon with a display view (for example kit.Image). Nil restores the default icon. Media should not contain interactive controls; the completed attachment's OnOpen handles activation of the whole preview.

func (*AttachmentView) MediaAspectRatio

func (v *AttachmentView) MediaAspectRatio(ratio float32) *AttachmentView

MediaAspectRatio controls vertical previews (width/height), default 1. Zero restores natural content sizing; invalid values are ignored.

func (*AttachmentView) MediaError

func (v *AttachmentView) MediaError() error

func (*AttachmentView) MediaLoading

func (v *AttachmentView) MediaLoading() bool

func (*AttachmentView) MediaOverlay

func (v *AttachmentView) MediaOverlay(view el.View) *AttachmentView

MediaOverlay centers a view above the media and its lifecycle overlay. It does not contribute to media size. Controls take their own clicks and obey attachment/ancestor disabled state. Nil removes the overlay.

func (*AttachmentView) MediaSource

func (v *AttachmentView) MediaSource(source string) *AttachmentView

MediaSource asynchronously loads a URL, data URL or local path using core.DecodeImage. Repeating a source does not reload it; empty restores the default icon. Media(view) also cancels any source request.

func (*AttachmentView) OnCancel

func (v *AttachmentView) OnCancel(fn func()) *AttachmentView

func (*AttachmentView) OnOpen

func (v *AttachmentView) OnOpen(fn func()) *AttachmentView

func (*AttachmentView) OnRemove

func (v *AttachmentView) OnRemove(fn func()) *AttachmentView

func (*AttachmentView) OnRetry

func (v *AttachmentView) OnRetry(fn func()) *AttachmentView

func (*AttachmentView) PartStatus

func (v *AttachmentView) PartStatus(part AttachmentPart, status AttachmentStatus) *AttachmentView

PartStatus overrides the default title animation or description presentation. Only Title and Description accept overrides; other parts and invalid states are ignored. The attachment lifecycle, media and action availability stay owned by SetStatus/SetProgress/SetError.

func (*AttachmentView) PartStyle

func (v *AttachmentView) PartStyle(part AttachmentPart, fn func(*el.DivEl)) *AttachmentView

PartStyle refines a fresh region after defaults, each frame. Nil clears the refinement. Do not retain the element or use this callback to append children. Identity and root semantics are owned by the component.

func (*AttachmentView) RemoveOnHover

func (v *AttachmentView) RemoveOnHover(on bool) *AttachmentView

RemoveOnHover shows the remove control on card hover or keyboard focus. Desktop defaults to true; Android/iOS default to false. Set false for touch web apps or any interface that requires an always-visible remove control. The control keeps its layout, semantics and Tab stop while visually hidden.

func (*AttachmentView) Render

func (v *AttachmentView) Render(cx *el.Context) el.Element

func (*AttachmentView) RetryMedia

func (v *AttachmentView) RetryMedia()

RetryMedia reloads the current source. It does not retry the attachment upload.

func (*AttachmentView) SetDisabled

func (v *AttachmentView) SetDisabled(on bool)

func (*AttachmentView) SetError

func (v *AttachmentView) SetError(msg string)

SetError shows why the upload failed; "" clears it.

func (*AttachmentView) SetProgress

func (v *AttachmentView) SetProgress(p float32)

SetProgress shows an upload at fraction p (0..1); a negative p means done.

func (*AttachmentView) SetStatus

func (v *AttachmentView) SetStatus(status AttachmentStatus)

SetStatus changes state without invoking callbacks. It clears any previous error/cancellation. Uploading retains a known fraction, or starts at zero; other states clear the fraction. Invalid states are ignored.

func (*AttachmentView) ShowActions

func (v *AttachmentView) ShowActions(on bool) *AttachmentView

ShowActions controls custom and built-in action-row controls. The media's lifecycle retry and MediaOverlay remain part of ShowMedia.

func (*AttachmentView) ShowContent

func (v *AttachmentView) ShowContent(on bool) *AttachmentView

ShowContent controls the metadata region without clearing its configuration. A vertical attachment with media and no content becomes an edge-to-edge tile.

func (*AttachmentView) ShowMedia

func (v *AttachmentView) ShowMedia(on bool) *AttachmentView

ShowMedia controls the preview region without clearing Media or MediaOverlay.

func (*AttachmentView) Size

Size sets the density. Medium is the default; explicit part styles apply last.

func (*AttachmentView) Status

func (v *AttachmentView) Status() AttachmentStatus

Status reads the effective state. An error temporarily overlays the base state, so SetError("") restores the state that preceded the error.

func (*AttachmentView) TitleShimmer

func (v *AttachmentView) TitleShimmer(style ShimmerStyle) *AttachmentView

TitleShimmer configures the default attachment title's loading animation. ShimmerStyle{} restores the defaults. PartStatus still controls when it runs.

func (*AttachmentView) Vertical

func (v *AttachmentView) Vertical(on bool) *AttachmentView

Vertical stacks the preview above metadata and actions. False restores the row.

type AvatarGroupView

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

AvatarGroupView displays overlapping avatars and an overflow count.

func AvatarGroup

func AvatarGroup(avatars ...*AvatarView) *AvatarGroupView

func (*AvatarGroupView) Avatars

func (v *AvatarGroupView) Avatars() []*AvatarView

func (*AvatarGroupView) Ellipsis

func (v *AvatarGroupView) Ellipsis(on bool) *AvatarGroupView

Ellipsis replaces the visible +N count with …; semantics retain the count.

func (*AvatarGroupView) Limit

func (v *AvatarGroupView) Limit(n int) *AvatarGroupView

Limit caps visible avatars. Negative means unlimited; zero shows only overflow.

func (*AvatarGroupView) Render

func (v *AvatarGroupView) Render(cx *el.Context) el.Element

func (*AvatarGroupView) SetAvatars

func (v *AvatarGroupView) SetAvatars(avatars ...*AvatarView)

SetAvatars copies the slice, ignoring nil entries. Avatar instances remain shared.

func (*AvatarGroupView) Size

type AvatarStatus

type AvatarStatus string
const (
	AvatarOnline  AvatarStatus = "online"
	AvatarBusy    AvatarStatus = "busy"
	AvatarOffline AvatarStatus = "offline"
)

type AvatarView

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

AvatarView displays decoded image pixels or initials in a fixed-size circle.

func Avatar

func Avatar(name string) *AvatarView

func (*AvatarView) Border

func (v *AvatarView) Border(width float32, c color.NRGBA) *AvatarView

Border draws a ring of width dp, such as a Surface-colored ring that separates overlapping avatars. Zero removes it.

func (*AvatarView) Colors

func (v *AvatarView) Colors(bg, fg color.NRGBA) *AvatarView

Colors sets the background behind initials or the placeholder, and their color. Zero colors keep the defaults: a color picked from the name, and the theme's text color.

func (*AvatarView) Image

func (v *AvatarView) Image(img image.Image) *AvatarView

Image sets already decoded pixels. Nil or empty images restore the initials. Load images outside the UI lock and assign them through core.Update.

func (*AvatarView) ImageError

func (v *AvatarView) ImageError() error

func (*AvatarView) Loading

func (v *AvatarView) Loading() bool

func (*AvatarView) Placeholder

func (v *AvatarView) Placeholder(name IconName) *AvatarView

Placeholder is the icon shown with neither an image nor a name, IconUser by default; IconNone shows nothing.

func (*AvatarView) Render

func (v *AvatarView) Render(cx *el.Context) el.Element

func (*AvatarView) Retry

func (v *AvatarView) Retry()

Retry reloads the current source, including cancelling any in-flight request.

func (*AvatarView) Rounded

func (v *AvatarView) Rounded(dp float32) *AvatarView

Rounded sets the corner radius in dp; avatars are circles by default. An app or team avatar is often a rounded square: Rounded(theme.RadiusLg).

func (*AvatarView) SetName

func (v *AvatarView) SetName(name string)

func (*AvatarView) Size

func (v *AvatarView) Size(dp float32) *AvatarView

Size accepts a diameter in dp, clamped to 16..256. Invalid values are ignored.

func (*AvatarView) Source

func (v *AvatarView) Source(source string) *AvatarView

Source asynchronously loads an image URL or local path. Empty restores initials. Repeating the same source does not reload; Retry restarts a failed request.

func (*AvatarView) Status

func (v *AvatarView) Status(s AvatarStatus) *AvatarView

func (*AvatarView) Style

func (v *AvatarView) Style(fn func(*el.DivEl)) *AvatarView

Style adjusts the avatar's box after its default styling on every Render, for anything the other options do not cover. Nil removes it.

type BadgeView

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

BadgeView is a count or dot, alone or on a child's top right corner. A count of 0 or less hides count/dot badges. On a child it never changes the child's layout: it is drawn over the corner.

func Badge

func Badge(count int) *BadgeView

func (*BadgeView) Child

func (v *BadgeView) Child(child el.View) *BadgeView

func (*BadgeView) Color

func (v *BadgeView) Color(c color.NRGBA) *BadgeView

Color overrides the background. Tone restores theme-derived colors.

func (*BadgeView) Dot

func (v *BadgeView) Dot() *BadgeView

func (*BadgeView) Icon

func (v *BadgeView) Icon(name IconName) *BadgeView

Icon replaces the count with a status icon, regardless of count. IconNone restores count mode. Icon badges sit at the child's bottom right.

func (*BadgeView) Max

func (v *BadgeView) Max(n int) *BadgeView

Max caps the shown number: above it the badge reads "99+" (default 99).

func (*BadgeView) Name

func (v *BadgeView) Name(name string) *BadgeView

Name sets an accessible status name; empty restores the raw count label.

func (*BadgeView) Render

func (v *BadgeView) Render(cx *el.Context) el.Element

func (*BadgeView) SetValue

func (v *BadgeView) SetValue(n int)

func (*BadgeView) Size

func (v *BadgeView) Size(dp float32) *BadgeView

Size sets count/icon height in dp, 18 by default. Dots scale proportionally.

func (*BadgeView) Tone

func (v *BadgeView) Tone(t Tone) *BadgeView

func (*BadgeView) Value

func (v *BadgeView) Value() int

type BarAlignment

type BarAlignment uint8

BarAlignment selects the side from which positive bars grow.

const (
	BarAlignmentBottom BarAlignment = iota
	BarAlignmentTop
	BarAlignmentLeft
	BarAlignmentRight
)

type BubbleGroupView

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

BubbleGroupView stacks conversation surfaces. The application decides which bubbles belong together; the group does not infer authors or change alignment.

func BubbleGroup

func BubbleGroup(items ...el.View) *BubbleGroupView

BubbleGroup copies the supplied views, ignoring nil entries. Reuse each view instance at most once in a group to preserve its element identity.

func (*BubbleGroupView) Gap

func (*BubbleGroupView) Items

func (v *BubbleGroupView) Items() []el.View

func (*BubbleGroupView) Name

func (v *BubbleGroupView) Name(name string) *BubbleGroupView

func (*BubbleGroupView) Render

func (v *BubbleGroupView) Render(cx *el.Context) el.Element

func (*BubbleGroupView) SetDisabled

func (v *BubbleGroupView) SetDisabled(on bool)

func (*BubbleGroupView) SetItems

func (v *BubbleGroupView) SetItems(items ...el.View)

func (*BubbleGroupView) Style

func (v *BubbleGroupView) Style(fn func(*el.DivEl)) *BubbleGroupView

Style refines a fresh group element after defaults. Nil clears the refinement.

type BubblePart

type BubblePart uint8
const (
	BubblePartRoot BubblePart = iota
	BubblePartContent
	BubblePartReactions
)

type BubbleReactionSide

type BubbleReactionSide uint8
const (
	BubbleReactionBottom BubbleReactionSide = iota
	BubbleReactionTop
)

type BubbleVariant

type BubbleVariant uint8

BubbleVariant selects a semantic surface independently of alignment.

const (
	BubbleAuto BubbleVariant = iota // primary for Mine, secondary otherwise
	BubbleFilled
	BubbleSecondary
	BubbleMuted
	BubbleTinted
	BubbleOutline
	BubbleGhost
	BubbleDestructive
)

type BubbleView

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

BubbleView lays out a chat surface and an optional application-owned reaction region.

func Bubble

func Bubble(content el.View) *BubbleView

func (*BubbleView) Alignment

func (v *BubbleView) Alignment(align el.Align) *BubbleView

Alignment changes placement without replacing content or reaction state.

func (*BubbleView) Content

func (v *BubbleView) Content(content el.View) *BubbleView

func (*BubbleView) Mine

func (v *BubbleView) Mine() *BubbleView

func (*BubbleView) PartStyle

func (v *BubbleView) PartStyle(part BubblePart, fn func(*el.DivEl)) *BubbleView

PartStyle refines fresh elements after defaults; nil restores the defaults.

func (*BubbleView) ReactionActions

func (v *BubbleView) ReactionActions(buttons ...*ButtonView) *BubbleView

ReactionActions replaces the typed action list, copying it and ignoring nils. Buttons retain their configuration and receive pill corners only in this slot. Each button instance must occur at most once; Reactions supplies generic content.

func (*BubbleView) ReactionAlignment

func (v *BubbleView) ReactionAlignment(align el.Align) *BubbleView

func (*BubbleView) ReactionSide

func (v *BubbleView) ReactionSide(side BubbleReactionSide) *BubbleView

func (*BubbleView) Reactions

func (v *BubbleView) Reactions(view el.View) *BubbleView

Reactions supplies arbitrary controls or content; nil clears this generic slot. Counts, selection and callbacks belong to the supplied view.

func (*BubbleView) Render

func (v *BubbleView) Render(cx *el.Context) el.Element

func (*BubbleView) Variant

func (v *BubbleView) Variant(variant BubbleVariant) *BubbleView

type ButtonAppearance

type ButtonAppearance struct {
	Background, Foreground            color.NRGBA
	Hover, Active                     color.NRGBA
	HoverForeground, ActiveForeground color.NRGBA
	Border, Focus                     color.NRGBA
}

ButtonAppearance contains colors for a button's normal and interactive states. Transparent colors are valid; disabled colors are supplied by the theme.

type ButtonGroupView

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

ButtonGroupView joins buttons into one control: only the outer corners are rounded, outlined neighbours share a border, and filled ones are split by a hairline. Each button keeps its own click, icon, loading and selected state. For a set of exclusive options, use ToggleGroup instead.

func ButtonGroup

func ButtonGroup(buttons ...*ButtonView) *ButtonGroupView

func (*ButtonGroupView) Add

func (g *ButtonGroupView) Add(buttons ...*ButtonView) *ButtonGroupView

Add appends buttons.

func (*ButtonGroupView) Buttons

func (g *ButtonGroupView) Buttons() []*ButtonView

Buttons returns the group's buttons, to change one after building.

func (*ButtonGroupView) Name

Name is the group's accessible name, such as "Text alignment".

func (*ButtonGroupView) Render

func (g *ButtonGroupView) Render(cx *el.Context) el.Element

func (*ButtonGroupView) SetDisabled

func (g *ButtonGroupView) SetDisabled(on bool)

SetDisabled disables every button in the group.

func (*ButtonGroupView) Vertical

func (g *ButtonGroupView) Vertical(on bool) *ButtonGroupView

Vertical stacks the buttons, rounding the top and bottom instead.

type ButtonVariant

type ButtonVariant uint8

ButtonVariant selects the button's visual treatment.

const (
	ButtonPrimary ButtonVariant = iota
	ButtonSecondary
	ButtonGhost
	ButtonDanger
	ButtonLink
	ButtonText
	ButtonSuccess
	ButtonWarning
	ButtonInfo
)

type ButtonView

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

ButtonView is an action with pointer and keyboard activation.

func Button

func Button(text string, onClick func()) *ButtonView

func (*ButtonView) Appearance

func (v *ButtonView) Appearance(fn func(ButtonAppearance) ButtonAppearance) *ButtonView

Appearance transforms variant colors on each Render, before disabled styling. Nil restores theme colors. It can reference the current theme at render time.

func (*ButtonView) Compact

func (v *ButtonView) Compact(on bool) *ButtonView

Compact reduces horizontal padding, preserving the configured height.

func (*ButtonView) Content

func (v *ButtonView) Content(content el.View) *ButtonView

Content replaces the icon and visible label. Supply display-only content; the constructor label (or Name) remains the accessible name. Nil restores it.

func (*ButtonView) ID

func (v *ButtonView) ID(id string) *ButtonView

ID names the button for el: cx.Focus, cx.Hovered and anchored layers.

func (*ButtonView) Icon

func (v *ButtonView) Icon(name IconName) *ButtonView

func (*ButtonView) IsSelected

func (v *ButtonView) IsSelected() bool

func (*ButtonView) Loading

func (v *ButtonView) Loading(on bool) *ButtonView

func (*ButtonView) Name

func (v *ButtonView) Name(s string) *ButtonView

Name sets the accessible name; icon-only buttons need one.

func (*ButtonView) Outline

func (v *ButtonView) Outline(on bool) *ButtonView

Outline keeps a colored border and text with a transparent background.

func (*ButtonView) Render

func (v *ButtonView) Render(cx *el.Context) el.Element

func (*ButtonView) Selected

func (v *ButtonView) Selected(on bool) *ButtonView

Selected shows the button as chosen, such as the current view in a toolbar or the active filter, and reports it to agents. Filled buttons darken; secondary, ghost, text and outline buttons take the selection colors. Clicking does not toggle it: set it from OnClick. For a set of mutually exclusive options, use ToggleGroup.

func (*ButtonView) SetDisabled

func (v *ButtonView) SetDisabled(on bool)

func (*ButtonView) SetLoading

func (v *ButtonView) SetLoading(on bool)

func (*ButtonView) SetSelected

func (v *ButtonView) SetSelected(on bool)

func (*ButtonView) SetText

func (v *ButtonView) SetText(s string)

func (*ButtonView) Size

func (v *ButtonView) Size(dp float32) *ButtonView

Size sets the height in dp. Recommended heights are 28, 32 and 40.

func (*ButtonView) Variant

func (v *ButtonView) Variant(variant ButtonVariant) *ButtonView

type CalendarSize

type CalendarSize uint8

CalendarSize controls day cells, navigation and text. Medium preserves defaults.

const (
	CalendarSizeMedium CalendarSize = iota
	CalendarSizeXSmall
	CalendarSizeSmall
	CalendarSizeLarge
)

type CalendarView

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

CalendarView shows one month and picks a date, or a range with Range. Tab reaches the focused day; arrows move by a day or week, PageUp and PageDown by a month, Home and End to the week's ends, Enter or Space picks. Week layout, day and month names come from ui/locale.

func Calendar

func Calendar() *CalendarView

func (*CalendarView) Bounds

func (v *CalendarView) Bounds(min, max time.Time) *CalendarView

Bounds limits selectable dates to [min, max]; a zero time leaves that side open.

func (*CalendarView) CancelRange

func (v *CalendarView) CancelRange()

CancelRange discards the unfinished range without changing Value or callbacks.

func (*CalendarView) DisableDates

func (v *CalendarView) DisableDates(fn func(time.Time) bool) *CalendarView

DisableDates blocks dates for which fn returns true, e.g. weekends.

func (*CalendarView) FirstWeekday

func (v *CalendarView) FirstWeekday(day time.Weekday) *CalendarView

FirstWeekday overrides the locale's first weekday. Invalid values are ignored. The override controls weekday headers, day layout and Home/End navigation.

func (*CalendarView) FocusID

func (v *CalendarView) FocusID() string

FocusID is the element ID of the focused day, for cx.Focus.

func (*CalendarView) Months

func (v *CalendarView) Months(count int) *CalendarView

Months displays 1–12 consecutive months, wrapping when the viewport is narrow.

func (*CalendarView) OnChange

func (v *CalendarView) OnChange(fn func(start, end time.Time)) *CalendarView

OnChange runs when the user picks a date or completes a range; for a single date start == end.

func (*CalendarView) Range

func (v *CalendarView) Range() *CalendarView

Range picks a span: the first click sets one end, the second the other.

func (*CalendarView) RangePending

func (v *CalendarView) RangePending() bool

RangePending reports whether the first endpoint is waiting for completion.

func (*CalendarView) Render

func (v *CalendarView) Render(cx *el.Context) el.Element

func (*CalendarView) ResetFirstWeekday

func (v *CalendarView) ResetFirstWeekday() *CalendarView

ResetFirstWeekday restores the current locale's week layout.

func (*CalendarView) SetDisabled

func (v *CalendarView) SetDisabled(on bool)

func (*CalendarView) SetMonth

func (v *CalendarView) SetMonth(t time.Time)

SetMonth shows the month containing t.

func (*CalendarView) SetValue

func (v *CalendarView) SetValue(start, end time.Time)

SetValue chooses dates without calling OnChange and shows start's month. A single-date calendar uses only start.

func (*CalendarView) Size

func (v *CalendarView) Size(size CalendarSize) *CalendarView

func (*CalendarView) Value

func (v *CalendarView) Value() (start, end time.Time)

Value returns the chosen date (start == end) or range; zero when none.

type Candle

type Candle struct {
	Label                  string
	Open, High, Low, Close float64
}

Candle is one ordered category of open/high/low/close data.

type CandlestickChartView

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

CandlestickChartView renders OHLC data. Rising bodies are hollow, falling bodies solid, so direction can be read without relying only on color.

func CandlestickChart

func CandlestickChart(data ...Candle) *CandlestickChartView

func (*CandlestickChartView) AutoDomain

func (v *CandlestickChartView) AutoDomain() *CandlestickChartView

func (*CandlestickChartView) AutoGutter

func (v *CandlestickChartView) AutoGutter() *CandlestickChartView

func (*CandlestickChartView) Format

func (*CandlestickChartView) FutureSlots

func (v *CandlestickChartView) FutureSlots(n int) *CandlestickChartView

func (*CandlestickChartView) GridColumns

func (v *CandlestickChartView) GridColumns(n int) *CandlestickChartView

func (*CandlestickChartView) GridDashed

func (v *CandlestickChartView) GridDashed(on bool) *CandlestickChartView

func (*CandlestickChartView) Gutter

Gutter configures margins for the OHLC plot.

func (*CandlestickChartView) Height

func (*CandlestickChartView) HoverAnimation

func (v *CandlestickChartView) HoverAnimation(on bool) *CandlestickChartView

func (*CandlestickChartView) PointCount

func (v *CandlestickChartView) PointCount(n int) *CandlestickChartView

func (*CandlestickChartView) ReferenceLines

func (v *CandlestickChartView) ReferenceLines(lines ...ChartReference) *CandlestickChartView

func (*CandlestickChartView) Render

func (v *CandlestickChartView) Render(cx *el.Context) el.Element

func (*CandlestickChartView) SetData

func (v *CandlestickChartView) SetData(data ...Candle)

SetData copies the data. Invalid candles become gaps, not repaired prices.

func (*CandlestickChartView) SetDisabled

func (v *CandlestickChartView) SetDisabled(on bool)

func (*CandlestickChartView) Title

func (*CandlestickChartView) TooltipContent

func (*CandlestickChartView) XTickCount

func (v *CandlestickChartView) XTickCount(n int) *CandlestickChartView

func (*CandlestickChartView) YDomain

YDomain pins the price axis; AutoDomain restores data-driven bounds.

func (*CandlestickChartView) YLabelsInside

func (v *CandlestickChartView) YLabelsInside(on bool) *CandlestickChartView

func (*CandlestickChartView) YTickCount

func (v *CandlestickChartView) YTickCount(n int) *CandlestickChartView

type CarouselView

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

CarouselView shows one slide or configurable slots with previous / next buttons and a dot per slide. Arrow keys follow orientation; Home/End select the endpoints. Autoplay advances on a timer, paused while the pointer is over it and off with reduced motion.

func Carousel(slides ...el.View) *CarouselView

func (*CarouselView) Autoplay

func (v *CarouselView) Autoplay(d time.Duration) *CarouselView

Autoplay advances every d; 0 turns it off.

func (*CarouselView) Basis

func (v *CarouselView) Basis(fraction float32) *CarouselView

Basis sets the default fraction of the viewport occupied by each slot, including its share of spacing. Values in (0, 1] are accepted; zero restores ItemsPerView. ItemsPerView clears this default but preserves item overrides.

func (*CarouselView) CanNext

func (v *CarouselView) CanNext() bool

func (*CarouselView) CanPrevious

func (v *CarouselView) CanPrevious() bool

CanPrevious/CanNext include the component's own disabled state and boundaries. They cannot inspect a parent view's inherited disabled state.

func (*CarouselView) Content

func (v *CarouselView) Content() el.View

Content renders the keyboard-focusable slide area without built-in controls. Mount either Content or the full Carousel once for each CarouselView.

func (*CarouselView) Draggable

func (v *CarouselView) Draggable(on bool) *CarouselView

Draggable enables pointer dragging, on by default. A release selects the nearest snap point. Disabling it cancels a pending drag without a callback.

func (*CarouselView) Gap

func (v *CarouselView) Gap(dp float32) *CarouselView

Gap sets the spacing in dp between items in multi-item mode. Invalid values are ignored. The effective gap shrinks in viewports too small to fit it.

func (*CarouselView) Height

func (v *CarouselView) Height(dp float32) *CarouselView

Height sets the slide area height in dp, 200 by default.

func (*CarouselView) ItemBasis

func (v *CarouselView) ItemBasis(index int, fraction float32) *CarouselView

ItemBasis overrides the viewport fraction for one zero-based item. Zero restores the default; invalid indices/fractions are ignored. Configuration changes preserve selection and do not emit OnChange.

func (*CarouselView) ItemSize

func (v *CarouselView) ItemSize(index int, dp float32) *CarouselView

ItemSize sets the main-axis size in dp for one zero-based item, excluding gaps. It overrides ItemBasis and the default fraction, and may exceed the viewport. Zero restores the proportional size. Invalid inputs are ignored. Resizing or changing orientation preserves the dp value and selection.

func (*CarouselView) ItemsPerView

func (v *CarouselView) ItemsPerView(count int) *CarouselView

ItemsPerView sets the default number of equal-size slots in the viewport. One restores single-slide presentation when no item overrides remain. Nonpositive values are ignored.

func (*CarouselView) Loop

func (v *CarouselView) Loop(on bool) *CarouselView

Loop controls boundary wrapping. True preserves the default behavior. Switching modes does not change selection or emit OnChange.

func (*CarouselView) Next

func (v *CarouselView) Next()

func (*CarouselView) NextControl

func (v *CarouselView) NextControl(button *ButtonView) el.View

func (*CarouselView) OnChange

func (v *CarouselView) OnChange(fn func(int)) *CarouselView

func (*CarouselView) PaginationItem

func (v *CarouselView) PaginationItem(index int, button *ButtonView) el.View

PaginationItem creates one independently placeable, keyboard-operable page button. The index is zero-based; invalid indices are disabled, never wrapped. Nil uses a numbered button with the selected page emphasized. Custom buttons retain their appearance; selected state is always exposed in semantics.

func (*CarouselView) Previous

func (v *CarouselView) Previous()

Previous and Next use the same transition and OnChange callback as navigation.

func (*CarouselView) PreviousControl

func (v *CarouselView) PreviousControl(button *ButtonView) el.View

PreviousControl and NextControl create independently placeable navigation views. Keep the returned views across frames. Nil uses an axis-aware icon. A supplied button provides appearance, content, name, loading and disabled settings; its ID and callback are replaced without mutating the source.

func (*CarouselView) Render

func (v *CarouselView) Render(cx *el.Context) el.Element

func (*CarouselView) Scrollable

func (v *CarouselView) Scrollable(on bool) *CarouselView

Scrollable enables scroll input, on by default. Trackpad scrolling snaps when the fingers lift and ignores the momentum that follows. A mouse wheel steps one item per notch along the carousel's axis. Where the platform reports neither (only macOS does), continuous deltas snap after 140ms without input.

func (*CarouselView) SetDisabled

func (v *CarouselView) SetDisabled(on bool)

SetDisabled blocks navigation and autoplay; programmatic SetValue still works.

func (*CarouselView) SetValue

func (v *CarouselView) SetValue(i int)

SetValue shows slide i without calling OnChange.

func (*CarouselView) Value

func (v *CarouselView) Value() int

func (*CarouselView) Vertical

func (v *CarouselView) Vertical(on bool) *CarouselView

Vertical arranges navigation above/below its indicators beside the stage. Up/Down replace Left/Right; changing orientation preserves selection and focus.

func (*CarouselView) WheelStep

func (v *CarouselView) WheelStep(on bool) *CarouselView

WheelStep selects one item per scroll event instead of accumulating pixels, for any device, and lets a horizontal carousel step on vertical scrolling too. Without it, stepping applies only to a detected mouse wheel.

type ChartBarDatum

type ChartBarDatum struct {
	Series, Index int
	Name, Label   string
	Value         float64
	Stacked       bool
	Color         color.NRGBA
}

ChartBarDatum identifies one original data value, including a stacked segment.

type ChartBarFill

type ChartBarFill struct {
	Color    color.NRGBA
	Gradient *ChartBarGradient
}

ChartBarFill uses Color unless Gradient is non-nil. Alpha is preserved.

type ChartBarGradient

type ChartBarGradient struct {
	Start, End color.NRGBA
	Direction  el.Side
}

ChartBarGradient interpolates Start to End toward Direction (default Bottom). Top/Bottom run vertically; Left/Right run horizontally across each bar's box.

type ChartBarRange

type ChartBarRange struct{ Min, Max, Base, Tip float64 }

ChartBarRange contains the displayed value domain and this segment's endpoints. Stacked segments use accumulated Base/Tip; ChartBarDatum.Value stays original.

func (ChartBarRange) ChartToBar

func (r ChartBarRange) ChartToBar(value float64) float64

ChartToBar maps a value to a base-to-tip gradient position, without clamping.

type ChartColorStop

type ChartColorStop struct {
	Position float64
	Color    color.NRGBA
}

ChartColorStop locates a color along a bar: zero is its base, one its tip. Positions outside [0,1] are interpolated at the visible boundaries.

type ChartCurve

type ChartCurve uint8

ChartCurve selects interpolation between finite data points.

const (
	ChartCurveLinear ChartCurve = iota
	ChartCurveStepAfter
	ChartCurveSmooth
)

type ChartGutter

type ChartGutter struct{ Left, Right, Top, Bottom float32 }

ChartGutter reserves space around the Cartesian plot in dp. Height still describes the plot itself. Bottom contains the categorical labels; zero hides those labels. The default is Left:52, Bottom:18, Top:0, Right:0.

type ChartKind

type ChartKind uint8

ChartKind selects how a Chart draws its series.

const (
	ChartLine ChartKind = iota
	ChartBar
	ChartArea
	ChartCandlestick
	ChartRadar
)

type ChartReference

type ChartReference struct {
	Value float64
	Color color.NRGBA
	Label string
}

type ChartSeriesStyle

type ChartSeriesStyle struct {
	Stroke, Fill *color.NRGBA
	Width        float32
	Dots         bool
}

ChartSeriesStyle overrides a series' theme colors and line presentation. Nil colors use the palette; zero Width uses 2dp. Fill alpha is preserved.

type ChartTooltip

type ChartTooltip struct {
	Index  int
	Label  string
	Values []ChartTooltipValue
}

type ChartTooltipValue

type ChartTooltipValue struct {
	Series int
	Name   string
	Value  float64
	Text   string
	Color  color.NRGBA
}

type ChartView

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

ChartView draws categorical data as lines or bars over one y-axis. Series take the theme's Chart colors in order: series i is always slot i, so a series keeps its color when others are added or removed. Hovering shows a crosshair and a tooltip with every series' value; the data-table toggle shows the same numbers as a Table. Two or more series get a legend.

func AreaChart

func AreaChart(labels []string, series ...Series) *ChartView

AreaChart fills each line to zero. Series overlap with translucent colors.

func BarChart

func BarChart(labels []string, series ...Series) *ChartView

BarChart draws a group of bars per label, one per series; Stacked piles them.

func LineChart

func LineChart(labels []string, series ...Series) *ChartView

LineChart plots each series as a line across the labels, e.g. months.

func RadarChart

func RadarChart(labels []string, series ...Series) *ChartView

RadarChart compares nonnegative series on three or more radial dimensions. Invalid/missing values leave gaps; values over RadarMax are clipped to the ring.

func (*ChartView) AutoDomain

func (v *ChartView) AutoDomain() *ChartView

func (*ChartView) AutoGutter

func (v *ChartView) AutoGutter() *ChartView

func (*ChartView) BarAlignment

func (v *ChartView) BarAlignment(side BarAlignment) *ChartView

func (*ChartView) BarFill

func (v *ChartView) BarFill(fn func(ChartBarDatum) ChartBarFill) *ChartView

BarFill customizes each bar or stacked segment during drawing. The callback must be pure: it may run during measurement as well as painting. Nil restores series colors. It does not alter legends, hit testing, values or data tables.

func (*ChartView) BarGradient

func (v *ChartView) BarGradient(fn func(ChartBarDatum, ChartBarRange) []ChartColorStop) *ChartView

BarGradient sets a pure per-segment gradient callback and clears BarFill. Nil restores series colors. Stops are copied, sorted and clipped; invalid or empty input falls back to the series color. Equal positions use the last color. Gradients run from the base to the tip for both positive and negative bars.

func (*ChartView) Curve

func (v *ChartView) Curve(curve ChartCurve) *ChartView

func (*ChartView) Data

func (v *ChartView) Data() ([]string, []Series)

Data returns owned copies of the chart's categories and series.

func (*ChartView) Format

func (v *ChartView) Format(fn func(float64) string) *ChartView

Format writes values for the axis, tooltip and table; by default with thousands separators and up to two decimals.

func (*ChartView) FutureSlots

func (v *ChartView) FutureSlots(n int) *ChartView

FutureSlots reserves n empty category positions after the data, from 0 to 100000. Existing points, bars and candles use the remaining portion of the plot. Empty slots have no labels, tooltip, data-table rows or effect on YDomain. This is a categorical spacing option; it does not generate dates or values.

func (*ChartView) GridColumns

func (v *ChartView) GridColumns(n int) *ChartView

func (*ChartView) GridDashed

func (v *ChartView) GridDashed(on bool) *ChartView

func (*ChartView) GridLevels

func (v *ChartView) GridLevels(n int) *ChartView

func (*ChartView) Gutter

func (v *ChartView) Gutter(g ChartGutter) *ChartView

Gutter sets all four plot margins. Negative, non-finite or over-4096 values reject the entire configuration. It does not affect radar or pie charts.

func (*ChartView) Height

func (v *ChartView) Height(dp float32) *ChartView

Height sets the plot height in dp, 220 by default.

func (*ChartView) HoverAnimation

func (v *ChartView) HoverAnimation(on bool) *ChartView

func (*ChartView) OuterRadius

func (v *ChartView) OuterRadius(dp float32) *ChartView

OuterRadius is the radar radius in dp; zero fits the available chart bounds.

func (*ChartView) PointCount

func (v *ChartView) PointCount(n int) *ChartView

PointCount pins the categorical axis to at least n positions (0–100000). Appending data fills reserved positions without moving existing categories. More data than n expands the axis. Zero restores automatic spacing. PointCount and FutureSlots replace one another. Radar ignores both.

func (*ChartView) RadarLabel

func (v *ChartView) RadarLabel(fn func(*el.Context, int, string) el.Element) *ChartView

func (*ChartView) RadarMax

func (v *ChartView) RadarMax(value float64) *ChartView

RadarMax pins the outer ring's positive value; zero restores automatic scaling.

func (*ChartView) ReferenceLines

func (v *ChartView) ReferenceLines(lines ...ChartReference) *ChartView

ReferenceLines replaces horizontal reference guides; non-finite values are ignored.

func (*ChartView) Render

func (v *ChartView) Render(cx *el.Context) el.Element

func (*ChartView) SeriesStyle

func (v *ChartView) SeriesStyle(index int, style ChartSeriesStyle) *ChartView

func (*ChartView) SetData

func (v *ChartView) SetData(labels []string, series ...Series)

SetData replaces the labels and series.

func (*ChartView) SetDisabled

func (v *ChartView) SetDisabled(on bool)

func (*ChartView) Stacked

func (v *ChartView) Stacked() *ChartView

Stacked piles a bar chart's series on each other instead of side by side.

func (*ChartView) Title

func (v *ChartView) Title(s string) *ChartView

Title names the chart; it also names it for agents.

func (*ChartView) TooltipContent

func (v *ChartView) TooltipContent(fn func(*el.Context, ChartTooltip) el.Element) *ChartView

TooltipContent replaces the tooltip body; nil restores the default. Values are copied.

func (*ChartView) XTickCount

func (v *ChartView) XTickCount(n int) *ChartView

XTickCount spreads labels from first to last; 0 restores width-based thinning.

func (*ChartView) YDomain

func (v *ChartView) YDomain(lo, hi float64) *ChartView

YDomain pins the exact domain. Invalid or equal endpoints leave it unchanged.

func (*ChartView) YLabelsInside

func (v *ChartView) YLabelsInside(on bool) *ChartView

YLabelsInside places y-axis labels at the left edge inside the plot. Without explicit Gutter, this also removes the outside left label column. Labels can cover data; reference labels and tooltips are drawn over them.

func (*ChartView) YTickCount

func (v *ChartView) YTickCount(n int) *ChartView

YTickCount uses evenly spaced ticks including both endpoints; 0 restores nice ticks.

type CheckboxView

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

CheckboxView is a labelled check box. Click, Space or Enter toggles it.

func Checkbox

func Checkbox(label string, checked bool) *CheckboxView

func (*CheckboxView) FocusID

func (v *CheckboxView) FocusID() string

func (*CheckboxView) OnChange

func (v *CheckboxView) OnChange(fn func(bool)) *CheckboxView

func (*CheckboxView) Render

func (v *CheckboxView) Render(cx *el.Context) el.Element

func (*CheckboxView) SetDisabled

func (v *CheckboxView) SetDisabled(on bool)

func (*CheckboxView) SetLabel

func (v *CheckboxView) SetLabel(s string)

func (*CheckboxView) SetMixed

func (v *CheckboxView) SetMixed(on bool)

SetMixed shows the indeterminate state, e.g. for "select all" when some rows are selected. The next click checks it.

func (*CheckboxView) SetValue

func (v *CheckboxView) SetValue(on bool)

SetValue sets the state without calling OnChange and clears mixed.

func (*CheckboxView) Size

func (v *CheckboxView) Size(dp float32) *CheckboxView

Size sets the square size in dp (12–64); zero restores 18dp.

func (*CheckboxView) TabIndex

func (v *CheckboxView) TabIndex(index int) *CheckboxView

func (*CheckboxView) TabStop

func (v *CheckboxView) TabStop(on bool) *CheckboxView

func (*CheckboxView) TextSize

func (v *CheckboxView) TextSize(sp float32) *CheckboxView

TextSize sets label size in sp (8–128); zero restores inherited text size.

func (*CheckboxView) Value

func (v *CheckboxView) Value() bool

type CodeCompletion

type CodeCompletion struct {
	Label, Detail, Insert string
}

CodeCompletion is one suggestion in the completion list. Insert replaces the word before the caret; it defaults to Label.

type CodeDecoration

type CodeDecoration struct {
	Range CodeRange
	Style CodeDecorationStyle
	Color *color.NRGBA
	// Weight and Italic restyle the glyphs of a CodeDecorationText range.
	// Glyphs keep the regular positions, so carets and clicks do not move.
	// With either set and Color nil, the syntax color stays.
	Weight font.Weight
	Italic bool
}

CodeDecoration paints a tracked range without affecting layout or input. Nil Color uses theme.CodeText (12% alpha for fills). Coordinates count runes.

type CodeDecorationCollection

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

CodeDecorationCollection owns annotations independently of other extensions. Dropping the handle leaves its annotations; Dispose removes them permanently. Call all methods on the UI thread, or inside core.Update.

func (*CodeDecorationCollection) Append

func (c *CodeDecorationCollection) Append(entries ...CodeDecoration)

func (*CodeDecorationCollection) Clear

func (c *CodeDecorationCollection) Clear()

func (*CodeDecorationCollection) Dispose

func (c *CodeDecorationCollection) Dispose()

func (*CodeDecorationCollection) Get

func (*CodeDecorationCollection) Set

func (c *CodeDecorationCollection) Set(entries ...CodeDecoration)

Set replaces this collection only. Empty/reversed/outside ranges are discarded; partially valid ranges are clipped to the document.

type CodeDecorationStyle

type CodeDecorationStyle uint8
const (
	CodeDecorationFrame CodeDecorationStyle = iota
	CodeDecorationFill
	CodeDecorationText
	CodeDecorationUnderline
)

type CodeDiagnostic

type CodeDiagnostic struct {
	Line, Col, EndLine, EndCol int
	Severity                   CodeSeverity
	Message                    string
}

CodeDiagnostic marks a range of a CodeEditor, as a language server reports it: a squiggle under the text, a dot in the gutter and the message on hover. Lines and columns count from 0; columns count runes.

type CodeEditorView

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

CodeEditorView edits source code: line numbers, syntax highlighting, several carets and column selection, find and replace, folding, bracket pairs, undo, clipboard and input methods. Only the visible lines are laid out, and lines are stored in chunks, so files of hundreds of thousands of lines stay responsive; highlighting is redone near an edit at once and for the whole file in the background.

It does not speak a language server protocol itself. The app connects one through SetDiagnostics, OnComplete, OnHover and OnDefinition.

Tab indents; press Esc first to move focus on with Tab.

func CodeEditor

func CodeEditor(text string) *CodeEditorView

func (*CodeEditorView) AutoClose

func (v *CodeEditorView) AutoClose(on bool) *CodeEditorView

AutoClose types the closing bracket or quote with the opening one, steps over a closing one typed next to it, and deletes an empty pair together. On by default; brackets are not paired inside strings and comments.

func (*CodeEditorView) CloseSearch

func (v *CodeEditorView) CloseSearch()

CloseSearch ends the search and hides its highlights. If the built-in panel was open, focus returns to the text.

func (*CodeEditorView) Cursor

func (v *CodeEditorView) Cursor() (line, col int)

Cursor returns the primary caret's line and column (in runes), from 0.

func (*CodeEditorView) Cursors

func (v *CodeEditorView) Cursors() int

Cursors is how many carets there are; Esc keeps only the primary one.

func (*CodeEditorView) Decorations

func (v *CodeEditorView) Decorations(entries ...CodeDecoration) *CodeDecorationCollection

func (*CodeEditorView) Fill

func (v *CodeEditorView) Fill() *CodeEditorView

func (*CodeEditorView) Focus

func (v *CodeEditorView) Focus()

Focus gives the editor keyboard focus on the next frame.

func (*CodeEditorView) Fold

func (v *CodeEditorView) Fold(line int)

Fold folds the region starting at a line (its more-indented lines below); Unfold opens it. FoldAll and UnfoldAll act on every region.

func (*CodeEditorView) FoldAll

func (v *CodeEditorView) FoldAll()

func (*CodeEditorView) Folded

func (v *CodeEditorView) Folded(line int) bool

Folded reports whether the region starting at a line is folded.

func (*CodeEditorView) Height

func (v *CodeEditorView) Height(dp float32) *CodeEditorView

Height sets the height in dp, 320 by default; Fill takes the parent's.

func (*CodeEditorView) Language

func (v *CodeEditorView) Language(name string) *CodeEditorView

Language picks the syntax highlighting and bracket rules by chroma lexer name, e.g. "go", "python", "json". Unknown names show plain text.

func (*CodeEditorView) Lines

func (v *CodeEditorView) Lines() int

Lines is the number of lines.

func (*CodeEditorView) Name

func (v *CodeEditorView) Name(s string) *CodeEditorView

Name is the editor's accessible name; agents find it by it.

func (*CodeEditorView) NextSearchMatch

func (v *CodeEditorView) NextSearchMatch()

func (*CodeEditorView) OnChange

func (v *CodeEditorView) OnChange(fn func(text string)) *CodeEditorView

func (*CodeEditorView) OnComplete

func (v *CodeEditorView) OnComplete(fn func(line, col int, prefix string) []CodeCompletion) *CodeEditorView

OnComplete supplies completions for the word before the caret. It runs when the user types a letter or presses Ctrl+Space; returning nothing closes the list.

func (*CodeEditorView) OnDefinition

func (v *CodeEditorView) OnDefinition(fn func(line, col int)) *CodeEditorView

OnDefinition runs on Cmd/Ctrl+click or F12 with the position of the word to look up, e.g. to ask a language server and SetCursor to the result. While Cmd/Ctrl is held the word under the pointer is underlined.

func (*CodeEditorView) OnHover

func (v *CodeEditorView) OnHover(fn func(line, col int) string) *CodeEditorView

OnHover supplies a tip for the text under the pointer after it rests there, e.g. a language server's hover; "" shows none.

func (*CodeEditorView) OnPaste

func (v *CodeEditorView) OnPaste(fn func(core.ClipboardData) bool) *CodeEditorView

OnPaste intercepts clipboard contents before multi-selection text insertion. Returning true consumes the paste. Read-only and disabled editors ignore it.

func (*CodeEditorView) OnPasteError

func (v *CodeEditorView) OnPasteError(fn func(error)) *CodeEditorView

OnPasteError reports a rich read failure before falling back to Gio text, or a text read failure before rejecting that paste. Runs on the UI thread.

func (*CodeEditorView) OpenSearch

func (v *CodeEditorView) OpenSearch(replace bool)

OpenSearch shows the find panel, with the replace row if replace is set and the editor is editable, starting from the selected text.

func (*CodeEditorView) PasteReader

func (v *CodeEditorView) PasteReader(reader core.ClipboardReader) *CodeEditorView

PasteReader supplies an asynchronous rich clipboard source. Nil uses Gio text.

func (*CodeEditorView) PreviousSearchMatch

func (v *CodeEditorView) PreviousSearchMatch()

func (*CodeEditorView) Render

func (v *CodeEditorView) Render(cx *el.Context) el.Element

func (*CodeEditorView) ReplaceAllSearchMatches

func (v *CodeEditorView) ReplaceAllSearchMatches(replacement string) int

ReplaceAllSearchMatches replaces every match as a single undo step and emits one OnChange. Its count is not limited by the displayed result cap.

func (*CodeEditorView) ReplaceCurrentSearchMatch

func (v *CodeEditorView) ReplaceCurrentSearchMatch(replacement string) bool

ReplaceCurrentSearchMatch replaces only an exactly selected match. It returns false when no match is selected or the editor is read-only/disabled.

func (*CodeEditorView) SearchMatches

func (v *CodeEditorView) SearchMatches() int

SearchMatches is how many matches the active search found, up to 10,000.

func (*CodeEditorView) SearchSession

func (v *CodeEditorView) SearchSession() CodeSearchSession

func (*CodeEditorView) Searchable

func (v *CodeEditorView) Searchable(on bool) *CodeEditorView

Searchable turns the find panel (Cmd/Ctrl+F) on or off; on by default.

func (*CodeEditorView) SelectSearchMatch

func (v *CodeEditorView) SelectSearchMatch(index int) bool

SelectSearchMatch selects a listed match, unfolds it and scrolls it into view.

func (*CodeEditorView) Selection

func (v *CodeEditorView) Selection() string

Selection returns the primary selection's text.

func (*CodeEditorView) SetCursor

func (v *CodeEditorView) SetCursor(line, col int)

SetCursor keeps one caret, moves it there, unfolds around it and scrolls to it.

func (*CodeEditorView) SetDiagnostics

func (v *CodeEditorView) SetDiagnostics(d []CodeDiagnostic)

SetDiagnostics replaces the marked ranges, e.g. after a language server publishes diagnostics.

func (*CodeEditorView) SetDisabled

func (v *CodeEditorView) SetDisabled(on bool)

func (*CodeEditorView) SetEditingRules

func (v *CodeEditorView) SetEditingRules(rules *CodeLanguageRules) error

SetEditingRules installs an editor-local override; nil restores the registry. It preserves AutoClose and SmartIndent preferences, the document and history.

func (*CodeEditorView) SetReadOnly

func (v *CodeEditorView) SetReadOnly(on bool)

func (*CodeEditorView) SetSearchQuery

func (v *CodeEditorView) SetSearchQuery(query string, options CodeSearchOptions)

SetSearchQuery starts a search without opening or focusing the built-in panel. It also works with Searchable(false) and on read-only/disabled editors.

func (*CodeEditorView) SetValue

func (v *CodeEditorView) SetValue(s string)

SetValue replaces the text, clears undo, folds and extra carets, and moves the caret to the start. It does not call OnChange.

func (*CodeEditorView) ShowWhitespace

func (v *CodeEditorView) ShowWhitespace(on bool) *CodeEditorView

ShowWhitespace marks spaces with dots and tabs with arrows.

func (*CodeEditorView) SmartIndent

func (v *CodeEditorView) SmartIndent(on bool) *CodeEditorView

SmartIndent controls structural/regex indentation on Enter. False still keeps the current line's leading whitespace, but does not add or split indentation.

func (*CodeEditorView) SoftWrap added in v0.0.4

func (v *CodeEditorView) SoftWrap(on bool) *CodeEditorView

SoftWrap wraps lines at the editor's width instead of scrolling sideways. Breaks fall after spaces when a row has one, otherwise mid-word. Up and Down move by visual rows; line numbers show on a line's first row.

func (*CodeEditorView) SyntaxContext

func (v *CodeEditorView) SyntaxContext(fn func(line, col int) CodeSyntaxContext) *CodeEditorView

SyntaxContext overrides Chroma's code/string/comment classification for rules.

func (*CodeEditorView) TabSize

func (v *CodeEditorView) TabSize(size int, hard bool) *CodeEditorView

TabSize sets the width of a tab stop in spaces, and whether Tab inserts a tab character (hard) or that many spaces. By default the width is 4 and Tab follows the file: tabs if its lines are indented with tabs.

func (*CodeEditorView) Unfold

func (v *CodeEditorView) Unfold(line int)

func (*CodeEditorView) UnfoldAll

func (v *CodeEditorView) UnfoldAll()

func (*CodeEditorView) Value

func (v *CodeEditorView) Value() string

Value returns the whole text. For very large files it builds a large string.

type CodeLanguageRules

type CodeLanguageRules struct {
	Brackets, AutoClosingPairs []CodePair
	AutoCloseBefore            string
	Increase, Decrease         string
}

CodeLanguageRules controls editing independently of highlighting. Nil AutoClosingPairs uses Brackets; an explicit empty slice disables auto pairs. Increase/Decrease are Go regex patterns, tested before/after the selection on Enter. Empty patterns use structural brackets (and Python's colon default).

type CodePair

type CodePair struct {
	Open, Close string
	NotIn       []CodeSyntaxContext
}

CodePair supports single- and multi-rune delimiters on one line.

type CodeRange

type CodeRange struct{ Line, Col, EndLine, EndCol int }

CodeRange is half-open, zero-based line/rune-column coordinates.

type CodeSearchOptions

type CodeSearchOptions struct{ MatchCase, WholeWord, Regex bool }

type CodeSearchSession

type CodeSearchSession struct {
	Query, Replacement                           string
	Options                                      CodeSearchOptions
	Active, PanelOpen, InvalidPattern, Truncated bool
	Current                                      int
	Matches                                      []CodeRange
}

CodeSearchSession is an owned snapshot; Current is -1 without a selected match. Truncated means only the first 10,000 matches are listed. ReplaceAll still visits the entire document. Plain queries match within a line; regular expressions search the whole text and may span lines. Empty hits are skipped.

type CodeSeverity

type CodeSeverity uint8

CodeSeverity is how serious a CodeDiagnostic is; it picks its color.

const (
	CodeSeverityError CodeSeverity = iota
	CodeSeverityWarning
	CodeSeverityInfo
)

type CodeSyntaxContext

type CodeSyntaxContext uint8
const (
	CodeSyntaxCode CodeSyntaxContext = iota
	CodeSyntaxString
	CodeSyntaxComment
)

type CollapsibleView

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

CollapsibleView owns one disclosure's state. Trigger and Content can be composed separately; Render combines them in a bordered panel.

func Collapsible

func Collapsible(label string, body el.View) *CollapsibleView

func (*CollapsibleView) Content

func (v *CollapsibleView) Content() el.View

func (*CollapsibleView) Heading

func (v *CollapsibleView) Heading(view el.View) *CollapsibleView

func (*CollapsibleView) OnChange

func (v *CollapsibleView) OnChange(fn func(bool)) *CollapsibleView

func (*CollapsibleView) Render

func (v *CollapsibleView) Render(cx *el.Context) el.Element

func (*CollapsibleView) SetDisabled

func (v *CollapsibleView) SetDisabled(on bool)

func (*CollapsibleView) SetValue

func (v *CollapsibleView) SetValue(open bool)

func (*CollapsibleView) Trigger

func (v *CollapsibleView) Trigger() el.View

func (*CollapsibleView) Value

func (v *CollapsibleView) Value() bool

type ColorFormat

type ColorFormat uint8

ColorFormat is how a ColorPicker shows and takes its value.

const (
	ColorHex ColorFormat = iota // #2563EB
	ColorRGB                    // rgb(37, 99, 235)
	ColorHSL                    // hsl(221, 83%, 53%)
)

type ColorPickerSize

type ColorPickerSize uint8

ColorPickerSize controls panel and trigger density; Medium preserves defaults.

const (
	ColorPickerSizeMedium ColorPickerSize = iota
	ColorPickerSizeXSmall
	ColorPickerSizeSmall
	ColorPickerSizeLarge
)

type ColorPickerView

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

ColorPickerView picks a color: drag in the square for saturation and brightness, along the bars for hue and (with Alpha) opacity, type a hex code, or click a swatch. Focused, the square and bars move with the arrow keys. The color is kept as HSV, so hue survives passing through gray.

func ColorPicker

func ColorPicker() *ColorPickerView

func (*ColorPickerView) Alpha

func (p *ColorPickerView) Alpha() *ColorPickerView

Alpha adds an opacity bar; the hex code then has eight digits.

func (*ColorPickerView) CurrentFormat

func (p *ColorPickerView) CurrentFormat() ColorFormat

CurrentFormat is the format now shown, after any switch by the user.

func (*ColorPickerView) Format

Format chooses the format the picker shows: its fields, and the text on a popup trigger. Users can switch it in the panel. The default is ColorHex.

func (*ColorPickerView) Icon

func (p *ColorPickerView) Icon(icon IconName) *ColorPickerView

Icon replaces the popup trigger's color swatch with an icon. IconNone restores it.

func (*ColorPickerView) IsOpen

func (p *ColorPickerView) IsOpen() bool

func (*ColorPickerView) Label

func (p *ColorPickerView) Label(label string) *ColorPickerView

Label displays a caption above the inline picker or popup trigger.

func (*ColorPickerView) OnChange

func (p *ColorPickerView) OnChange(fn func(color.NRGBA)) *ColorPickerView

func (*ColorPickerView) Placement

func (p *ColorPickerView) Placement(side el.Side, align el.Align) *ColorPickerView

Placement sets where the popup panel opens beside its trigger (popup pickers only), as for a Popover: Placement(el.Top, el.End).

func (*ColorPickerView) Popup

func (p *ColorPickerView) Popup(on bool) *ColorPickerView

Popup opts into a built-in trigger and anchored panel. The default is inline.

func (*ColorPickerView) Render

func (p *ColorPickerView) Render(cx *el.Context) el.Element

func (*ColorPickerView) SetDisabled

func (p *ColorPickerView) SetDisabled(on bool)

SetDisabled blocks user input. Disabling cancels an uncommitted HEX draft; SetValue remains available and never calls OnChange.

func (*ColorPickerView) SetOpen

func (p *ColorPickerView) SetOpen(open bool)

SetOpen changes popup visibility without changing the color or invoking OnChange.

func (*ColorPickerView) SetValue

func (p *ColorPickerView) SetValue(c color.NRGBA)

SetValue shows c without calling OnChange.

func (*ColorPickerView) Size

func (*ColorPickerView) Swatches

func (p *ColorPickerView) Swatches(colors ...color.NRGBA) *ColorPickerView

Swatches offers preset colors under the picker.

func (*ColorPickerView) Text

func (p *ColorPickerView) Text() string

Text is the value in the current format, such as "rgb(37, 99, 235)".

func (*ColorPickerView) Value

func (p *ColorPickerView) Value() color.NRGBA

Value is the current color.

type ColumnSpec

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

ColumnSpec describes a Table column. Create one with Col.

func Col

func Col(title string) *ColumnSpec

Col creates a column that takes an equal share of the width.

func (*ColumnSpec) Cell

func (c *ColumnSpec) Cell(fn func(cx *el.Context, row int) el.Element) *ColumnSpec

Cell renders the column's cells with fn instead of plain text; row indexes the data given to SetRows. Agents still see the row's text.

func (*ColumnSpec) Flex

func (c *ColumnSpec) Flex(w float32) *ColumnSpec

Flex sets the column's share of the free width relative to other flexible columns.

func (*ColumnSpec) Movable

func (c *ColumnSpec) Movable(on bool) *ColumnSpec

Movable controls header dragging and MoveColumn; a locked column also prevents other columns crossing it. Explicit layout restoration remains application-controlled.

func (*ColumnSpec) NoSort

func (c *ColumnSpec) NoSort() *ColumnSpec

NoSort stops the header from sorting by this column.

func (*ColumnSpec) Numeric

func (c *ColumnSpec) Numeric() *ColumnSpec

Numeric right-aligns the column and sorts it as numbers.

func (*ColumnSpec) Resizable

func (c *ColumnSpec) Resizable(on bool) *ColumnSpec

func (*ColumnSpec) Selectable

func (c *ColumnSpec) Selectable(on bool) *ColumnSpec

func (*ColumnSpec) Width

func (c *ColumnSpec) Width(dp float32) *ColumnSpec

Width fixes the column width in dp. Users can still resize it.

type ComboboxGroup

type ComboboxGroup struct {
	ID, Label string
	Items     []ComboboxItem
}

ComboboxGroup is an ordered section of candidates with a stable nonempty ID. Label defaults to ID. Empty groups are not displayed.

type ComboboxItem

type ComboboxItem struct {
	Value, Label string
	Disabled     bool
}

ComboboxItem separates a stable application value from its visible label. Empty Value entries are ignored; empty Label falls back to Value.

type ComboboxTriggerContext

type ComboboxTriggerContext struct {
	Selection      []ComboboxItem
	Open, Disabled bool
	Size           float32
	Placeholder    string
	Toggle, Clear  func()
}

ComboboxTriggerContext is a per-render snapshot. Selection is caller-owned. Toggle and Clear are for UI event callbacks, not for use during rendering.

type ComboboxView

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

ComboboxView is a text field with a filtered list of suggestions. Typing opens and filters the list; clicking an option takes it. Enter takes the typed text if it is an option (or AllowCustom is set), else the first match. Esc or a click elsewhere closes the list. ↓ opens the list and moves the highlight, ↑ moves it back, and Enter takes the highlighted option. Without AllowCustom, leaving the field with text that is not an option restores the last choice.

func Combobox

func Combobox(label string, options ...string) *ComboboxView

func (*ComboboxView) AllowCustom

func (v *ComboboxView) AllowCustom() *ComboboxView

func (*ComboboxView) CheckIcon

func (v *ComboboxView) CheckIcon(icon *IconView) *ComboboxView

CheckIcon replaces the selected-row icon with a snapshot of a built-in or vector icon. Its configured size scales with Size; color is preserved. Nil restores the default check. Icon(IconNone) hides it but reserves its slot.

func (*ComboboxView) Clearable

func (v *ComboboxView) Clearable(on bool) *ComboboxView

Clearable shows a clear button when a selection exists. Clearing closes the popup, invalidates pending searches and discards draft text and errors. It reports an empty selection once; programmatic setters remain silent.

func (*ComboboxView) DisableOption

func (v *ComboboxView) DisableOption(value string, on bool) *ComboboxView

DisableOption controls whether the user may choose a value. Disabled entries remain visible, and configuration survives filtering and async result updates. Existing selections are retained and may still be removed; SetValue/SetValues remain application-controlled. False removes the override, including for values not currently offered. AllowCustom does not bypass this restriction.

func (*ComboboxView) Error

func (v *ComboboxView) Error() string

func (*ComboboxView) FocusID

func (v *ComboboxView) FocusID() string

func (*ComboboxView) Footer

func (v *ComboboxView) Footer(view el.View) *ComboboxView

Footer sets persistent content below the scrolling candidates, including loading, error and empty states. Nil removes it. Actions manage selection through the public setters; interacting with the footer does not choose a row.

func (*ComboboxView) Multiple

func (v *ComboboxView) Multiple() *ComboboxView

func (*ComboboxView) OnChange

func (v *ComboboxView) OnChange(fn func(value string)) *ComboboxView

func (*ComboboxView) OnConfirm

func (v *ComboboxView) OnConfirm(fn func([]string)) *ComboboxView

OnConfirm runs once after the user closes an open popup, after any selection change callbacks. Values are a snapshot of that completed interaction. Programmatic setters, disabling, removal and Searchable changes are silent. Esc/outside clicks use the existing draft-settling behavior; confirmation describes completion and does not imply a selection changed.

func (*ComboboxView) OnSearch

func (v *ComboboxView) OnSearch(fn func(query string, token uint64)) *ComboboxView

OnSearch delegates suggestion lookup to the application. Deliver asynchronous results on the UI loop via SetResults/SetSearchError; stale tokens are ignored.

func (*ComboboxView) OnValuesChange

func (v *ComboboxView) OnValuesChange(fn func([]string)) *ComboboxView

func (*ComboboxView) Placeholder

func (v *ComboboxView) Placeholder(s string) *ComboboxView

func (*ComboboxView) Render

func (v *ComboboxView) Render(cx *el.Context) el.Element

func (*ComboboxView) RenderItem

func (v *ComboboxView) RenderItem(fn func(ComboboxItem, bool) el.View) *ComboboxView

RenderItem replaces candidate label content, leaving selection, disabled state and the trailing check under Combobox control. Nil callbacks or nil results restore the label. Only visible virtual rows invoke the callback. Reuse stateful Views by stable item Value; do not mutate selection in Render.

func (*ComboboxView) RenderTrigger

func (v *ComboboxView) RenderTrigger(fn func(ComboboxTriggerContext) el.View) *ComboboxView

RenderTrigger replaces the complete default field presentation. The component retains an accessible keyboard target and a background click surface. Custom buttons may use the context's Toggle/Clear actions without double activation. Searchable mode places its editor inside the popup. Nil restores the default.

func (*ComboboxView) RowHeight

func (v *ComboboxView) RowHeight(dp float32) *ComboboxView

RowHeight sets the full candidate slot height in dp, including row margins. All candidates use this height. Zero restores 30dp scaled with Size; positive explicit heights do not scale with Size. Invalid values are ignored.

func (*ComboboxView) Searchable

func (v *ComboboxView) Searchable(on bool) *ComboboxView

Searchable controls query editing (enabled by default). Changing the mode closes the popup, invalidates old requests and discards uncommitted text. In non-searchable mode async lookup receives an empty query on open/retry; AllowCustom is inactive, and existing selections remain unchanged.

func (*ComboboxView) SetDisabled

func (v *ComboboxView) SetDisabled(on bool)

func (*ComboboxView) SetError

func (v *ComboboxView) SetError(msg string)

func (*ComboboxView) SetGroupResults

func (v *ComboboxView) SetGroupResults(token uint64, groups ...ComboboxGroup) bool

SetGroupResults delivers grouped asynchronous results on the UI loop. Stale, closed and disabled requests are rejected without changing content.

func (*ComboboxView) SetGroups

func (v *ComboboxView) SetGroups(groups ...ComboboxGroup)

SetGroups replaces candidates with grouped items. Input slices are copied; duplicate group IDs and item values keep their first occurrence. Empty group IDs and item values are ignored. Selection and disabled overrides survive.

func (*ComboboxView) SetItemResults

func (v *ComboboxView) SetItemResults(token uint64, items ...ComboboxItem) bool

SetItemResults delivers structured async results. Like SetResults it must run on the UI loop, and returns false for stale, closed or disabled requests.

func (*ComboboxView) SetItems

func (v *ComboboxView) SetItems(items ...ComboboxItem)

SetItems replaces candidate metadata, copying the entries and taking the first occurrence of each value. Selections and independent DisableOption overrides are retained. A selected value absent from the new results keeps its prior label. No selection callback runs.

func (*ComboboxView) SetOptions

func (v *ComboboxView) SetOptions(options ...string)

func (*ComboboxView) SetResults

func (v *ComboboxView) SetResults(token uint64, options ...string) bool

func (*ComboboxView) SetSearchError

func (v *ComboboxView) SetSearchError(token uint64, message string) bool

func (*ComboboxView) SetValue

func (v *ComboboxView) SetValue(s string)

func (*ComboboxView) SetValues

func (v *ComboboxView) SetValues(values []string)

func (*ComboboxView) Size

func (v *ComboboxView) Size(dp float32) *ComboboxView

Size sets the minimum field height in dp, scaling text, spacing, controls and candidate rows. Recommended values are 28, 36 and 48. Zero restores defaults. Invalid values are ignored. Footer content keeps its own size configuration.

func (*ComboboxView) Value

func (v *ComboboxView) Value() string

func (*ComboboxView) Values

func (v *ComboboxView) Values() []string

type CommandItem

type CommandItem struct {
	Title, Group, Shortcut string
	// ActionName resolves the default row hint through core.Bindings.
	// Register the same Action with cx.Action to enable it outside this palette.
	ActionName string
	Icon       IconName
	Checked    bool
	Action     func()
	Disabled   bool
	Keywords   []string
	// Separator introduces a non-interactive divider; other fields are ignored.
	Separator bool
}

CommandItem is one entry of a command palette. Shortcut uses core.ParseShortcut syntax and is only displayed; Group introduces a section. Keywords adds extra fuzzy-search terms. Constructors and SetItems copy the slice.

type CommandView

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

CommandView is a command palette: a search box over a list of commands that narrows as you type. Prefix matches rank first, then substrings, then characters that merely appear in order ("设置" finds "打开设置", "nwo" finds "New window"). ↑ ↓ move, Enter runs, Esc closes. Bind it to a shortcut yourself: cx.Shortcut("mod+k", palette.Toggle).

func Command

func Command(items ...CommandItem) *CommandView

func (*CommandView) AutoRowHeight

func (v *CommandView) AutoRowHeight(on bool) *CommandView

AutoRowHeight measures custom row contents and virtualizes using cached heights. RowHeight becomes the minimum slot height and initial estimate. False restores uniform slots. Width/scale and model changes invalidate the measurements; offscreen content changes can call InvalidateRows.

func (*CommandView) Bordered

func (v *CommandView) Bordered(on bool) *CommandView

Bordered controls the default frame border, rounding and shadow.

func (*CommandView) Empty

func (v *CommandView) Empty(content el.View) *CommandView

Empty replaces the no-matches content. Nil restores the default message.

func (*CommandView) Focus

func (v *CommandView) Focus(cx *el.Context)

Focus explicitly focuses an open palette. Inline palettes never steal focus merely because they render.

func (*CommandView) FocusID

func (v *CommandView) FocusID() string

FocusID is the current search input or non-searchable frame's focus target.

func (*CommandView) Footer

func (v *CommandView) Footer(content el.View) *CommandView

Footer adds content below every result state. Nil removes it.

func (*CommandView) Header

func (v *CommandView) Header(content el.View) *CommandView

Header adds content above the optional search field. Nil removes it.

func (*CommandView) Inline

func (v *CommandView) Inline(on bool) *CommandView

Inline places the palette in normal layout and opens it when enabled. Running an inline command leaves it visible. SetValue still controls its visibility. Switching presentation invalidates outstanding search requests.

func (*CommandView) InvalidateRows

func (v *CommandView) InvalidateRows()

InvalidateRows discards measured heights after application-owned offscreen content or typography changes. Visible rows are measured every frame.

func (*CommandView) IsLoading

func (v *CommandView) IsLoading() bool

IsLoading reports whether the palette is waiting for results.

func (*CommandView) MatchedCount

func (v *CommandView) MatchedCount() int

MatchedCount reports matching items, including disabled items, but excludes group headings and dividers. Loading does not erase the installed model.

func (*CommandView) MaxHeight

func (v *CommandView) MaxHeight(dp float32) *CommandView

MaxHeight caps the results viewport in dp. Zero restores 360dp. The actual height also respects the window and supplementary header/footer areas.

func (*CommandView) OnCancel

func (v *CommandView) OnCancel(fn func()) *CommandView

OnCancel reports a user dismissal, after internal close. Escape first clears a nonempty searchable query; only the next Escape cancels. Outside clicks cancel immediately. Programmatic close/disable does not cancel.

func (*CommandView) OnConfirm

func (v *CommandView) OnConfirm(fn func(int)) *CommandView

OnConfirm reports the original index after executing the item's Action. The callback and index are captured before Action; callback-driven model changes do not change which command was confirmed. Items without actions also confirm. Programmatic close does not confirm or cancel.

func (*CommandView) OnQuery

func (v *CommandView) OnQuery(fn func(string)) *CommandView

OnQuery observes user query edits (including Escape clearing). It does not replace local filtering. Unlike OnSearch it does not run on opening/retry. Refiltering updates OnSelect before OnQuery.

func (*CommandView) OnSearch

func (v *CommandView) OnSearch(fn func(query string, token uint64)) *CommandView

OnSearch replaces local fuzzy filtering with application-provided results. Each request has a new token. Use core.Update to deliver asynchronous results through SetResults/SetSearchError; stale tokens and closed palettes are ignored.

func (*CommandView) OnSelect

func (v *CommandView) OnSelect(fn func(int)) *CommandView

OnSelect reports the original SetItems index of a newly highlighted item, or -1 when none is available. Group headings do not contribute indices. Initial/model-driven selection is delivered after render, never from Render.

func (*CommandView) PanelStyle

func (v *CommandView) PanelStyle(fn func(*el.DivEl)) *CommandView

PanelStyle refines each freshly built panel, e.g. width and background. Do not retain the element. Nil removes the customization.

func (*CommandView) Placeholder

func (v *CommandView) Placeholder(text string) *CommandView

Placeholder replaces the localized search hint. Empty restores the default.

func (*CommandView) Query

func (v *CommandView) Query() string

Query returns the current query, including a hidden non-searchable query.

func (*CommandView) Render

func (v *CommandView) Render(cx *el.Context) el.Element

func (*CommandView) RenderItem

func (v *CommandView) RenderItem(fn func(CommandItem, bool) el.View) *CommandView

RenderItem replaces a visible command's presentation, including its shortcut. Nil content uses the default row. The outer row retains selection and disabled semantics. Reuse stateful children; nested actions do not execute the command.

func (*CommandView) RowHeight

func (v *CommandView) RowHeight(dp float32) *CommandView

RowHeight sets a uniform virtual slot height in dp. Zero restores 36dp; negative or non-finite values are ignored. Group headings share this height.

func (*CommandView) Searchable

func (v *CommandView) Searchable(on bool) *CommandView

Searchable toggles the search field and local filtering. Without search all items are shown and OnSearch is not invoked. Changing mode clears the query.

func (*CommandView) SelectedIndex

func (v *CommandView) SelectedIndex() int

SelectedIndex returns the highlighted original item index, or -1. Model changes are reconciled on render; group headings/dividers are never selected.

func (*CommandView) SetDisabled

func (v *CommandView) SetDisabled(on bool)

func (*CommandView) SetItems

func (v *CommandView) SetItems(items ...CommandItem)

func (*CommandView) SetLoading

func (v *CommandView) SetLoading(on bool)

SetLoading controls the spinner for application-owned synchronous models. OnSearch/SetResults manage it automatically for token-based remote results.

func (*CommandView) SetQuery

func (v *CommandView) SetQuery(query string)

SetQuery changes an open searchable palette as if typed, including callbacks. Closed/non-searchable palettes only store the text. Opening resets it.

func (*CommandView) SetResults

func (v *CommandView) SetResults(token uint64, items ...CommandItem) bool

func (*CommandView) SetSearchError

func (v *CommandView) SetSearchError(token uint64, message string) bool

func (*CommandView) SetValue

func (v *CommandView) SetValue(open bool)

func (*CommandView) Toggle

func (v *CommandView) Toggle()

Toggle opens or closes the palette; bind it to a shortcut or a button.

func (*CommandView) Value

func (v *CommandView) Value() bool

type CopyButtonView

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

CopyButtonView copies text to the clipboard and confirms with 已复制.

func CopyButton

func CopyButton(text func() string) *CopyButtonView

CopyButton copies what text returns when clicked; text runs at click time.

func (*CopyButtonView) Content

func (v *CopyButtonView) Content(content el.View) *CopyButtonView

Content replaces the default icon and label. Supply display-only content, without nested buttons or inputs. Nil restores the default. Use Copied inside a ViewFunc to customize feedback.

func (*CopyButtonView) Copied

func (v *CopyButtonView) Copied() bool

Copied reports whether the current copy feedback interval is active.

func (*CopyButtonView) OnCopied

func (v *CopyButtonView) OnCopied(fn func(string)) *CopyButtonView

OnCopied runs after requesting a clipboard write, with the exact copied text. The platform does not acknowledge whether the system clipboard accepted it.

func (*CopyButtonView) Render

func (v *CopyButtonView) Render(cx *el.Context) el.Element

func (*CopyButtonView) SetDisabled

func (v *CopyButtonView) SetDisabled(on bool)

type DatePickerPreset

type DatePickerPreset struct {
	ID, Label  string
	Start, End time.Time
	// IncludeTime stores the endpoint clocks, including in range mode.
	// Otherwise the current clocks are preserved.
	IncludeTime bool
}

DatePickerPreset is a shortcut with a stable nonempty ID and visible label. Single-date mode ignores End; in range mode a zero End uses Start.

type DatePickerView

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

DatePickerView is a field that opens a calendar. Picking a date (or completing a range with Range) closes it; Esc or a click outside closes it without a change. WithTime keeps the popup open for immediate date/time editing. Dates are shown with locale's Date format.

func DatePicker

func DatePicker(label string) *DatePickerView

func (*DatePickerView) Appearance

func (v *DatePickerView) Appearance(on bool) *DatePickerView

Appearance controls the field background, border, rounding and padding. The calendar popup keeps its own appearance; minimum height is preserved.

func (*DatePickerView) Bounds

func (v *DatePickerView) Bounds(min, max time.Time) *DatePickerView

Bounds limits selectable dates; a zero time leaves that side open.

func (*DatePickerView) Clearable

func (v *DatePickerView) Clearable(on bool) *DatePickerView

Clearable shows an independent clear button when a date is selected.

func (*DatePickerView) DateTimeValue

func (v *DatePickerView) DateTimeValue() (start, end time.Time)

DateTimeValue combines calendar dates with their stored clocks. Unlike Value, it includes both endpoint clocks in range mode. Zero dates remain zero.

func (*DatePickerView) DateValue

func (v *DatePickerView) DateValue() (start, end time.Time)

DateValue returns only the calendar dates, including in time editing mode.

func (*DatePickerView) DefaultTime

func (v *DatePickerView) DefaultTime(value time.Duration) *DatePickerView

DefaultTime sets the clock used for subsequent date selections. It wraps within one day and truncates to the configured precision, without a callback.

func (*DatePickerView) DisableDates

func (v *DatePickerView) DisableDates(fn func(time.Time) bool) *DatePickerView

func (*DatePickerView) Error

func (v *DatePickerView) Error() string

func (*DatePickerView) FirstWeekday

func (v *DatePickerView) FirstWeekday(day time.Weekday) *DatePickerView

FirstWeekday overrides the locale week layout for this picker's calendar. Invalid values are ignored; dates and range drafts are preserved.

func (*DatePickerView) FocusID

func (v *DatePickerView) FocusID() string

func (*DatePickerView) Format

func (v *DatePickerView) Format(layout string) *DatePickerView

Format sets a Go time layout for both endpoints. Empty restores locale.Date. It changes display only, without changing selection or firing OnChange.

func (*DatePickerView) Months

func (v *DatePickerView) Months(n int) *DatePickerView

Months requests consecutive month panels; narrow windows show fewer panels.

func (*DatePickerView) OnChange

func (v *DatePickerView) OnChange(fn func(start, end time.Time)) *DatePickerView

OnChange runs when the user picks a date or completes a range (start == end for one date). WithTime also reports committed clock edits. Clearing sends two zero times.

func (*DatePickerView) Placeholder

func (v *DatePickerView) Placeholder(s string) *DatePickerView

func (*DatePickerView) Presets

func (v *DatePickerView) Presets(items ...DatePickerPreset) *DatePickerView

Presets replaces the shortcuts, copying the slice. Empty IDs/labels and duplicate IDs are ignored (first wins). No arguments removes all shortcuts. Dates are snapshots; refresh them explicitly for moving windows like Today.

func (*DatePickerView) Range

func (v *DatePickerView) Range() *DatePickerView

Range picks a span of dates instead of one.

func (*DatePickerView) Render

func (v *DatePickerView) Render(cx *el.Context) el.Element

func (*DatePickerView) ResetFirstWeekday

func (v *DatePickerView) ResetFirstWeekday() *DatePickerView

ResetFirstWeekday restores the locale week layout.

func (*DatePickerView) SetDateTimeValue

func (v *DatePickerView) SetDateTimeValue(start, end time.Time)

SetDateTimeValue stores dates and endpoint clocks without a callback or enabling time editing. Missing End uses Start; reversed ranges are sorted with their clocks. Configured time precision applies to both endpoints.

func (*DatePickerView) SetDateValue

func (v *DatePickerView) SetDateValue(start, end time.Time)

SetDateValue changes the dates while preserving both clocks, without a callback.

func (*DatePickerView) SetDisabled

func (v *DatePickerView) SetDisabled(on bool)

func (*DatePickerView) SetError

func (v *DatePickerView) SetError(msg string)

func (*DatePickerView) SetValue

func (v *DatePickerView) SetValue(start, end time.Time)

func (*DatePickerView) Size

func (v *DatePickerView) Size(dp float32) *DatePickerView

Size sets the field's minimum height in dp, scaling its text, icons and spacing. Recommended heights are 28, 36 and 48. Zero restores theme defaults. It does not change the calendar or preset sizes; invalid values are ignored.

func (*DatePickerView) TimeHour12

func (v *DatePickerView) TimeHour12(on bool) *DatePickerView

TimeHour12 overrides the locale clock format and enables time editing.

func (*DatePickerView) TimeSeconds

func (v *DatePickerView) TimeSeconds() *DatePickerView

TimeSeconds enables time editing with whole-second precision.

func (*DatePickerView) Value

func (v *DatePickerView) Value() (start, end time.Time)

func (*DatePickerView) WithTime

func (v *DatePickerView) WithTime() *DatePickerView

WithTime enables minute precision time editing for a single date. Range pickers edit dates only; DateTimeValue retains both endpoint clocks. Changes commit immediately; selecting the selected date again closes the popup. Single-date Value and all OnChange callbacks include time.

type Description

type Description struct{ Label, Text string }

Description pairs a label with text; use ItemView for rich values.

type DescriptionListView

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

func DescriptionList

func DescriptionList() *DescriptionListView

func (*DescriptionListView) Bordered

func (v *DescriptionListView) Bordered(on bool) *DescriptionListView

Bordered draws a padded border around each item; the default is unbordered.

func (*DescriptionListView) Columns

Columns sets the number of equal-width item columns (at least one).

func (*DescriptionListView) Item

func (v *DescriptionListView) Item(label, value string) *DescriptionListView

func (*DescriptionListView) ItemView

func (v *DescriptionListView) ItemView(label string, value el.View) *DescriptionListView

func (*DescriptionListView) LabelWidth

func (v *DescriptionListView) LabelWidth(dp float32) *DescriptionListView

func (*DescriptionListView) Render

func (v *DescriptionListView) Render(cx *el.Context) el.Element

func (*DescriptionListView) Separator

func (v *DescriptionListView) Separator() *DescriptionListView

Separator inserts a full-width divider and starts subsequent items on a new row.

func (*DescriptionListView) SetItems

func (v *DescriptionListView) SetItems(items ...Description)

func (*DescriptionListView) Size

Size sets text size in sp; use theme.TextSm/TextBody/TextLg for size tiers.

func (*DescriptionListView) Span

Span makes the most recently added item occupy n columns, clamped at render time.

func (*DescriptionListView) Vertical

Vertical places each label above its value.

type DialogView

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

DialogView is a modal dialog: the page dims, ignores the pointer and loses keyboard focus until the dialog closes; focus then returns where it was.

Build a custom one with Body and Footer:

edit := kit.Dialog("编辑订单").Body(form).Footer(cancel, save)
edit.SetValue(true)

or reuse one instance for standard messages:

dlg := kit.Dialog("")
dlg.ConfirmDanger("删除订单", "确定删除?", "删除", remove)

Render it in the view tree; it renders nothing in place.

func Dialog

func Dialog(title string) *DialogView

func (*DialogView) Alert

func (v *DialogView) Alert(title, message string, onOK func())

Alert shows a message with a single 确定; onOK may be nil.

func (*DialogView) BeforeCancel

func (v *DialogView) BeforeCancel(fn func() bool) *DialogView

BeforeCancel may reject user dismissal; nil removes the guard. It does not prevent programmatic closing or cleanup when the owner disappears.

func (*DialogView) BeforeConfirm

func (v *DialogView) BeforeConfirm(fn func() bool) *DialogView

BeforeConfirm runs before a standard message's OK action. False keeps the dialog open and skips onOK. Nil removes the guard. It persists across message reuse; custom Footer actions remain owned by the application.

func (*DialogView) Body

func (v *DialogView) Body(b el.View) *DialogView

func (*DialogView) CloseButton

func (v *DialogView) CloseButton(on bool) *DialogView

CloseButton shows an explicit header close action, hidden by default.

func (*DialogView) Confirm

func (v *DialogView) Confirm(title, message string, onOK func())

Confirm asks a question with 取消 and 确定; onOK runs only on 确定. Focus starts on 确定, so Enter confirms.

func (*DialogView) ConfirmDanger

func (v *DialogView) ConfirmDanger(title, message, okText string, onOK func())

ConfirmDanger asks before a destructive action. Focus starts on 取消, a press on the scrim is ignored, and Esc cancels.

func (*DialogView) Footer

func (v *DialogView) Footer(views ...el.View) *DialogView

func (*DialogView) Icon

func (v *DialogView) Icon(name IconName) *DialogView

Icon shows an icon before the title, such as IconWarning on a destructive confirmation. Its color follows the tone: danger for ConfirmDanger, info otherwise, unless IconTone sets one. IconNone removes it. It persists across message reuse.

func (*DialogView) IconTone

func (v *DialogView) IconTone(t Tone) *DialogView

IconTone colors the title icon: ToneInfo, ToneSuccess, ToneWarning or ToneDanger.

func (*DialogView) Keyboard

func (v *DialogView) Keyboard(on bool) *DialogView

Keyboard controls Esc dismissal, enabled by default.

func (*DialogView) OnClose

func (v *DialogView) OnClose(fn func()) *DialogView

func (*DialogView) Overlay

func (v *DialogView) Overlay(on bool) *DialogView

Overlay controls scrim painting, not modality or outside-click behavior.

func (*DialogView) OverlayClosable

func (v *DialogView) OverlayClosable(on bool) *DialogView

OverlayClosable overrides outside-click dismissal, including Persistent.

func (*DialogView) Persistent

func (v *DialogView) Persistent() *DialogView

Persistent makes it an alertdialog: a press on the scrim does not close it; Esc still does. ConfirmDanger dialogs are persistent.

func (*DialogView) Render

func (v *DialogView) Render(cx *el.Context) el.Element

func (*DialogView) SetDisabled

func (v *DialogView) SetDisabled(on bool)

func (*DialogView) SetTitle

func (v *DialogView) SetTitle(s string)

func (*DialogView) SetValue

func (v *DialogView) SetValue(open bool)

func (*DialogView) Show added in v0.0.5

func (v *DialogView) Show(cx *el.Context)

Show opens the dialog in the window of cx without placing it in a view tree; it leaves the window when closed.

func (*DialogView) Value

func (v *DialogView) Value() bool

func (*DialogView) Width

func (v *DialogView) Width(dp float32) *DialogView

Width sets the dialog width in dp, 420 by default.

type DockAxis

type DockAxis uint8

DockAxis is the direction in which a split's two children are arranged.

const (
	DockAxisHorizontal DockAxis = iota
	DockAxisVertical
)

type DockLayout

type DockLayout struct {
	LeftTree, RightTree, BottomTree *DockNode `json:",omitempty"`
	CenterTree                      *DockNode `json:",omitempty"`
	Center                          []string  `json:",omitempty"`
	CenterActive                    string    `json:",omitempty"`
	// Detached panels are open in windows of their own (see OnDetach).
	Detached                        []string `json:",omitempty"`
	Version                         int      `json:"version,omitempty"`
	Left, Right, Bottom             []string `json:",omitempty"`
	LeftActive, RightActive         string   `json:",omitempty"`
	BottomActive                    string   `json:",omitempty"`
	LeftSize, RightSize, BottomSize float32
	Hidden                          []string `json:",omitempty"`
	// Closed regions are collapsed; their panels keep their places.
	LeftClosed, RightClosed, BottomClosed bool `json:",omitempty"`
	// Zoomed is the panel maximized over the whole dock, or "".
	Zoomed string `json:",omitempty"`
}

DockLayout is everything about a Dock's arrangement, for saving and restoring it (it encodes as JSON). Panel lists are in tab order.

type DockNode

type DockNode struct {
	Panels        []string  `json:",omitempty"`
	Active        string    `json:",omitempty"`
	Axis          DockAxis  `json:",omitempty"`
	Ratio         float32   `json:",omitempty"`
	First, Second *DockNode `json:",omitempty"`
}

DockNode is either a tab group (Panels, Active), or a binary split (First, Second, Axis, Ratio). Ratio is the first child's share, in [0.05,0.95]. Each panel occurs exactly once across the region trees.

type DockPanel

type DockPanel struct {
	ID, Title string
	View      el.View
	// Kind identifies the registered factory used by Restore. Empty means
	// this panel can only be reused in a Dock that already contains it.
	Kind string
	// SaveState returns application-owned JSON. Snapshot copies the bytes.
	// Set Kind when using SaveState so Restore can reconstruct the panel.
	SaveState func() (json.RawMessage, error)

	// Icon shows before the title in the panel's tab.
	Icon IconName
	// Tab replaces the tab's icon and title with custom content; selected
	// reports whether it is the group's active tab. Title stays the tab's
	// accessible name.
	Tab func(selected bool) el.View
	// Toolbar shows controls in the group header, before the menu, while
	// the panel is the active tab.
	Toolbar el.View
	// Menu adds items to the panel's menu, above the dock's own items.
	Menu func(m *MenuView)
	// NoClose and NoZoom remove closing and maximizing from the panel's
	// menu; NoZoom also ignores double clicks on its tab and Zoom.
	NoClose, NoZoom bool
	// NoPadding drops the body's inner padding, for panels that draw edge
	// to edge.
	NoPadding bool
}

DockPanel is a tool window that lives in a Dock region. IDs must be unique. The panel gets the region's full height; long content should scroll itself.

type DockPanelFactory

type DockPanelFactory func(DockPanelState) (DockPanel, error)

DockPanelFactory creates a fresh view from one saved instance, on the UI thread. Return its SaveState callback to support subsequent snapshots. An empty returned ID/Kind/Title inherits the saved value. ID and Kind must otherwise match. Avoid external side effects: Dock can roll back its own state on failure, but cannot undo work performed by application factories.

type DockPanelState

type DockPanelState struct {
	ID    string          `json:"id"`
	Kind  string          `json:"kind,omitempty"`
	Title string          `json:"title"`
	State json.RawMessage `json:"state,omitempty"`
}

DockPanelState describes one instance. Kind selects the factory; State's schema and migrations belong to the application. ID is stable across loads.

type DockPlacement

type DockPlacement uint8

DockPlacement selects the edge of the target group for a new split.

const (
	DockPlacementLeft DockPlacement = iota
	DockPlacementRight
	DockPlacementTop
	DockPlacementBottom
)

type DockSide

type DockSide uint8

DockSide is where a Dock region sits around the center.

const (
	DockLeft DockSide = iota
	DockRight
	DockBottom
	// DockCenter holds documents in the middle, in tab groups that split
	// like the side regions. While it has any, they replace the center view.
	DockCenter
)

type DockSkin

type DockSkin struct {
	Panel     func(*el.DivEl)
	Header    func(*el.DivEl)
	Body      func(*el.DivEl)
	Tab       func(tab *el.DivEl, selected bool)
	Separator func(*el.DivEl)
}

DockSkin styles a Dock independently of its persisted arrangement. Callbacks run on fresh elements each frame. Use them for colors, borders, typography and panel padding; preserve element identity, children and event handlers. Separators retain their 4dp thickness; do not change their geometry.

type DockState

type DockState struct {
	Version int              `json:"version"`
	Layout  DockLayout       `json:"layout"`
	Panels  []DockPanelState `json:"panels"`
}

DockState persists both the arrangement and all panels, including hidden and detached ones. Version is currently 1, independent of DockLayout.Version.

type DockView

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

DockView arranges tool panels around a central view, like an IDE. Each region holds tabbed panels and resizes against the center; a panel's menu moves it to another region or closes it. Layout and SetLayout save and restore the arrangement.

func Dock

func Dock(center el.View) *DockView

func (*DockView) Detach

func (v *DockView) Detach(id string)

Detach moves a shown panel out of the dock into a window of its own, by calling the OnDetach function. It does nothing without one.

func (*DockView) Detached

func (v *DockView) Detached() []string

Detached lists the panels now in windows of their own. A restored layout does not reopen windows: SetLayout puts detached panels back in the dock.

func (*DockView) Layout

func (v *DockView) Layout() DockLayout

Layout returns a copy of the arrangement.

func (*DockView) Move

func (v *DockView) Move(id string, to DockSide)

Move puts a panel at the end of a region and makes it that region's active tab.

func (*DockView) OnDetach

func (v *DockView) OnDetach(fn func(p DockPanel, reattach func())) *DockView

OnDetach lets panels leave the dock for a window of their own: their menu gains "Open in new window", and dragging a tab out of the dock detaches it. fn should open a window showing p.View; when that window closes, call reattach (from a UI callback, or through core.Update) to put the panel back where it was. kit does not open windows itself, so the app chooses the window's size and options.

d.OnDetach(func(p kit.DockPanel, reattach func()) {
    window.Open(window.Options{Title: p.Title, Content: el.Root(p.View), OnClose: reattach})
})

func (*DockView) OnLayoutChange

func (v *DockView) OnLayoutChange(fn func(DockLayout)) *DockView

OnLayoutChange runs after the user moves, closes, switches or resizes a panel, with the new layout to save.

func (*DockView) Panel

func (v *DockView) Panel(p DockPanel, side DockSide) *DockView

Panel adds a panel to a region; the first panel added to a region is active.

func (*DockView) RegionButton added in v0.0.4

func (v *DockView) RegionButton(s DockSide) el.View

RegionButton is a toggle for a side region, selected while it is open, to put in a title bar or toolbar. Build it once and keep it; it reads the region's state on every Render.

func (*DockView) RegionOpen added in v0.0.4

func (v *DockView) RegionOpen(s DockSide) bool

RegionOpen reports whether a side region is shown. The center is always open.

func (*DockView) RegisterPanel

func (v *DockView) RegisterPanel(kind string, factory DockPanelFactory) error

RegisterPanel registers a type for this Dock. Empty kinds, nil factories and duplicate kinds return errors. It does not create or display any panels.

func (*DockView) Render

func (v *DockView) Render(cx *el.Context) el.Element

func (*DockView) Restore

func (v *DockView) Restore(state DockState) error

Restore replaces the panel collection and arrangement without emitting OnLayoutChange. It validates the complete manifest and layout before calling factories, then commits only when all succeed. Panels absent from state are removed. Unknown kinds, unknown layout IDs and unplaced panels are errors. Detached panels return to the Dock; application windows are not opened or closed. The center view, skin, registrations and callbacks are retained.

func (*DockView) SetDisabled

func (v *DockView) SetDisabled(on bool)

func (*DockView) SetLayout

func (v *DockView) SetLayout(l DockLayout) bool

SetLayout restores an arrangement. Unknown panel IDs are dropped; panels it does not mention stay where they are.

func (*DockView) SetRegionOpen added in v0.0.4

func (v *DockView) SetRegionOpen(s DockSide, open bool)

SetRegionOpen collapses or reopens a side region. Its panels keep their tabs, splits and size, and a closed region is part of Layout.

func (*DockView) SetVisible

func (v *DockView) SetVisible(id string, on bool)

SetVisible closes a panel or reopens it in the region it was last in (left if none).

func (*DockView) Skin

func (v *DockView) Skin(skin *DockSkin) *DockView

Skin uses a shared live style configuration. Passing nil restores defaults without changing panel contents, focus or layout. Mutate it on the UI thread.

func (*DockView) Snapshot

func (v *DockView) Snapshot() (DockState, error)

Snapshot captures panel data in ID order and copies the layout and JSON. Call on the UI thread. A panel with SaveState must have a Kind; panels with no Kind can only be restored by reusing existing stateless views with that ID. This does not invoke OnLayoutChange.

func (*DockView) Split

func (v *DockView) Split(id, target string, placement DockPlacement) bool

Split moves id into its own group on the given edge of target's group. Other tabs remain together. Empty groups collapse. Programmatic changes do not call OnLayoutChange. Invalid arguments leave the layout unchanged.

func (*DockView) ToggleRegion added in v0.0.4

func (v *DockView) ToggleRegion(s DockSide)

ToggleRegion flips a side region and reports the change to OnLayoutChange.

func (*DockView) Visible

func (v *DockView) Visible(id string) bool

Visible reports whether a panel is shown in the dock: not closed and not detached into a window of its own.

func (*DockView) Zoom

func (v *DockView) Zoom(id string)

Zoom maximizes a shown panel over the whole dock, hiding the center and the other panels until Zoom(""), its menu, a double click on its tab or Esc. The zoomed panel is part of Layout.

func (*DockView) Zoomed

func (v *DockView) Zoomed() string

Zoomed is the maximized panel, or "".

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

DropdownButtonView is a button that opens a menu. With Split, the label runs a main action and a separate arrow opens the menu:

kit.DropdownButton("导出", formats)            // the whole button opens the menu
kit.DropdownButton("保存", more).Split(save)   // 保存 runs save; ▾ opens more
func DropdownButton(label string, menu *MenuView) *DropdownButtonView
func (v *DropdownButtonView) Button(button *ButtonView) *DropdownButtonView

Button supplies the main half of a split button. Render copies its configuration so the source can be reused. Nil restores the ordinary/Split configuration.

func (v *DropdownButtonView) Loading(on bool) *DropdownButtonView

Loading overrides loading on the main action only. A split arrow remains usable.

Offset configures the supplied menu's anchor gap in dp.

func (v *DropdownButtonView) Placement(side el.Side, align el.Align) *DropdownButtonView

Placement configures the supplied menu's top-level anchor placement. Split menus anchor to the arrow; ordinary menus anchor to the whole button.

func (v *DropdownButtonView) Render(cx *el.Context) el.Element
func (v *DropdownButtonView) SetDisabled(on bool)

Size sets both halves' height in dp; zero inherits the inner button/default.

func (v *DropdownButtonView) Split(action func()) *DropdownButtonView

type EmptyPart

type EmptyPart uint8

EmptyPart identifies a region for per-frame style refinement.

const (
	EmptyPartRoot EmptyPart = iota
	EmptyPartHeader
	EmptyPartMedia
	EmptyPartTitle
	EmptyPartDescription
	EmptyPartContent
	EmptyPartFooter
)

type EmptyVariant

type EmptyVariant uint8

EmptyVariant is the surface an Empty sits on.

const (
	// EmptyPlain is the default: the Surface color, no border.
	EmptyPlain EmptyVariant = iota
	// EmptyOutline draws a dashed rounded border on a transparent surface,
	// the usual look for a drop zone or an area waiting to be filled.
	EmptyOutline
	// EmptyMuted fills a rounded area with the subtle background color, to
	// set the empty state apart inside a card or panel.
	EmptyMuted
)

type EmptyView

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

EmptyView explains why a region contains no results.

func Empty

func Empty(title string) *EmptyView

func (*EmptyView) Action

func (v *EmptyView) Action(e el.View) *EmptyView

func (*EmptyView) Description

func (v *EmptyView) Description(s string) *EmptyView

func (*EmptyView) DescriptionContent

func (v *EmptyView) DescriptionContent(view el.View) *EmptyView

DescriptionContent replaces the description text; nil restores it.

func (*EmptyView) Footer

func (v *EmptyView) Footer(view el.View) *EmptyView

Footer adds supporting content after Action; nil removes it.

func (*EmptyView) Heading

func (v *EmptyView) Heading(view el.View) *EmptyView

Heading replaces the title text; nil restores it.

func (*EmptyView) Icon

func (v *EmptyView) Icon(i IconName) *EmptyView

func (*EmptyView) Media

func (v *EmptyView) Media(view el.View) *EmptyView

Media replaces the icon with arbitrary content, preserving its size and semantics. Nil restores the configured icon; IconNone hides that fallback.

func (*EmptyView) PartStyle

func (v *EmptyView) PartStyle(part EmptyPart, fn func(*el.DivEl)) *EmptyView

PartStyle refines a fresh region each frame, after defaults. Do not retain it. Nil restores defaults. Invalid parts are ignored; slot identities are preserved.

func (*EmptyView) Render

func (v *EmptyView) Render(cx *el.Context) el.Element

func (*EmptyView) SetDescription

func (v *EmptyView) SetDescription(s string)

func (*EmptyView) SetTitle

func (v *EmptyView) SetTitle(s string)

func (*EmptyView) Variant

func (v *EmptyView) Variant(variant EmptyVariant) *EmptyView

Variant picks the surface: EmptyPlain, EmptyOutline or EmptyMuted. PartStyle(EmptyPartRoot, ...) still adjusts it afterwards.

type FormFieldOptions

type FormFieldOptions struct {
	Description        string
	DescriptionContent el.View
	Required, Hidden   bool
	ColSpan, ColStart  int
}

FormFieldOptions configures a field without changing its control or validator. ColStart is one-based; zero uses the next free column. Required is visual only.

type FormView

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

FormView lays out labelled fields in a configurable grid and validates them on Submit. A validator returns an error message, or "" when the value is fine; the message appears under the field until the next Submit or the user changes the field.

f := kit.Form().
    Field("客户", customer, func() string { return kit.Required(customer.Value(), "请填写客户") }).
    Field("金额", amount, nil)
kit.Button("创建", func() { if f.Validate(cx) { create() } })

func Form

func Form() *FormView

func (*FormView) Actions

func (v *FormView) Actions(views ...el.View) *FormView

Actions sets the buttons below the fields, aligned with the control column. They stay usable while a submission is pending, so one can cancel it.

func (*FormView) BeginSubmit

func (v *FormView) BeginSubmit(cx *el.Context) uint64

BeginSubmit runs synchronous validators and freezes fields while an async validation/submission is in flight. Zero means invalid, disabled or busy. Capture field values here, then return from the UI callback before doing I/O.

func (*FormView) CancelSubmit

func (v *FormView) CancelSubmit()

CancelSubmit invalidates pending results and restores editing. Call before programmatically replacing data during a submission.

func (*FormView) Columns

func (v *FormView) Columns(n int) *FormView

Columns sets independent field columns. Responsive column choices belong to the caller.

func (*FormView) Errors

func (v *FormView) Errors() []string

Errors returns a copy in Field order.

func (*FormView) Field

func (v *FormView) Field(label string, control el.View, validate func() string) *FormView

Field adds a row. validate may be nil; then control needs no Validatable.

func (*FormView) FieldWithOptions

func (v *FormView) FieldWithOptions(label string, control el.View, validate func() string, options FormFieldOptions) *FormView

FieldWithOptions adds a configured field; options are copied.

func (*FormView) FinishSubmit

func (v *FormView) FinishSubmit(token uint64, errors []string) bool

FinishSubmit accepts errors in Field order (nil means success). Call under core.Update for background work. Stale/canceled tokens are ignored.

func (*FormView) Footer

func (v *FormView) Footer(view el.View) *FormView

Footer adds a full-width trailing-aligned view after Actions; nil removes it.

func (*FormView) Gap

func (v *FormView) Gap(dp float32) *FormView

func (*FormView) LabelTextSize

func (v *FormView) LabelTextSize(sp float32) *FormView

func (*FormView) LabelWidth

func (v *FormView) LabelWidth(dp float32) *FormView

LabelWidth sets the label column width in dp, 72 by default.

func (*FormView) Render

func (v *FormView) Render(cx *el.Context) el.Element

func (*FormView) SetDisabled

func (v *FormView) SetDisabled(on bool)

func (*FormView) SetFieldOptions

func (v *FormView) SetFieldOptions(index int, options FormFieldOptions) bool

SetFieldOptions replaces presentation options by insertion index. A visibility change cancels pending submission and clears the field's previous error.

func (*FormView) Submitting

func (v *FormView) Submitting() bool

func (*FormView) Validate

func (v *FormView) Validate(cx *el.Context) bool

Validate runs visible fields' validators, shows their messages, and focuses the first invalid field. It reports whether all passed. Call it from a callback.

func (*FormView) VerticalLabels

func (v *FormView) VerticalLabels(on bool) *FormView

VerticalLabels puts labels above controls; false restores side labels.

type GroupBoxVariant

type GroupBoxVariant uint8
const (
	GroupBoxSurface GroupBoxVariant = iota // legacy surface and border
	GroupBoxNormal
	GroupBoxFill
	GroupBoxOutline
)

type GroupBoxView

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

GroupBoxView visually and semantically groups views under a title.

func GroupBox

func GroupBox(title string) *GroupBoxView

func (*GroupBoxView) Child

func (v *GroupBoxView) Child(views ...el.View) *GroupBoxView

func (*GroupBoxView) ContentStyle

func (v *GroupBoxView) ContentStyle(fn func(*el.DivEl)) *GroupBoxView

ContentStyle refines only the body, after the variant defaults. Do not retain it. Nil restores default styling; child view state is preserved.

func (*GroupBoxView) Description

func (v *GroupBoxView) Description(s string) *GroupBoxView

func (*GroupBoxView) Footer

func (v *GroupBoxView) Footer(view el.View) *GroupBoxView

Footer sets supporting content below the body; nil removes it.

func (*GroupBoxView) Render

func (v *GroupBoxView) Render(cx *el.Context) el.Element

func (*GroupBoxView) SetChildren

func (v *GroupBoxView) SetChildren(children ...el.View)

func (*GroupBoxView) SetTitle

func (v *GroupBoxView) SetTitle(s string)

func (*GroupBoxView) TitleStyle

func (v *GroupBoxView) TitleStyle(fn func(*el.TextEl)) *GroupBoxView

TitleStyle refines the freshly built title each frame. Do not retain the element. Nil restores default styling.

func (*GroupBoxView) Variant

func (v *GroupBoxView) Variant(variant GroupBoxVariant) *GroupBoxView

Variant changes the body surface; the title, description and footer stay outside.

type HoverCardView

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

HoverCardView previews richer content when the pointer rests on a view. Moving from the view onto the card keeps it open, so the card may contain links and buttons. Esc or a click outside closes it.

func HoverCard

func HoverCard(target, content el.View) *HoverCardView

func (*HoverCardView) CloseDelay

func (v *HoverCardView) CloseDelay(d time.Duration) *HoverCardView

CloseDelay sets how long the card stays open after hover and focus leave.

func (*HoverCardView) Offset

func (v *HoverCardView) Offset(dp float32) *HoverCardView

Offset sets the anchor gap in dp. Non-finite values are ignored.

func (*HoverCardView) OpenDelay

func (v *HoverCardView) OpenDelay(d time.Duration) *HoverCardView

OpenDelay sets the hover delay. Negative durations become zero; keyboard focus still opens immediately. Changing a pending delay restarts its timer.

func (*HoverCardView) Placement

func (v *HoverCardView) Placement(side el.Side, align el.Align) *HoverCardView

Placement chooses the preferred side and alignment; viewport avoidance remains active.

func (*HoverCardView) Render

func (v *HoverCardView) Render(cx *el.Context) el.Element

func (*HoverCardView) SetDisabled

func (v *HoverCardView) SetDisabled(on bool)

func (*HoverCardView) Width

func (v *HoverCardView) Width(dp float32) *HoverCardView

Width sets the card width in dp, 300 by default.

type IconName

type IconName uint8

IconName names a built-in icon. The zero value IconNone draws nothing and takes no space, so an optional icon field can be left unset.

const (
	IconNone IconName = iota
	IconCheck
	IconClose
	IconPlus
	IconSearch
	IconCopy
	IconChevronDown
	IconChevronRight
	IconInfo
	IconWarning
	IconError
	IconUser
	IconInbox
	IconDone // a plain check mark, e.g. inside a checkbox
	IconChevronLeft
	IconMinus
	IconStar
	IconStarOutline
	IconCalendar
	IconClock
	IconSettings
	IconBell
	IconLock
	IconFolder
	IconFile
	IconArchive
	IconReceipt
	IconHome
	IconTrash
	IconEdit
	IconMore // three dots, for overflow menus
	IconExternalLink
	IconBan
	IconRetry
	IconChevronUp
)

type IconView

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

IconView wraps a Gio vector icon. Labels belong to its containing control.

func Icon

func Icon(name IconName) *IconView

func SVGIcon

func SVGIcon(data []byte) (*IconView, error)

SVGIcon parses SVG bytes synchronously. Keep the returned view for reuse; parsing should not happen every Render. Input is limited to 1MiB. Unsupported SVG elements return an error. As with built-in icons, Color tints the alpha silhouette; OriginalColors(true) preserves the SVG's colors instead.

func SVGIconFile

func SVGIconFile(path string) (*IconView, error)

SVGIconFile reads a local SVG file once. It does not watch files or fetch URLs.

func VectorIcon

func VectorIcon(icon *giowidget.Icon) *IconView

VectorIcon supports custom Gio icons, including icons decoded by widget.NewIcon.

func (*IconView) Color

func (i *IconView) Color(c color.NRGBA) *IconView

func (*IconView) OriginalColors

func (i *IconView) OriginalColors(on bool) *IconView

OriginalColors preserves an SVG's source colors (currentColor becomes black). It has no effect on built-in or Gio vector icons. False restores Color/theme tint.

func (*IconView) Render

func (i *IconView) Render(*el.Context) el.Element

func (*IconView) Rotate

func (i *IconView) Rotate(degrees float32) *IconView

Rotate rotates the icon clockwise around its layout center, in degrees. It does not change layout size. Negative angles rotate counterclockwise; non-finite values are ignored. A non-square or tightly cropped icon may paint outside its original box, subject to ancestor clipping.

func (*IconView) Size

func (i *IconView) Size(dp float32) *IconView

type ImageCache

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

ImageCache is a thread-safe LRU of decoded images. Concurrent readers of a source share its request; cancelling one reader does not cancel the others. Disk adds a persistent cache of HTTP(S) downloads with revalidation.

func NewImageCache

func NewImageCache(maxBytes int64) *ImageCache

NewImageCache creates a decoded-image cache with an estimated byte budget. Nonpositive budgets disable retained results, while still coalescing requests.

func (*ImageCache) Clear

func (c *ImageCache) Clear()

Clear evicts retained results and prevents older in-flight requests from repopulating the cache. Existing readers still receive their own completion.

func (*ImageCache) Delete

func (c *ImageCache) Delete(source string)

Delete invalidates one source, including its eligibility for in-flight reuse.

func (*ImageCache) Disk added in v0.0.4

func (c *ImageCache) Disk(dir string, maxBytes int64, ttl time.Duration) *ImageCache

Disk also stores HTTP(S) downloads under dir, up to maxBytes in total, so they survive restarts. A copy younger than ttl is used without a request; an older one is revalidated with its ETag or Last-Modified. Data URLs and local files are never copied. An empty dir turns the disk cache off.

type ImageFit

type ImageFit uint8

ImageFit controls pixels inside a fixed Size. Without a height, aspect ratio determines the height regardless of Fit.

const (
	ImageContain ImageFit = iota
	ImageCover
	ImageFill
)

type ImageView

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

ImageView shows decoded pixels scaled to fit its width, keeping their aspect ratio. Source loads pixels asynchronously; SetImage accepts decoded pixels.

func Image

func Image(img image.Image, alt string) *ImageView

func (*ImageView) Cache

func (v *ImageView) Cache(cache *ImageCache) *ImageView

Cache replaces the shared default (64MiB estimated budget). Nil disables caching. Changing cache cancels and restarts the current source.

func (*ImageView) Fallback

func (v *ImageView) Fallback(view el.View) *ImageView

func (*ImageView) Fit

func (v *ImageView) Fit(fit ImageFit) *ImageView

func (*ImageView) ImageError

func (v *ImageView) ImageError() error

func (*ImageView) Loading

func (v *ImageView) Loading() bool

func (*ImageView) LoadingContent

func (v *ImageView) LoadingContent(view el.View) *ImageView

func (*ImageView) OnClick

func (v *ImageView) OnClick(fn func()) *ImageView

func (*ImageView) OnRetry

func (v *ImageView) OnRetry(fn func()) *ImageView

func (*ImageView) Preview

func (v *ImageView) Preview() *ImageView

Preview opens the current pixels in a modal when clicked or keyboard activated.

func (*ImageView) Render

func (v *ImageView) Render(cx *el.Context) el.Element

func (*ImageView) Retry

func (v *ImageView) Retry()

Retry refreshes the source, bypassing its cached result. Without Source it invokes OnRetry for an error state. Disabled components ignore user retries.

func (*ImageView) Rounded

func (v *ImageView) Rounded(dp float32) *ImageView

func (*ImageView) SetDisabled

func (v *ImageView) SetDisabled(on bool)

func (*ImageView) SetError

func (v *ImageView) SetError(message string)

SetError replaces pixels with a retryable failure. SetImage clears the error.

func (*ImageView) SetImage

func (v *ImageView) SetImage(img image.Image)

SetImage replaces the pixels; nil shows the placeholder.

func (*ImageView) Size

func (v *ImageView) Size(width, height float32) *ImageView

func (*ImageView) Source

func (v *ImageView) Source(source string) *ImageView

Source loads an HTTP(S) URL, file path/URL or data URL asynchronously. Same source is a no-op; Retry forces a refresh. Empty clears and cancels the load. Call from the UI thread or core.Update, like other component mutations.

func (*ImageView) Width

func (v *ImageView) Width(dp float32) *ImageView

Width caps the displayed width in dp; by default the image fills its parent's width, no wider than its own pixels.

type InputContent

type InputContent = el.InputContent

func NewInputContent

func NewInputContent(text string, tokens ...InputTokenSpan) (InputContent, error)

type InputGroupAlignment

type InputGroupAlignment uint8

InputGroupAlignment places an addon around the editor row.

const (
	InputGroupInlineStart InputGroupAlignment = iota
	InputGroupInlineEnd
	InputGroupBlockStart
	InputGroupBlockEnd
)

type InputGroupView

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

InputGroupView composes a text input and independent inline/block views inside one field border. The input remains the owner of its value and events.

func InputGroup

func InputGroup(label string, input *InputView) *InputGroupView

InputGroup wraps input; nil creates an empty single-line input. Render the input through this group only, not separately in the same frame.

func (*InputGroupView) Addon

func (v *InputGroupView) Addon(id string, alignment InputGroupAlignment, view el.View) *InputGroupView

Addon inserts content at one of four positions. IDs must be nonempty and stable. Reusing an ID replaces its content/position; nil removes it. Each side preserves insertion order. Buttons retain their own configuration.

func (*InputGroupView) Error

func (v *InputGroupView) Error() string

func (*InputGroupView) FocusID

func (v *InputGroupView) FocusID() string

func (*InputGroupView) OnChange

func (v *InputGroupView) OnChange(fn func(string)) *InputGroupView

func (*InputGroupView) Prefix

func (v *InputGroupView) Prefix(view el.View) *InputGroupView

func (*InputGroupView) Render

func (v *InputGroupView) Render(cx *el.Context) el.Element

func (*InputGroupView) SetDisabled

func (v *InputGroupView) SetDisabled(on bool)

func (*InputGroupView) SetError

func (v *InputGroupView) SetError(s string)

func (*InputGroupView) SetValue

func (v *InputGroupView) SetValue(s string)

func (*InputGroupView) Suffix

func (v *InputGroupView) Suffix(view el.View) *InputGroupView

func (*InputGroupView) Value

func (v *InputGroupView) Value() string

type InputRange

type InputRange = el.InputRange

type InputSize

type InputSize uint8

InputSize sets the field text and frame density. Medium preserves defaults.

const (
	InputSizeMedium InputSize = iota
	InputSizeXSmall
	InputSizeSmall
	InputSizeLarge
)

type InputToken

type InputToken = el.InputToken

type InputTokenSpan

type InputTokenSpan = el.InputTokenSpan

type InputView

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

InputView is a labelled text field with optional prefix, suffix, clear button and error message. TextArea makes a multi-line one.

func Input

func Input(label string) *InputView

func TextArea

func TextArea(label string) *InputView

TextArea is a multi-line field at least rows lines tall (3 by default); Enter inserts a newline.

func (*InputView) ActivateToken

func (v *InputView) ActivateToken() bool

ActivateToken opens the selected reference through the application's handler. Applications can bind this command to their preferred keyboard shortcut.

func (*InputView) AutoGrow

func (v *InputView) AutoGrow(minRows, maxRows int) *InputView

AutoGrow sizes a TextArea between minRows and maxRows wrapped lines. Additional content scrolls inside the field. Invalid ranges are ignored; Rows restores the original minimum-height mode. Input ignores this option.

func (*InputView) Clearable

func (v *InputView) Clearable() *InputView

func (*InputView) Content

func (v *InputView) Content() InputContent

Content returns an immutable draft, including atomic reference metadata.

func (*InputView) ContextMenu

func (v *InputView) ContextMenu(menu *MenuView) *InputView

ContextMenu replaces the built-in editing menu. Nil restores it. The menu belongs to this input; its Trigger is unused. Enablement still controls both.

func (*InputView) ContextMenuEnabled

func (v *InputView) ContextMenuEnabled(on bool) *InputView

ContextMenuEnabled controls the built-in or custom right-click menu, enabled by default. Disabling closes any open menu without changing the input value.

func (*InputView) Error

func (v *InputView) Error() string

func (*InputView) Filter

func (v *InputView) Filter(chars string) *InputView

Filter accepts only these runes, typed or pasted; "" accepts everything.

func (*InputView) FocusID

func (v *InputView) FocusID() string

FocusID is the element ID that cx.Focus uses to focus the text box.

func (*InputView) Mask

func (v *InputView) Mask(pattern string) *InputView

Mask formats single-line input using # for a required ASCII digit, 9 for an optional digit, A for a Unicode letter and * for a letter or digit. Backslash quotes the next rune. Other runes are literals. Empty removes the mask. Invalid trailing escapes leave the existing configuration unchanged.

func (*InputView) MaskComplete

func (v *InputView) MaskComplete() bool

MaskComplete reports whether all required slots are filled. Number masks require at least one digit; a trailing decimal point is an incomplete draft. It is a formatting check, not domain validation such as a valid calendar date.

func (*InputView) MaxLength

func (v *InputView) MaxLength(n int) *InputView

func (*InputView) NumberMask

func (v *InputView) NumberMask(separator rune, fraction int) *InputView

NumberMask groups ASCII integer digits in threes and limits decimal places without floating-point conversion or rounding. Zero separator disables grouping; fraction -1 allows arbitrary precision, 0 permits integers only. Invalid separators or precision leave the existing configuration unchanged.

func (*InputView) OnChange

func (v *InputView) OnChange(fn func(string)) *InputView

func (*InputView) OnPaste

func (v *InputView) OnPaste(fn func(core.ClipboardData) bool) *InputView

OnPaste intercepts clipboard text, images and file references before insertion. True consumes the paste; false inserts its text through the normal edit path.

func (*InputView) OnPasteError

func (v *InputView) OnPasteError(fn func(error)) *InputView

OnPasteError receives read errors on the UI thread. Native errors fall back to Gio text paste; an oversized or unreadable Gio text payload is rejected.

func (*InputView) OnSubmit

func (v *InputView) OnSubmit(fn func(string)) *InputView

func (*InputView) OnTokenActivate

func (v *InputView) OnTokenActivate(fn func(InputToken)) *InputView

func (*InputView) Password

func (v *InputView) Password() *InputView

func (*InputView) PasteReader

func (v *InputView) PasteReader(fn core.ClipboardReader) *InputView

PasteReader supplies a platform or application rich clipboard reader.

func (*InputView) Placeholder

func (v *InputView) Placeholder(s string) *InputView

func (*InputView) Prefix

func (v *InputView) Prefix(p el.View) *InputView

func (*InputView) Render

func (v *InputView) Render(cx *el.Context) el.Element

func (*InputView) ReplaceWithToken

func (v *InputView) ReplaceWithToken(token InputToken) error

ReplaceWithToken replaces the current selection. Unlike SetContent, this is an edit, records undo and invokes OnChange. Read-only and disabled fields reject it.

func (*InputView) Rows

func (v *InputView) Rows(n int) *InputView

Rows sets the minimum height of a TextArea in lines.

func (*InputView) SetContent

func (v *InputView) SetContent(c InputContent) error

SetContent restores a draft and clears undo. Atomic references are supported by Input and TextArea; masks, password fields and text filters cannot be combined with references.

func (*InputView) SetDisabled

func (v *InputView) SetDisabled(on bool)

func (*InputView) SetError

func (v *InputView) SetError(msg string)

SetError shows msg under the field and marks it invalid; "" clears it. Form sets it from validators.

func (*InputView) SetLabel

func (v *InputView) SetLabel(s string)

func (*InputView) SetReadOnly

func (v *InputView) SetReadOnly(on bool)

func (*InputView) SetValue

func (v *InputView) SetValue(s string)

func (*InputView) Size

func (v *InputView) Size(size InputSize) *InputView

func (*InputView) Suffix

func (v *InputView) Suffix(s el.View) *InputView

func (*InputView) TokenRenderer

func (v *InputView) TokenRenderer(fn el.InputTokenRenderer) *InputView

TokenRenderer customizes passive inline reference contents. See el.InputTokenRenderer.

func (*InputView) UnmaskedValue

func (v *InputView) UnmaskedValue() string

UnmaskedValue returns accepted slot characters, or the ungrouped decimal text. With no mask it returns Value unchanged. Value and callbacks use display text.

func (*InputView) Value

func (v *InputView) Value() string

type KbdView

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

KbdView displays a shortcut without registering a keyboard handler.

func Kbd

func Kbd(shortcut string) *KbdView

Kbd displays a ParseShortcut chord, or the literal label if parsing fails.

func KbdFor

func KbdFor(action string) *KbdView

KbdFor displays the first chord bound to a keymap action (core.Bind), and follows rebinding; it shows nothing while the action is unbound.

func (*KbdView) At added in v0.0.4

func (v *KbdView) At(elementID string) *KbdView

At resolves a KbdFor action as it applies to an element, through that element's KeyContext path and core.BindIn predicates, as its own key handling would: the hint on a toolbar button shows the editor's binding. It shows nothing while the element is missing, hidden or disabled.

func (*KbdView) Plain

func (v *KbdView) Plain() *KbdView

Plain hides the keycap outline, preserving its spacing.

func (*KbdView) Render

func (v *KbdView) Render(cx *el.Context) el.Element

func (*KbdView) Size

func (v *KbdView) Size(sp float32) *KbdView

Size sets the font size in sp and scales padding with it. Zero restores inherited text size and default padding. Values outside 0–128 are ignored.

func (*KbdView) Style

func (v *KbdView) Style(fn func(*el.TextEl)) *KbdView

Style refines the newly built keycap after defaults; nil restores defaults. Do not retain the element. The shortcut remains its accessible name.

type LabelView

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

LabelView displays one wrapping text flow with optional secondary text.

func Label

func Label(text string) *LabelView

func (*LabelView) HighlightColor

func (v *LabelView) HighlightColor(c color.NRGBA) *LabelView

func (*LabelView) HighlightPrefix

func (v *LabelView) HighlightPrefix(text string) *LabelView

HighlightPrefix colors a match only at the start of the primary text.

func (*LabelView) Highlights

func (v *LabelView) Highlights(text string) *LabelView

Highlights colors all non-overlapping, case-sensitive exact matches. Empty clears.

func (*LabelView) Masked

func (v *LabelView) Masked(on bool) *LabelView

func (*LabelView) Render

func (v *LabelView) Render(cx *el.Context) el.Element

func (*LabelView) Secondary

func (v *LabelView) Secondary(text string) *LabelView

func (*LabelView) SetText

func (v *LabelView) SetText(text string)

func (*LabelView) Style

func (v *LabelView) Style(fn func(*el.TextEl)) *LabelView

Style configures typography, alignment, sizing and field association on each fresh TextEl.

type LinkView

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

LinkView is clickable text in the primary color, e.g. "查看详情". Tab reaches it; Enter or Space follows it.

func Link(text string, onClick func()) *LinkView

func (*LinkView) Render

func (v *LinkView) Render(cx *el.Context) el.Element

func (*LinkView) SetDisabled

func (v *LinkView) SetDisabled(on bool)

func (*LinkView) SetText

func (v *LinkView) SetText(s string)

type ListItem

type ListItem struct {
	ID, Label string
	Disabled  bool
	Group     string
	Keywords  []string
	Icon      IconName
}

ListItem gives an entry a stable identity, label and interaction state.

type ListItemContext

type ListItemContext struct {
	Item               ListItem
	Index              int
	Selected, Disabled bool
}

ListItemContext is a copied source-item snapshot for custom row rendering.

type ListView

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

ListView is a list of text items with one selection. Click or use ↑ ↓ Home End PageUp PageDown to select; double-click or Enter activates. Only rows near the viewport are built, so it handles long lists.

func List

func List(items ...string) *ListView

func (*ListView) EmptyContent added in v0.0.5

func (v *ListView) EmptyContent(view el.View) *ListView

EmptyContent shows view when the list has no items and no search is active. Nil restores the default message.

func (*ListView) Entries

func (v *ListView) Entries() []ListItem

func (*ListView) ErrorContent added in v0.0.5

func (v *ListView) ErrorContent(fn func(message string, retry func()) el.View) *ListView

ErrorContent replaces the load error message and its Retry button; retry requests the rows again.

func (*ListView) Fill

func (v *ListView) Fill() *ListView

func (*ListView) Height

func (v *ListView) Height(dp float32) *ListView

Height sets the viewport height in dp, 320 by default; Fill grows instead.

func (*ListView) InitialContent added in v0.0.5

func (v *ListView) InitialContent(view el.View) *ListView

InitialContent shows view in place of the rows while a searchable list has an empty query, as for a search that has not started. Nil turns it off.

func (*ListView) Items

func (v *ListView) Items() []string

func (*ListView) LoadingContent added in v0.0.5

func (v *ListView) LoadingContent(view el.View) *ListView

LoadingContent replaces the spinner shown while more rows load.

func (*ListView) Move

func (v *ListView) Move(from, to int)

func (*ListView) MultiSelect

func (v *ListView) MultiSelect() *ListView

func (*ListView) NoMatchesContent added in v0.0.5

func (v *ListView) NoMatchesContent(view el.View) *ListView

NoMatchesContent shows view when a search finds nothing. Nil restores the default message.

func (*ListView) OnActivate

func (v *ListView) OnActivate(fn func(index int)) *ListView

func (*ListView) OnChange

func (v *ListView) OnChange(fn func(index int)) *ListView

func (*ListView) OnLoadMore

func (v *ListView) OnLoadMore(fn func()) *ListView

func (*ListView) OnSearch

func (v *ListView) OnSearch(fn func(string)) *ListView

func (*ListView) OnSelectionChange

func (v *ListView) OnSelectionChange(fn func([]int)) *ListView

func (*ListView) Plain

func (v *ListView) Plain() *ListView

Plain drops the frame and background, for a list that sits inside a panel or sidebar that already frames it. Focus still shows as an outline.

func (*ListView) Query

func (v *ListView) Query() string

func (*ListView) Render

func (v *ListView) Render(cx *el.Context) el.Element

func (*ListView) RenderGroupFooter

func (v *ListView) RenderGroupFooter(fn func(*el.Context, string) el.Element) *ListView

func (*ListView) RenderGroupHeader

func (v *ListView) RenderGroupHeader(fn func(*el.Context, string) el.Element) *ListView

func (*ListView) RenderItem

func (v *ListView) RenderItem(fn func(*el.Context, ListItemContext) el.Element) *ListView

RenderItem replaces row contents. Nil results use the default label/icon.

func (*ListView) Reorderable

func (v *ListView) Reorderable(fn func(from, to int)) *ListView

Reorderable enables drag reordering. The callback runs after the list owns the new order and receives the old and new indexes. Programmatic Move is silent.

func (*ListView) RowHeight

func (v *ListView) RowHeight(dp float32) *ListView

func (*ListView) Searchable

func (v *ListView) Searchable(on bool) *ListView

func (*ListView) SelectedValues

func (v *ListView) SelectedValues() []int

func (*ListView) SetDisabled

func (v *ListView) SetDisabled(on bool)

func (*ListView) SetEntries

func (v *ListView) SetEntries(entries ...ListItem)

SetEntries copies entries and preserves selection by ID. Empty/duplicate IDs panic before changing the list. Removed IDs are discarded from selection.

func (*ListView) SetHasMore

func (v *ListView) SetHasMore(on bool)

func (*ListView) SetItemDisabled

func (v *ListView) SetItemDisabled(index int, on bool)

func (*ListView) SetItems

func (v *ListView) SetItems(items ...string)

SetItems replaces labels using index identities. Use SetEntries for stable application IDs across insertions and reorders.

func (*ListView) SetLoadError

func (v *ListView) SetLoadError(message string)

func (*ListView) SetLoading

func (v *ListView) SetLoading(on bool)

func (*ListView) SetQuery

func (v *ListView) SetQuery(query string)

func (*ListView) SetSelectedValues

func (v *ListView) SetSelectedValues(values []int)

func (*ListView) SetValue

func (v *ListView) SetValue(i int)

SetValue selects item i (-1 clears) without calling OnChange.

func (*ListView) Value

func (v *ListView) Value() int

type MarkerShape

type MarkerShape uint8
const (
	MarkerDot MarkerShape = iota
	MarkerSquare
	MarkerDiamond
)

type MarkerView

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

MarkerView is decoration only; callers supply their own adjacent Text.

func Marker

func Marker(shape MarkerShape) *MarkerView

func (*MarkerView) Color

func (v *MarkerView) Color(c color.NRGBA) *MarkerView

func (*MarkerView) Render

func (v *MarkerView) Render(*el.Context) el.Element

func (*MarkerView) Size

func (v *MarkerView) Size(dp float32) *MarkerView
type MenuView struct {
	// contains filtered or unexported fields
}

MenuView is a list of commands in a layer next to its trigger:

more := kit.Menu().Item("复制", "mod+c", copy).Separator().Sub("导出", exportMenu)
more.Trigger(kit.Button("更多", more.Toggle).Variant(kit.ButtonGhost))

↑ ↓ move between enabled items, Home / End jump, Enter / Space run the item, → opens a submenu, ← or Esc closes one level. Running any item closes the whole menu. Shortcuts are only displayed, never registered.

func Menu() *MenuView
func (v *MenuView) ActionContext(id string) *MenuView

ActionContext chooses the element ID whose KeyContext ancestry resolves ActionItem hints. Empty restores the trigger context (inherited by submenus). It also picks the handler an ActionItem without a callback runs.

func (v *MenuView) ActionItem(label, keymapAction string, fn func()) *MenuView

ActionItem adds a command that shows the key bound to a keymap action (core.Bind/BindIn), following rebinding and the trigger or ActionContext. With fn nil, choosing it runs the action's handler where the menu acts, as its key would: the innermost cx.ActionAt enclosing the trigger or ActionContext, else cx.Action. Otherwise only fn runs.

func (v *MenuView) CheckItem(label, shortcut string, checked bool, onChange func(bool)) *MenuView

CheckItem toggles stored state, closes the menu, then calls onChange.

func (v *MenuView) CheckSide(side el.Side) *MenuView

CheckSide chooses Left (default) or Right. Left checks replace item icons.

func (v *MenuView) ContentItem(label, shortcut string, content el.View, action func()) *MenuView

ContentItem adds a command with arbitrary display-only content. Label remains its accessible name and typeahead key. Nil content falls back to the label.

func (v *MenuView) ExternalLinkIcon(on bool) *MenuView
func (v *MenuView) IconItem(label, shortcut string, icon IconName, action func()) *MenuView

IconItem adds an ordinary command with a leading icon.

func (v *MenuView) Item(label, shortcut string, action func()) *MenuView

Item adds a command; shortcut uses core.ParseShortcut syntax and may be empty.

func (v *MenuView) ItemChecked(label string) (bool, bool)

ItemChecked returns the first matching check item's state and whether it exists.

func (v *MenuView) Label(label string) *MenuView

Label adds a non-interactive section heading. Empty labels are ignored. Headings retain a row of space but are skipped by keyboard navigation/search.

func (v *MenuView) Link(label, url string) *MenuView

Link adds an external link command. It closes the menu before opening the URL.

func (v *MenuView) Offset(dp float32) *MenuView

Offset sets the top-level anchor gap in dp, including zero or overlap. Non-finite values are ignored; the default is 4dp.

func (v *MenuView) OnLink(fn func(string)) *MenuView

OnLink replaces system URL opening. Submenus inherit the nearest configured ancestor handler. Nil restores inheritance/default opening.

func (v *MenuView) OnLinkError(fn func(error)) *MenuView

OnLinkError receives default URL validation/launch errors, with ancestor fallback.

func (v *MenuView) Placement(side el.Side, align el.Align) *MenuView

Placement sets the top-level menu's direction and alignment. Submenus retain their right/start placement and automatic edge flipping.

func (v *MenuView) Render(cx *el.Context) el.Element
func (v *MenuView) Separator() *MenuView
func (v *MenuView) SetDisabled(on bool)
func (v *MenuView) SetItemChecked(label string, checked bool)

SetItemChecked updates matching check items without calling onChange.

func (v *MenuView) SetItemContent(label string, content el.View)

SetItemContent changes matching actionable rows without changing their IDs.

func (v *MenuView) SetItemDisabled(label string, disabled bool)

SetItemDisabled enables or disables the item with label.

func (v *MenuView) SetItemIcon(label string, icon IconName)

SetItemIcon updates all matching non-separator items, including submenus.

func (v *MenuView) SetValue(open bool)
func (v *MenuView) Sub(label string, sub *MenuView) *MenuView

Sub adds an item that opens sub to its side.

func (v *MenuView) Toggle()

Toggle opens or closes the menu; pass it as the trigger's click handler.

func (v *MenuView) Trigger(t el.View) *MenuView

Trigger sets the view the menu opens from (top-level menus only).

func (v *MenuView) Value() bool
func (v *MenuView) Width(dp float32) *MenuView

Width sets the minimum menu width in dp, 220 by default.

type MessageContentView

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

MessageContentView mixes typed bubbles with arbitrary message content. Direct BubbleView items inherit message alignment and contribute Ghost metadata.

func MessageContent

func MessageContent(items ...el.View) *MessageContentView

MessageContent copies items, ignoring nils. Reuse each item at most once. Custom views must provide stable identities to retain state when reordered.

func (*MessageContentView) Gap

func (*MessageContentView) Items

func (v *MessageContentView) Items() []el.View

func (*MessageContentView) Render

func (v *MessageContentView) Render(cx *el.Context) el.Element

Render lays out the stack independently with leading alignment. When installed directly in Message.Content, the message supplies alignment and default tone.

func (*MessageContentView) SetDisabled

func (v *MessageContentView) SetDisabled(on bool)

func (*MessageContentView) SetItems

func (v *MessageContentView) SetItems(items ...el.View)

SetItems replaces the mixed sequence, retaining identities of surviving bubbles.

func (*MessageContentView) Style

func (v *MessageContentView) Style(fn func(*el.DivEl)) *MessageContentView

Style refines the content stack after defaults. Nil restores defaults. Do not retain the element or append children in this callback.

type MessageGroupView

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

MessageGroupView stacks complete message rows. The application decides which messages belong together; the group does not infer authors or change alignment.

func MessageGroup

func MessageGroup(items ...el.View) *MessageGroupView

MessageGroup copies the supplied views, ignoring nil entries. Reuse each view instance at most once in a group to preserve its element identity.

func (*MessageGroupView) Gap

func (*MessageGroupView) Items

func (v *MessageGroupView) Items() []el.View

func (*MessageGroupView) Name

func (v *MessageGroupView) Name(name string) *MessageGroupView

func (*MessageGroupView) Render

func (v *MessageGroupView) Render(cx *el.Context) el.Element

func (*MessageGroupView) SetDisabled

func (v *MessageGroupView) SetDisabled(on bool)

func (*MessageGroupView) SetItems

func (v *MessageGroupView) SetItems(items ...el.View)

func (*MessageGroupView) Style

func (v *MessageGroupView) Style(fn func(*el.DivEl)) *MessageGroupView

Style refines a fresh group element after defaults. Nil clears the refinement.

type MessagePart

type MessagePart uint8

MessagePart identifies a styleable region of a complete message.

const (
	MessagePartRoot MessagePart = iota
	MessagePartStack
	MessagePartAvatar
	MessagePartHeader
	MessagePartContent
	MessagePartFooter
	MessagePartStatus
	MessagePartActions
	MessagePartReactions
)

type MessageReaction

type MessageReaction struct {
	Name   string
	Count  int
	Active bool
}

MessageReaction is an application-named reaction and its current count.

type MessageScrollerView

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

MessageScrollerView virtualizes a conversation with stable message keys. It follows the bottom while the user is there and preserves the visible message when history is prepended or an earlier message changes height.

func MessageScroller

func MessageScroller(keys []string, estimate float32, row func(*el.Context, int) el.Element) *MessageScrollerView

MessageScroller renders only the visible rows and nearby overscan. Keys are unique, nonempty IDs in oldest-first order. estimate is a positive height in dp until a message has been measured; its content can have any natural height.

func (*MessageScrollerView) Invalidate

func (v *MessageScrollerView) Invalidate(keys ...string)

Invalidate refreshes estimated heights for changed offscreen messages. Visible streaming text and image growth are detected automatically.

func (*MessageScrollerView) IsFollowingTail

func (v *MessageScrollerView) IsFollowingTail(cx *el.Context) bool

IsFollowingTail reports effective automatic tail following. A pending message jump suspends it; reaching the bottom normally resumes it when SetFollow is on.

func (*MessageScrollerView) IsScrolledUp

func (v *MessageScrollerView) IsScrolledUp(cx *el.Context) bool

IsScrolledUp reports whether the last painted viewport has content below it. Before the first paint (or with no scrollable content) it returns false.

func (*MessageScrollerView) LatestButton

func (v *MessageScrollerView) LatestButton(on bool) *MessageScrollerView

LatestButton enables the built-in control, which is enabled by default.

func (*MessageScrollerView) LatestLabel

func (v *MessageScrollerView) LatestLabel(label string) *MessageScrollerView

LatestLabel overrides the control's label and accessible name. Empty restores the current locale's label.

func (*MessageScrollerView) LatestRenderer

func (v *MessageScrollerView) LatestRenderer(fn func(*ButtonView) *ButtonView) *MessageScrollerView

LatestRenderer refines a fresh default button each frame. Nil restores the default renderer; returning nil falls back to the default button. The scroller always owns its identity and scroll action, including for a replacement button.

func (*MessageScrollerView) LatestTransition

func (v *MessageScrollerView) LatestTransition(d time.Duration) *MessageScrollerView

LatestTransition sets the enter/leave fade duration. Zero disables animation; negative durations are ignored. Reduced motion always displays the final state.

func (*MessageScrollerView) OnReachTop

func (v *MessageScrollerView) OnReachTop(fn func()) *MessageScrollerView

func (*MessageScrollerView) Render

func (v *MessageScrollerView) Render(cx *el.Context) el.Element

func (*MessageScrollerView) ScrollToEnd

func (v *MessageScrollerView) ScrollToEnd()

func (*MessageScrollerView) ScrollToMessage

func (v *MessageScrollerView) ScrollToMessage(id string) bool

ScrollToMessage minimally reveals a stable message ID, including before the first render. It takes precedence over tail following and pending end jumps. Unknown IDs return false without changing a pending request. The application owns unread/bookmark meaning and can call this after installing message keys.

func (*MessageScrollerView) SetDisabled

func (v *MessageScrollerView) SetDisabled(on bool)

func (*MessageScrollerView) SetFollow

func (v *MessageScrollerView) SetFollow(on bool)

func (*MessageScrollerView) SetKeys

func (v *MessageScrollerView) SetKeys(keys []string)

SetKeys copies the new order, retaining measurements and the visible anchor. Call after inserting, appending, removing or reordering messages.

type MessageState

type MessageState uint8

MessageState describes delivery of a message.

const (
	MessageReady MessageState = iota
	MessageSending
	MessageFailed
)

type MessageView

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

MessageView is one turn of a conversation: an avatar, the content and a row of actions (copy, retry…) under it. User messages show as a Bubble on the right without an avatar; others show full width beside the author's avatar, which suits long Markdown answers.

func Message

func Message(author string, content el.View) *MessageView

Message creates a message from author; its avatar shows author's initials.

func (*MessageView) Actions

func (v *MessageView) Actions(views ...el.View) *MessageView

Actions sets the views under the content and copies the slice.

func (*MessageView) Alignment

func (v *MessageView) Alignment(align el.Align) *MessageView

Alignment sets placement independently of User's default surface and avatar. Only Start and End are accepted; invalid values leave the current setting.

func (*MessageView) Avatar

func (v *MessageView) Avatar(view el.View) *MessageView

Avatar replaces the default initials with arbitrary content. Nil hides the avatar. Explicit avatars also appear on user messages, on the trailing side.

func (*MessageView) Bubble

func (v *MessageView) Bubble(surface *BubbleView) *MessageView

Bubble installs a typed surface. Its alignment follows the message and its Ghost variant removes automatic header/footer insets. The source is not mutated; reuse it to update presentation. Nil clears the body.

func (*MessageView) Content

func (v *MessageView) Content(view el.View) *MessageView

Content replaces the body independently of metadata and delivery state.

func (*MessageView) DefaultAvatar

func (v *MessageView) DefaultAvatar() *MessageView

DefaultAvatar restores initials for incoming messages and no avatar for User.

func (*MessageView) Footer

func (v *MessageView) Footer(view el.View) *MessageView

Footer supplies content below delivery state, actions and reactions. It may contain interactive controls. Nil removes this slot.

func (*MessageView) FooterInset

func (v *MessageView) FooterInset(on bool) *MessageView

FooterInset overrides automatic surface padding for the footer.

func (*MessageView) Header

func (v *MessageView) Header(view el.View) *MessageView

Header supplies metadata above the body. Nil removes this slot.

func (*MessageView) HeaderInset

func (v *MessageView) HeaderInset(on bool) *MessageView

HeaderInset overrides automatic surface padding for the header.

func (*MessageView) OnReaction

func (v *MessageView) OnReaction(fn func(int, bool)) *MessageView

func (*MessageView) OnRetry

func (v *MessageView) OnRetry(fn func()) *MessageView

func (*MessageView) PartStyle

func (v *MessageView) PartStyle(part MessagePart, fn func(*el.DivEl)) *MessageView

PartStyle refines a fresh region after defaults, each frame. Nil restores defaults; invalid parts are ignored. Do not retain the element or append children here. The component owns identity, root semantics and disabled state.

func (*MessageView) Reactions

func (v *MessageView) Reactions(items ...MessageReaction) *MessageView

func (*MessageView) Render

func (v *MessageView) Render(cx *el.Context) el.Element

func (*MessageView) ResetAlignment

func (v *MessageView) ResetAlignment() *MessageView

ResetAlignment restores Start for incoming messages and End for User.

func (*MessageView) ResetContentInsets

func (v *MessageView) ResetContentInsets() *MessageView

ResetContentInsets restores automatic header and footer padding.

func (*MessageView) SetDisabled

func (v *MessageView) SetDisabled(on bool)

func (*MessageView) SetState

func (v *MessageView) SetState(state MessageState, failure string)

SetState updates delivery without replacing the content or action views.

func (*MessageView) User

func (v *MessageView) User() *MessageView

User marks the current user's message.

type Notice

type Notice struct {
	Title, Body string
	Tone        Tone
	Timeout     time.Duration
	Placement   NoticePlacement
	Delivery    NoticeDelivery
	// Content replaces Body when non-nil; Title remains the accessible name.
	Content el.View
	// Action renders below the body. Call Dismiss explicitly to close on action.
	Action el.View
	// OnClick activates the card without dismissing it; child controls act independently.
	OnClick func()
	// OnClose runs once when the in-app notice closes, including timeout and
	// programmatic Dismiss. System-only notices never call it.
	OnClose func()
}

Notice is one notification. Timeout 0 means NotificationTimeout; a negative Timeout keeps it until the user closes it.

type NoticeActivation

type NoticeActivation struct{ Token string }

NoticeActivation carries optional platform window-activation data. Token is opaque; it may be empty and is consumed by the application's backend.

type NoticeDelivery

type NoticeDelivery uint8

NoticeDelivery chooses where a notice is sent. Default follows the host.

const (
	NoticeDeliveryDefault NoticeDelivery = iota
	NoticeInApp
	NoticeSystemOnly
	NoticeInAppAndSystem
)

type NoticePlacement

type NoticePlacement uint8

NoticePlacement chooses one of eight window-edge positions.

const (
	NoticeDefault NoticePlacement = iota
	NoticeTopRight
	NoticeTopLeft
	NoticeTopCenter
	NoticeBottomRight
	NoticeBottomLeft
	NoticeBottomCenter
	NoticeLeftCenter
	NoticeRightCenter
)

type NoticeSystemActivationBackend

type NoticeSystemActivationBackend interface {
	NoticeSystemBackend
	PostActivated(id, title, body string, activated func(NoticeActivation), done func(error))
}

NoticeSystemActivationBackend adds activation data to system click delivery. Notifier prefers it when a backend implements both interactive interfaces.

type NoticeSystemBackend

type NoticeSystemBackend interface {
	Post(id, title, body string, done func(error))
	Remove(id string, done func(error))
}

NoticeSystemBackend bridges kit to an application's platform integration. Each method must call done exactly once, including failures. Methods run on a worker goroutine; they must not directly mutate UI state. Requests are serialized per Notifier, including asynchronous completion, to prevent post/remove races.

type NoticeSystemInteractiveBackend

type NoticeSystemInteractiveBackend interface {
	NoticeSystemBackend
	PostInteractive(id, title, body string, activated func(), done func(error))
}

NoticeSystemInteractiveBackend optionally adds system click delivery. activated may run on any goroutine; kit forwards it to the UI frame lock.

type NoticeSystemResult

type NoticeSystemResult struct {
	ID       int
	Removing bool
	Err      error
}

NoticeSystemResult reports a completed backend request on the UI frame lock.

type NotifierView

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

NotifierView stacks notices by placement (top right by default). Render one as a direct child of the root view's top element, then call Notify from callbacks (or core.Update from other goroutines). Hovering or focusing a notice pauses its remaining timeout; notices never take focus or Esc.

func Notifier

func Notifier() *NotifierView

func WindowNotifier added in v0.0.5

func WindowNotifier(cx *el.Context) *NotifierView

WindowNotifier is the window's own Notifier, created and mounted on first use: kit.WindowNotifier(cx).Notify(...) needs no Notifier in the view tree. Configure it like any Notifier.

func (*NotifierView) Clear

func (v *NotifierView) Clear() int

Clear removes all notices present at entry, retracts their system deliveries, and calls OnClose for any remaining in-app notices in queue order. Notices added by callbacks survive unless explicitly removed by another callback. The return value counts the removed notices.

func (*NotifierView) Delivery

func (v *NotifierView) Delivery(mode NoticeDelivery) *NotifierView

Delivery sets the default for subsequent Notify and Update calls. It does not migrate existing notices. Default restores in-app delivery; invalid values are ignored.

func (*NotifierView) Dismiss

func (v *NotifierView) Dismiss(id int)

Dismiss removes a notice, shown or waiting.

func (*NotifierView) DismissKey

func (v *NotifierView) DismissKey(key string) bool

DismissKey removes a shown or waiting keyed notice. Empty and unknown keys return false. A later NotifyKey for this key creates a new notice ID.

func (*NotifierView) Len

func (v *NotifierView) Len() int

Len reports all managed notices, including system-only and expired in-app notices retained for later system removal.

func (*NotifierView) Notify

func (v *NotifierView) Notify(n Notice) int

Notify delivers n and returns its id for Dismiss.

func (*NotifierView) NotifyKey

func (v *NotifierView) NotifyKey(key string, n Notice) int

NotifyKey creates or replaces a notice with a business key local to this Notifier. Replacement preserves its ID and queue position and restarts its timeout, like Update. An empty key creates a new anonymous notice.

func (*NotifierView) OnSystemActivate

func (v *NotifierView) OnSystemActivate(fn func()) *NotifierView

OnSystemActivate sets the application's window activation hook (e.g. Raise). It runs before the notice's close and click callbacks, on the UI frame lock.

func (*NotifierView) OnSystemActivation

func (v *NotifierView) OnSystemActivation(fn func(NoticeActivation)) *NotifierView

OnSystemActivation receives platform activation data on the UI frame lock, before OnSystemActivate and the notice's close/click callbacks.

func (*NotifierView) Placement

func (v *NotifierView) Placement(position NoticePlacement) *NotifierView

Placement sets this host's default for notices without an override. Existing notices follow changes. Default restores top right; invalid values are ignored.

func (*NotifierView) Render

func (v *NotifierView) Render(cx *el.Context) el.Element

func (*NotifierView) SystemBackend

func (v *NotifierView) SystemBackend(backend NoticeSystemBackend, onResult func(NoticeSystemResult)) *NotifierView

SystemBackend configures future notices. Existing notices retain their backend so later updates and removal reach the service that originally received them. onResult may be nil; delivery errors are also available from SystemError.

func (*NotifierView) SystemError

func (v *NotifierView) SystemError() error

SystemError returns the most recent completed backend request's error.

func (*NotifierView) Update

func (v *NotifierView) Update(id int, n Notice) bool

Update replaces a shown or queued notice in place and restarts its timeout. Like Notify, call it on the UI frame lock (core.Update for background work).

type NumberInputView

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

NumberInputView edits a number with − and + buttons. Typing may pass through out-of-range text; Enter or leaving the field clamps it to the range and applies the configured decimal precision. ↑ ↓ step like the buttons; PageUp and PageDown move ten steps.

func NumberInput

func NumberInput(label string) *NumberInputView

func (*NumberInputView) Appearance

func (v *NumberInputView) Appearance(on bool) *NumberInputView

Appearance disables/enables the default background, border, rounding and padding. It preserves the configured minimum height and keyboard behavior.

func (*NumberInputView) Decimals

func (v *NumberInputView) Decimals(n int) *NumberInputView

Decimals rounds values to 0–15 decimal places; -1 (default) keeps precision. Exact range endpoints take precedence when they need more decimal places.

func (*NumberInputView) Error

func (v *NumberInputView) Error() string

func (*NumberInputView) FocusID

func (v *NumberInputView) FocusID() string

func (*NumberInputView) OnChange

func (v *NumberInputView) OnChange(fn func(float64)) *NumberInputView

func (*NumberInputView) OnStep

func (v *NumberInputView) OnStep(fn func(NumberStepEvent)) *NumberInputView

OnStep replaces built-in stepping with an application callback. It does not commit the draft or emit OnChange; the callback may use SetValue. nil restores the previous fixed/dynamic strategy. Step and StepBy leave this mode. Range boundaries and disabled state still prevent outward actions.

func (*NumberInputView) Prefix

func (v *NumberInputView) Prefix(content el.View) *NumberInputView

Prefix places content between the decrement button and text. nil removes it.

func (*NumberInputView) Range

func (v *NumberInputView) Range(min, max float64) *NumberInputView

Range limits the value to [min, max].

func (*NumberInputView) Render

func (v *NumberInputView) Render(cx *el.Context) el.Element

func (*NumberInputView) SetDisabled

func (v *NumberInputView) SetDisabled(on bool)

func (*NumberInputView) SetError

func (v *NumberInputView) SetError(msg string)

func (*NumberInputView) SetValue

func (v *NumberInputView) SetValue(x float64)

func (*NumberInputView) Size

Size sets the minimum field height in dp and scales its typography and step buttons together. Recommended heights are 28, 36 and 48. Zero restores theme.ControlHeight and inherited typography; invalid values are ignored.

func (*NumberInputView) Step

Step sets how far − and + move, 1 by default.

func (*NumberInputView) StepBy

StepBy calculates a positive step from the normalized draft and direction. It runs once per action; PageUp/PageDown multiply that step by ten. Invalid results cancel the action without committing the draft. nil restores the last fixed Step. The callback should not mutate this NumberInput.

func (*NumberInputView) Suffix

func (v *NumberInputView) Suffix(content el.View) *NumberInputView

Suffix places content between the text and increment button. nil removes it.

func (*NumberInputView) ThousandsSeparator

func (v *NumberInputView) ThousandsSeparator(separator rune) *NumberInputView

ThousandsSeparator groups integer digits while editing and displaying values. Supported separators are comma, space, apostrophe and narrow/nonbreaking space. Zero disables grouping. Numeric Value, range and step semantics are unchanged.

func (*NumberInputView) Value

func (v *NumberInputView) Value() float64

type NumberStepAction

type NumberStepAction int

NumberStepAction identifies the requested direction for StepBy.

const (
	NumberStepActionIncrement NumberStepAction = iota
	NumberStepActionDecrement
)

type NumberStepEvent

type NumberStepEvent struct {
	Value  float64
	Action NumberStepAction
	Count  int64
}

NumberStepEvent requests an application-managed step. Value is the normalized draft (or the committed value for invalid text). Count is positive: one for arrows/buttons, ten for PageUp/PageDown. Action supplies the direction.

type OtpInputView

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

OtpInputView enters a one-time code of a fixed number of digits, one box per digit. Typing moves to the next box, Backspace goes back, and pasting a whole code fills every box. OnComplete runs when the last digit is entered.

func OtpInput

func OtpInput(label string, length int) *OtpInputView

OtpInput creates a field for a code of length digits (6 if length < 1).

func (*OtpInputView) Error

func (v *OtpInputView) Error() string

func (*OtpInputView) FocusID

func (v *OtpInputView) FocusID() string

func (*OtpInputView) Groups

func (v *OtpInputView) Groups(count int) *OtpInputView

Groups splits the digits into count groups (clamped to 1..length). Extra digits go in the first groups. Changing groups preserves the value.

func (*OtpInputView) Masked

func (v *OtpInputView) Masked(on bool) *OtpInputView

Masked controls whether digits are concealed in both cells and semantics.

func (*OtpInputView) OnChange

func (v *OtpInputView) OnChange(fn func(string)) *OtpInputView

func (*OtpInputView) OnComplete

func (v *OtpInputView) OnComplete(fn func(string)) *OtpInputView

func (*OtpInputView) Render

func (v *OtpInputView) Render(cx *el.Context) el.Element

func (*OtpInputView) SetDisabled

func (v *OtpInputView) SetDisabled(on bool)

func (*OtpInputView) SetError

func (v *OtpInputView) SetError(msg string)

func (*OtpInputView) SetValue

func (v *OtpInputView) SetValue(s string)

SetValue sets the digits without calling OnChange; extra or non-digit characters are dropped.

func (*OtpInputView) Size

func (v *OtpInputView) Size(dp float32) *OtpInputView

Size sets cell height in dp; width and spacing scale with it. Invalid sizes are ignored. Cells shrink horizontally to fit the available width.

func (*OtpInputView) Value

func (v *OtpInputView) Value() string

type PaginationView

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

PaginationView pages through total items, pageSize at a time. Pages are numbered from 1; long ranges show the first, the last and the pages around the current one, with … between.

func Pagination

func Pagination(total, pageSize int) *PaginationView

func (*PaginationView) Bounds

func (v *PaginationView) Bounds() (start, end int)

Bounds returns the item range [start, end) of the current page.

func (*PaginationView) Compact

func (v *PaginationView) Compact(on bool) *PaginationView

Compact shows only previous/next controls, retaining page semantics.

func (*PaginationView) OnChange

func (v *PaginationView) OnChange(fn func(page int)) *PaginationView

func (*PaginationView) Pages

func (v *PaginationView) Pages() int

Pages is the number of pages, at least 1.

func (*PaginationView) Render

func (v *PaginationView) Render(cx *el.Context) el.Element

func (*PaginationView) SetDisabled

func (v *PaginationView) SetDisabled(on bool)

func (*PaginationView) SetTotal

func (v *PaginationView) SetTotal(n int)

SetTotal changes the item count, keeping the page in range.

func (*PaginationView) SetValue

func (v *PaginationView) SetValue(p int)

SetValue goes to page p (clamped) without calling OnChange.

func (*PaginationView) Size

func (v *PaginationView) Size(dp float32) *PaginationView

Size sets button height in dp (16–128); zero restores the default 28dp.

func (*PaginationView) Value

func (v *PaginationView) Value() int

Value is the current page, from 1.

func (*PaginationView) VisiblePages

func (v *PaginationView) VisiblePages(n int) *PaginationView

VisiblePages limits numbered buttons, excluding gaps and previous/next. Positive limits are clamped to 3–101 to retain first/current/last pages. Zero restores the original page window; negative values are ignored.

type PieChartTooltip

type PieChartTooltip struct {
	Index                          int
	Slice                          PieSlice
	Share                          float64
	FormattedValue, FormattedShare string
	Color                          color.NRGBA
}

PieChartTooltip is a value snapshot of the hovered visible sector. Share is a fraction in [0,1], recalculated after legend visibility changes.

type PieChartView

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

func PieChart

func PieChart(data ...PieSlice) *PieChartView

func (*PieChartView) Donut

func (v *PieChartView) Donut(fraction float32) *PieChartView

Donut cuts a central hole, clamped to 0..0.9 of the radius.

func (*PieChartView) Format

func (v *PieChartView) Format(fn func(float64) string) *PieChartView

func (*PieChartView) Height

func (v *PieChartView) Height(dp float32) *PieChartView

func (*PieChartView) HoverAnimation

func (v *PieChartView) HoverAnimation(on bool) *PieChartView

HoverAnimation enables 150ms hover emphasis transitions, on by default. Reduced motion always shows the target emphasis immediately.

func (*PieChartView) Render

func (v *PieChartView) Render(cx *el.Context) el.Element

func (*PieChartView) SetData

func (v *PieChartView) SetData(data ...PieSlice)

SetData copies all slices and restores their visibility.

func (*PieChartView) SetDisabled

func (v *PieChartView) SetDisabled(on bool)

func (*PieChartView) Title

func (v *PieChartView) Title(s string) *PieChartView

func (*PieChartView) TooltipContent

func (v *PieChartView) TooltipContent(fn func(*el.Context, PieChartTooltip) el.Element) *PieChartView

TooltipContent adds a display-only floating tooltip. Nil restores the default bottom readout alone; a callback returning nil suppresses the floating panel. The bottom readout and accessible table remain available. Do not mutate chart data from this render callback.

type PieSlice

type PieSlice struct {
	Name  string
	Value float64
}

PieSlice is one labeled part. Only finite positive values make sectors.

type PlotPoint

type PlotPoint struct{ X, Y float64 }

PlotPoint is one measurement.

type PlotSeries

type PlotSeries struct {
	Name   string
	Points []PlotPoint
}

PlotSeries is a named set of points, drawn as dots, or joined by a line with Lines.

type PlotView

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

PlotView plots numeric x/y data and lets the user explore it: the wheel zooms around the pointer, dragging pans, hovering picks the nearest point and double-clicking (or the 复位 button, or 0) restores the full view. Focused, + and − zoom and the arrow keys pan.

func Plot

func Plot(series ...PlotSeries) *PlotView

func (*PlotView) Format

func (v *PlotView) Format(fn func(float64) string) *PlotView

func (*PlotView) Height

func (v *PlotView) Height(dp float32) *PlotView

func (*PlotView) Lines

func (v *PlotView) Lines() *PlotView

func (*PlotView) Render

func (v *PlotView) Render(cx *el.Context) el.Element

func (*PlotView) Reset

func (v *PlotView) Reset()

Reset fits the view to all the data.

func (*PlotView) SetDisabled

func (v *PlotView) SetDisabled(on bool)

func (*PlotView) SetSeries

func (v *PlotView) SetSeries(series ...PlotSeries)

SetSeries replaces the data and fits the view to it.

func (*PlotView) SetView

func (v *PlotView) SetView(x0, x1, y0, y1 float64)

SetView shows the given ranges.

func (*PlotView) Title

func (v *PlotView) Title(s string) *PlotView

func (*PlotView) View

func (v *PlotView) View() (x0, x1, y0, y1 float64)

View returns the visible ranges.

type PopoverView

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

PopoverView shows content next to a trigger. The trigger opens it itself, so it keeps its own Tab stop and keyboard handling:

filters := kit.Popover(form)
filters.Trigger(kit.Button("筛选", filters.Toggle).Variant(kit.ButtonSecondary))

Clicking outside or pressing Esc closes it. It does not move focus.

func Popover

func Popover(content el.View) *PopoverView

func (*PopoverView) Appearance

func (v *PopoverView) Appearance(on bool) *PopoverView

Appearance controls the default background, border, radius, shadow and padding. It is enabled by default; disabling it leaves positioning and behavior intact.

func (*PopoverView) Arrow

func (v *PopoverView) Arrow(on bool) *PopoverView

Arrow shows a pointer toward the trigger, following placement and flips. Offset measures to its tip; the panel is placed another 6dp away.

func (*PopoverView) MouseButton

func (v *PopoverView) MouseButton(button pointer.Buttons) *PopoverView

MouseButton selects an automatic mouse-press trigger. Zero (the default) leaves activation to the trigger view; invalid values and chords are ignored. The trigger's own handlers still run: do not also bind Toggle to that button.

func (*PopoverView) Offset

func (v *PopoverView) Offset(dp float32) *PopoverView

Offset sets the gap from the trigger in dp, 4 by default. Zero makes the panel touch the trigger; negative values overlap it. Non-finite values are ignored. Viewport avoidance remains active.

func (*PopoverView) OnChange

func (v *PopoverView) OnChange(fn func(bool)) *PopoverView

OnChange is called when the user opens or closes the popover, not by SetOpen.

func (*PopoverView) PanelStyle

func (v *PopoverView) PanelStyle(fn func(*el.DivEl)) *PopoverView

PanelStyle refines the panel after appearance defaults and Width, each frame. Nil removes the refinement. Do not retain the element. Identity, dialog role, viewport limits and scrolling are maintained by the popover.

func (*PopoverView) Placement

func (v *PopoverView) Placement(side el.Side, align el.Align) *PopoverView

func (*PopoverView) Render

func (v *PopoverView) Render(cx *el.Context) el.Element

func (*PopoverView) RightClick

func (v *PopoverView) RightClick(on bool) *PopoverView

RightClick toggles the popover on secondary presses over its trigger. Primary and keyboard actions remain owned by the trigger. The default is false. Do not also wire Toggle to the trigger's context-menu handler.

func (*PopoverView) SetDisabled

func (v *PopoverView) SetDisabled(on bool)

func (*PopoverView) SetValue

func (v *PopoverView) SetValue(open bool)

func (*PopoverView) Toggle

func (v *PopoverView) Toggle()

Toggle opens or closes the popover as a user action; pass it as the trigger's click handler.

func (*PopoverView) Trigger

func (v *PopoverView) Trigger(t el.View) *PopoverView

Trigger sets the view the popover is anchored to.

func (*PopoverView) Value

func (v *PopoverView) Value() bool

func (*PopoverView) Width

func (v *PopoverView) Width(dp float32) *PopoverView

Width sets the panel width in dp; by default it fits its content.

type ProgressCircleView

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

ProgressCircleView shows determinate or indeterminate progress with optional centered content. It is a display, not a focusable control.

func ProgressCircle

func ProgressCircle(label string) *ProgressCircleView

func (*ProgressCircleView) Child

func (v *ProgressCircleView) Child(child el.View) *ProgressCircleView

Child places a view in the center. Keep it compact; the ring bounds clip it.

func (*ProgressCircleView) Color

Color overrides the foreground; without an override it follows the theme.

func (*ProgressCircleView) Render

func (v *ProgressCircleView) Render(cx *el.Context) el.Element

func (*ProgressCircleView) SetIndeterminate

func (v *ProgressCircleView) SetIndeterminate(on bool)

func (*ProgressCircleView) SetLabel

func (v *ProgressCircleView) SetLabel(label string)

func (*ProgressCircleView) SetValue

func (v *ProgressCircleView) SetValue(value float32)

SetValue clamps the fraction to 0..1 and leaves indeterminate mode. NaN is zero.

func (*ProgressCircleView) Size

func (*ProgressCircleView) Value

func (v *ProgressCircleView) Value() float32

type ProgressView

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

ProgressView is a labelled progress bar. SetValue shows a fraction; SetIndeterminate shows work of unknown length as a sliding segment (still, with reduced motion).

func Progress

func Progress(label string) *ProgressView

func (*ProgressView) Color

func (v *ProgressView) Color(c color.NRGBA) *ProgressView

Color overrides the fill color and suppresses the theme's primary gradient.

func (*ProgressView) Height

func (v *ProgressView) Height(dp float32) *ProgressView

Height sets the track height in dp (1–128), ignoring invalid values.

func (*ProgressView) Render

func (v *ProgressView) Render(cx *el.Context) el.Element

func (*ProgressView) Rounded

func (v *ProgressView) Rounded(dp float32) *ProgressView

Rounded sets the track and segment radius; invalid values are ignored.

func (*ProgressView) SetIndeterminate

func (v *ProgressView) SetIndeterminate(on bool)

func (*ProgressView) SetLabel

func (v *ProgressView) SetLabel(s string)

func (*ProgressView) SetValue

func (v *ProgressView) SetValue(f float32)

SetValue sets the fraction done, clamped to 0..1, and leaves indeterminate mode.

func (*ProgressView) TrackStyle

func (v *ProgressView) TrackStyle(fn func(*el.DivEl)) *ProgressView

TrackStyle refines the fresh track each frame, after defaults. Nil restores defaults. Do not retain the element. The segment still fills its inner height.

func (*ProgressView) Value

func (v *ProgressView) Value() float32

type Question

type Question struct {
	ID, Title, Description string
	Kind                   QuestionKind
	Options                []string // Single and Multiple
	Scale                  int      // Rating: number of stars, 5 by default
	Required               bool
	Disabled               bool
	FreeformLabel          string // Single/Multiple: optional freeform input.
	Validate               func(Answer, map[string]Answer) string
	DefaultAnswer          Answer
}

Question is one question of a questionnaire. IDs must be unique.

type QuestionKind

type QuestionKind uint8

QuestionKind is the kind of answer a Question takes.

const (
	QuestionSingle   QuestionKind = iota // one of Options
	QuestionMultiple                     // any of Options
	QuestionText                         // one line of text
	QuestionLongText                     // several lines of text
	QuestionRating                       // 1..Scale stars
)

type QuestionnaireContext

type QuestionnaireContext struct {
	Size     QuestionnaireSize
	Question Question
	Answer   Answer
	Progress QuestionnaireProgress
	Page     int
	Error    string
	Disabled bool
}

QuestionnaireContext is an owned snapshot for custom presentation. Question option/default-answer slices and Answer choices are independent of internal state.

type QuestionnaireParts

type QuestionnaireParts struct {
	Progress, Title, Description el.Element
	Answer, Freeform, Error      el.Element
	Previous, Skip, Forward      el.Element
}

QuestionnaireParts contains fresh elements backed by the questionnaire's existing controls and commands. Optional parts are nil. Insert each element at most once and do not retain it after the current Render.

type QuestionnaireProgress

type QuestionnaireProgress struct {
	Current, Total, Answered, Skipped, Unanswered int
	Completed                                     bool
}

QuestionnaireProgress is an enabled-item snapshot; Current is one-based, or zero.

type QuestionnaireShortcuts

type QuestionnaireShortcuts uint8

QuestionnaireShortcuts enables unmodified choice shortcuts outside text inputs.

const (
	QuestionnaireShortcutsOff QuestionnaireShortcuts = iota
	QuestionnaireShortcutsLetters
	QuestionnaireShortcutsNumbers
)

type QuestionnaireSize

type QuestionnaireSize uint8

QuestionnaireSize controls all built-in question parts and answer controls.

const (
	QuestionnaireSizeMedium QuestionnaireSize = iota
	QuestionnaireSizeXSmall
	QuestionnaireSizeSmall
	QuestionnaireSizeLarge
)

type QuestionnaireView

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

QuestionnaireView asks questions one page at a time with a progress bar. 下一题 checks that a required question is answered; 提交 on the last page checks every question, jumps to the first unanswered one, and otherwise calls OnSubmit with all answers by question ID.

func Questionnaire

func Questionnaire(questions ...Question) *QuestionnaireView

func (*QuestionnaireView) ExternalError

func (v *QuestionnaireView) ExternalError(id string) string

func (*QuestionnaireView) KeyboardNavigation

func (v *QuestionnaireView) KeyboardNavigation(on bool) *QuestionnaireView

KeyboardNavigation toggles built-in arrows and confirmation; option shortcut configuration is independent.

func (*QuestionnaireView) Layout

Layout replaces the arrangement of the current question's parts. The outer form retains disabled inheritance, keyboard navigation and focus management. Return nil, or pass nil, to use the default layout. Keep answer and navigation parts in the returned tree to retain their built-in interactions. Omitting parts intentionally hides those controls; it does not disable their commands.

func (*QuestionnaireView) OnAnswerChange

func (v *QuestionnaireView) OnAnswerChange(fn func(string, Answer)) *QuestionnaireView

func (*QuestionnaireView) OnComplete

func (v *QuestionnaireView) OnComplete(fn func(map[string]Answer)) *QuestionnaireView

func (*QuestionnaireView) OnSubmit

func (v *QuestionnaireView) OnSubmit(fn func(answers map[string]Answer)) *QuestionnaireView

func (*QuestionnaireView) Page

func (v *QuestionnaireView) Page() int

Page is the index of the question shown; SetPage moves to another.

func (*QuestionnaireView) Progress

func (*QuestionnaireView) Render

func (v *QuestionnaireView) Render(cx *el.Context) el.Element

func (*QuestionnaireView) Reset

func (v *QuestionnaireView) Reset()

Reset restores schema default answers and clears completion, preserving external errors and disabled conditions.

func (*QuestionnaireView) SetChoiceDisabled

func (v *QuestionnaireView) SetChoiceDisabled(id, option string, on bool) bool

SetChoiceDisabled excludes a choice from effective answers and shortcuts. The stored selection is retained for re-enabling. Unknown IDs/options return false.

func (*QuestionnaireView) SetDisabled

func (v *QuestionnaireView) SetDisabled(on bool)

SetDisabled disables every answer control, navigation, and submission. SetPage and SetValue remain available for programmatic updates.

func (*QuestionnaireView) SetExternalError

func (v *QuestionnaireView) SetExternalError(id, message string) bool

SetExternalError stores an owner-managed error. Empty clears it; edits and Reset preserve it.

func (*QuestionnaireView) SetPage

func (v *QuestionnaireView) SetPage(i int)

func (*QuestionnaireView) SetQuestionDisabled

func (v *QuestionnaireView) SetQuestionDisabled(id string, on bool) bool

SetQuestionDisabled removes a question from navigation, validation, progress and submission. Its stored answer is retained and remains available in Value.

func (*QuestionnaireView) SetValue

func (v *QuestionnaireView) SetValue(answers map[string]Answer)

SetValue fills in answers without submitting; unknown IDs are ignored.

func (*QuestionnaireView) Shortcuts

func (*QuestionnaireView) Size

func (*QuestionnaireView) Skip

func (v *QuestionnaireView) Skip()

Skip clears an optional answer and records an intentional skipped state. Skipping the final enabled question attempts submission.

func (*QuestionnaireView) Value

func (v *QuestionnaireView) Value() map[string]Answer

Value returns every answer so far, by question ID.

type RadioGroupView

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

RadioGroupView picks one of several options. Tab enters the group at the chosen option; arrow keys move the choice, like native radio groups.

func RadioGroup

func RadioGroup(label string, options ...string) *RadioGroupView

func (*RadioGroupView) ClearItemTab

func (v *RadioGroupView) ClearItemTab(value string) *RadioGroupView

ClearItemTab restores group settings and the default single-stop behavior.

func (*RadioGroupView) Content

func (v *RadioGroupView) Content(value string, content el.View) *RadioGroupView

Content replaces an option's visible label with display-only content. The option string remains its value and accessible name. Nil restores the text label; unknown options are ignored. Removed options discard their content.

func (*RadioGroupView) FocusID

func (v *RadioGroupView) FocusID() string

func (*RadioGroupView) Horizontal

func (v *RadioGroupView) Horizontal() *RadioGroupView

func (*RadioGroupView) Item

func (v *RadioGroupView) Item(value string) el.View

Item renders an option independently, sharing this group's selection and keyboard order. Render each option at most once per root/frame.

func (*RadioGroupView) ItemSize

func (v *RadioGroupView) ItemSize(value string, dp, sp float32) *RadioGroupView

ItemSize overrides an option's indicator diameter (dp) and inherited font size (sp). Each zero value inherits the group's setting. Unknown options or negative/non-finite sizes are ignored; positive sizes use the group limits.

func (*RadioGroupView) ItemTab

func (v *RadioGroupView) ItemTab(value string, stop bool, index int) *RadioGroupView

ItemTab explicitly configures an individual option's Tab participation, overriding group settings and the default single-stop radio behavior. Mouse and arrow selection remain available. Unknown options are ignored.

func (*RadioGroupView) OnChange

func (v *RadioGroupView) OnChange(fn func(value string)) *RadioGroupView

func (*RadioGroupView) Options

func (v *RadioGroupView) Options() []string

Options returns a copy of the options, in keyboard navigation order.

func (*RadioGroupView) Render

func (v *RadioGroupView) Render(cx *el.Context) el.Element

func (*RadioGroupView) SetDisabled

func (v *RadioGroupView) SetDisabled(on bool)

func (*RadioGroupView) SetOptionDisabled

func (v *RadioGroupView) SetOptionDisabled(value string, on bool)

SetOptionDisabled prevents user selection while preserving a selected value.

func (*RadioGroupView) SetOptions

func (v *RadioGroupView) SetOptions(options ...string)

func (*RadioGroupView) SetValue

func (v *RadioGroupView) SetValue(s string)

SetValue chooses an option ("" clears) without calling OnChange.

func (*RadioGroupView) Size

func (v *RadioGroupView) Size(dp float32) *RadioGroupView

Size sets the indicator diameter in dp (12–64); zero restores 18dp.

func (*RadioGroupView) TabIndex

func (v *RadioGroupView) TabIndex(index int) *RadioGroupView

TabIndex sets the group's position in a single el root's Tab order. Negative values skip Tab entry. Arrow navigation is unchanged.

func (*RadioGroupView) TabStop

func (v *RadioGroupView) TabStop(on bool) *RadioGroupView

TabStop controls Tab entry into the group without disabling selection.

func (*RadioGroupView) TextSize

func (v *RadioGroupView) TextSize(sp float32) *RadioGroupView

TextSize sets inherited option text size in sp (8–128); zero restores inheritance.

func (*RadioGroupView) Value

func (v *RadioGroupView) Value() string

type RadioView

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

RadioView is one radio button on its own, for layouts a RadioGroup does not fit, such as options spread through a form or a table. Clicking or Space checks it; it never unchecks itself, so the app clears the others in OnChange. For a plain list of options, RadioGroup handles that and the arrow keys.

func Radio

func Radio(label string) *RadioView

func (*RadioView) Checked

func (v *RadioView) Checked(on bool) *RadioView

Checked sets the initial state.

func (*RadioView) Content

func (v *RadioView) Content(view el.View) *RadioView

Content replaces the text label with any view, such as a title and a description on two lines. The constructor label stays the accessible name.

func (*RadioView) FocusID

func (v *RadioView) FocusID() string

FocusID is the element that takes keyboard focus.

func (*RadioView) ID

func (v *RadioView) ID(id string) *RadioView

ID names the radio for cx.Focus and anchored layers.

func (*RadioView) OnChange

func (v *RadioView) OnChange(fn func(checked bool)) *RadioView

OnChange runs when the user checks the radio; programmatic SetValue is silent.

func (*RadioView) Render

func (v *RadioView) Render(cx *el.Context) el.Element

func (*RadioView) SetDisabled

func (v *RadioView) SetDisabled(on bool)

func (*RadioView) SetValue

func (v *RadioView) SetValue(checked bool)

func (*RadioView) Size

func (v *RadioView) Size(dp float32) *RadioView

Size sets the ring's diameter in dp, 18 by default; TextSize the label's.

func (*RadioView) TextSize

func (v *RadioView) TextSize(sp float32) *RadioView

func (*RadioView) Value

func (v *RadioView) Value() bool

type RatingView

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

RatingView picks a whole number of stars from 0 to max. Click a star, or use ← → (Home / End for the ends) once it has focus.

func Rating

func Rating(label string, max int) *RatingView

Rating creates a rating out of max stars (5 if max < 1).

func (*RatingView) Color

func (v *RatingView) Color(c color.NRGBA) *RatingView

Color sets the filled star color; outlines continue to use theme.Muted.

func (*RatingView) FocusID

func (v *RatingView) FocusID() string

func (*RatingView) OnChange

func (v *RatingView) OnChange(fn func(int)) *RatingView

func (*RatingView) ReadOnly

func (v *RatingView) ReadOnly() *RatingView

func (*RatingView) Render

func (v *RatingView) Render(cx *el.Context) el.Element

func (*RatingView) Score

func (v *RatingView) Score() float64

Score returns the exact value, including fractions used for display.

func (*RatingView) SetDisabled

func (v *RatingView) SetDisabled(on bool)

func (*RatingView) SetScore

func (v *RatingView) SetScore(n float64)

SetScore sets a fractional score without callbacks. User editing remains whole-star; use ReadOnly for averages. NaN becomes zero, infinities clamp.

func (*RatingView) SetValue

func (v *RatingView) SetValue(n int)

func (*RatingView) Size

func (v *RatingView) Size(dp float32) *RatingView

Size sets each star's diameter in dp (8–128); invalid values are ignored.

func (*RatingView) Value

func (v *RatingView) Value() int

type ResizableGroupView

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

ResizableGroupView lays out independently constrained panes on one axis.

func ResizableGroup

func ResizableGroup(panels ...ResizablePanel) *ResizableGroupView

func (*ResizableGroupView) HandleAppearance

func (*ResizableGroupView) OnChange

func (v *ResizableGroupView) OnChange(fn func(map[string]float32)) *ResizableGroupView

func (*ResizableGroupView) Render

func (v *ResizableGroupView) Render(cx *el.Context) el.Element

func (*ResizableGroupView) SetDisabled

func (v *ResizableGroupView) SetDisabled(on bool)

func (*ResizableGroupView) SetPanels

func (v *ResizableGroupView) SetPanels(panels ...ResizablePanel)

SetPanels preserves sizes for retained IDs; new IDs use Size. Empty and duplicate IDs are ignored. Hidden panes retain their size and content state.

func (*ResizableGroupView) SetSizes

func (v *ResizableGroupView) SetSizes(sizes map[string]float32)

SetSizes applies finite nonnegative sizes without a callback. Layout fits them to the available axis length and panel constraints on the next render.

func (*ResizableGroupView) SetVisible

func (v *ResizableGroupView) SetVisible(id string, visible bool)

func (*ResizableGroupView) Sizes

func (v *ResizableGroupView) Sizes() map[string]float32

func (*ResizableGroupView) Vertical

func (v *ResizableGroupView) Vertical() *ResizableGroupView

type ResizableHandleAppearance

type ResizableHandleAppearance struct {
	Idle, Hover, Pressed, Dragging float32
	Color, ActiveColor             color.NRGBA
	Duration                       time.Duration
}

ResizableHandleAppearance describes visual line widths in dp, independently of the fixed 6dp hit area. Widths are clamped to 0..6; zero hides that state.

type ResizablePanel

type ResizablePanel struct {
	ID             string
	Content        el.View
	Size, Min, Max float32
	Hidden         bool
}

ResizablePanel identifies a pane. Size is its initial dp size (zero shares available space); Min defaults to zero and Max zero means unbounded.

type ResizableView

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

ResizableView puts two panes side by side (or stacked with Vertical) with a handle between them. Drag the handle, or focus it and use the arrow keys (16dp a press, Home / End for the limits). The first pane keeps its size when the window resizes; the second takes the rest.

func Resizable

func Resizable(first, second el.View) *ResizableView

func (*ResizableView) HandleAppearance

HandleAppearance customizes the theme-derived defaults on each render. nil restores defaults. It must not mutate the element tree.

func (*ResizableView) Max

func (v *ResizableView) Max(first, second float32) *ResizableView

Max limits the two pane sizes in dp. Zero removes that pane's maximum. Negative/non-finite values are ignored independently. A maximum below Min uses Min. If both maxima leave spare space, it remains after the second pane.

func (*ResizableView) Min

func (v *ResizableView) Min(first, second float32) *ResizableView

Min sets the smallest sizes of the two panes in dp (80 each by default).

func (*ResizableView) OnChange

func (v *ResizableView) OnChange(fn func(size float32)) *ResizableView

func (*ResizableView) Render

func (v *ResizableView) Render(cx *el.Context) el.Element

func (*ResizableView) SetDisabled

func (v *ResizableView) SetDisabled(on bool)

SetDisabled disables the splitter and its pane content. SetValue remains available.

func (*ResizableView) SetValue

func (v *ResizableView) SetValue(dp float32)

SetValue sets the first pane's size without calling OnChange.

func (*ResizableView) Value

func (v *ResizableView) Value() float32

Value is the first pane's size in dp.

func (*ResizableView) Vertical

func (v *ResizableView) Vertical() *ResizableView

Vertical stacks the panes, first on top.

func (*ResizableView) Visible

func (v *ResizableView) Visible(first, second bool) *ResizableView

Visible controls the two panes independently; both are visible by default. With one pane visible it fills the container without a handle or split limits. Hidden content remains declared, preserving widget state, but cannot receive input. Restoring both panes clamps the stored split size to the current constraints. This does not call OnChange.

type SankeyAlign

type SankeyAlign uint8
const (
	SankeyAlignJustify SankeyAlign = iota
	SankeyAlignLeft
	SankeyAlignRight
	SankeyAlignCenter
)

type SankeyChartView

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

SankeyChartView lays out a directed acyclic flow graph, with raw throughput labels, hover highlighting and a data table. Node throughput is max(in,out).

func SankeyChart

func SankeyChart(nodes []SankeyNode, links []SankeyLink) *SankeyChartView

func (*SankeyChartView) Error

func (v *SankeyChartView) Error() error

func (*SankeyChartView) Format

func (v *SankeyChartView) Format(fn func(float64) string) *SankeyChartView

func (*SankeyChartView) Height

func (v *SankeyChartView) Height(dp float32) *SankeyChartView

func (*SankeyChartView) HoverAnimation

func (v *SankeyChartView) HoverAnimation(on bool) *SankeyChartView

func (*SankeyChartView) Iterations

func (v *SankeyChartView) Iterations(n int) *SankeyChartView

func (*SankeyChartView) Labels

Labels replaces the text beside each node; nil restores name and raw throughput.

func (*SankeyChartView) LinkOpacity

func (v *SankeyChartView) LinkOpacity(a float32) *SankeyChartView

func (*SankeyChartView) MinLinkWidth

func (v *SankeyChartView) MinLinkWidth(dp float32) *SankeyChartView

MinLinkWidth sets a visual minimum width in dp for positive flows (0–64). Zero preserves proportional sizing. Nodes grow to fit their incident links; when the column cannot hold all minima, the minimum is reduced uniformly. Displayed values and tooltips retain the original data, not adjusted widths.

func (*SankeyChartView) NodeAlign

func (v *SankeyChartView) NodeAlign(a SankeyAlign) *SankeyChartView

func (*SankeyChartView) NodePadding

func (v *SankeyChartView) NodePadding(dp float32) *SankeyChartView

func (*SankeyChartView) NodeRadius

func (v *SankeyChartView) NodeRadius(dp float32) *SankeyChartView

func (*SankeyChartView) NodeWidth

func (v *SankeyChartView) NodeWidth(dp float32) *SankeyChartView

func (*SankeyChartView) Render

func (v *SankeyChartView) Render(cx *el.Context) el.Element

func (*SankeyChartView) SetData

func (v *SankeyChartView) SetData(nodes []SankeyNode, links []SankeyLink) error

SetData validates all references, totals and topology before replacing data. Cycles, self-links, negative/non-finite values and overflowing totals return errors and preserve the previous graph. Inputs and optional colors are copied.

func (*SankeyChartView) SetDisabled

func (v *SankeyChartView) SetDisabled(on bool)

func (*SankeyChartView) Title

func (v *SankeyChartView) Title(s string) *SankeyChartView

func (*SankeyChartView) TooltipContent

func (v *SankeyChartView) TooltipContent(fn func(*el.Context, SankeyTooltip) el.Element) *SankeyChartView

func (*SankeyChartView) ValueScale

type SankeyLink struct {
	Source, Target int
	Value          float64
}

SankeyLink references node indices; Value must be finite and nonnegative.

type SankeyNode

type SankeyNode struct {
	Name  string
	Color *color.NRGBA
}

SankeyNode is a named flow endpoint. Nil Color uses the theme palette.

type SankeyTooltip

type SankeyTooltip struct {
	Index int
	Node  SankeyNode
	Value float64
}

type SankeyValueScale

type SankeyValueScale uint8
const (
	SankeyValueScaleLinear SankeyValueScale = iota
	SankeyValueScaleSqrt
)

type ScrollAlign added in v0.0.5

type ScrollAlign uint8

ScrollAlign is where ScrollToAlign puts a row in the viewport.

const (
	// ScrollNearest scrolls as little as needed to show the row.
	ScrollNearest ScrollAlign = iota
	// ScrollStart puts the row at the viewport's top (or left).
	ScrollStart
	// ScrollCenter centers the row.
	ScrollCenter
	// ScrollEnd puts the row at the viewport's bottom (or right).
	ScrollEnd
)

type SelectItemContext

type SelectItemContext struct {
	Option           SelectOption
	Index            int
	Selected, Active bool
}

SelectItemContext describes a visible option. Index addresses Entries, not the filtered/grouped list. Custom content should be presentational; the row retains selection, keyboard behavior and accessible option semantics.

type SelectOption

type SelectOption struct {
	Value, Label, Group string
	Disabled            bool
}

SelectOption separates the stored value from its label and section title.

type SelectView

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

SelectView picks one option from a list that opens under the field. Enter, Space or ↓ opens it; in the list ↑ ↓ move, Enter chooses, Esc closes and focus returns to the field. Searchable adds a filter box on top; ↓ moves from it into the list.

func Select

func Select(label string, options ...string) *SelectView

func (*SelectView) Appearance

func (v *SelectView) Appearance(on bool) *SelectView

func (*SelectView) Clearable

func (v *SelectView) Clearable(on bool) *SelectView

func (*SelectView) Empty

func (v *SelectView) Empty(view el.View) *SelectView

func (*SelectView) Entries

func (v *SelectView) Entries() []SelectOption

func (*SelectView) Error

func (v *SelectView) Error() string

func (*SelectView) FocusID

func (v *SelectView) FocusID() string

func (*SelectView) Hint

func (v *SelectView) Hint(s string) *SelectView

Hint is shown while nothing is chosen; empty uses the locale's SelectHint.

func (*SelectView) Match

func (v *SelectView) Match(fn func(SelectOption, string) bool) *SelectView

Match replaces the local search predicate. Nil restores label/value matching. Reapply it after changing captured search data to invalidate cached results.

func (*SelectView) MenuMaxHeight

func (v *SelectView) MenuMaxHeight(dp float32) *SelectView

MenuMaxHeight includes search and padding. Positive values have a 64dp floor; zero restores the 240dp default. Window bounds always take precedence.

func (*SelectView) MenuWidth

func (v *SelectView) MenuWidth(dp float32) *SelectView

MenuWidth sets popup width in dp; zero restores anchor width. The overlay still constrains it to the window. Negative/non-finite values are ignored.

func (*SelectView) Multiple

func (v *SelectView) Multiple() *SelectView

func (*SelectView) OnChange

func (v *SelectView) OnChange(fn func(value string)) *SelectView

func (*SelectView) OnValuesChange

func (v *SelectView) OnValuesChange(fn func([]string)) *SelectView

func (*SelectView) Render

func (v *SelectView) Render(cx *el.Context) el.Element

func (*SelectView) RenderItem

func (v *SelectView) RenderItem(fn func(*el.Context, SelectItemContext) el.Element) *SelectView

func (*SelectView) RenderValue

func (v *SelectView) RenderValue(fn func(*el.Context, []SelectOption) el.Element) *SelectView

RenderValue replaces selected text, leaving the empty hint unchanged. The supplied entries are an owned snapshot; nil output uses the ordinary labels.

func (*SelectView) RowHeight

func (v *SelectView) RowHeight(dp float32) *SelectView

RowHeight sets the uniform option/group height; zero follows Size.

func (*SelectView) Searchable

func (v *SelectView) Searchable() *SelectView

func (*SelectView) SetDisabled

func (v *SelectView) SetDisabled(on bool)

func (*SelectView) SetEntries

func (v *SelectView) SetEntries(options ...SelectOption)

func (*SelectView) SetError

func (v *SelectView) SetError(msg string)

func (*SelectView) SetOptionDisabled

func (v *SelectView) SetOptionDisabled(value string, on bool)

func (*SelectView) SetOptions

func (v *SelectView) SetOptions(options ...string)

SetOptions replaces the options, keeping the choice if it is still offered.

func (*SelectView) SetValue

func (v *SelectView) SetValue(s string)

SetValue chooses an option ("" clears) without calling OnChange.

func (*SelectView) SetValues

func (v *SelectView) SetValues(values []string)

func (*SelectView) Size

func (v *SelectView) Size(dp float32) *SelectView

Size scales field height, spacing, text, navigation icon and default row height. Zero restores the theme size. Values below 20dp are clamped to 20dp.

func (*SelectView) TitlePrefix

func (v *SelectView) TitlePrefix(prefix string) *SelectView

func (*SelectView) Value

func (v *SelectView) Value() string

func (*SelectView) Values

func (v *SelectView) Values() []string

type Series

type Series struct {
	Name   string
	Values []float64
}

Series is one named row of values, one value per chart label.

type SettingGroup

type SettingGroup struct {
	Title  string
	Items  []SettingItem
	Footer el.View
	// Nil inherits the settings group variant.
	Variant *GroupBoxVariant
}

SettingGroup collects rows under an optional title and an outside footer.

type SettingItem

type SettingItem struct {
	Label, Description string
	Control            el.View
	// DescriptionContent replaces plain description rendering; Description remains searchable.
	DescriptionContent el.View
	Keywords           []string
	Content            el.View // Replaces the whole row body.
	Vertical, Disabled bool
	// Reset restores application-owned defaults; disabled rows are skipped.
	Reset func()
}

SettingItem is one row of a settings page: a label, an optional description, and the control that changes it.

type SettingPage

type SettingPage struct {
	Title       string
	Icon        IconName
	Groups      []SettingGroup
	TitleSuffix el.View
	Resettable  bool
}

SettingPage is one navigation destination. Titles must be unique.

type SettingsSize

type SettingsSize uint8

SettingsSize controls settings labels, row padding, gaps and control columns. Application-provided controls retain their own size configuration.

const (
	SettingsSizeMedium SettingsSize = iota
	SettingsSizeXSmall
	SettingsSizeSmall
	SettingsSizeLarge
)

type SettingsView

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

SettingsView is a preferences page: a list of sections on the left, the chosen section's rows on the right, and a search box that finds rows in every section by label or description.

func Settings

func Settings() *SettingsView

func (*SettingsView) GroupNavigation

func (v *SettingsView) GroupNavigation(on bool) *SettingsView

func (*SettingsView) GroupVariant

func (v *SettingsView) GroupVariant(variant GroupBoxVariant) *SettingsView

GroupVariant sets the default group surface.

func (*SettingsView) Page

func (v *SettingsView) Page(page SettingPage) *SettingsView

Page adds an owned snapshot of a page and its groups. Views and callbacks remain shared.

func (*SettingsView) Query

func (v *SettingsView) Query() string

Query returns the current search text. SetQuery also reconciles page selection.

func (*SettingsView) Render

func (v *SettingsView) Render(cx *el.Context) el.Element

func (*SettingsView) ResetPage

func (v *SettingsView) ResetPage(title string)

ResetPage invokes each enabled row's reset callback, including filtered-out rows. Callbacks are captured before invocation so reentrant page additions do not join this reset.

func (*SettingsView) RowSpacing

func (v *SettingsView) RowSpacing(dp float32) *SettingsView

RowSpacing sets row vertical padding in dp; zero restores the theme default.

func (*SettingsView) Section

func (v *SettingsView) Section(title string, icon IconName, items ...SettingItem) *SettingsView

Section adds a section of rows; its title also names it in the side list.

func (*SettingsView) SetQuery

func (v *SettingsView) SetQuery(query string)

func (*SettingsView) SetValue

func (v *SettingsView) SetValue(title string)

func (*SettingsView) ShowGroup

func (v *SettingsView) ShowGroup(page, title string) bool

ShowGroup selects a page and requests scrolling to its named group. It returns false for a missing, ambiguous, or search-filtered group. It does not clear search. GroupNavigation need not be enabled for programmatic navigation.

func (*SettingsView) Size

func (v *SettingsView) Size(size SettingsSize) *SettingsView

func (*SettingsView) Value

func (v *SettingsView) Value() string

Value is the shown section's title; SetValue shows another.

type SheetView

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

SheetView is a modal panel against one edge of the window: settings, details, a long form. It closes on Esc, a press on the scrim, or its close button, and returns focus where it was.

func Sheet

func Sheet(side el.Side, title string) *SheetView

Sheet creates a sheet against side (el.Right, el.Left, el.Top, el.Bottom).

func (*SheetView) Body

func (v *SheetView) Body(b el.View) *SheetView

func (*SheetView) CloseButton

func (v *SheetView) CloseButton(on bool) *SheetView

func (*SheetView) Footer

func (v *SheetView) Footer(views ...el.View) *SheetView

Footer adds fixed actions below the scrollable body and copies the slice.

func (*SheetView) Keyboard

func (v *SheetView) Keyboard(on bool) *SheetView

func (*SheetView) MarginTop

func (v *SheetView) MarginTop(dp float32) *SheetView

MarginTop reserves space above the panel in dp; zero restores full height. Invalid values are ignored. The modal scrim still covers the whole window.

func (*SheetView) OnClose

func (v *SheetView) OnClose(fn func()) *SheetView

func (*SheetView) OnResize

func (v *SheetView) OnResize(fn func(float32)) *SheetView

OnResize reports user size changes in dp; Size does not invoke it.

func (*SheetView) Overlay

func (v *SheetView) Overlay(on bool) *SheetView

func (*SheetView) OverlayClosable

func (v *SheetView) OverlayClosable(on bool) *SheetView

func (*SheetView) PanelSize

func (v *SheetView) PanelSize() float32

PanelSize returns the requested width or height in dp, including user resizing.

func (*SheetView) PanelStyle

func (v *SheetView) PanelStyle(fn func(*el.DivEl)) *SheetView

PanelStyle refines the panel's default colors, border, padding and gap each frame. Do not retain the element. Size, bounds and dialog identity are applied afterward; use Body and Footer for content. Nil restores the default style.

func (*SheetView) Render

func (v *SheetView) Render(cx *el.Context) el.Element

func (*SheetView) Resizable

func (v *SheetView) Resizable(on bool) *SheetView

Resizable enables the inner-edge handle, enabled by default.

func (*SheetView) SetDisabled

func (v *SheetView) SetDisabled(on bool)

func (*SheetView) SetTitle

func (v *SheetView) SetTitle(s string)

func (*SheetView) SetValue

func (v *SheetView) SetValue(open bool)

func (*SheetView) Show added in v0.0.5

func (v *SheetView) Show(cx *el.Context)

Show opens the sheet in the window of cx without placing it in a view tree; it leaves the window when closed.

func (*SheetView) Size

func (v *SheetView) Size(dp float32) *SheetView

Size sets the width (left/right) or height (top/bottom) in dp, 360 by default.

func (*SheetView) Value

func (v *SheetView) Value() bool

type ShimmerStyle

type ShimmerStyle struct {
	Duration time.Duration
	Spread   float32
	Reverse  bool
	Once     bool
}

ShimmerStyle is reusable motion configuration for text and attachment titles. The zero value uses a two-second forward loop with a 0.3 half-width.

type ShimmerTextView

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

ShimmerTextView highlights readable text without replacing it with a skeleton.

func ShimmerText

func ShimmerText(text string) *ShimmerTextView

func (*ShimmerTextView) Color

func (*ShimmerTextView) Duration

func (v *ShimmerTextView) Duration(d time.Duration) *ShimmerTextView

func (*ShimmerTextView) Enabled

func (v *ShimmerTextView) Enabled(on bool) *ShimmerTextView

func (*ShimmerTextView) Highlight

func (v *ShimmerTextView) Highlight(c color.NRGBA) *ShimmerTextView

func (*ShimmerTextView) MaxLines

func (v *ShimmerTextView) MaxLines(n int) *ShimmerTextView

func (*ShimmerTextView) Once

func (v *ShimmerTextView) Once(on bool) *ShimmerTextView

func (*ShimmerTextView) Render

func (v *ShimmerTextView) Render(cx *el.Context) el.Element

func (*ShimmerTextView) Restart

func (v *ShimmerTextView) Restart()

Restart begins a new sweep on the next render, including after Once completes.

func (*ShimmerTextView) Reverse

func (v *ShimmerTextView) Reverse(on bool) *ShimmerTextView

func (*ShimmerTextView) SetText

func (v *ShimmerTextView) SetText(text string)

func (*ShimmerTextView) Size

func (*ShimmerTextView) Spread

func (v *ShimmerTextView) Spread(f float32) *ShimmerTextView

func (*ShimmerTextView) Style

func (v *ShimmerTextView) Style(style ShimmerStyle) *ShimmerTextView

Style replaces all motion settings, leaving text and typography unchanged. An effective setting change restarts the sweep. Reapplying the same settings each frame preserves progress. Invalid duration/spread values use defaults.

type SidebarItem

type SidebarItem struct {
	ID, Label   string
	Icon        IconName // optional; IconNone shows no icon
	Disabled    bool
	Children    []SidebarItem
	Badge       int       // a count shown at the end; 0 hides it
	Suffix      el.View   // optional independent trailing content, hidden when collapsed
	ContextMenu *MenuView // optional menu owned by this item; do not share between items
}

SidebarItem is one destination in a Sidebar. IDs must be unique.

type SidebarView

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

SidebarView is the app's navigation column: sections of items, one selected. Collapsed it shows only icons, each with a tooltip. Items take focus with Tab; ↑ ↓ move between them.

func Sidebar() *SidebarView

func (*SidebarView) BorderWidth

func (v *SidebarView) BorderWidth(dp float32) *SidebarView

BorderWidth sets the inner dividing line in dp; zero hides it.

func (*SidebarView) Collapsed

func (v *SidebarView) Collapsed() bool

func (*SidebarView) Collapsible

func (v *SidebarView) Collapsible(on bool) *SidebarView

Collapsible controls the built-in toggle. SetCollapsed remains available.

func (*SidebarView) Expanded

func (v *SidebarView) Expanded(id string) bool

func (*SidebarView) Filter

func (v *SidebarView) Filter(query string)

Filter shows only items whose label contains query, ignoring case, with the parents that lead to them; "" shows everything. Sections without a match drop out with their heading. The selection is kept even when hidden.

func (*SidebarView) Footer

func (v *SidebarView) Footer(view el.View) *SidebarView

func (*SidebarView) Header

func (v *SidebarView) Header(view el.View) *SidebarView

func (*SidebarView) Height

func (v *SidebarView) Height(dp float32) *SidebarView

Height fixes the sidebar height; by default it sizes to content within the viewport.

func (*SidebarView) OnChange

func (v *SidebarView) OnChange(fn func(id string)) *SidebarView

func (*SidebarView) Render

func (v *SidebarView) Render(cx *el.Context) el.Element

func (*SidebarView) Section

func (v *SidebarView) Section(title string, items ...SidebarItem) *SidebarView

Section adds a titled group of items; an empty title adds no heading.

func (*SidebarView) SetBadge

func (v *SidebarView) SetBadge(id string, n int)

SetBadge updates an item's count.

func (*SidebarView) SetCollapsed

func (v *SidebarView) SetCollapsed(on bool)

func (*SidebarView) SetContextMenu

func (v *SidebarView) SetContextMenu(id string, menu *MenuView)

SetContextMenu replaces an item's menu and closes the previous one. The menu belongs to this item; its Trigger is unused. Nil removes the menu.

func (*SidebarView) SetDisabled

func (v *SidebarView) SetDisabled(on bool)

func (*SidebarView) SetExpanded

func (v *SidebarView) SetExpanded(id string, on bool)

func (*SidebarView) SetItemDisabled

func (v *SidebarView) SetItemDisabled(id string, on bool)

func (*SidebarView) SetSuffix

func (v *SidebarView) SetSuffix(id string, content el.View)

SetSuffix replaces an item's independent trailing content. Nil removes it.

func (*SidebarView) SetValue

func (v *SidebarView) SetValue(id string)

func (*SidebarView) Side

func (v *SidebarView) Side(side el.Side) *SidebarView

Side sets the application edge, Left by default. The application places the sidebar in its containing row; this changes the border, toggle and tooltip.

func (*SidebarView) Value

func (v *SidebarView) Value() string

func (*SidebarView) Width

func (v *SidebarView) Width(dp float32) *SidebarView

Width sets the expanded width in dp, 220 by default.

type SkeletonView

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

SkeletonView is decorative loading geometry. Shimmer is an option, not a separate component, and both animations honor ReducedMotion.

func Skeleton

func Skeleton() *SkeletonView

func (*SkeletonView) Circle

func (v *SkeletonView) Circle() *SkeletonView

func (*SkeletonView) H

func (*SkeletonView) Render

func (v *SkeletonView) Render(cx *el.Context) el.Element

func (*SkeletonView) Rounded

func (v *SkeletonView) Rounded(dp float32) *SkeletonView

Rounded sets a rectangle's corner radius in dp; zero makes square corners. It replaces Circle. Negative and non-finite values are ignored.

func (*SkeletonView) Secondary

func (v *SkeletonView) Secondary(on bool) *SkeletonView

Secondary halves the opacity of the whole placeholder, including its animation.

func (*SkeletonView) Shimmer

func (v *SkeletonView) Shimmer() *SkeletonView

func (*SkeletonView) W

type SliderAppearance

type SliderAppearance struct {
	TrackColor, FillColor, ThumbColor, ThumbBorderColor color.NRGBA
	TrackSize, ThumbSize, ThumbBorderWidth              float32
	TrackRadius, ThumbRadius                            float32
}

SliderAppearance describes the track and both thumbs. Dimensions are dp. A callback receives current theme defaults on each render.

type SliderScale

type SliderScale uint8

SliderScale controls the mapping between values and track position.

const (
	SliderLinear SliderScale = iota
	SliderLogarithmic
)

type SliderView

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

SliderView picks a number in a range by dragging or with the keyboard: ← ↓ and → ↑ step, PageUp / PageDown move ten steps, Home / End jump to the ends.

func RangeSlider

func RangeSlider(label string, min, max float64) *SliderView

RangeSlider creates a two-ended slider initialized to the full range.

func Slider

func Slider(label string, min, max float64) *SliderView

Slider creates a slider over [min, max]; reversed bounds are swapped and the value starts at min. Without Step it moves by 1% of the range.

func (*SliderView) Appearance

func (v *SliderView) Appearance(fn func(*SliderAppearance)) *SliderView

Appearance customizes this slider without changing its value or callbacks. Nil restores theme defaults. The callback runs during Render and should only edit the supplied configuration; both range endpoints share this appearance.

func (*SliderView) FocusID

func (v *SliderView) FocusID() string

func (*SliderView) OnChange

func (v *SliderView) OnChange(fn func(float64)) *SliderView

func (*SliderView) OnRangeChange

func (v *SliderView) OnRangeChange(fn func(float64, float64)) *SliderView

func (*SliderView) OnRangeRelease

func (v *SliderView) OnRangeRelease(fn func(float64, float64)) *SliderView

func (*SliderView) OnRelease

func (v *SliderView) OnRelease(fn func(float64)) *SliderView

OnRelease runs once on pointer release or a navigation key's release. Canceled/disabled interactions and programmatic changes do not call it.

func (*SliderView) Render

func (v *SliderView) Render(cx *el.Context) el.Element

func (*SliderView) Scale

func (v *SliderView) Scale(scale SliderScale) *SliderView

Scale selects a mapping. Logarithmic ranges require 0 < min < max; otherwise the mapping falls back to linear until valid bounds are supplied.

func (*SliderView) SetDisabled

func (v *SliderView) SetDisabled(on bool)

func (*SliderView) SetRange

func (v *SliderView) SetRange(a, b float64)

func (*SliderView) SetValue

func (v *SliderView) SetValue(x float64)

func (*SliderView) SetValues

func (v *SliderView) SetValues(a, b float64)

SetValues sorts and clamps both ends without calling user callbacks.

func (*SliderView) Step

func (v *SliderView) Step(s float64) *SliderView

Step snaps values to min + k·step; 0 means continuous.

func (*SliderView) Value

func (v *SliderView) Value() float64

func (*SliderView) Values

func (v *SliderView) Values() (float64, float64)

func (*SliderView) Vertical

func (v *SliderView) Vertical(height float32) *SliderView

Vertical uses a bottom-to-top track with the given height in dp.

type SpinnerView

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

func Spinner

func Spinner() *SpinnerView

Spinner shows an indeterminate progress ring labelled with the locale's Loading text until Label sets another one ("" hides the text).

func (*SpinnerView) Color

func (v *SpinnerView) Color(c color.NRGBA) *SpinnerView

Color changes the graphic color, leaving the label in the theme's muted color.

func (*SpinnerView) Icon

func (v *SpinnerView) Icon(name IconName) *SpinnerView

Icon replaces the ring with a rotating built-in icon. IconNone restores the ring.

func (*SpinnerView) Label

func (v *SpinnerView) Label(s string) *SpinnerView

func (*SpinnerView) Period

func (v *SpinnerView) Period(d time.Duration) *SpinnerView

Period sets the duration of one rotation. Zero restores one second; negative durations are ignored. Reduced motion always keeps the graphic still.

func (*SpinnerView) Render

func (v *SpinnerView) Render(cx *el.Context) el.Element

func (*SpinnerView) Size

func (v *SpinnerView) Size(dp float32) *SpinnerView

func (*SpinnerView) VectorIcon

func (v *SpinnerView) VectorIcon(icon *giowidget.Icon) *SpinnerView

VectorIcon uses a custom decoded Gio icon; nil restores the ring.

type StatusBarView

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

StatusBarView is a single-line 24dp status strip; its parent places it. Items added with Add move into a "…" menu, lowest priority first, when they do not fit; views given to Left and Right always stay.

func StatusBar

func StatusBar() *StatusBarView

func (*StatusBarView) Add

func (v *StatusBarView) Add(items ...StatusItem) *StatusBarView

Add appends items to the left group, after the Left views.

func (*StatusBarView) AddRight

func (v *StatusBarView) AddRight(items ...StatusItem) *StatusBarView

AddRight appends items to the right group, before the Right views.

func (*StatusBarView) Hidden

func (v *StatusBarView) Hidden() []string

Hidden returns the labels of the items now in the overflow menu.

func (*StatusBarView) Left

func (v *StatusBarView) Left(views ...el.View) *StatusBarView

func (*StatusBarView) Render

func (v *StatusBarView) Render(cx *el.Context) el.Element

func (*StatusBarView) Right

func (v *StatusBarView) Right(views ...el.View) *StatusBarView

type StatusItem

type StatusItem struct {
	// Label names the item in the overflow menu, and is the text shown in
	// the bar when View is nil.
	Label string
	// View is shown in the bar; nil shows Label.
	View el.View
	// Action runs when the item is clicked, in the bar (for a Label-only
	// item) or in the overflow menu.
	Action func()
	// Priority orders hiding: lower priorities move to the menu first, and
	// later items before earlier ones at the same priority.
	Priority int
}

StatusItem is one entry of a status bar that may move into its overflow menu when the bar is too narrow.

type StatusMarkerLoadingStyle

type StatusMarkerLoadingStyle uint8
const (
	StatusMarkerLoadingStyleSpinner StatusMarkerLoadingStyle = iota
	StatusMarkerLoadingStyleShimmer
)

type StatusMarkerPart

type StatusMarkerPart uint8
const (
	StatusMarkerPartRoot StatusMarkerPart = iota
	StatusMarkerPartRow
	StatusMarkerPartIcon
	StatusMarkerPartContent
	StatusMarkerPartSeparator
)

type StatusMarkerVariant

type StatusMarkerVariant uint8
const (
	StatusMarkerPlain StatusMarkerVariant = iota
	StatusMarkerSeparator
	StatusMarkerBorder
)

type StatusMarkerView

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

StatusMarkerView composes a status or timeline boundary with optional loading. It does not own a notification, counter, or row click action.

func StatusMarker

func StatusMarker(text string) *StatusMarkerView

func (*StatusMarkerView) Alignment

func (v *StatusMarkerView) Alignment(value el.Align) *StatusMarkerView

Alignment places the row contents; only Start, Center and End are accepted. Without an override, separators center and other variants start.

func (*StatusMarkerView) Children

func (v *StatusMarkerView) Children(views ...el.View) *StatusMarkerView

Children replaces direct row children, after the icon/content slots.

func (*StatusMarkerView) Content

func (v *StatusMarkerView) Content(view el.View) *StatusMarkerView

Content adds rich content after the text. Empty text allows a rich-only marker.

func (*StatusMarkerView) ID

func (*StatusMarkerView) Icon

func (v *StatusMarkerView) Icon(view el.View) *StatusMarkerView

Icon supplies the compact icon slot; nil restores automatic spinner behavior.

func (*StatusMarkerView) Loading

func (v *StatusMarkerView) Loading(on bool) *StatusMarkerView

func (*StatusMarkerView) LoadingStyle

func (*StatusMarkerView) PartStyle

func (v *StatusMarkerView) PartStyle(part StatusMarkerPart, fn func(*el.DivEl)) *StatusMarkerView

PartStyle refines fresh elements after defaults. IDs remain stable for slots.

func (*StatusMarkerView) Render

func (v *StatusMarkerView) Render(cx *el.Context) el.Element

func (*StatusMarkerView) ResetAlignment

func (v *StatusMarkerView) ResetAlignment() *StatusMarkerView

func (*StatusMarkerView) Role

func (v *StatusMarkerView) Role(role string) *StatusMarkerView

func (*StatusMarkerView) SetText

func (v *StatusMarkerView) SetText(text string)

func (*StatusMarkerView) ShimmerStyle

func (v *StatusMarkerView) ShimmerStyle(fn func(*ShimmerTextView)) *StatusMarkerView

ShimmerStyle configures the persistent text effect (duration, spread, color, direction and single-sweep mode). The marker controls its text/enabled state.

func (*StatusMarkerView) Variant

type StepperItem

type StepperItem struct {
	Label    string
	Icon     IconName
	Disabled bool
	Content  el.View
}

StepperItem describes a step. Content optionally replaces the visible label; Label remains its accessible name. Content should contain no interactive controls.

type StepperNavigation

type StepperNavigation uint8

StepperNavigation controls which enabled steps the user may select.

const (
	StepperNavigationNone StepperNavigation = iota
	StepperNavigationCompleted
	StepperNavigationAll
)

type StepperView

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

StepperView shows progress through a sequence of steps. Steps before the current one are done; with Navigable the user may click back to them.

func Stepper

func Stepper(steps ...string) *StepperView

func (*StepperView) Entries

func (v *StepperView) Entries() []StepperItem

func (*StepperView) Horizontal

func (v *StepperView) Horizontal() *StepperView

Horizontal restores left-to-right layout after Vertical.

func (*StepperView) Navigable

func (v *StepperView) Navigable() *StepperView

Navigable lets the user click a finished step to return to it.

func (*StepperView) Navigation

func (v *StepperView) Navigation(mode StepperNavigation) *StepperView

Navigation chooses read-only, completed-only, or unrestricted navigation. Programmatic SetValue is unaffected. Clicking the current step is a no-op.

func (*StepperView) OnChange

func (v *StepperView) OnChange(fn func(int)) *StepperView

func (*StepperView) Render

func (v *StepperView) Render(cx *el.Context) el.Element

func (*StepperView) SetDisabled

func (v *StepperView) SetDisabled(on bool)

func (*StepperView) SetEntries

func (v *StepperView) SetEntries(items ...StepperItem)

SetEntries copies the items and clamps the current index, without OnChange. Views in Content remain owned by the caller and are not deep-copied.

func (*StepperView) SetItemDisabled

func (v *StepperView) SetItemDisabled(index int, on bool)

func (*StepperView) SetValue

func (v *StepperView) SetValue(i int)

SetValue moves to step i without calling OnChange, e.g. after "下一步".

func (*StepperView) Size

func (v *StepperView) Size(dp float32) *StepperView

Size sets the marker diameter in dp; 20, 24 (default), and 32 are typical.

func (*StepperView) TextCenter

func (v *StepperView) TextCenter(on bool) *StepperView

TextCenter centers text and rich content. In horizontal layout the content sits below the marker, with connectors between neighboring marker centers. In vertical layout the marker stays beside the content.

func (*StepperView) Value

func (v *StepperView) Value() int

Value is the index of the current step; len(steps) means all are done.

func (*StepperView) Vertical

func (v *StepperView) Vertical() *StepperView

Vertical stacks steps and their connecting lines from top to bottom.

type SwitchSize

type SwitchSize uint8
const (
	SwitchMedium SwitchSize = iota
	SwitchSmall
)

type SwitchView

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

SwitchView turns a setting on or off immediately; use Checkbox for choices that are applied later by a submit button.

func Switch

func Switch(label string, on bool) *SwitchView

func (*SwitchView) ClearColor

func (v *SwitchView) ClearColor() *SwitchView

func (*SwitchView) Color

func (v *SwitchView) Color(c color.NRGBA) *SwitchView

Color overrides the checked track color. ClearColor restores the theme.

func (*SwitchView) FocusID

func (v *SwitchView) FocusID() string

func (*SwitchView) FocusRing

func (v *SwitchView) FocusRing(on bool) *SwitchView

FocusRing controls the keyboard/programmatic focus outline, enabled by default. Disabling it preserves focus and keyboard activation for custom focus treatments.

func (*SwitchView) LabelSide

func (v *SwitchView) LabelSide(side el.Side) *SwitchView

LabelSide accepts el.Left and el.Right; other sides are ignored.

func (*SwitchView) OnChange

func (v *SwitchView) OnChange(fn func(bool)) *SwitchView

func (*SwitchView) Render

func (v *SwitchView) Render(cx *el.Context) el.Element

func (*SwitchView) SetDisabled

func (v *SwitchView) SetDisabled(on bool)

func (*SwitchView) SetValue

func (v *SwitchView) SetValue(on bool)

func (*SwitchView) Size

func (v *SwitchView) Size(size SwitchSize) *SwitchView

Size selects a 36×20dp (medium) or 28×16dp (small) track.

func (*SwitchView) TabIndex

func (v *SwitchView) TabIndex(index int) *SwitchView

TabIndex sets ascending traversal order within the el root or active trap. Negative indexes skip Tab; equal indexes retain tree order.

func (*SwitchView) TabStop

func (v *SwitchView) TabStop(on bool) *SwitchView

TabStop controls Tab traversal while preserving mouse and programmatic focus.

func (*SwitchView) Value

func (v *SwitchView) Value() bool

type TabItem

type TabItem struct {
	Title    string
	Page     el.View
	Icon     IconName
	Content  el.View
	Disabled bool
}

TabItem describes a page and its label. Content replaces the visible title; use display-only content. Title remains the accessible and overflow name.

type TableCell

type TableCell struct{ Row, Column int }

TableCell is a source row/column address, unchanged by display sorting.

type TableColumnState

type TableColumnState struct {
	Column int     `json:"column"`
	Width  float32 `json:"width"`
	Flex   float32 `json:"flex"`
	Hidden bool    `json:"hidden"`
}

TableColumnState identifies a source column, independently of its display order. Width zero uses Flex; Hidden columns retain their position and width.

type TableLayout

type TableLayout struct {
	Columns     []TableColumnState `json:"columns"`
	FrozenLeft  int                `json:"frozen_left"`
	FrozenRight int                `json:"frozen_right"`
}

TableLayout is a caller-owned, JSON-serializable column layout. Restore it only to a table with the same source-column schema.

type TableView

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

TableView shows rows of text in columns. Click a header to sort by it (again to reverse); drag a header to reorder, or its right edge to resize. Click a row, or use ↑ ↓ Home End PageUp PageDown once the table has focus, to select it; double-click or press Enter to activate it. Only rows near the viewport are built, so tables with many thousands of rows stay fast. Columns wider than the viewport scroll horizontally together with the header.

Row indexes in callbacks, Value and SetValue are positions in the data given to SetRows, whatever the sort order.

func Table

func Table(cols ...*ColumnSpec) *TableView

func (*TableView) CellMenu

func (v *TableView) CellMenu(build func(row, column int) *MenuView) *TableView

CellMenu takes precedence over RowMenu for cell context actions. Returning nil falls back to RowMenu. Indexes refer to the source data, not visual order.

func (*TableView) CellSelect

func (v *TableView) CellSelect() *TableView

CellSelect enables cell rectangles and whole-column selection. Click a header to select its column; double-click it to sort. Row selection is cleared.

func (*TableView) ColumnSelect

func (v *TableView) ColumnSelect() *TableView

ColumnSelect enables independent whole-column selection, retained across SetRows.

func (*TableView) Empty

func (v *TableView) Empty(s string) *TableView

Empty sets the text shown when there are no rows; "" uses the locale's NoData.

func (*TableView) Fill

func (v *TableView) Fill() *TableView

func (*TableView) FrozenColumns

func (v *TableView) FrozenColumns(left, right int) *TableView

FrozenColumns pins the first left and last right columns. Counts are clamped; left columns take priority. Flexible frozen columns become 120dp.

func (*TableView) Height

func (v *TableView) Height(dp float32) *TableView

Height sets the height of the rows' viewport in dp, 320 by default; Fill grows instead.

func (*TableView) LayoutState

func (v *TableView) LayoutState() TableLayout

LayoutState returns a deep snapshot suitable for encoding with encoding/json.

func (*TableView) Len

func (v *TableView) Len() int

func (*TableView) MoveColumn

func (v *TableView) MoveColumn(column, position int)

MoveColumn moves a source column to a display position (including hidden columns). Invalid indexes are ignored. It never moves row data.

func (*TableView) MultiSelect

func (v *TableView) MultiSelect() *TableView

MultiSelect enables additive and range row selection. Value is the active row; SelectedRows reports membership in current display order.

func (*TableView) OnActivate

func (v *TableView) OnActivate(fn func(row int)) *TableView

func (*TableView) OnCellSelectionChange

func (v *TableView) OnCellSelectionChange(fn func([]TableCell)) *TableView

func (*TableView) OnChange

func (v *TableView) OnChange(fn func(row int)) *TableView

func (*TableView) OnColumnMove

func (v *TableView) OnColumnMove(fn func(column, from, to int)) *TableView

OnColumnMove runs after a header drop changes the display order. Column is a source index; from/to are display positions including hidden columns. MoveColumn and SetLayoutState do not invoke it.

func (*TableView) OnColumnSelectionChange

func (v *TableView) OnColumnSelectionChange(fn func([]int)) *TableView

func (*TableView) OnLoadMore

func (v *TableView) OnLoadMore(fn func()) *TableView

OnLoadMore requests another page near the bottom. The callback runs once per delivered dataset and sets Loading before calling fn. Deliver rows and clear Loading through core.Update; SetHasMore(false) marks the final page.

func (*TableView) OnSelectionChange

func (v *TableView) OnSelectionChange(fn func([]int)) *TableView

func (*TableView) Render

func (v *TableView) Render(cx *el.Context) el.Element

func (*TableView) Row

func (v *TableView) Row(i int) []string

Row returns a copy of row i, or nil.

func (*TableView) RowHeight

func (v *TableView) RowHeight(dp float32) *TableView

RowHeight sets uniform row height including the separator. Zero restores 40dp.

func (*TableView) RowMenu

func (v *TableView) RowMenu(build func(row int) *MenuView) *TableView

RowMenu creates a menu for a source row when requested, not on every frame.

func (*TableView) Rows

func (v *TableView) Rows() [][]string

Rows returns a deep copy; use SetRows to replace data and refresh sorting.

func (*TableView) SelectedCells

func (v *TableView) SelectedCells() []TableCell

SelectedCells returns a snapshot in display order, including hidden columns.

func (*TableView) SelectedColumns

func (v *TableView) SelectedColumns() []int

func (*TableView) SelectedRows

func (v *TableView) SelectedRows() []int

func (*TableView) SelectionText

func (v *TableView) SelectionText() string

SelectionText copies visible columns of selected rows as TSV, in current display order. Tabs, newlines and quotes inside values are CSV-escaped.

func (*TableView) SetColumnVisible

func (v *TableView) SetColumnVisible(column int, visible bool)

SetColumnVisible hides or shows a source column without changing its data, sort order, or configured position. All columns may be hidden.

func (*TableView) SetColumnWidth

func (v *TableView) SetColumnWidth(column int, dp float32)

SetColumnWidth changes this table's column width in dp (minimum 40), independently of the ColumnSpec used to construct it. Invalid indexes and non-finite widths are ignored. It does not change sorting or selection.

func (*TableView) SetDisabled

func (v *TableView) SetDisabled(on bool)

func (*TableView) SetFilter

func (v *TableView) SetFilter(match func([]string) bool)

SetFilter filters source rows before sorting. The predicate receives a copy; nil clears filtering. Hidden selections are retained but not copied/exported. Update the predicate via SetFilter when external filter criteria change.

func (*TableView) SetHasMore

func (v *TableView) SetHasMore(more bool)

func (*TableView) SetLayoutState

func (v *TableView) SetLayoutState(state TableLayout) error

SetLayoutState validates the entire snapshot before applying any changes. It does not change sorting, row selection, or invoke user callbacks.

func (*TableView) SetLoadError

func (v *TableView) SetLoadError(message string)

SetLoadError stops loading and exposes a retry action. Errors suppress automatic retries; a user retry invokes OnLoadMore again.

func (*TableView) SetLoading

func (v *TableView) SetLoading(on bool)

SetLoading shows a spinner over the rows while data loads elsewhere; deliver the rows with core.Update, then SetRows and SetLoading(false).

func (*TableView) SetRows

func (v *TableView) SetRows(rows [][]string)

SetRows copies the data, keeping the sort column. The selection is cleared when its index no longer exists.

func (*TableView) SetSelectedCells

func (v *TableView) SetSelectedCells(cells []TableCell)

func (*TableView) SetSelectedColumns

func (v *TableView) SetSelectedColumns(columns []int)

func (*TableView) SetSelectedRows

func (v *TableView) SetSelectedRows(rows []int)

SetSelectedRows replaces row selection without callbacks. Invalid indexes are ignored. In single selection mode only the first valid row is selected.

func (*TableView) SetValue

func (v *TableView) SetValue(i int)

SetValue selects row i (-1 clears) and scrolls it into view, without calling OnChange.

func (*TableView) SortBy

func (v *TableView) SortBy(col int, desc bool)

SortBy sorts by column col, descending if desc; col -1 restores data order.

func (*TableView) Stripe

func (v *TableView) Stripe(on bool) *TableView

func (*TableView) Value

func (v *TableView) Value() int

Value is the selected row, or -1.

func (*TableView) VisibleLen

func (v *TableView) VisibleLen() int

VisibleLen reports the row count after filtering; Len is the source count.

type TabsVariant

type TabsVariant uint8
const (
	TabsUnderline TabsVariant = iota
	TabsPill
	TabsOutline
	TabsSegmented
)

type TabsView

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

TabsView switches between pages. Only the current page renders; each page is a view the app keeps, so its state survives switching. Tab reaches the current tab; ← → move between tabs, Home / End jump. Tabs that do not fit move into a 更多 menu; with Closable each tab has a close button.

func Tabs

func Tabs() *TabsView

func (*TabsView) Add

func (v *TabsView) Add(title string, page el.View) *TabsView

func (*TabsView) AddItem

func (v *TabsView) AddItem(item TabItem) *TabsView

func (*TabsView) Closable

func (v *TabsView) Closable(fn func(index int)) *TabsView

Closable shows a close button on each tab; fn decides what closing means, usually Remove(i).

func (*TabsView) Leading

func (v *TabsView) Leading(view el.View) *TabsView

func (*TabsView) Len

func (v *TabsView) Len() int

Len is the number of tabs.

func (*TabsView) MaxWidth

func (v *TabsView) MaxWidth(dp float32) *TabsView

MaxWidth caps each tab's label area in dp, excluding the close button. Zero removes the cap; negative and non-finite values are ignored.

func (*TabsView) Move

func (v *TabsView) Move(from, to int)

Move preserves the selected page and does not invoke callbacks.

func (*TabsView) OnChange

func (v *TabsView) OnChange(fn func(index int)) *TabsView

func (*TabsView) Remove

func (v *TabsView) Remove(i int)

Remove deletes tab i, keeping the current tab when it remains.

func (*TabsView) Render

func (v *TabsView) Render(cx *el.Context) el.Element

func (*TabsView) Reorderable

func (v *TabsView) Reorderable(fn func(from, to int)) *TabsView

Reorderable enables dragging visible tabs; Move can reorder hidden tabs.

func (*TabsView) ScrollState

func (v *TabsView) ScrollState(cx *el.Context) (offset, viewport, content float32)

ScrollState reports horizontal offset, viewport and content widths in dp.

func (*TabsView) ScrollTo

func (v *TabsView) ScrollTo(i int)

ScrollTo reveals a tab in scrollable mode without selecting it or firing callbacks. It is applied after layout, including when called before the first frame.

func (*TabsView) Scrollable

func (v *TabsView) Scrollable(on bool) *TabsView

Scrollable shows all tabs in a horizontal viewport instead of an overflow menu.

func (*TabsView) SetDisabled

func (v *TabsView) SetDisabled(on bool)

func (*TabsView) SetItem

func (v *TabsView) SetItem(i int, item TabItem)

SetItem changes a tab without replacing its stable identity or firing callbacks.

func (*TabsView) SetItemDisabled

func (v *TabsView) SetItemDisabled(i int, disabled bool)

SetItemDisabled skips this tab in pointer, keyboard, overflow and drag interaction. Disabling the selected tab selects the next enabled tab without OnChange. If all tabs are disabled, the current page remains displayed without a tab stop.

func (*TabsView) SetValue

func (v *TabsView) SetValue(i int)

SetValue shows tab i without calling OnChange.

func (*TabsView) Size

func (v *TabsView) Size(height float32) *TabsView

func (*TabsView) Trailing

func (v *TabsView) Trailing(view el.View) *TabsView

func (*TabsView) Value

func (v *TabsView) Value() int

func (*TabsView) Variant

func (v *TabsView) Variant(variant TabsVariant) *TabsView

Variant selects the tab appearance. Underline is the default.

type TagAppearance

type TagAppearance struct {
	Background, Foreground, Border, SelectedBackground color.NRGBA
}

TagAppearance defines normal, selected and border colors, resolved each frame.

type TagView

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

TagView displays an optional selectable/removable label.

func Tag

func Tag(text string) *TagView

func (*TagView) Appearance

func (v *TagView) Appearance(fn func(TagAppearance) TagAppearance) *TagView

Appearance transforms theme-derived colors each frame. Nil restores them.

func (*TagView) Content

func (v *TagView) Content(content el.View) *TagView

Content replaces the visible text with display-only content; nil restores it. The constructor text remains the accessible name and action label.

func (*TagView) OnChange

func (v *TagView) OnChange(fn func(bool)) *TagView

func (*TagView) OnRemove

func (v *TagView) OnRemove(fn func()) *TagView

func (*TagView) Outline

func (v *TagView) Outline(on bool) *TagView

Outline uses a transparent background until selected.

func (*TagView) Render

func (v *TagView) Render(cx *el.Context) el.Element

func (*TagView) Rounded

func (v *TagView) Rounded(dp float32) *TagView

Rounded sets a corner radius in dp, including zero for square corners.

func (*TagView) Selectable

func (v *TagView) Selectable() *TagView

func (*TagView) SetDisabled

func (v *TagView) SetDisabled(b bool)

func (*TagView) SetText

func (v *TagView) SetText(s string)

func (*TagView) SetValue

func (v *TagView) SetValue(b bool)

func (*TagView) Size

func (v *TagView) Size(dp float32) *TagView

Size sets minimum height in dp; long labels can wrap to additional lines.

func (*TagView) Tone

func (v *TagView) Tone(t Tone) *TagView

func (*TagView) Value

func (v *TagView) Value() bool

type TimeFieldSize

type TimeFieldSize uint8

TimeFieldSize selects coordinated frame, text, icon and segment dimensions.

const (
	TimeFieldSizeMedium TimeFieldSize = iota
	TimeFieldSizeXSmall
	TimeFieldSizeSmall
	TimeFieldSizeLarge
)

type TimeFieldView

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

TimeFieldView edits a time of day as HH:MM. It accepts 9:30, 0930 or 930; Enter or leaving the field normalizes the text, and text that is not a valid time reverts to the last value. ↑ ↓ change it by a minute, PageUp and PageDown by an hour, wrapping around midnight.

func TimeField

func TimeField(label string) *TimeFieldView

func (*TimeFieldView) Error

func (v *TimeFieldView) Error() string

func (*TimeFieldView) FocusID

func (v *TimeFieldView) FocusID() string

func (*TimeFieldView) Hour12

func (v *TimeFieldView) Hour12(on bool) *TimeFieldView

Hour12 overrides the locale's segmented clock format without changing Value.

func (*TimeFieldView) OnChange

func (v *TimeFieldView) OnChange(fn func(time.Duration)) *TimeFieldView

func (*TimeFieldView) Render

func (v *TimeFieldView) Render(cx *el.Context) el.Element

func (*TimeFieldView) Seconds

func (v *TimeFieldView) Seconds() *TimeFieldView

Seconds enables segmented editing with second precision.

func (*TimeFieldView) SegmentKeys

func (v *TimeFieldView) SegmentKeys(on bool) *TimeFieldView

SegmentKeys enables segmented replacement, automatic advance after two valid digits, arrow navigation, deletion reset and independent unit stepping. False keeps draft editing with Enter/blur commit and carry between units.

func (*TimeFieldView) Segmented

func (v *TimeFieldView) Segmented() *TimeFieldView

Segmented enables independently editable hour and minute fields.

func (*TimeFieldView) SetDisabled

func (v *TimeFieldView) SetDisabled(on bool)

func (*TimeFieldView) SetError

func (v *TimeFieldView) SetError(msg string)

func (*TimeFieldView) SetValue

func (v *TimeFieldView) SetValue(d time.Duration)

SetValue sets the time without calling OnChange; it wraps around 24 hours.

func (*TimeFieldView) Size

func (v *TimeFieldView) Size(size TimeFieldSize) *TimeFieldView

Size changes presentation without committing drafts or changing focus.

func (*TimeFieldView) Value

func (v *TimeFieldView) Value() time.Duration

Value is the time since midnight, in minutes or whole seconds with Seconds.

type TitleBarView

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

TitleBarView is a window title bar drawn by the app, for windows opened with window.Options{Frameless: true}. Dragging its empty area moves the window. On macOS the close / minimize / zoom buttons sit on the left as colored circles; elsewhere minimize / maximize / close sit on the right. Leading and Trailing add the app's own controls (a search box, buttons).

In a window with a system title bar it draws only the title and the app's controls, as a header.

func TitleBar

func TitleBar(title string) *TitleBarView

func (*TitleBarView) Leading

func (v *TitleBarView) Leading(views ...el.View) *TitleBarView

Leading adds views after the window buttons on the left.

func (*TitleBarView) Render

func (v *TitleBarView) Render(cx *el.Context) el.Element

func (*TitleBarView) SetTitle

func (v *TitleBarView) SetTitle(s string)

func (*TitleBarView) Trailing

func (v *TitleBarView) Trailing(views ...el.View) *TitleBarView

Trailing adds views at the right, before the window buttons off macOS.

type ToggleGroupView

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

ToggleGroupView is a row of toggles: one choice at a time (the default) or, with Multiple, any number. Value lists the pressed options in option order.

func ToggleGroup

func ToggleGroup(options ...string) *ToggleGroupView

func (*ToggleGroupView) Gap

Gap sets finite nonnegative spacing in dp. Segmented defaults to zero; ordinary groups default to theme.SpaceXs. ResetGap restores that default.

func (*ToggleGroupView) Item

func (v *ToggleGroupView) Item(option string, toggle *ToggleView) *ToggleGroupView

Item snapshots a Toggle's presentation for an existing option. The group owns selected state, IDs and change callbacks; the source Value and OnChange are ignored. Explicit item Variant/Size override the group, unset ones inherit it. nil clears the override. Unknown options are ignored. Reapply Item after edits.

func (*ToggleGroupView) Multiple

func (v *ToggleGroupView) Multiple() *ToggleGroupView

func (*ToggleGroupView) OnChange

func (v *ToggleGroupView) OnChange(fn func(values []string)) *ToggleGroupView

func (*ToggleGroupView) Render

func (v *ToggleGroupView) Render(cx *el.Context) el.Element

func (*ToggleGroupView) ResetGap

func (v *ToggleGroupView) ResetGap() *ToggleGroupView

func (*ToggleGroupView) Segmented

func (v *ToggleGroupView) Segmented(on bool) *ToggleGroupView

Segmented connects adjacent buttons. Explicit positive Gap separates them again. Selection behavior is unchanged: single by default, multiple with Multiple.

func (*ToggleGroupView) SetDisabled

func (v *ToggleGroupView) SetDisabled(on bool)

func (*ToggleGroupView) SetValue

func (v *ToggleGroupView) SetValue(values ...string)

SetValue presses exactly these options without calling OnChange; a single group keeps only the first.

func (*ToggleGroupView) Size

func (*ToggleGroupView) Value

func (v *ToggleGroupView) Value() []string

Value returns a copy of the pressed options.

func (*ToggleGroupView) Variant

func (v *ToggleGroupView) Variant(variant ToggleVariant) *ToggleGroupView

type ToggleSize

type ToggleSize uint8

ToggleSize selects coordinated button height, text, icon and padding.

const (
	ToggleSizeMedium ToggleSize = iota
	ToggleSizeXSmall
	ToggleSizeSmall
	ToggleSizeLarge
)

type ToggleVariant

type ToggleVariant uint8

ToggleVariant selects the unpressed surface. The default preserves the original filled outline.

const (
	ToggleDefault ToggleVariant = iota
	ToggleGhost
	ToggleOutline
)

type ToggleView

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

ToggleView is a button that stays pressed, e.g. bold in a toolbar.

func Toggle

func Toggle(text string, on bool) *ToggleView

func (*ToggleView) Icon

func (v *ToggleView) Icon(name IconName) *ToggleView

func (*ToggleView) OnChange

func (v *ToggleView) OnChange(fn func(bool)) *ToggleView

func (*ToggleView) Render

func (v *ToggleView) Render(cx *el.Context) el.Element

func (*ToggleView) SetDisabled

func (v *ToggleView) SetDisabled(on bool)

func (*ToggleView) SetValue

func (v *ToggleView) SetValue(on bool)

func (*ToggleView) Size

func (v *ToggleView) Size(size ToggleSize) *ToggleView

func (*ToggleView) Value

func (v *ToggleView) Value() bool

func (*ToggleView) Variant

func (v *ToggleView) Variant(variant ToggleVariant) *ToggleView

type Tone

type Tone uint8

Tone selects a semantic status color, resolved each time a view renders.

const (
	ToneNeutral Tone = iota
	ToneInfo
	ToneSuccess
	ToneWarning
	ToneDanger
)

type ToolbarItem

type ToolbarItem struct {
	// Content inserts an interactive view at this position. It takes precedence
	// over Action/Icon, but not Separator. Its children own their Tab stops.
	Content el.View
	// Width is the custom group's width in dp; invalid/zero values use 160dp.
	Width float32
	// OverflowContent optionally replaces Content in the overflow dialog.
	OverflowContent el.View
	Label           string
	Icon            IconName
	IconOnly        bool // with an Icon, the label becomes the tooltip
	Action          func()
	Disabled        bool
	Separator       bool
}

ToolbarItem is a command, separator, or custom group.

type ToolbarView

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

ToolbarView is a row of commands. Buttons that do not fit move into a 更多 menu at the end. Commands share one Tab stop: ← → Home End move between buttons. Custom groups retain their children's independent Tab stops.

func Toolbar

func Toolbar(items ...ToolbarItem) *ToolbarView

func (*ToolbarView) Items

func (v *ToolbarView) Items() []ToolbarItem

func (*ToolbarView) Leading

func (v *ToolbarView) Leading(view el.View) *ToolbarView

func (*ToolbarView) Render

func (v *ToolbarView) Render(cx *el.Context) el.Element

func (*ToolbarView) SetDisabled

func (v *ToolbarView) SetDisabled(on bool)

func (*ToolbarView) SetItemDisabled

func (v *ToolbarView) SetItemDisabled(i int, on bool)

func (*ToolbarView) SetItems

func (v *ToolbarView) SetItems(items ...ToolbarItem)

SetItems replaces the buttons.

func (*ToolbarView) Size

func (v *ToolbarView) Size(height float32) *ToolbarView

func (*ToolbarView) Trailing

func (v *ToolbarView) Trailing(view el.View) *ToolbarView

type TooltipView

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

TooltipView shows a short hint next to a view: after TooltipDelay of hovering, or at once when keyboard focus is inside the view. Moving away or pressing Esc hides it. The hint never takes focus or clicks.

func WithTooltip

func WithTooltip(target el.View, text string) *TooltipView

WithTooltip wraps target with a hint.

func (*TooltipView) Action

func (v *TooltipView) Action(action string) *TooltipView

Action displays the first current key binding for an action; it does not register or execute the action. Unbound actions show no key label.

func (*TooltipView) Content

func (v *TooltipView) Content(content el.View) *TooltipView

Content replaces the displayed text with a rich, noninteractive view. The text supplied to WithTooltip/SetText remains the accessible name. Nil restores text.

func (*TooltipView) Offset

func (v *TooltipView) Offset(dp float32) *TooltipView

func (*TooltipView) Placement

func (v *TooltipView) Placement(side el.Side, align el.Align) *TooltipView

func (*TooltipView) Render

func (v *TooltipView) Render(cx *el.Context) el.Element

func (*TooltipView) SetDisabled

func (v *TooltipView) SetDisabled(on bool)

func (*TooltipView) SetText

func (v *TooltipView) SetText(s string)

type TreeItemContext

type TreeItemContext struct {
	ID, Label                                          string
	Index, Depth                                       int
	Expanded, Selected, Disabled, HasChildren, Loading bool
	Error                                              string
	Toggle, Retry                                      func()
}

TreeItemContext describes one visible row. Actions are for UI event handlers, not render callbacks. Disabled describes this node/the tree; ancestor-disabled containers are enforced by the outer element and actions at event time.

type TreeNode

type TreeNode struct {
	ID, Label string
	Children  []*TreeNode
	Disabled  bool
	// Lazy marks a branch whose children have not yet been loaded.
	Lazy bool
}

TreeNode is one node of a Tree. IDs must be unique within the tree.

type TreeView

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

TreeView shows nested nodes that expand and collapse. With focus: ↑ ↓ move, → expands or enters the first child, ← collapses or goes to the parent, Home / End jump, Enter activates. Only visible rows are built.

func Tree

func Tree(roots ...*TreeNode) *TreeView

func (*TreeView) Expanded

func (v *TreeView) Expanded(id string) bool

func (*TreeView) Fill

func (v *TreeView) Fill() *TreeView

func (*TreeView) Height

func (v *TreeView) Height(dp float32) *TreeView

func (*TreeView) Indent

func (v *TreeView) Indent(dp float32) *TreeView

Indent sets the additional dp indent per level. Zero removes nesting indent.

func (*TreeView) MoveNode

func (v *TreeView) MoveNode(id, parent string, index int) error

MoveNode moves a subtree into parent ("" means roots). index is its final sibling position; len(target) means append. Invalid moves leave the tree intact. Programmatic moves do not invoke callbacks.

func (*TreeView) MultiSelect

func (v *TreeView) MultiSelect() *TreeView

func (*TreeView) Node

func (v *TreeView) Node(id string) *TreeNode

Node returns a deep snapshot of a node; nil means no such ID.

func (*TreeView) NodeError

func (v *TreeView) NodeError(id string) string

func (*TreeView) NodeLoading

func (v *TreeView) NodeLoading(id string) bool

NodeLoading and NodeError expose per-node loading state for custom rows.

func (*TreeView) OnActivate

func (v *TreeView) OnActivate(fn func(id string)) *TreeView

func (*TreeView) OnChange

func (v *TreeView) OnChange(fn func(id string)) *TreeView

func (*TreeView) OnExpand

func (v *TreeView) OnExpand(fn func(string, bool)) *TreeView

OnExpand observes user expansion/collapse after internal state changes. SetExpanded and automatic ancestor expansion are silent.

func (*TreeView) OnLoad

func (v *TreeView) OnLoad(fn func(string, uint64)) *TreeView

OnLoad supplies lazy children. Deliver asynchronous results on the UI thread using core.Update and SetChildResults/SetChildError. Replacing the provider invalidates outstanding requests; explicitly reopen or ReloadNode to retry.

func (*TreeView) OnSelectionChange

func (v *TreeView) OnSelectionChange(fn func([]string)) *TreeView

func (*TreeView) Plain

func (v *TreeView) Plain() *TreeView

Plain drops the frame and background, like ListView.Plain.

func (*TreeView) ReloadNode

func (v *TreeView) ReloadNode(id string) bool

ReloadNode starts a new request for an expanded enabled node; earlier results for it become stale. Existing children remain visible until replaced.

func (*TreeView) Render

func (v *TreeView) Render(cx *el.Context) el.Element

func (*TreeView) RenderItem

func (v *TreeView) RenderItem(fn func(TreeItemContext) el.View) *TreeView

RenderItem replaces the content after the expand control. Nil callback/content uses the default label. Indentation, selection and disabled semantics remain on the row; child buttons operate independently. Reuse stateful child Views.

func (*TreeView) Reorderable

func (v *TreeView) Reorderable(fn func(id, parent string, index int)) *TreeView

func (*TreeView) Roots

func (v *TreeView) Roots() []*TreeNode

Roots returns an owned snapshot for persistence after a move.

func (*TreeView) RowHeight

func (v *TreeView) RowHeight(dp float32) *TreeView

RowHeight sets the virtual row height in dp (minimum 20). Zero restores 28. Use enough height for custom content; rows are uniformly sized.

func (*TreeView) ScrollTo

func (v *TreeView) ScrollTo(cx *el.Context, id string) bool

ScrollTo reveals an existing node by ID, expanding its ancestors without changing selection or sending selection/expansion notifications.

func (*TreeView) SelectedIDs

func (v *TreeView) SelectedIDs() []string

SelectedIDs includes collapsed selections in tree order, as a fresh snapshot.

func (*TreeView) SetChildError

func (v *TreeView) SetChildError(id string, token uint64, message string) bool

SetChildError completes the current request with a retryable error.

func (*TreeView) SetChildResults

func (v *TreeView) SetChildResults(id string, token uint64, children ...*TreeNode) (bool, error)

SetChildResults rejects stale, collapsed, removed or disabled requests. A valid token with invalid children returns an error without changing data.

func (*TreeView) SetChildren

func (v *TreeView) SetChildren(id string, children ...*TreeNode) error

SetChildren atomically replaces one node's children, retaining other branches and surviving selections/expansion. Invalid IDs/cycles leave the tree intact. Applied nodes are deep-copied. An empty result turns a Lazy node into a leaf. Pending requests for this subtree are invalidated, not unrelated requests.

func (*TreeView) SetDisabled

func (v *TreeView) SetDisabled(on bool)

func (*TreeView) SetExpanded

func (v *TreeView) SetExpanded(id string, open bool)

func (*TreeView) SetNodeDisabled

func (v *TreeView) SetNodeDisabled(id string, on bool)

func (*TreeView) SetNodeLabel

func (v *TreeView) SetNodeLabel(id, label string) bool

SetNodeLabel updates a label without replacing children or selection.

func (*TreeView) SetRoots

func (v *TreeView) SetRoots(roots ...*TreeNode)

SetRoots deep-copies the nodes and preserves selection/expansion by ID. Nil nodes are skipped. Empty or duplicate IDs (including cycles) panic before modifying the tree. Removed selections and expansion entries are discarded.

func (*TreeView) SetSelectedIDs

func (v *TreeView) SetSelectedIDs(ids []string)

func (*TreeView) SetValue

func (v *TreeView) SetValue(id string)

SetValue selects a node without calling OnChange and expands its ancestors so it shows.

func (*TreeView) Value

func (v *TreeView) Value() string

Value is the selected node's ID, or "".

type Validatable

type Validatable interface {
	el.View
	SetError(msg string)
	FocusID() string
}

Validatable is a control that can show a validation error and be focused: Input, TextArea, Select, NumberInput, OtpInput, TimeField, Combobox and DatePicker.

type VariableListView

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

VariableListView virtualizes naturally sized rows. Keys identify data across insertion and reordering; the caller keeps row data and calls SetKeys when its order changes. Visible rows are measured after layout, with estimates used for rows that have not been visited. Heights and prefix sums are cached.

func VariableList

func VariableList(keys []string, estimate float32, row func(*el.Context, int) el.Element) *VariableListView

VariableList makes a variable-height list. Keys must be unique and nonempty; invalid keys panic before changing the list. estimate is a positive row height in dp, used only until a row is measured.

func (*VariableListView) Count

func (v *VariableListView) Count() int

func (*VariableListView) Fill

func (*VariableListView) Height

func (v *VariableListView) Height(dp float32) *VariableListView

func (*VariableListView) Horizontal

func (v *VariableListView) Horizontal(on bool) *VariableListView

Horizontal switches the virtualization axis, keeping the leading stable key and discarding measurements from the old axis. Pending reveals are retained.

func (*VariableListView) ID

func (v *VariableListView) ID() string

func (*VariableListView) Invalidate

func (v *VariableListView) Invalidate(keys ...string)

Invalidate drops cached heights after offscreen data or font changes. With no keys it invalidates all rows. Visible size changes are detected each frame.

func (*VariableListView) Render

func (v *VariableListView) Render(cx *el.Context) el.Element

func (*VariableListView) ScrollTo

func (v *VariableListView) ScrollTo(cx *el.Context, i int)

ScrollTo minimally reveals row i, retrying after measurement or first mount.

func (*VariableListView) ScrollToAlign added in v0.0.5

func (v *VariableListView) ScrollToAlign(cx *el.Context, i int, align ScrollAlign)

ScrollToAlign scrolls row i to the top, center or bottom of the viewport, as far as the content allows; rows not yet measured use their estimate and settle once measured.

func (*VariableListView) ScrollToEnd

func (v *VariableListView) ScrollToEnd(cx *el.Context)

ScrollToEnd reveals the final stable key on the current axis.

func (*VariableListView) ScrollToKey

func (v *VariableListView) ScrollToKey(cx *el.Context, key string)

ScrollToKey minimally reveals the row with key, independent of its current index. Missing keys are ignored, leaving any pending reveal unchanged.

func (*VariableListView) ScrollToKeyAlign added in v0.0.5

func (v *VariableListView) ScrollToKeyAlign(cx *el.Context, key string, align ScrollAlign)

ScrollToKeyAlign is ScrollToAlign by stable key.

func (*VariableListView) SetDisabled

func (v *VariableListView) SetDisabled(on bool)

func (*VariableListView) SetKeys

func (v *VariableListView) SetKeys(keys []string)

SetKeys copies the new order, retains measurements for surviving keys, and keeps the current first visible row at the same screen position. If that row is removed, the row at its old index becomes the new anchor.

func (*VariableListView) Width

Width sets viewport width. In horizontal mode it replaces Fill; in vertical mode it constrains the cross axis. Horizontal default width is 320dp.

type VirtualListView

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

VirtualListView scrolls through many rows of one height, building only the rows near the viewport, so a list of 100 000 rows costs what 30 do.

kit.VirtualList(len(logs), 24, func(cx *el.Context, i int) el.Element { return el.Text(logs[i]) })

func VirtualList

func VirtualList(count int, rowHeight float32, row func(cx *el.Context, i int) el.Element) *VirtualListView

func (*VirtualListView) Count

func (v *VirtualListView) Count() int

func (*VirtualListView) Fill

func (v *VirtualListView) Fill() *VirtualListView

Fill makes the viewport grow to the space its parent gives it instead.

func (*VirtualListView) Height

func (v *VirtualListView) Height(dp float32) *VirtualListView

Height sets the viewport height in dp, 320 by default.

func (*VirtualListView) Horizontal

func (v *VirtualListView) Horizontal(on bool) *VirtualListView

Horizontal switches the virtualization axis. Item size is the constructor's rowHeight on either axis. It preserves the current leading item's offset; a pending ScrollTo takes precedence. False restores vertical rendering.

func (*VirtualListView) ID

func (v *VirtualListView) ID() string

ID is the scroll container's element ID.

func (*VirtualListView) ItemKey

func (v *VirtualListView) ItemKey(fn func(int) string) *VirtualListView

ItemKey uses stable, unique, nonempty data keys for row element identity. The default is the row index. The callback is called only for built rows.

func (*VirtualListView) Render

func (v *VirtualListView) Render(cx *el.Context) el.Element

func (*VirtualListView) ScrollTo

func (v *VirtualListView) ScrollTo(cx *el.Context, i int)

ScrollTo scrolls as little as needed to show row i; call it from Render or a callback. A list that is not on screen yet (another tab) scrolls when it first shows.

func (*VirtualListView) ScrollToAlign added in v0.0.5

func (v *VirtualListView) ScrollToAlign(cx *el.Context, i int, align ScrollAlign)

ScrollToAlign scrolls row i to the top, center or bottom of the viewport, as far as the content allows, or minimally with ScrollNearest.

func (*VirtualListView) ScrollToEnd

func (v *VirtualListView) ScrollToEnd(cx *el.Context)

ScrollToEnd reveals the last item on the current axis.

func (*VirtualListView) SetCount

func (v *VirtualListView) SetCount(n int)

func (*VirtualListView) Width

func (v *VirtualListView) Width(dp float32) *VirtualListView

Width sets viewport width in dp. In horizontal mode it replaces Fill; in vertical mode it constrains the cross axis. Horizontal default width is 320.

Source Files

Jump to

Keyboard shortcuts

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