Documentation
¶
Overview ¶
Package kvitui is the Kvit component library for desktop applications drawn with unison: the components that give every Kvit app the same look and behaviour, built from the design values in the tokens package.
Index ¶
- Constants
- Variables
- func AccessText(s string) (plain string, key rune, at int)
- func At(ui *UI, x, y, height Measure, child unison.Paneler) *unison.Panel
- func AtLeast(ui *UI, height Measure, l unison.Layout) unison.Layout
- func AtMost(ui *UI, height Measure, l unison.Layout) unison.Layout
- func Caption(ui *UI, words string, ink Ink) []text.Span
- func Centred[T unison.Paneler](p T) T
- func Color(c palette.Color) unison.Color
- func Column(ui *UI, gap Measure, children ...unison.Paneler) *unison.Panel
- func DefaultSettingsPath(app string) string
- func DialogButtonOrder(ui *UI, safe unison.Paneler, actions ...unison.Paneler) []unison.Paneler
- func DrawSurface(gc *unison.Canvas, ui *UI, r geom.Rect, radius Measure)
- func FillLayout() unison.Layout
- func FixedWidth[T unison.Paneler](p T, w Measure) T
- func FullWidth[T unison.Paneler](p T) T
- func Grow[T unison.Paneler](p T) T
- func GrowShare[T unison.Paneler](p T, share float32) T
- func Height(ui *UI, h Measure, child unison.Paneler) *unison.Panel
- func Insets(ui *UI, top, left, bottom, right Measure) unison.Border
- func InsetsOf(target *unison.Panel) geom.Insets
- func KeepsFindKey(p unison.Paneler, keys ...Shortcut)
- func Left[T unison.Paneler](p T) T
- func Line(ui *UI, gap Measure, children ...unison.Paneler) *unison.Panel
- func NewAboutSection(ui *UI, a About) *unison.Panel
- func NewRowLayout(ui *UI, gap Measure) unison.Layout
- func NewScrollBar(ui *UI, horizontal bool) *unison.ScrollBar
- func OpensPopup(p unison.Paneler)
- func OwnWidth[T unison.Paneler](p T) T
- func OwnWidthEnd[T unison.Paneler](p T) T
- func Padding(ui *UI, m Measure) unison.Border
- func PlaceBelow(ui *UI, anchor unison.Paneler) func(bounds geom.Rect, size geom.Size) geom.Rect
- func PlaceBeside(ui *UI, anchor unison.Paneler) func(bounds geom.Rect, size geom.Size) geom.Rect
- func PlaceCentred(anchor unison.Paneler) func(bounds geom.Rect, size geom.Size) geom.Rect
- func PlaceOver(anchor unison.Paneler) func(bounds geom.Rect, size geom.Size) geom.Rect
- func PlainMenuText(s string) string
- func PointerOn(p *unison.Panel, where geom.Point, inside bool) bool
- func PointerOver(p *unison.Panel, where geom.Point, inside bool) bool
- func Relayout(p unison.Paneler, children bool)
- func RoveStep[T unison.Paneler](members []T, from T, key unison.KeyCode, vertical, wrap bool) (T, bool)
- func Row(ui *UI, gap Measure, children ...unison.Paneler) *unison.Panel
- func ShortcutTextIn(f Form, s Shortcut) string
- func ShownIn(target *unison.Panel) []*unison.Panel
- func Sized(ui *UI, w, h Measure, child unison.Paneler) *unison.Panel
- func Stack(ui *UI, gap Measure, children ...unison.Paneler) *unison.Panel
- func TextColor(c palette.Color) text.Color
- func TitleCase(s string) string
- func Width(ui *UI, w Measure, child unison.Paneler) *unison.Panel
- func WithPane(ui *UI, under unison.Paneler, pane *Pane) *unison.Panel
- type About
- type AboutLink
- type AccessKey
- type Badge
- type BadgeTone
- type Bar
- type BarMenu
- type BeforeAfter
- type BenchmarkTableModel
- func (b *BenchmarkTableModel) AllShownChecked() bool
- func (b *BenchmarkTableModel) Cell(row, column int) CellValue
- func (b *BenchmarkTableModel) Columns() []TableColumn
- func (b *BenchmarkTableModel) Filter() string
- func (b *BenchmarkTableModel) Rows() int
- func (b *BenchmarkTableModel) SetChecked(row int, checked bool)
- func (b *BenchmarkTableModel) SetEveryShownChecked(checked bool)
- func (b *BenchmarkTableModel) SetFilter(text string)
- func (b *BenchmarkTableModel) SomeShownChecked() bool
- func (b *BenchmarkTableModel) Total() int
- type Breadcrumb
- type Button
- func (c *Button) Focus()
- func (c *Button) Hovered() bool
- func (c *Button) KeyboardFocus() bool
- func (b *Button) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Button) Pressed() bool
- func (b *Button) ProvideAccessibility(bl *unison.AccessibilityBuilder)
- func (c *Button) SetTooltip(words func() string)
- func (c *Button) TooltipWords() string
- func (b *Button) Words() string
- type ButtonForm
- type Card
- func (c *Card) Focus()
- func (c *Card) Hovered() bool
- func (c *Card) KeyboardFocus() bool
- func (c *Card) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Card) Pressed() bool
- func (c *Card) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Card) SetTooltip(words func() string)
- func (c *Card) TooltipWords() string
- type Cell
- type CellKind
- type CellMark
- type CellValue
- type Check
- func (c *Check) Focus()
- func (c *Check) Hovered() bool
- func (c *Check) KeyboardFocus() bool
- func (c *Check) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Check) Pressed() bool
- func (c *Check) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Check) SetTooltip(words func() string)
- func (c *Check) TooltipWords() string
- type Chip
- type ChipButton
- func (c *ChipButton) Focus()
- func (c *ChipButton) Hovered() bool
- func (c *ChipButton) KeyboardFocus() bool
- func (c *ChipButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *ChipButton) Pressed() bool
- func (c *ChipButton) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *ChipButton) SetTooltip(words func() string)
- func (c *ChipButton) TooltipWords() string
- type ChoiceButton
- type Command
- func (c *Command) CanRun() bool
- func (c *Command) Do() bool
- func (c *Command) FirstShortcut(f Form) Shortcut
- func (c *Command) IsChecked() bool
- func (c *Command) Label(u *UI) string
- func (c *Command) Plain(u *UI) string
- func (c *Command) Shortcuts(f Form) []Shortcut
- func (c *Command) SymbolName() string
- type ConfirmInPlace
- type CountPart
- type Crumb
- type Delta
- type Dialog
- func (d *Dialog) Accept()
- func (d *Dialog) ApplyButton() *Button
- func (d *Dialog) ButtonWords() []string
- func (d *Dialog) Buttons() []*Button
- func (d *Dialog) CancelButton() *Button
- func (d *Dialog) Close()
- func (d *Dialog) ConfirmButton() *Button
- func (d *Dialog) Done()
- func (d *Dialog) MarkChanged()
- func (d *Dialog) MoveTo(x, y Measure)
- func (d *Dialog) Open(window *Window)
- func (d *Dialog) OtherButton() *Button
- func (d *Dialog) Position() (x, y int, placed bool)
- func (d *Dialog) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (d *Dialog) SafeButton() bool
- func (d *Dialog) Suppressed() bool
- type DialogKind
- type Direction
- type Disclosure
- type Distribution
- type Divider
- type Dot
- type DualList
- type EmptyForm
- type EmptyState
- type Field
- type Figure
- type FigureBlock
- type FloatingView
- type FlowLayout
- type Form
- type FormRow
- type Gauge
- type Header
- type HelpLink
- type Hint
- type History
- type HoverCard
- type Icon
- type IconButton
- func (c *IconButton) Focus()
- func (c *IconButton) Hovered() bool
- func (c *IconButton) KeyboardFocus() bool
- func (b *IconButton) Name() string
- func (b *IconButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *IconButton) Pressed() bool
- func (b *IconButton) ProvideAccessibility(bl *unison.AccessibilityBuilder)
- func (c *IconButton) SetTooltip(words func() string)
- func (c *IconButton) TooltipWords() string
- type IconButtonForm
- type Ink
- type KeyFocus
- type Label
- type LineData
- type LineLayout
- type Link
- func (c *Link) Focus()
- func (c *Link) Hovered() bool
- func (c *Link) KeyboardFocus() bool
- func (l *Link) Lead() unison.Paneler
- func (l *Link) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Link) Pressed() bool
- func (l *Link) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (l *Link) SetLead(p unison.Paneler)
- func (c *Link) SetTooltip(words func() string)
- func (c *Link) TooltipWords() string
- type ListRow
- func (c *ListRow) Focus()
- func (c *ListRow) Hovered() bool
- func (c *ListRow) KeyboardFocus() bool
- func (r *ListRow) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *ListRow) Pressed() bool
- func (r *ListRow) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *ListRow) SetTooltip(words func() string)
- func (c *ListRow) TooltipWords() string
- type Look
- type Measure
- type MenuBar
- func (b *MenuBar) Add(cmds ...*Command) *MenuBar
- func (b *MenuBar) AddMenu(title string, items ...MenuItem) *MenuBar
- func (b *MenuBar) AddTo(menu StdMenu, items ...MenuItem) *MenuBar
- func (b *MenuBar) Commands() []*Command
- func (b *MenuBar) Menus() []BarMenu
- func (b *MenuBar) OpenMenu(i int)
- func (b *MenuBar) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (b *MenuBar) ProvideAccessibility(bl *unison.AccessibilityBuilder)
- type MenuButton
- func (c *MenuButton) Focus()
- func (c *MenuButton) Hovered() bool
- func (c *MenuButton) KeyboardFocus() bool
- func (b *MenuButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *MenuButton) Pressed() bool
- func (b *MenuButton) ProvideAccessibility(bl *unison.AccessibilityBuilder)
- func (c *MenuButton) SetTooltip(words func() string)
- func (c *MenuButton) TooltipWords() string
- type MenuItem
- type ModalPress
- type Mods
- type MoneyField
- type Mover
- type NetFlow
- type Notice
- type NumberField
- type Option
- type Options
- type OwnSizeLayout
- type Pane
- type Panel
- type PhonePages
- type PhoneSettings
- type Pip
- type Popover
- func (p *Popover) Close()
- func (p *Popover) Open(anchor unison.Paneler, place func(bounds geom.Rect, size geom.Size) geom.Rect)
- func (p *Popover) OpenModal(anchor unison.Paneler, place func(bounds geom.Rect, size geom.Size) geom.Rect)
- func (p *Popover) Opened() bool
- func (p *Popover) ProvideAccessibility(b *unison.AccessibilityBuilder)
- type Popup
- type Progress
- type RadioGroup
- type RadioOption
- type Region
- type RowForm
- type RowPress
- type SearchField
- type SectionHeading
- func (h *SectionHeading) CountPhrase() string
- func (c *SectionHeading) Focus()
- func (c *SectionHeading) Hovered() bool
- func (c *SectionHeading) KeyboardFocus() bool
- func (h *SectionHeading) Lead() unison.Paneler
- func (h *SectionHeading) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *SectionHeading) Pressed() bool
- func (h *SectionHeading) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (h *SectionHeading) SetLead(p unison.Paneler)
- func (c *SectionHeading) SetTooltip(words func() string)
- func (c *SectionHeading) TooltipWords() string
- type Segment
- type Segmented
- type Select
- func (s *Select) Choose(value string)
- func (c *Select) Focus()
- func (c *Select) Hovered() bool
- func (c *Select) KeyboardFocus() bool
- func (s *Select) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Select) Pressed() bool
- func (s *Select) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Select) SetTooltip(words func() string)
- func (c *Select) TooltipWords() string
- type SettingRow
- type SettingsPane
- type SettingsPanes
- type SettingsWindow
- type Shape
- type Shortcut
- type ShownMenu
- type Sidebar
- type SidebarHeading
- type SidebarItem
- func (it *SidebarItem) Add(places ...*SidebarItem)
- func (it *SidebarItem) Clear()
- func (it *SidebarItem) Depth() int
- func (c *SidebarItem) Focus()
- func (c *SidebarItem) Hovered() bool
- func (it *SidebarItem) Items() []*SidebarItem
- func (c *SidebarItem) KeyboardFocus() bool
- func (it *SidebarItem) Lead() unison.Paneler
- func (it *SidebarItem) Name() string
- func (it *SidebarItem) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *SidebarItem) Pressed() bool
- func (it *SidebarItem) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (it *SidebarItem) SetExpanded(open bool)
- func (it *SidebarItem) SetLead(p unison.Paneler)
- func (c *SidebarItem) SetTooltip(words func() string)
- func (c *SidebarItem) TooltipWords() string
- func (it *SidebarItem) Within() *SidebarItem
- type Signal
- type Slider
- func (c *Slider) Focus()
- func (c *Slider) Hovered() bool
- func (c *Slider) KeyboardFocus() bool
- func (s *Slider) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Slider) Pressed() bool
- func (s *Slider) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Slider) SetTooltip(words func() string)
- func (c *Slider) TooltipWords() string
- type SlimRow
- type Slug
- type Spark
- type SplitButton
- type SplitView
- type Spotlight
- type StackData
- type StackLayout
- type StackedBar
- type StatTile
- type StatusBar
- type StatusFact
- type StatusGroup
- type StdCommand
- type StdMenu
- type Stepper
- type Suggestion
- type Switch
- func (c *Switch) Focus()
- func (c *Switch) Hovered() bool
- func (c *Switch) KeyboardFocus() bool
- func (s *Switch) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Switch) Pressed() bool
- func (s *Switch) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Switch) SetTooltip(words func() string)
- func (c *Switch) TooltipWords() string
- type Tab
- func (c *Tab) Focus()
- func (c *Tab) Hovered() bool
- func (c *Tab) KeyboardFocus() bool
- func (t *Tab) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (c *Tab) Pressed() bool
- func (t *Tab) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (c *Tab) SetTooltip(words func() string)
- func (c *Tab) TooltipWords() string
- type Table
- func (t *Table) CopySelection() string
- func (t *Table) CurrentRow() int
- func (t *Table) FocusRow(row int)
- func (t *Table) HideColumn(column int)
- func (t *Table) IsRowSelected(row int) bool
- func (t *Table) MoveColumnBy(column, by int)
- func (t *Table) Position() (x, y float32)
- func (t *Table) Refresh()
- func (t *Table) Reset()
- func (t *Table) ResizeColumnBy(column int, pixels float32)
- func (t *Table) RowCount() int
- func (t *Table) ScrollTo(x, y float32)
- func (t *Table) SelectedRows() []int
- func (t *Table) SortBy(column int, ascending bool)
- type TableColumn
- type TableModel
- type TableRowNamer
- type Tag
- type TextArea
- type TextFit
- type Timeline
- type TimelineEntry
- type Tip
- type TipFocus
- type Toast
- type Tone
- type ToolGroup
- type Toolbar
- func (t *Toolbar) Add(group ToolGroup, cmds ...*Command) *Toolbar
- func (t *Toolbar) AddMenu(group ToolGroup, name, symbol string, items ...MenuItem) *Toolbar
- func (t *Toolbar) Commands() []*Command
- func (t *Toolbar) InMore() []*Command
- func (t *Toolbar) ProvideAccessibility(b *unison.AccessibilityBuilder)
- type Tooltip
- type Tree
- func (t *Tree) Current() []int
- func (t *Tree) ExpandTo(depth int)
- func (t *Tree) IsExpanded(path []int) bool
- func (t *Tree) PerformAccessibilityAction(req accessibility.ActionRequest) bool
- func (t *Tree) ProvideAccessibility(b *unison.AccessibilityBuilder)
- func (t *Tree) Refresh()
- func (t *Tree) SetExpanded(path []int, open bool)
- type TreeModel
- type TreeNode
- type TreeNodes
- type Trend
- type TypeAhead
- type TypeRole
- type UI
- func (u *UI) Chrome(size int, weight int, color palette.Color) text.Style
- func (u *UI) CommandCase(s string) string
- func (u *UI) CountPhrase(n int, singular, plural string) string
- func (u *UI) DecimalSeparator() string
- func (u *UI) Form() Form
- func (u *UI) Icon(size int, color palette.Color) text.Style
- func (u *UI) KeyTurn() bool
- func (u *UI) Look() Look
- func (u *UI) Mac() bool
- func (u *UI) MenuLines(items []MenuItem, context bool) []MenuItem
- func (u *UI) Mono(size int, color palette.Color) text.Style
- func (u *UI) Notify(t *platform.Tray, n platform.Notification) bool
- func (u *UI) Number(n int) string
- func (u *UI) OnChanged(fn func())
- func (u *UI) OnChangedWhile(alive func() bool, fn func())
- func (u *UI) OnPointer(w *unison.Window, owner *unison.Panel, f func(where geom.Point, inside bool))
- func (u *UI) Refresh()
- func (u *UI) ResetTips()
- func (u *UI) SetContextMenu(p unison.Paneler, menu func(where geom.Point) (title string, items []MenuItem))
- func (u *UI) SetForm(f Form)
- func (u *UI) SetLook(l Look)
- func (u *UI) ShortcutText(s Shortcut) string
- func (u *UI) ShowMenu(anchor unison.Paneler, title string, items []MenuItem) (closeMenu func())
- func (u *UI) ShowMenuAt(owner unison.Paneler, part geom.Rect, title string, items []MenuItem) (closeMenu func())
- func (u *UI) ShowTooltip(anchor unison.Paneler, words string) (hide func())
- func (u *UI) Size(r TypeRole) int
- func (u *UI) StdName(s StdCommand) string
- func (u *UI) TopicURL(topic string) string
- func (u *UI) WatchKeys(w *unison.Window)
- func (u *UI) WindowOf(p unison.Paneler) *Window
- type UndoStack
- func (s *UndoStack) Add(name string, undo, redo func())
- func (s *UndoStack) CanRedo() bool
- func (s *UndoStack) CanUndo() bool
- func (s *UndoStack) Clear()
- func (s *UndoStack) Commands() (undo, redo *Command)
- func (s *UndoStack) Confirm(words string) *ConfirmInPlace
- func (s *UndoStack) Redo()
- func (s *UndoStack) RedoName() string
- func (s *UndoStack) Toast(words string) *Toast
- func (s *UndoStack) Undo()
- func (s *UndoStack) UndoName() string
- type ViewHead
- type Window
- func (w *Window) AccessKeys() []AccessKey
- func (w *Window) AddCommands(cmds ...*Command) error
- func (w *Window) Commands() []*Command
- func (w *Window) DocumentTitle() string
- func (w *Window) Edited() bool
- func (w *Window) FitToScreen()
- func (w *Window) FullScreen() bool
- func (w *Window) FullScreenCommand() *Command
- func (w *Window) MenuBar() *MenuBar
- func (w *Window) Narrow() bool
- func (w *Window) OffSurface() []*Command
- func (w *Window) Popups() []*Popup
- func (w *Window) RememberFrame(key string)
- func (w *Window) SetBody(p unison.Paneler)
- func (w *Window) SetDocument(name string)
- func (w *Window) SetEdited(edited bool)
- func (w *Window) SetFullScreen(on bool)
- func (w *Window) SetHeader(p unison.Paneler)
- func (w *Window) SetMenuBar(b *MenuBar)
- func (w *Window) SetSidebar(p unison.Paneler)
- func (w *Window) SetStatusBar(p unison.Paneler)
- func (w *Window) Show(p *Popup) (hide func())
- func (w *Window) Showing(p *Popup) bool
- func (w *Window) ShownMenus() []ShownMenu
- func (w *Window) ShowsAccessKeys() bool
- func (w *Window) SidebarCollapsed() bool
- func (w *Window) SidebarExpanded() bool
- func (w *Window) SidebarNarrow() bool
- func (w *Window) UI() *UI
Constants ¶
const BenchmarkRows = 250000
BenchmarkRows is how many rows a BenchmarkTableModel generates unless told otherwise: the size of kvit-cash's transaction browser.
Variables ¶
var NoOptions = text.Options{}
NoOptions lays text out on one line at its natural width.
var NotMeasured = math.NaN()
NotMeasured marks a period, in a series of values, that nobody measured. It is drawn as an absence rather than as a zero, which would be a claim.
var PlainSelectInset = SizeSpaceNear
PlainSelectInset is how far a plain Select's words stand in from its left edge, which gives the ground under the pointer room around them. A list that names the column above its selects insets the name by this much, so the name stands over the words.
var TitleCaseKept = map[string]bool{ "kvit-ui": true, }
TitleCaseKept lists words title case leaves as they are written, by their lower-case spelling: a name written lower case on purpose. An app adds its own; a word already holding a capital, such as iCloud, macOS or PDF, is kept as written without being listed.
Functions ¶
func AccessText ¶
AccessText splits a menu line's words at the access key: "Open &folder…" is "Open folder…" with the key f at rune 5. key is 0 and at -1 for words without one.
func At ¶
At puts a panel at a point inside a panel the width of the container and the given height.
func AtMost ¶
AtMost wraps a layout so the panel is never taller than a Measure: it is as tall as the wrapped layout asks at the width offered, up to the limit, and neither shorter nor taller than that. Widths pass through unchanged.
func Caption ¶
Caption is words in the caption role in a colour, as spans for the text layer, for drawing text over a chart.
func DefaultSettingsPath ¶
DefaultSettingsPath is where an application keeps kvit-ui's settings: ui.json in the app's folder under the user's configuration directory, the file the Kvit versions built with Qt saved them in.
func DialogButtonOrder ¶
DialogButtonOrder is a surface's own buttons in the order the form reads them: on the Windows form, which Linux takes, the actions and then the safe button; on the macOS form the safe button and then the actions. A Dialog orders its own buttons itself.
func DrawSurface ¶
DrawSurface draws the ground a floating surface stands on: the popup colour with a strong hairline edge, its corners rounded by radius. A nil radius is a card's corners, which is what a Popover draws.
func FillLayout ¶
FillLayout gives every child the whole of the panel's content, one over another, and asks for nothing.
func FixedWidth ¶
FixedWidth holds a panel to a width in the line it sits in.
func FullWidth ¶
FullWidth makes a panel take the width the row, column or frame it sits in has to spare, centred on the height.
func GrowShare ¶
GrowShare makes a panel take a share of the width the line it sits in has left over, against the shares of the line's other growers.
func Height ¶
Height holds a panel to a height, as a Measure, and lets it take the width its container gives it.
func Insets ¶
Insets is space inside a panel's edges, a Measure on each side; a nil Measure is no space. Set it with panel.SetBorder.
func KeepsFindKey ¶
KeepsFindKey marks a control that uses one of Find's keys for something of its own, as a text editor uses Ctrl+E for inline code: while the keyboard is in the control, or in anything inside it, the window does not send those keys to its search field, and the control's own key handler gets them. From anywhere else in the window the keys still go to the search field (KEY-13). A key that a command has stays the command's. Calling it again adds to the keys already kept.
func Left ¶
Left keeps a panel at its own width at the start of the row or column it sits in, where a column would otherwise stretch it across.
func Line ¶
Line is a panel whose children are laid out by a LineLayout: side by side, a gap apart, centred on the line's height. Unlike a Row, a hidden child takes no room and no gap.
func NewAboutSection ¶
NewAboutSection returns the About section that ends the settings page on the Windows form (CMD-3, WIN-16): a heading naming the app, its version and facts, and its links. On the macOS form About is in the app menu, and the app shows the same section in a window of its own from there.
func NewRowLayout ¶
NewRowLayout returns the layout Row gives its panel, for a panel filled after it is made: side by side, a gap apart, centred on one line, with one column for every child, hidden ones included, counted again before every size question and layout. A child with no layout data is given the middle alignment Row gives it. A hidden child keeps its room and its gap, as in any flex layout; a Line leaves it out.
func NewScrollBar ¶
NewScrollBar returns a scroll bar that occupies a strip of its own rather than floating over what it scrolls. A bar drawn over the content hides the right-hand column of a table and the last character of every cut-short label, and content that moves aside when a bar appears is worse, so the strip is kept whether or not the bar is showing. The bar is hidden when everything fits: a full-length handle says "there is more" when there is not.
It is unison's scroll bar, so dragging, clicking the track and what a screen reader is told are unison's, drawn in the Kvit colours: the panel ground, and a handle in the border colour that turns the strong border colour under the pointer or while dragged.
func OpensPopup ¶
OpensPopup marks a control that opens a popover or a menu of its own: a press on it while another popup is open closes that one and still reaches the control, so its own popup opens in the same press (PTR-13). The library's own openers, a select, a menu button, a hint, are marked already. A popup whose closing press should reach anything under it says so itself, with Popup.PressPasses.
func OwnWidthEnd ¶
OwnWidthEnd keeps a panel at its own width at the end of the stack it sits in.
func Padding ¶
Padding is space on every side of a panel's content, a Measure wide, that follows the interface size. Set it with panel.SetBorder.
func PlaceBelow ¶
PlaceBelow is under the anchor, a near space below it, starting at its left edge, or ending at its right edge where that would run off the window.
func PlaceBeside ¶
PlaceBeside is where a tooltip goes, taking the first of these places that fits: beside the anchor on its trailing side, level with its top, since a row in a list has neighbours above and below and none across; inside the anchor's own band, at its trailing end, for a row as wide as its surface, where it covers no more than the anchor's trailing half; then below it; then above. A tooltip wider than that would sit over a small anchor, such as a close button at the window's edge, hiding what it names.
func PlaceCentred ¶
PlaceCentred is in the middle of the anchor, or of the window when the anchor is nil.
func PlainMenuText ¶
PlainMenuText escapes the ampersands of words that are not a menu line's own, such as a name read from disk, so none is taken for an access key.
func PointerOn ¶
PointerOn reports whether the innermost panel under a root point is p or inside p, so a part of p scrolled out of view or under a popup does not count.
func PointerOver ¶
PointerOver reports whether a root point is inside p's box, p being in a window and it and everything it sits in shown. The point and inside are what an OnPointer listener is given.
func Relayout ¶
Relayout asks for a panel and everything it sits in to be laid out again and drawn; with children, everything inside it too.
func RoveStep ¶
func RoveStep[T unison.Paneler](members []T, from T, key unison.KeyCode, vertical, wrap bool) (T, bool)
RoveStep is the member of a group a key moves to from one: the arrow keys along the group's way (Up and Down where vertical is set, Left and Right otherwise) to the member before or after, Home and End to the ends, and round from the last to the first where wrap is set. A disabled member is passed by.
The caller builds members, so it decides which of a list's rows are passed by beyond the disabled ones, by leaving them out. A caller whose list has no Home and End does not pass those keys in.
The second result is false when the key does not move: it is not an arrow along the group's way, Home or End, or there are fewer than two members, or from is not among them. The zero T with true means the key moves but there is nowhere to go, which is the end of a list that does not wrap; a caller that passes the key on at the end of its list treats that as the key not being used.
func ShortcutTextIn ¶
ShortcutTextIn is how a shortcut is written in a form.
func ShownIn ¶
ShownIn are a panel's children that are not hidden, in order, for a layout in which a hidden child takes no room.
func Sized ¶
Sized holds a panel to a width and a height, as Measures; a nil height lets it take the height it needs at that width.
func Stack ¶
Stack is a panel whose children are laid out by a StackLayout: top to bottom, a gap apart, each as wide as the stack. Unlike a Column, a hidden child takes no room and no gap, so a part comes and goes by its Hidden field alone.
func TitleCase ¶
TitleCase is a sentence-case label in Apple's title case: every word capitalised except articles, coordinating conjunctions and prepositions of three letters or fewer, which stay lower case unless first or last. "Move to trash…" is "Move to Trash…", "Set up" is "Set Up". A word with a capital, a digit or a dot already in it is kept as written, and so is one in TitleCaseKept. An access-key marker ("Save &as") stays where it is.
Types ¶
type About ¶
type About struct {
// Name is the app's name; the UI's AppName unless set.
Name string
// Version is the version the app is, "2.4.1".
Version string
// Details are further lines of facts, such as a build or a copyright.
Details []string
// Links are the places to go: the website, a place to report a problem
// or ask for a feature, the third-party notices, the legal terms.
Links []AboutLink
}
About is what an About section says about the app (CMD-3): its name and version, and where to go for more.
type AboutLink ¶
type AboutLink struct {
// Text says where it goes, in sentence case.
Text string
// OnActivate follows it.
OnActivate func()
}
AboutLink is one place an About section links to.
type AccessKey ¶
type AccessKey struct {
// Panel is the control.
Panel *unison.Panel
// Words are its words as drawn.
Words string
// Key is the letter, in lower case; 0 for a control left without one.
Key rune
// Chosen says the app chose the letter with "&".
Chosen bool
// contains filtered or unexported fields
}
AccessKey is the access key a control has in a window.
type Badge ¶
type Badge struct {
unison.Panel
// Count is the number; zero or less hides the badge.
Count int
// Max is the largest count written out; 99 unless set.
Max int
// Counted is the word for one of the things counted, so a screen reader
// hears "1 decision" or "11 decisions"; "" says "items".
Counted string
// CountedPlural is the word for several; "" adds an s to Counted. Two
// words rather than one already inflected, because one word is right at
// one count and wrong at every other.
CountedPlural string
// Tone is the pill's colour.
Tone BadgeTone
// contains filtered or unexported fields
}
Badge is a count attached to something else: unread items, pending changes, matches. The number is small on the screen and possibly large in value, so past Max it says "99+" rather than growing wide enough to move what it is attached to, and at zero it is not drawn at all, because a badge reading 0 says "look here" about nothing. The number is written with the reader's digit grouping, drawn and announced alike.
func (*Badge) Phrase ¶
Phrase is what a screen reader is told: the whole count and its noun, "214 decisions", never capped, since a screen reader has room for the number and is the one reader who cannot look it up somewhere else.
func (*Badge) ProvideAccessibility ¶
func (b *Badge) ProvideAccessibility(ab *unison.AccessibilityBuilder)
ProvideAccessibility gives the whole count and its noun, or nothing at all when the badge is hidden.
type Bar ¶
type Bar struct {
unison.Panel
// Value against Maximum, the scale.
Value, Maximum float64
// Measured is false for a value nobody measured.
Measured bool
// Bounded marks the value as "at most this much".
Bounded bool
// Ink is the fill; the accent unless set.
Ink Ink
// Wide draws the taller form.
Wide bool
// Label and Unit say what the bar is, for a screen reader.
Label, Unit string
// contains filtered or unexported fields
}
Bar is one quantity against a stated scale. A bar with no value is drawn as its track and a tick where it would start, not as a zero-width fill, which cannot be told from a measured zero. A value that is an upper bound is hatched, which is geometry and survives grayscale. And the scale is stated rather than taken from the largest value around it, so two screenshots a day apart can be compared.
func (*Bar) ProvideAccessibility ¶
func (b *Bar) ProvideAccessibility(ab *unison.AccessibilityBuilder)
ProvideAccessibility reads the bar as its value against its scale.
type BarMenu ¶
type BarMenu struct {
// Title is the menu's name, with an access key: "&File".
Title string
// Items are its lines.
Items []MenuItem
// contains filtered or unexported fields
}
BarMenu is one menu of a menu bar: its title and its lines.
type BeforeAfter ¶
type BeforeAfter struct {
unison.Panel
// Before and After are the values, already formatted.
Before, After string
// Unit is drawn after each value.
Unit string
// BeforeMeasured and AfterMeasured false draw an em dash on that side.
BeforeMeasured, AfterMeasured bool
// Label says what the pair is a value of; "" for none, where a heading
// already says it.
Label string
// Role is both values' type role, so the two are always the same size.
Role TypeRole
// contains filtered or unexported fields
}
BeforeAfter is one value as it stands and the value something proposes to replace it with: the shape every screen asking the reader to approve a change is built from, of which kvit-cash alone has four (the import preview, the quarantine group, the diff before a recipe update, the review of an agent's proposal). The old value is on the left in the muted colour and the new one on the right in the ordinary colour, with an arrow between, so position, weight of colour and the arrow's direction all say which is which. Both are Figures, so a side nobody measured is an em dash: a record being added has no before, which is not a before of zero. Where the two are the same, the arrow and the second value go, since an arrow between equal values sends the reader looking for a difference.
func NewBeforeAfter ¶
func NewBeforeAfter(ui *UI, label, before, after string) *BeforeAfter
NewBeforeAfter returns a pair of measured values in the body role.
func (*BeforeAfter) ProvideAccessibility ¶
func (b *BeforeAfter) ProvideAccessibility(bl *unison.AccessibilityBuilder)
ProvideAccessibility reads the pair as a sentence: "Amount, was 42.00 GBP, now 44.50 GBP", or "Date, unchanged, was 2026-08-14".
func (*BeforeAfter) Unchanged ¶
func (b *BeforeAfter) Unchanged() bool
Unchanged reports whether the two values are the same.
type BenchmarkTableModel ¶
type BenchmarkTableModel struct {
// contains filtered or unexported fields
}
BenchmarkTableModel is a ledger of generated transactions, thirteen columns wide, that holds no row: every cell is worked out from its row number when it is asked for. It is the model the gallery shows a quarter of a million rows with, and the one the check that a Table scrolls smoothly and filters in under 100 ms at that size is run against.
The ticks in its column of boxes are kept by generated row rather than by the row shown, so a reader who ticks forty rows, narrows the filter and widens it again finds the forty still ticked.
func NewBenchmarkTableModel ¶
func NewBenchmarkTableModel(total int) *BenchmarkTableModel
NewBenchmarkTableModel returns a model of total generated rows.
func (*BenchmarkTableModel) AllShownChecked ¶
func (b *BenchmarkTableModel) AllShownChecked() bool
AllShownChecked reports whether every row shown is ticked, and SomeShownChecked whether some are and not all: the three states of the box in the column's header.
func (*BenchmarkTableModel) Cell ¶
func (b *BenchmarkTableModel) Cell(row, column int) CellValue
Cell works one cell out from its row number.
func (*BenchmarkTableModel) Columns ¶
func (b *BenchmarkTableModel) Columns() []TableColumn
Columns are the thirteen columns.
func (*BenchmarkTableModel) Filter ¶
func (b *BenchmarkTableModel) Filter() string
Filter is the text the descriptions shown contain.
func (*BenchmarkTableModel) Rows ¶
func (b *BenchmarkTableModel) Rows() int
Rows is how many rows the filter shows.
func (*BenchmarkTableModel) SetChecked ¶
func (b *BenchmarkTableModel) SetChecked(row int, checked bool)
SetChecked ticks one row shown, or clears it.
func (*BenchmarkTableModel) SetEveryShownChecked ¶
func (b *BenchmarkTableModel) SetEveryShownChecked(checked bool)
SetEveryShownChecked ticks every row the filter shows, or clears them.
func (*BenchmarkTableModel) SetFilter ¶
func (b *BenchmarkTableModel) SetFilter(text string)
SetFilter shows only the rows whose description contains text, ignoring case; "" shows them all. It tests every generated row, which is the operation the 100 ms budget is about.
func (*BenchmarkTableModel) SomeShownChecked ¶
func (b *BenchmarkTableModel) SomeShownChecked() bool
SomeShownChecked reports whether some rows shown are ticked and not all.
func (*BenchmarkTableModel) Total ¶
func (b *BenchmarkTableModel) Total() int
Total is how many rows the model generates, whatever the filter shows.
type Breadcrumb ¶
type Breadcrumb struct {
unison.Panel
// Trail is the places from the root to the current one.
Trail []Crumb
// MaximumVisible is how many crumbs are drawn before the middle of the
// trail is replaced by "…"; 4 unless set.
MaximumVisible int
// OnActivate runs when a crumb before the current one is followed.
OnActivate func(Crumb)
// contains filtered or unexported fields
}
Breadcrumb says where the reader is, and gives the way back.
The last crumb is the current place and is not a link: a last crumb that could be followed would be followed and do nothing, and a screen reader would announce a link that goes nowhere. A long trail is cut from the middle rather than the end, because the first crumb says which part of the application this is and the last says where the reader is, and what a reader can do without is the middle. The "…" standing for the middle opens a list of the crumbs it folds, so every place on the trail can still be followed (LAY-10).
func NewBreadcrumb ¶
func NewBreadcrumb(ui *UI, trail ...Crumb) *Breadcrumb
NewBreadcrumb returns a breadcrumb showing a trail, root first.
func (*Breadcrumb) ProvideAccessibility ¶
func (b *Breadcrumb) ProvideAccessibility(ab *unison.AccessibilityBuilder)
ProvideAccessibility names the trail as a group; each crumb says itself.
func (*Breadcrumb) Shown ¶
func (b *Breadcrumb) Shown() []Crumb
Shown is the crumbs as drawn: the whole trail when it is short enough, and otherwise the first crumb, a crumb reading "…" with no ID that opens a list of the crumbs it stands for, and the last few.
type Button ¶
type Button struct {
// Command, when set, is what the button runs: its words, symbol,
// explanation, whether it can act and whether it is on all come from
// the command, read each time the button is drawn.
Command *Command
// Text is what the button says, in sentence case: kvit-ui writes it in
// title case on the macOS form (WRD-6).
Text string
// Asks marks a button that asks for more before acting, such as one
// opening a dialog: "…" is added to its words (WRD-4).
Asks bool
// Form is ordinary, primary or quiet.
Form ButtonForm
// Danger draws the button in the danger colour.
Danger bool
// Symbol is an optional meaning name drawn before the words.
Symbol string
// Busy says the button is doing something: it stays enabled so its name
// can say what, and the words change to BusyText rather than a spinner
// appearing, since a spinner says "wait" without saying for what.
Busy bool
// BusyText is what a busy button says: an -ing phrase naming the work,
// "Importing statement…", never "Working…" (WRD-25). A busy button
// without one keeps its words and is warned about once.
BusyText string
// Explanation is one sentence the words cannot say: why the button is
// disabled, or what pressing it opens. It is the tooltip and the
// accessible description, and a disabled button still shows it.
Explanation string
// Checkable makes a press toggle Checked.
Checkable bool
// Checked draws a button that turns a mode on as on: tinted and outlined
// in the accent, two marks rather than one, since a tint alone is a few
// percent of lightness in the high-contrast theme.
Checked bool
// OnClick runs when the button is pressed.
OnClick func()
// contains filtered or unexported fields
}
Button is a button with words on it. Danger is separate from the form, because a destructive action can take any of the three: a primary Delete in a confirmation, an ordinary one in a settings row, a quiet one in a strip. The words on a filled button take the colour that contrasts with its own fill, so a filled danger button stays readable.
func NewCommandButton ¶
NewCommandButton returns an ordinary button that runs a command.
func (*Button) Focus ¶
func (c *Button) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Button) Hovered ¶
func (c *Button) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Button) KeyboardFocus ¶
func (c *Button) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Button) PerformAccessibilityAction ¶
func (b *Button) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the button for a screen reader.
func (*Button) Pressed ¶
func (c *Button) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Button) ProvideAccessibility ¶
func (b *Button) ProvideAccessibility(bl *unison.AccessibilityBuilder)
ProvideAccessibility describes the button by its words, what it is doing when busy, its explanation, and its checked state when it has one.
func (*Button) SetTooltip ¶
func (c *Button) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Button) TooltipWords ¶
func (c *Button) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type ButtonForm ¶
type ButtonForm int
ButtonForm is how a button with words on it looks.
const ( // ButtonOrdinary is outlined: every action that is not the one the // screen is for. ButtonOrdinary ButtonForm = iota // ButtonPrimary is filled with the accent: the action the screen is for, // one per region of the screen. A screen with three has told the reader // nothing about which to press. ButtonPrimary // ButtonQuiet has the chip ground and a hairline of the faint border, for // a dense strip where a row of full outlines would read as a fence. It is // drawn as pressable at rest rather than only once the pointer is on it. ButtonQuiet // ButtonFlat has no ground and no outline at rest, only the hover tint // under the pointer and the selection tint while pressed or checked, for // a toolbar of many buttons told apart by their words. ButtonFlat )
type Card ¶
type Card struct {
// Interactive makes the card something to press.
Interactive bool
// NoOpensMark leaves the chevron off a pressable card whose ways in are
// the rows inside it, so each row carries its own.
NoOpensMark bool
// OpensLabel says in words what pressing the card opens: the tooltip on
// the chevron, and the card's accessible description.
OpensLabel string
// Selected marks a chosen card.
Selected bool
// Label is what a screen reader calls the card; the words it holds
// unless set. A pressable card with no name is read as a bare "group".
Label string
// Padding is the space inside the edge; the loose space unless set.
Padding Measure
// OnActivate runs when a pressable card is pressed.
OnActivate func()
// contains filtered or unexported fields
}
Card is a bounded block of content sitting on a surface: a dashboard widget, a summary, a group of related figures. It has a corner radius where a panel has none, because it is an object on a surface rather than a part of the window.
Its outline is the ordinary border colour unless the card can be pressed, in which case it is a control and takes the strong border colour, the hover tint, and the chevron a pressable row has, in its top corner. A press on something inside the card that acts on a press of its own is that thing's, and not also the card's. A pressable card also takes the keyboard focus and opens on Return, Enter or Space.
func (*Card) Focus ¶
func (c *Card) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Card) Hovered ¶
func (c *Card) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Card) KeyboardFocus ¶
func (c *Card) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Card) PerformAccessibilityAction ¶
func (c *Card) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the card for a screen reader.
func (*Card) Pressed ¶
func (c *Card) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Card) ProvideAccessibility ¶
func (c *Card) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes a pressable card as a group that can be pressed, with what it opens as its description.
func (*Card) SetTooltip ¶
func (c *Card) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Card) TooltipWords ¶
func (c *Card) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Cell ¶
type Cell struct {
unison.Panel
// Kind is how the cell is drawn.
Kind CellKind
// Value is what it holds.
Value CellValue
// Leads draws the text in the link colour: the row's name, which the
// reader presses to open the row.
Leads bool
// Selected draws the text in the primary colour.
Selected bool
// Current says the keyboard cursor is on the cell, which discloses a
// value cut short as the pointer does.
Current bool
// OnToggle asks for a Check cell's box to change. The cell does not tick
// itself: whatever owns the selection does, and sets Value.Checked, so a
// request that is refused leaves no tick behind.
OnToggle func(checked bool)
// contains filtered or unexported fields
}
Cell is one cell of a table, drawn according to the kind of value its column holds, for a caller laying cells out itself; a Table draws its own. The value is disclosed where the cell cuts it short, under the pointer and under the keyboard cursor, because a reader who never touches the pointer has the same column to read. A cell is not a control and takes no focus of its own, so whatever owns the cursor says where it is through Current.
func (*Cell) ProvideAccessibility ¶
func (c *Cell) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the cell as its whole value. A Marks cell is a group of its marks, each named on its own, so a reader is told where one state ends and the next begins; a Check cell leaves its name to the box, which says it is a box and whether it is ticked.
type CellKind ¶
type CellKind int
CellKind is how the cells of a column are drawn. The kind belongs to the column rather than to each value, which is what makes a column readable: every cell in it is aligned the same way, set in the same face, and says the same thing about a missing value. A cell that decided for itself would give a column where some rows are right-aligned and some are not, depending on whether that row's value happened to look like a number.
const ( // CellText is ordinary text, left aligned, cut short with an ellipsis. CellText CellKind = iota // CellFigure is a measured value: tabular numerals, right aligned, an em // dash where nothing was measured. CellFigure // CellChip is a small labelled mark in the value's Tone. CellChip // CellSlug is a monospace identifier, without the ground a slug has // elsewhere: a box on every row reads as a column of boxes. CellSlug // CellDate is a date. CellDate // CellMoney is an amount already formatted by the caller, right aligned, // in the danger colour where its sign says it is money leaving. CellMoney // CellMarks is every state the row is in at once, one dot each. CellMarks // CellCheck is a box the reader ticks. CellCheck )
The kinds.
type CellMark ¶
CellMark is one state a row is in, drawn as one dot in a Marks cell. Label is both the word on hover and the name a screen reader says, so the two cannot drift apart. Shape is the second channel beside the hue, and Hollow doubles what the shapes can say, since a row can be in more states than there are shapes.
type CellValue ¶
type CellValue struct {
// Text is the value as it is drawn.
Text string
// Date is a Date cell's date where Text is empty; it is drawn as
// 2006-01-02.
Date time.Time
// Unmeasured says there is no value, which a Figure or Money cell draws
// as an em dash: a balance nobody has computed is not a balance of zero.
Unmeasured bool
// Tone is a Chip cell's tone.
Tone Tone
// Marks are a Marks cell's states.
Marks []CellMark
// Checked is whether a Check cell's box is ticked.
Checked bool
// Unit is what a Figure or Money cell draws beside the value: a currency
// code or a unit of measure, kept apart from the digits so a column
// lines up down its decimal separator.
Unit string
// FullText is the whole value where Text is a shortened one; "" says
// Text is all there is. For a Money cell it is what is behind the
// amount, one fact to a line — the native amount, the rate, the date of
// the rate — shown in a hover card.
FullText string
}
CellValue is what one cell holds. A cell formats nothing: it is given the string it draws. Money is where that matters most, since an amount is a count of the minor unit of its own currency, and how many minor digits it has belongs to the currency — none for the yen, three for the dinar — which a cell printing two decimal places would get wrong.
type Check ¶
type Check struct {
// Text is the box's label.
Text string
// Checked is the box's state.
Checked bool
// Partial says some of what the box stands for is checked; it is drawn
// with a dash, and a press checks the whole.
Partial bool
// OnChange runs after a press, with the new state.
OnChange func(checked bool)
// Name is what a screen reader calls a box with no words beside it, such
// as the one on each row of a table; the words unless set.
Name string
// contains filtered or unexported fields
}
Check is a checkbox, in three states. The third, partial, is what a parent row shows when some of its children are checked and some are not: drawn as unchecked it loses that anything under it is selected, and drawn as checked it says something false that the reader acts on.
func (*Check) Focus ¶
func (c *Check) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Check) Hovered ¶
func (c *Check) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Check) KeyboardFocus ¶
func (c *Check) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Check) PerformAccessibilityAction ¶
func (c *Check) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction toggles the box for a screen reader.
func (*Check) Pressed ¶
func (c *Check) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Check) ProvideAccessibility ¶
func (c *Check) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the box as a check box in one of three states.
func (*Check) SetTooltip ¶
func (c *Check) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Check) TooltipWords ¶
func (c *Check) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Chip ¶
type Chip struct {
unison.Panel
// Text is the chip's word.
Text string
// Tone is what its colour means.
Tone Tone
// Strong fills the chip, for the one chip on a row that is its point.
Strong bool
// Symbol is an optional meaning name before the word.
Symbol string
// Explanation says in a sentence what the word means and what to do
// about it: the tooltip and the accessible description.
Explanation string
// contains filtered or unexported fields
}
Chip is a small labelled mark: what kind of thing this is, what state it is in, one word about it. Every tone has a second channel besides its hue: the outline is drawn in the tone as well as the ground tinted with it, and a strong chip is filled rather than tinted, so a reader who cannot tell the red tone from the amber one can still tell a warning from a failure.
func (*Chip) ProvideAccessibility ¶
func (c *Chip) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the chip as its word, with the explanation.
type ChipButton ¶
type ChipButton struct {
// Text is the chip's words.
Text string
// Tone is what its colour means.
Tone Tone
// Strong fills the chip in its tone.
Strong bool
// Symbol is an optional meaning name before the words; TrailingSymbol one
// after them, for a caller that knows where pressing leads.
Symbol, TrailingSymbol string
// Explanation says where pressing the chip goes, where the words do not.
Explanation string
UnavailableReason string
// Current marks the chip whose destination is already open.
Current bool
// Selectable makes the chip a choice that is on or off; Selected is
// whether it is on.
Selectable, Selected bool
// OnActivate runs when an available chip is pressed.
OnActivate func()
// contains filtered or unexported fields
}
ChipButton is a chip's twin for a fact that opens something when pressed: "3 changes", "1 ahead". At rest it is drawn as a chip is, from the same tones, so a row mixing facts that act with facts that do not reads as one row of facts; what sets it apart is what a control does anyway: the ground changes under the pointer, the focus ring shows for the keyboard, and a screen reader is told it is a button.
It has three states beside its tone. Current marks the chip whose destination is already open: the selection tint, an accent edge and bold words. Selectable makes it a quick filter that is on or off: a control's height, filled with the accent when Selected. And UnavailableReason says why it cannot be pressed; it stays in the tab order with its fill gone, so the one chip with something to explain is not the one a reader cannot reach.
func NewChipButton ¶
func NewChipButton(ui *UI, words string) *ChipButton
NewChipButton returns a neutral chip button.
func (*ChipButton) Focus ¶
func (c *ChipButton) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*ChipButton) Hovered ¶
func (c *ChipButton) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*ChipButton) KeyboardFocus ¶
func (c *ChipButton) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*ChipButton) PerformAccessibilityAction ¶
func (c *ChipButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the chip for a screen reader.
func (*ChipButton) Pressed ¶
func (c *ChipButton) Pressed() bool
Pressed reports whether the control is being pressed.
func (*ChipButton) ProvideAccessibility ¶
func (c *ChipButton) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the chip as a button: why it cannot be pressed, or where it goes; whether it is the current one; and, for a choice, whether it is on.
func (*ChipButton) SetTooltip ¶
func (c *ChipButton) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*ChipButton) TooltipWords ¶
func (c *ChipButton) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type ChoiceButton ¶
type ChoiceButton struct {
unison.Panel
// Command, when set, is what the button runs, as a Button's is: its
// words, symbol, explanation and whether it can act come from the
// command, and its Run reads Current for the value. A command that
// cannot act disables both parts.
Command *Command
// Text is what the button says, in sentence case: kvit-ui writes it in
// title case on the macOS form (WRD-6). The values are shown as written.
Text string
// Form is how both parts look: ordinary, primary, quiet or flat.
Form ButtonForm
// Danger draws both parts in the danger colour.
Danger bool
// Symbol is an optional meaning name drawn before the button's words.
Symbol string
// Busy says the action is running: the button's words change to
// BusyText, as a Button's do.
Busy bool
// BusyText is what the busy button says: an -ing phrase naming the
// work, such as "Measuring…" (WRD-25).
BusyText string
// Explanation is one sentence the words cannot say: why the button is
// disabled, or what pressing it does. It is the button's tooltip and
// accessible description.
Explanation string
// ChoiceLabel names the choice for a screen reader, saying what its
// values are, such as "How many".
ChoiceLabel string
// Options are the values to choose from.
Options []Option
// Current is the Value of the chosen option.
Current string
// OnChoose runs after a value is chosen, with the value.
OnChoose func(value string)
// OnPress runs when the button is pressed, with the value chosen. A
// Command runs in its place when one is set.
OnPress func(value string)
// contains filtered or unexported fields
}
ChoiceButton is a button with a choice of value fused to its right side, drawn as one control: [Measure | All ▾]. The button runs the action, and the choice shows the value it runs with, so the reader sees what a press will do before pressing. Pressing the choice opens the list of values; choosing one changes the value and runs nothing.
It is for an action repeated with a setting changed less often than the action is run, such as how many items Measure takes. When each value is an action of its own, chosen and run in one press, a SplitButton of variants is right instead (CMD-17).
The two parts are two stops in the Tab order. The choice is a Select: Up and Down change the value without opening the list, and typing the start of a value's words chooses it.
func NewChoiceButton ¶
func NewChoiceButton(ui *UI, label, choiceLabel string, options ...Option) *ChoiceButton
NewChoiceButton returns an ordinary button with a choice of values fused to it, the first value chosen.
func (*ChoiceButton) ProvideAccessibility ¶
func (c *ChoiceButton) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the pair as a group, by the button's words; a screen reader then reads the button and the choice with its value.
type Command ¶
type Command struct {
// Name is what the command is called everywhere: a verb first, in
// sentence case, "Export…" with the ellipsis left to Asks. kvit-ui gives
// it the form's case. A standard command's name is the standard one
// unless set.
Name string
// Std names a standard command, StdNone for the app's own.
Std StdCommand
// Symbol is the meaning name of its symbol, drawn on a symbol button and
// before the words in a menu on the Windows form, unless the menu line is
// one of a set of options (MenuItem.Radio); a standard command has its
// standard one unless set.
Symbol string
// Shortcut is the app's own key for the command; a standard command's
// keys are the form's standard ones, and this adds one more. Give new
// shortcuts only to frequent commands (KEY-5).
Shortcut Shortcut
// Asks marks a command that asks for more before it acts, a dialog, a
// chooser or a confirmation: its name gains "…" on both forms (WRD-4).
Asks bool
// OpensWindow marks a command whose whole job is to show a window, such
// as Settings: "…" on the macOS form only (WRD-4).
OpensWindow bool
// Explanation is one sentence the name cannot say, such as why the
// command cannot act now: a tooltip's second line and the description a
// screen reader is told.
Explanation string
// Enabled reports whether the command can act now; nil is always. A
// command that cannot act stays where it is, disabled, and its key does
// nothing (CMD-9, KEY-2). One too slow to check leaves this nil and
// says why when it is run and cannot act.
Enabled func() bool
// Checked makes the command a switch, reporting whether it is on now: a
// tick on its menu line and a checked button.
Checked func() bool
// FindBar, on a Find command (Std: StdFind), says the command opens a
// find bar of the app's own, apart from the window's search field: it
// takes only Find's first key on each form, Ctrl+F or Cmd-F, and the
// Windows form's Ctrl+E still goes to the search field (KEY-13).
FindBar bool
// TurnOn and TurnOff are a switch's words on the macOS form, where the
// menu line says what choosing it does: "Show sidebar" while it is off,
// "Hide sidebar" while it is on. The Windows form keeps Name and ticks
// it (WRD-12). Empty keeps Name on both forms.
TurnOn, TurnOff string
// Run does it.
Run func()
}
Command is one thing the app can do, made once and shown wherever it is offered: a menu line, a button, a symbol button on a toolbar, a shortcut. Every place draws its name, symbol and shortcut from the command, so a command has one name and one key everywhere (CON-1), and is disabled everywhere at once (CMD-9).
A standard command, one with Std set, takes its name, symbol and keys from the platform's conventions unless they are set here: an app that has Save gets Ctrl+S on the Windows form and Cmd-S on the macOS form without choosing it (KEY-2). A window answers a command's keys once the command is added to it (Window.AddCommands).
func (*Command) Do ¶
Do runs the command if it can act, and reports whether it did. Every window is drawn again afterwards, since what it did may have enabled or disabled other commands.
func (*Command) FirstShortcut ¶
FirstShortcut is the key a menu line and a tooltip show for the command in a form, or the zero shortcut.
func (*Command) IsChecked ¶
IsChecked reports whether a switch is on now; false for a plain command.
func (*Command) Label ¶
Label is the command's name as it is shown in the app's form: its words for its state, its ellipsis, and the form's case for a command.
func (*Command) Plain ¶
Plain is the command's name in the app's form without the ellipsis and the access-key marker, as a dialog it opens is titled.
func (*Command) Shortcuts ¶
Shortcuts are the keys that run the command in a form: its standard keys, then its own. A find bar's Find has only the first of Find's keys.
func (*Command) SymbolName ¶
SymbolName is the command's symbol: its own, or its standard one.
type ConfirmInPlace ¶
type ConfirmInPlace struct {
unison.Panel
// Text says what happened.
Text string
// UndoText is the words on the undo; "" draws no undo, for an action that
// has stopped being reversible.
UndoText string
// Shown opens the strip, growing to its height; false closes it.
Shown bool
// Affected is how many things the action touched, so the reader can
// check the count before undoing; below zero says nothing.
Affected int
// OnUndo and OnDismiss run when the undo or the close button is pressed.
OnUndo, OnDismiss func()
// contains filtered or unexported fields
}
ConfirmInPlace is a strip that appears where the reader is, saying what just happened and offering to undo it: the undo goes inside the confirmation rather than a confirmation coming before the action. When the reader does the same thing forty times, a dialog before each costs a press every time and stops being read by the third, while a confirmation after, with an undo, costs nothing unless something went wrong. That makes it right only for an action the application can reverse. It stays until it is dismissed or replaced: an undo that expires while the reader is checking what happened is an undo they cannot use, and a timed message is a Toast.
func NewConfirmInPlace ¶
func NewConfirmInPlace(ui *UI, text string) *ConfirmInPlace
NewConfirmInPlace returns a closed strip saying text, with an undo.
func (*ConfirmInPlace) ProvideAccessibility ¶
func (c *ConfirmInPlace) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the strip as what happened and how much it touched, holding its undo and close buttons.
type CountPart ¶
type CountPart struct {
// Text is drawn as written.
Text string
// Ink is the part's colour; nil is the faint ink of a written count.
Ink Ink
}
CountPart is one stretch of a SectionHeading's written count.
type Crumb ¶
type Crumb struct {
Label string
// ID is the caller's own name for the place, handed back when the crumb
// is followed.
ID string
}
Crumb is one place in a breadcrumb trail.
type Delta ¶
type Delta struct {
unison.Panel
// Change is the change.
Change float64
// Unit follows it.
Unit string
// Measured is false for a change nobody measured.
Measured bool
// Good is the direction that is good; Neither draws the muted colour.
Good Direction
// Precision is how many decimal places to draw.
Precision int
// contains filtered or unexported fields
}
Delta is how much something changed and in which direction, carried by an arrow as well as a colour: green-up and red-down is the most common place a screen rests a meaning on hue, and the pair a deuteranope cannot separate. Whether up is good is the caller's to say, since a rise in spending and a rise in savings are the same arrow in opposite colours.
func (*Delta) ProvideAccessibility ¶
func (d *Delta) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility says the change in words: "up 12 %", "unchanged".
type Dialog ¶
type Dialog struct {
unison.Panel
// Kind is what the dialog is for: asking (the default), informing, or
// showing an object's properties.
Kind DialogKind
// Title names the question or what happened, on every dialog (WIN-6,
// decided Q-42); Detail says more.
Title, Detail string
// ConfirmText names the action the dialog confirms, "Import" or
// "Delete": a dialog that asks needs it, and has no "Confirm" to fall
// back on (WRD-7). A properties dialog's is OK unless set.
ConfirmText string
// CancelText is the safe button's words, Cancel unless set; a dialog
// that asks always has one (WIN-3).
CancelText string
// OtherText is an optional second answer, such as "Don't save", beside
// the action on the Windows form and at the leading end on the macOS
// form; "" for none.
OtherText string
// Destructive draws the confirming button in the danger colour, and
// takes away the default on both forms.
Destructive bool
// DefaultConfirm makes the action the default on the Windows form, which
// Enter presses wherever the keyboard is in the dialog: only where it is
// clearly the likely and safe answer. The macOS form's default is the
// action unless the dialog is destructive.
DefaultConfirm bool
// Suppressible offers "Don't show this message again" under the detail,
// for a routine message that can recur; an error or a destructive
// question never offers it (WIN-2). SuppressNoun names what is not shown
// again, "message" unless set.
Suppressible bool
SuppressNoun string
// Helper lets the dialog open over another on the Windows form, as a
// chooser over the dialog that needs it; an informing dialog may open
// over another on both forms. Otherwise one dialog is open at a time
// (WIN-7).
Helper bool
// Alert lets a question about something outside the dialog under it,
// such as quitting while that dialog is open, open over it on both
// forms, as an alert may sit over a dialog (WIN-7).
Alert bool
// OnAccept and OnReject run when the dialog is answered; OnOther when
// the second answer is chosen; OnApply when a properties dialog's Apply
// is pressed, which leaves it open.
OnAccept, OnReject, OnOther, OnApply func()
// OnDiscard is asked before the close symbol or Escape throws away what
// the reader put into the dialog: true goes ahead, false keeps it open.
// The app asks the reader there when the input took effort (WIN-8).
// Cancel discards without asking.
OnDiscard func() bool
// OnMove runs when the reader lets go of the dialog after dragging it,
// with where its top-left corner is now, as Position gives it.
OnMove func(x, y int)
// Help opens the help topic for the dialog, where the topic says what
// the dialog cannot; nil for none (HLP-6). On the Windows form it is the
// question-worded link at the bottom of the content, which Tab reaches
// after the buttons (KEY-9); on the macOS form it is the round help
// button at the leading end of the button row.
Help *HelpLink
// ConfirmKeepsOpen leaves the dialog open when it is confirmed, for an
// answer the application checks and may refuse, saying why in the
// dialog; Close takes it away once the answer is taken.
ConfirmKeepsOpen bool
// contains filtered or unexported fields
}
Dialog is a surface that has to be answered before anything else happens: a destructive action, a choice the next step depends on. Modality is expensive, and a confirmation of something reversible belongs in a toast with an undo instead.
Its buttons follow the platform (WIN-1): on the Windows form, which Linux takes, the action first and the safe button at the right end; on the macOS form Cancel and then the action at the trailing end. Every dialog has a safe button (WIN-3). Return presses the default button on the macOS form, which is the action unless the dialog is destructive; on the Windows form Enter presses the focused button, and the action only where DefaultConfirm marks it as the likely and safe answer (KEY-6). Escape, and Command-period on the macOS form, cancel; on the Windows form so does the close symbol beside the title, which the macOS form does not draw (WIN-6). The keyboard starts in the first field of the content, or on the default button, stays inside while the dialog is open, and goes back to where it was when it closes (KEY-8).
A Dialog is a panel; Open shows it modal in a Kvit window, and it can also be placed on a page as it is. An open dialog moves when the reader drags its title row, as a window does, so it can be pulled off what it covers. It opens in the middle of the window unless MoveTo says where, and OnMove tells the application where the reader left it, to keep and give back to MoveTo the next time.
func NewDialog ¶
NewDialog returns a dialog asking a question, holding content under its detail. Give it ConfirmText, the words of the action it asks about.
func NewMessage ¶
NewMessage returns a dialog that only informs: one button, Close on the Windows form and OK on the macOS form.
func (*Dialog) Accept ¶
func (d *Dialog) Accept()
Accept answers the dialog as its confirming button does, closing it, unless ConfirmKeepsOpen, and running OnAccept: what Return in a dialog's text field does, where the field holds the keyboard rather than the button.
func (*Dialog) ApplyButton ¶
ApplyButton is a properties dialog's Apply on the Windows form, which the reader presses once MarkChanged says something changed: nil when the dialog shows none, as every dialog does on the macOS form.
func (*Dialog) ButtonWords ¶
ButtonWords are the words of the dialog's buttons as they are shown, left to right.
func (*Dialog) Buttons ¶
Buttons are the dialog's buttons as they are shown, left to right: the same buttons ButtonWords names, as handles the application can enable, focus or press, rather than finding by their words.
func (*Dialog) CancelButton ¶
CancelButton is the dialog's safe button, Cancel unless set, Close or Done once Done: nil when the dialog shows none, as an informing dialog does.
func (*Dialog) Close ¶
func (d *Dialog) Close()
Close takes the dialog away without answering it, so neither OnAccept nor OnReject runs: for an application that has taken the answer another way, as one closes a dialog that stays open on confirming once the answer it checked is taken.
func (*Dialog) ConfirmButton ¶
ConfirmButton is the dialog's action, "Import" or OK: nil when the dialog shows no action, as an asking dialog does once Done. An informing dialog's only button, Close on the Windows form and OK on the macOS form, is its confirming button.
func (*Dialog) Done ¶
func (d *Dialog) Done()
Done says the dialog's work has been carried out and cannot be taken back: Cancel becomes Close on the Windows form and Done on the macOS form, and the action goes (WRD-8).
func (*Dialog) MarkChanged ¶
func (d *Dialog) MarkChanged()
MarkChanged tells a properties dialog that the reader has changed something, which enables Apply on the Windows form until it is pressed (WIN-23). Call it from the fields' and boxes' change callbacks.
func (*Dialog) MoveTo ¶
MoveTo puts the dialog's top-left corner x across and y down from the top-left corner of the window's content: where it opens, or where it goes at once when it is open. The window keeps the whole dialog inside it, however far out x and y are. Px of what OnMove reported opens the dialog where the reader left it last time.
func (*Dialog) Open ¶
Open shows the dialog modal, in the middle of the window or where MoveTo put it, with the keyboard in the first field of its content, or on the default button, or on the safe one. A dialog is refused, with a warning, while another is open, unless it may sit over it (WIN-7); one that asks without ConfirmText is opened and warned about (WRD-7, WIN-3).
func (*Dialog) OtherButton ¶
OtherButton is the dialog's optional second answer, such as "Don't save": nil when the dialog shows none.
func (*Dialog) Position ¶
Position is where the dialog's top-left corner is put, in design pixels from the top-left corner of the window's content, and false while it is put in the middle, as it is until MoveTo or the reader moves it.
func (*Dialog) ProvideAccessibility ¶
func (d *Dialog) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the dialog by its question and detail.
func (*Dialog) SafeButton ¶
SafeButton reports whether the dialog has a button that leaves without acting (WIN-3).
func (*Dialog) Suppressed ¶
Suppressed reports whether the reader ticked "Don't show this message again".
type DialogKind ¶
type DialogKind int
DialogKind is what a dialog is for, which decides its buttons.
const ( // DialogAsk asks a question: a button naming the action (ConfirmText, // required, never "Confirm" or "OK"), and the safe button, Cancel. DialogAsk DialogKind = iota // DialogInform only tells the reader something: one button, Close on // the Windows form and OK on the macOS form (WRD-7, decided Q-5). DialogInform // DialogProperties shows the settings of one object: OK, Cancel and, // on the Windows form, Apply, the one place those words belong (WRD-7, // WIN-23). Apply is enabled once MarkChanged says something changed; // the macOS form leaves it out. DialogProperties )
type Disclosure ¶
type Disclosure struct {
unison.Panel
// Title names the section.
Title string
// Group makes sections sharing it an accordion; "" stands alone.
Group string
// Count is how many things are inside, beside the title; below zero
// draws none.
Count int
// OnToggle runs after the section opened or closed, with the new state.
OnToggle func(expanded bool)
// contains filtered or unexported fields
}
Disclosure is a trigger with a body under it that opens and closes. The chevron turns rather than being swapped for another, so the reader sees the state change happen, and the body grows open rather than appearing; both follow the reduced-motion setting.
Sections that share a Group behave as an accordion: opening one closes the others in the same window.
func NewDisclosure ¶
func NewDisclosure(ui *UI, title string, content ...unison.Paneler) *Disclosure
NewDisclosure returns a closed section holding content.
func (*Disclosure) Expanded ¶
func (d *Disclosure) Expanded() bool
Expanded reports whether the section is open.
func (*Disclosure) SetExpanded ¶
func (d *Disclosure) SetExpanded(expanded bool)
SetExpanded opens or closes the section, and closes the others in its group when it opens.
type Distribution ¶
type Distribution struct {
unison.Panel
// The five numbers.
Minimum, LowerQuartile, Median, UpperQuartile, Maximum float64
// ScaleMinimum and ScaleMaximum are the scale's ends.
ScaleMinimum, ScaleMaximum float64
// Measured is false for a spread nobody measured, drawn as "—".
Measured bool
// Ink is the box's colour; the accent unless set.
Ink Ink
// Label and Unit say what it is, for a screen reader.
Label, Unit string
// contains filtered or unexported fields
}
Distribution is a spread of values: the whole range as a thin line, the middle half as a box, and the median as a mark, against a stated scale.
func NewDistribution ¶
func NewDistribution(ui *UI) *Distribution
NewDistribution returns a measured spread on a scale from 0 to 1.
func (*Distribution) ProvideAccessibility ¶
func (d *Distribution) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the spread as its five numbers.
type Divider ¶
type Divider struct {
unison.Panel
// Vertical draws the rule top to bottom rather than across.
Vertical bool
// Inset stops the rule short of both ends, for a rule inside a padded
// container where a full-length line would cut the padding in half.
Inset Measure
// contains filtered or unexported fields
}
Divider is a rule between two things: one hairline in the border colour. The border colour rather than the strong one, because a rule is decoration and not the edge of a control, and a separator drawn like the edge of something clickable reads as one.
func (*Divider) ProvideAccessibility ¶
func (d *Divider) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility says the rule is a separator.
type Dot ¶
type Dot struct {
unison.Panel
// Ink is the colour; the muted text colour unless set.
Ink Ink
// Shape is circle, square or diamond.
Shape Shape
// Hollow draws the outline only.
Hollow bool
// Label says what the dot means, for a screen reader; "" hides it from
// one.
Label string
// Size is the dot's side; a near space unless set.
Size Measure
// contains filtered or unexported fields
}
Dot is a small shape standing for one thing's state: a health level, a severity, whether something is running. It is drawn as geometry rather than as a glyph, since a circle six pixels across is exact as geometry and approximate as a glyph. Shape is its second channel beside the colour.
func (*Dot) ProvideAccessibility ¶
func (d *Dot) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the dot by its meaning, or hides it.
type DualList ¶
type DualList struct {
unison.Panel
// Available and Chosen are the two lists; Chosen is in order.
Available, Chosen []Option
// AvailableLabel and ChosenLabel head the two lists.
AvailableLabel, ChosenLabel string
// OnChange runs after an item moves, with both lists as they now are.
OnChange func(available, chosen []Option)
// contains filtered or unexported fields
}
DualList is two lists with items moving between them: what is available, and what is chosen and in what order, which is the shape of choosing which columns a table shows. The chosen side is ordered and the available side is not, because column order matters and which columns exist does not. Everything works from the keyboard: each list is one stop in the tab order whose cursor the arrow keys move and whose Return moves the item across, and the buttons between them move and reorder, each saying which way with an arrow and what it does in its name. A dual list whose only route is dragging between the panes is unusable without a mouse.
func NewDualList ¶
NewDualList returns the two lists.
type EmptyForm ¶
type EmptyForm int
EmptyForm is how much room an empty state takes.
const ( // EmptyFull is the block for an empty pane: a symbol, a sentence, a line // under it and the way to fill it, centred. EmptyFull EmptyForm = iota // EmptyCompact is the same words on one line at a slim row's height, // starting where rows start, for an empty section in a stack of them. EmptyCompact )
type EmptyState ¶
type EmptyState struct {
unison.Panel
// Form is the full block or the compact line.
Form EmptyForm
// Title says what would be here, in one short sentence.
Title string
// Detail says why it is not, or what to do about it; optional.
Detail string
// Symbol is an optional meaning name.
Symbol string
// Action is the words of the action that would fill it; "" for none. It
// is a button in the full form and a link in the compact one.
Action string
// Dashed draws a dashed edge, for a region something can be put into.
Dashed bool
// OnAction runs when the action is taken.
OnAction func()
// contains filtered or unexported fields
}
EmptyState is what a view says when it has nothing to show: what would be here and, where there is one, the action that would put something there. A blank region says nothing about whether the data is loading, the filter is too narrow or nothing has been made yet. It is also the answer for a chart with no data, since an axis drawn around zeros says the values are zero, which is a different claim from having none.
Dashed makes it the place a file is dropped. The drop is the application's; what belongs here is the dashed edge and the action, since there is no keyboard gesture for dropping a file and a drop target with no other way in is unusable without a mouse.
func NewEmptyState ¶
func NewEmptyState(ui *UI, title string) *EmptyState
NewEmptyState returns a full empty state saying title.
func (*EmptyState) ProvideAccessibility ¶
func (e *EmptyState) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the empty state as its sentence, "No transactions yet. Import a statement…", holding its action.
type Field ¶
type Field struct {
unison.Panel
// Label names the field for a screen reader.
Label string
// Placeholder is shown, faint, while the field is empty.
Placeholder string
// Error is a message under the field. Non-empty is what "in error"
// means; there is no separate flag, so the two cannot disagree.
Error string
// Shortcut names the keys that reach the field, where something does. On
// the Windows form it is shown in parentheses after the label as the
// field's tooltip, "Search (Ctrl+F)", so a route to the field is written
// down somewhere; the macOS form puts no shortcut in a tooltip (KEY-14).
// "" shows no tooltip.
Shortcut string
// ReadOnly lets the text be selected and copied but not changed.
ReadOnly bool
// Required marks a field that must be filled: told to a screen reader,
// and drawn as an asterisk after the label of the FormRow holding it
// (CON-4).
Required bool
// Masked hides what is typed behind dots, for a secret; the text can be
// neither copied nor cut (CTL-7).
Masked bool
// MaxLength is the most characters the field takes, 0 for no limit.
// Text past it, typed or pasted, is kept and reported as the field's
// error, rather than cut without a word (CTL-7).
MaxLength int
// OnChange runs after every change to the text.
OnChange func(text string)
// contains filtered or unexported fields
}
Field is a single line of text the reader types.
The editing is unison's field: the caret, selection, the clipboard, undo and what a screen reader is told about the text. The Kvit part is how it looks and what it says around the text: an outline in the strong border colour, since a field outlined in the ordinary border colour is below 3:1 in every theme and its edges cannot be found; the focus ring whenever it holds the focus, since typing goes there; a placeholder in the faint text colour; and an error that is a message under the field as well as a red outline, never the outline alone. A field that turns red and says nothing has told a reader who cannot see the red nothing at all.
The typed text is drawn by unison's own text engine rather than the Kvit text layer, so it can differ slightly from the labels around it.
The caret blinks while the field is in use, and stops, shown, once nothing has been typed or pressed in the field and the caret has not moved for ten seconds, since unison redraws the whole window for every blink (fieldcaret.go).
func (*Field) SetEnabled ¶
SetEnabled enables or disables the field, the text field inside included.
type Figure ¶
type Figure struct {
unison.Panel
// Value is the number as the caller formatted it.
Value string
// Unit follows the value; "" for none.
Unit string
// Measured is false for a value nobody measured, which draws "—".
Measured bool
// Bounded marks an upper bound rather than a measurement, drawn "~12".
Bounded bool
// Role is the value's type role; RoleBody unless set.
Role TypeRole
// Ink is the value's colour; InkTextPrimary unless set.
Ink Ink
// contains filtered or unexported fields
}
Figure is a measured value, with three rules that are the reason it is a component rather than a label with a number in it:
- tabular digits, so a column of figures lines up and a value that changes does not shift what is beside it;
- the unit smaller and muted, because the unit is the same on every row and the number is not, and setting them alike makes the reader re-read the unit to find the number;
- an em dash where nothing was measured, rather than a zero: a balance nobody has computed is not a balance of zero, and drawing it as 0 states something false.
func (*Figure) Phrase ¶
Phrase is what a screen reader is told: "12 h", "at most 12 h", or "not measured".
func (*Figure) ProvideAccessibility ¶
func (f *Figure) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the figure as text.
type FigureBlock ¶
type FigureBlock struct {
unison.Panel
Figure *Figure
// Label names the figure.
Label string
// contains filtered or unexported fields
}
FigureBlock is a figure with its name under it: one number a reader is meant to take away. The number is above and larger, because a row of these is read across the numbers.
func NewFigureBlock ¶
func NewFigureBlock(ui *UI, value, unit, label string) *FigureBlock
NewFigureBlock returns a figure in the headline role with its name.
func (*FigureBlock) ProvideAccessibility ¶
func (f *FigureBlock) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the block as "Balance: 1,284 GBP".
type FloatingView ¶
type FloatingView struct {
unison.Panel
// Title names what is in the view.
Title string
// TitleDetail is the whole of what the title names where the title is
// shortened, shown under the pointer on the title; "" says the title is
// the whole of it.
TitleDetail string
// CloseLabel is what the close control is called on hover and to a
// screen reader: "Close record" rather than "Close the view", since the
// reader is closing the record.
CloseLabel string
// Closable draws the close control.
Closable bool
// ViewWidth is the card's width, at most the region's less the margins;
// the floating view width unless set.
ViewWidth Measure
// CloseOnPressOutside closes the view on a press on the dimmed area. It
// is off unless set, since a reader half way through typing into the
// view should not lose it to a press that missed the card.
CloseOnPressOutside bool
// OnCloseRequested runs when the reader asks to close the view, by the
// close control, Escape, or a press outside where that is on.
OnCloseRequested func()
// contains filtered or unexported fields
}
FloatingView is detail about the one thing the reader selected, held over the list they selected it from rather than beside it: a centred card with the thing's name and a close control along its top, and the list dimmed behind it. A Pane takes its width out of the layout, which on a narrow window pushes a table's last columns off the edge (kvit-cash measured a ledger left 430 pixels wide at its 880-pixel minimum); a floating view takes no width, so the list keeps the whole of it at every window size. It is not a Dialog: it is closed rather than answered, floats over one region rather than the window, and holds whatever the caller puts in it.
Nothing under it hears a press meant for it, since the dimmed area takes every press and the wheel. Its card is the height of the region less the view margin, whatever it holds scrolls inside it, and its title stays put above what scrolls. Escape closes it from wherever the keyboard is.
func NewFloatingView ¶
func NewFloatingView(ui *UI, title string, body unison.Paneler) *FloatingView
NewFloatingView returns a closed view titled title, holding body.
func (*FloatingView) Open ¶
func (v *FloatingView) Open(over unison.Paneler)
Open floats the view over a region, which must be in a Kvit window.
func (*FloatingView) Opened ¶
func (v *FloatingView) Opened() bool
Opened reports whether the view is showing.
func (*FloatingView) ProvideAccessibility ¶
func (v *FloatingView) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the view by its title.
type FlowLayout ¶
type FlowLayout struct {
// Gap is the room between children in a line and between lines.
Gap Measure
// Unasked is the width to assume when none is offered; nil assumes the
// width of every child on one line.
Unasked Measure
// FillsHint makes the width asked for the width offered or assumed,
// where it is otherwise the width of every child on one line.
FillsHint bool
// ItemWidth, when set, answers the width every child is measured at and
// framed to, from the line's width, in place of the child's own.
ItemWidth func(lineWidth float32) float32
// contains filtered or unexported fields
}
FlowLayout lays the children that are not hidden out left to right, a gap apart, starting a new line where the next does not fit. The same gap separates one line from the next. Each child keeps its own width, cut to the line's width, and its own height.
func NewFlowLayout ¶
func NewFlowLayout(ui *UI, gap Measure) *FlowLayout
NewFlowLayout returns a wrapping layout with a gap between the children.
func (*FlowLayout) LayoutSizes ¶
func (f *FlowLayout) LayoutSizes(target *unison.Panel, hint geom.Size) (minSize, prefSize, maxSize geom.Size)
LayoutSizes implements unison.Layout.
func (*FlowLayout) PerformLayout ¶
func (f *FlowLayout) PerformLayout(target *unison.Panel)
PerformLayout implements unison.Layout.
type Form ¶
type Form int
Form is which system's conventions a window follows where Apple's and Microsoft's guidelines differ: the order of a dialog's buttons, the case of labels, the command key and the shortcuts, where Settings and Exit or Quit go, access keys, the words for a toggle. Linux takes the Windows form (the owner's decision of 2026-10-23, docs/ui-guidelines Q-40).
The form says what the app does, not what the system can do: the system's own menus on macOS, and which key deletes a word, follow the system the app runs on whatever the form, so a test can draw the macOS form on Linux.
type FormRow ¶
type FormRow struct {
unison.Panel
// Label names the field, in sentence case, with an "&" before the
// access key's letter where the app chooses one.
Label string
// Required marks a field that must be filled.
Required bool
// LabelWidth, on the macOS form, is the width of the label's column, so
// the fields of a form line up; nil takes the label's own width.
LabelWidth Measure
// contains filtered or unexported fields
}
FormRow is a field with its visible label (LAY-6, WRD-19): above the field on the Windows form, which Linux takes, and beside it on the macOS form. The label names the field for a screen reader, so the two cannot differ; it ends without a colon, and with an asterisk when the field must be filled, the one marking on every system (CON-4). On the Windows form the label holds the field's access key: Alt and its letter put the keyboard in the field (KEY-15).
func NewFormRow ¶
NewFormRow returns a field with its label.
func (*FormRow) ProvideAccessibility ¶
func (r *FormRow) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility leaves the row out: the field is what a reader meets.
type Gauge ¶
type Gauge struct {
unison.Panel
// Value against Allowance.
Value, Allowance float64
// Pace is how far through the period it is, 0 to 1, drawn as a tick;
// below zero draws none.
Pace float64
// Measured is false for a value nobody measured.
Measured bool
// Label and Unit say what it is, for a screen reader.
Label, Unit string
// contains filtered or unexported fields
}
Gauge is spending against an allowance: green while under, amber when ahead of the pace the period is at, red past the allowance with a bright end cap, so being over is a shape as well as a colour.
func (*Gauge) ProvideAccessibility ¶
func (g *Gauge) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the gauge as its value, allowance and how far over it is.
type Header ¶
type Header struct {
Panel
// contains filtered or unexported fields
}
Header is the strip across the top of the window: what the application is, where the reader is in it, and the actions that apply everywhere. It has three places in a fixed order, the wordmark on the left, navigation in the middle and actions on the right, because a reader who has learned where the back control is on one screen should find it in the same place on every screen and in every application.
func NewHeader ¶
func NewHeader(ui *UI, wordmark string, navigation unison.Paneler, actions ...unison.Paneler) *Header
NewHeader returns a header with a wordmark ("" for none), navigation in the middle (nil for none) and actions at the right, a near space apart.
func (*Header) ProvideAccessibility ¶
func (h *Header) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the header, which holds the application's top-level navigation.
type HelpLink ¶
type HelpLink struct {
unison.Panel
// Topic is the page and its anchor under UI.HelpRoot.
Topic string
// Question is what the topic answers, a whole question ending in a
// question mark; the link's words on the Windows form.
Question string
// contains filtered or unexported fields
}
HelpLink opens the help topic for the place it stands, where the window cannot say what the topic says (HLP-6, decided Q-34). On the Windows form, which Linux takes, it is a link worded as the question the topic answers, "How is the balance worked out?", at the bottom of the content or under the group it concerns; on the macOS form it is the round question-mark button, one per window. A topic is an HTML page shipped with the app, opened in the system's browser at its anchor: "budgets#rollover" is budgets.html in UI.HelpRoot, at #rollover.
func NewHelpLink ¶
NewHelpLink returns the help for a topic.
func (*HelpLink) ProvideAccessibility ¶
func (h *HelpLink) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility leaves the holder out; the link or button inside it is what a reader meets.
type Hint ¶
type Hint struct {
unison.Panel
// Label names what is explained; it is the button's name and the
// popover's title.
Label string
// Text is the explanation.
Text string
// contains filtered or unexported fields
}
Hint is an information symbol that opens an explanation too long for a tooltip. A press, or Space or Return on it, opens a popover holding the label and the explanation, which stays while it is read; Escape or a press outside closes it. There is no tooltip first: the label and the explanation are one piece of information, reached by one action.
type History ¶
type History struct {
// OnGo shows a place the reader went back to.
OnGo func(place any)
// contains filtered or unexported fields
}
History is the reader's own way back through the places they went in a window (LAY-10). The app says when the reader goes somewhere that counts as a step, and Back takes them to the place before. Choosing the place already shown, switching between peers in one navigation element, moving through a list and its details, and opening a dialog or a popup are not steps. Back is disabled when there is nowhere to go back to, and is never the only way to a place.
func NewHistory ¶
NewHistory returns a history that starts at a place.
func (*History) Back ¶
func (h *History) Back()
Back takes the reader to the place before, through OnGo.
type HoverCard ¶
HoverCard shows more about the thing under the pointer, without a press: the full name behind a cut-short one, the exact figure behind a rounded one, the date behind "3 days ago". It is read-only and must stay so: nothing inside one may be the only route to an action, because a surface that appears on hover cannot be reached by keyboard or by touch. A screen reader passes over it, since everything in it is a second view of what is already on the screen. Show it with Window.Show, or place it yourself.
func NewHoverCard ¶
NewHoverCard returns a card holding content, stacked top to bottom a tight space apart.
func (*HoverCard) ProvideAccessibility ¶
func (c *HoverCard) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility leaves the card and all it holds out of what a screen reader is told.
type Icon ¶
type Icon struct {
unison.Panel
// Name is the symbol's meaning name.
Name string
// Ink is the colour; InkTextPrimary unless set.
Ink Ink
// Size is the glyph's size; SizeIconSize unless set.
Size Measure
// Label, when set, is what a screen reader is told the symbol means. An
// icon without one is decoration and is hidden from screen readers.
Label string
// contains filtered or unexported fields
}
Icon is a symbol asked for by what it means rather than by what it looks like (icons.MeaningNames lists the names), so the drawing can change without touching a call site. An unrecognised name draws a box with "?" in the danger colour and logs a warning naming it, so a typo shows on the first render instead of shipping as an empty space.
func (*Icon) ProvideAccessibility ¶
func (i *Icon) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names a labelled icon as an image and hides a decorative one.
func (*Icon) Recognized ¶
Recognized reports whether the name is a known symbol.
type IconButton ¶
type IconButton struct {
// Command, when set, is what the button runs: its symbol, name,
// explanation, whether it can act and whether it is on all come from the
// command, read each time the button is drawn, and on the Windows form
// its tooltip shows the command's shortcut.
Command *Command
// Symbol is the meaning name of the symbol drawn.
Symbol string
// Label says what the button does: a verb first, in sentence case, as a
// tooltip is written on both forms.
Label string
// Asks marks a button that asks for more before acting: "…" is added to
// its tooltip (WRD-4).
Asks bool
// Explanation says more than the label can; optional.
Explanation string
// Form is Quiet or Ordinary.
Form IconButtonForm
// Dense draws the symbol at the small icon size, the size every symbol
// beside words is drawn at, rather than the full one.
Dense bool
// Checkable makes a press toggle Checked.
Checkable bool
// Checked draws the button as on: an accent edge as well as a tint, so
// the state does not rest on colour alone.
Checked bool
// TooltipEnabled shows the tooltip; true unless turned off by a control
// that already shows the label in a surface of its own.
TooltipEnabled bool
// Size is the button's square side; a control's height unless set.
Size Measure
// OnClick runs when the button is pressed.
OnClick func()
// contains filtered or unexported fields
}
IconButton is a button whose whole label is a symbol. Label is required: it is what a screen reader announces and what the tooltip shows, so the two cannot disagree. Explanation is a second sentence for what the name cannot hold, such as why the button is disabled; it follows the label in the tooltip and becomes the accessible description.
func NewBackButton ¶
func NewBackButton(ui *UI, h *History) *IconButton
NewBackButton returns the Back button for a history, a symbol button for the top leading corner of the window's header.
func NewCommandIconButton ¶
func NewCommandIconButton(ui *UI, c *Command) *IconButton
NewCommandIconButton returns a quiet icon button that runs a command.
func NewIconButton ¶
func NewIconButton(ui *UI, symbol, label string) *IconButton
NewIconButton returns a quiet icon button.
func (*IconButton) Focus ¶
func (c *IconButton) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*IconButton) Hovered ¶
func (c *IconButton) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*IconButton) KeyboardFocus ¶
func (c *IconButton) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*IconButton) Name ¶
func (b *IconButton) Name() string
Name is what the button is called: its label, or its command's name.
func (*IconButton) PerformAccessibilityAction ¶
func (b *IconButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the button for a screen reader.
func (*IconButton) Pressed ¶
func (c *IconButton) Pressed() bool
Pressed reports whether the control is being pressed.
func (*IconButton) ProvideAccessibility ¶
func (b *IconButton) ProvideAccessibility(bl *unison.AccessibilityBuilder)
ProvideAccessibility describes the button: its label as the name, its explanation as the description, and its checked state when it has one.
func (*IconButton) SetTooltip ¶
func (c *IconButton) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*IconButton) TooltipWords ¶
func (c *IconButton) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type IconButtonForm ¶
type IconButtonForm int
IconButtonForm is how an icon button looks at rest.
const ( // Quiet has no resting ground and draws one on hover, which is what a // dense toolbar wants. Quiet IconButtonForm = iota // Ordinary keeps its outline the whole time, so its edges are findable. Ordinary )
type Ink ¶
Ink is one of the theme's colours, chosen by what it is for rather than by its value, so a component given an Ink keeps following the theme as it changes. inks_gen.go has one for every token: InkTextMuted, InkDanger and the rest.
var ( InkWindowBackground Ink = func(t tokens.Tokens) palette.Color { return t.WindowBackground } InkPanelBackground Ink = func(t tokens.Tokens) palette.Color { return t.PanelBackground } InkListBackground Ink = func(t tokens.Tokens) palette.Color { return t.ListBackground } InkPopupBackground Ink = func(t tokens.Tokens) palette.Color { return t.PopupBackground } InkChipBackground Ink = func(t tokens.Tokens) palette.Color { return t.ChipBackground } InkBannerBackground Ink = func(t tokens.Tokens) palette.Color { return t.BannerBackground } InkCodePanelBackground Ink = func(t tokens.Tokens) palette.Color { return t.CodePanelBackground } InkTextPrimary Ink = func(t tokens.Tokens) palette.Color { return t.TextPrimary } InkTextSecondary Ink = func(t tokens.Tokens) palette.Color { return t.TextSecondary } InkTextMuted Ink = func(t tokens.Tokens) palette.Color { return t.TextMuted } InkTextFaint Ink = func(t tokens.Tokens) palette.Color { return t.TextFaint } InkTextDisabled Ink = func(t tokens.Tokens) palette.Color { return t.TextDisabled } InkBannerText Ink = func(t tokens.Tokens) palette.Color { return t.BannerText } InkOnAccent Ink = func(t tokens.Tokens) palette.Color { return t.OnAccent } InkBorder Ink = func(t tokens.Tokens) palette.Color { return t.Border } InkBorderStrong Ink = func(t tokens.Tokens) palette.Color { return t.BorderStrong } InkQuoteBar Ink = func(t tokens.Tokens) palette.Color { return t.QuoteBar } InkMutedGlyph Ink = func(t tokens.Tokens) palette.Color { return t.MutedGlyph } InkHoverTint Ink = func(t tokens.Tokens) palette.Color { return t.HoverTint } InkBlockHoverTint Ink = func(t tokens.Tokens) palette.Color { return t.BlockHoverTint } InkFocusTint Ink = func(t tokens.Tokens) palette.Color { return t.FocusTint } InkFocusRing Ink = func(t tokens.Tokens) palette.Color { return t.FocusRing } InkSelectionTint Ink = func(t tokens.Tokens) palette.Color { return t.SelectionTint } InkSelectionActiveTint Ink = func(t tokens.Tokens) palette.Color { return t.SelectionActiveTint } InkBlockSelectionTint Ink = func(t tokens.Tokens) palette.Color { return t.BlockSelectionTint } InkAccent Ink = func(t tokens.Tokens) palette.Color { return t.Accent } InkDanger Ink = func(t tokens.Tokens) palette.Color { return t.Danger } InkDangerBright Ink = func(t tokens.Tokens) palette.Color { return t.DangerBright } InkSuccess Ink = func(t tokens.Tokens) palette.Color { return t.Success } InkWarning Ink = func(t tokens.Tokens) palette.Color { return t.Warning } InkPinColor Ink = func(t tokens.Tokens) palette.Color { return t.PinColor } InkMarker Ink = func(t tokens.Tokens) palette.Color { return t.Marker } InkInlineCodeBackground Ink = func(t tokens.Tokens) palette.Color { return t.InlineCodeBackground } InkHighlightBackground Ink = func(t tokens.Tokens) palette.Color { return t.HighlightBackground } InkLink Ink = func(t tokens.Tokens) palette.Color { return t.Link } InkSearchMatchBackground Ink = func(t tokens.Tokens) palette.Color { return t.SearchMatchBackground } InkSearchCurrentBackground Ink = func(t tokens.Tokens) palette.Color { return t.SearchCurrentBackground } InkChangedTextBackground Ink = func(t tokens.Tokens) palette.Color { return t.ChangedTextBackground } InkAddedTextBackground Ink = func(t tokens.Tokens) palette.Color { return t.AddedTextBackground } InkRemovedTextBackground Ink = func(t tokens.Tokens) palette.Color { return t.RemovedTextBackground } InkAddedText Ink = func(t tokens.Tokens) palette.Color { return t.AddedText } InkRemovedText Ink = func(t tokens.Tokens) palette.Color { return t.RemovedText } InkCodeKeyword Ink = func(t tokens.Tokens) palette.Color { return t.CodeKeyword } InkCodeType Ink = func(t tokens.Tokens) palette.Color { return t.CodeType } InkCodeString Ink = func(t tokens.Tokens) palette.Color { return t.CodeString } InkCodeComment Ink = func(t tokens.Tokens) palette.Color { return t.CodeComment } InkCodeNumber Ink = func(t tokens.Tokens) palette.Color { return t.CodeNumber } InkCalloutTip Ink = func(t tokens.Tokens) palette.Color { return t.CalloutTip } InkAxisAttention Ink = func(t tokens.Tokens) palette.Color { return t.AxisAttention } InkAxisAttentionText Ink = func(t tokens.Tokens) palette.Color { return t.AxisAttentionText } InkAxisAgent Ink = func(t tokens.Tokens) palette.Color { return t.AxisAgent } InkAxisAgentText Ink = func(t tokens.Tokens) palette.Color { return t.AxisAgentText } InkScopeDiscovered Ink = func(t tokens.Tokens) palette.Color { return t.ScopeDiscovered } InkSignalHard Ink = func(t tokens.Tokens) palette.Color { return t.SignalHard } InkSignalSoft Ink = func(t tokens.Tokens) palette.Color { return t.SignalSoft } InkSignalHygiene Ink = func(t tokens.Tokens) palette.Color { return t.SignalHygiene } InkHatchAlt Ink = func(t tokens.Tokens) palette.Color { return t.HatchAlt } )
One Ink for every colour of the theme, named after its token.
func InkCategorical ¶
InkCategorical is categorical colour i of the current theme, for the segments of a breakdown.
type KeyFocus ¶
type KeyFocus struct {
// KeptOnPress keeps the keyboard focus shown on a panel that holds it
// when the panel is pressed, where Pressed otherwise ends it. A press on
// a panel that does not hold the focus still gives it focus that does
// not show.
KeptOnPress bool
// contains filtered or unexported fields
}
KeyFocus tracks, for a panel that takes the focus itself, whether the focus it holds came from the keyboard, by the rule Kvit's controls use: a key moved it there, or the component asked for it as an arrow key does, and a press of the pointer did not. The panel shows its focus ring while Shows answers true.
Call Pressed from the panel's MouseDownCallback before it asks for the focus, Asked before the component gives the panel the focus itself, Gained from its GainedFocusCallback and Lost from its LostFocusCallback.
func (*KeyFocus) Asked ¶
func (f *KeyFocus) Asked()
Asked says the component is about to give the panel the focus itself, as an arrow key in a list does.
type Label ¶
type Label struct {
unison.Panel
// Text is what the label says.
Text string
// Role is what the text is; its size follows from it.
Role TypeRole
// Mono sets the text in the monospace family, for an identifier that has
// to line up down a column.
Mono bool
// Tabular gives every digit the same width, so a column of figures lines
// up and a changing value does not shift the text beside it.
Tabular bool
// Weight is text.Regular unless set.
Weight int
// Ink is the colour; InkTextPrimary unless set.
Ink Ink
// Wrap lets the text run onto further lines instead of being cut short.
Wrap bool
// LineHeight multiplies the lines' height, for a paragraph read in a
// popover; 0 is 1.
LineHeight float32
// Selectable lets content text the reader may want again, a message, an
// address, an identifier, be selected whole and copied: a press selects
// it, and Copy, Ctrl+C or the context menu copies it (CTL-18). A
// control's label is never selectable.
Selectable bool
// Italic sets the text in italics, in the chrome and the monospace
// family alike.
Italic bool
// MaxLines, with Wrap, cuts the text short with "…" after this many
// lines; 0 is no limit.
MaxLines int
// Middle cuts one line short in its middle rather than at its end,
// keeping the text's start and its end. It applies where the text is
// not wrapped.
Middle bool
// Align places each line across the label's width: at its start (the
// default), in its middle or at its end.
Align text.Alignment
// Name is what a screen reader is told; the text when "".
Name string
// Heading describes the label to screen readers as a heading.
Heading bool
// Ignored keeps the label from screen readers.
Ignored bool
// NoTooltip leaves a label that is cut short without the tooltip of its
// whole text.
NoTooltip bool
// EmptyTakesNoRoom makes a label with no text ask for no size, draw
// nothing and stay out of a screen reader's way, so a line vanishes when
// it is emptied. Without it an empty label is one line tall.
EmptyTakesNoRoom bool
// Top, with Wrap, draws the text from the top of the label's box, where
// it is otherwise centred on the box's height.
Top bool
// WeightedMono, with Mono, applies Weight, which the monospace family
// otherwise ignores.
WeightedMono bool
// WrapOwnWidth, with Wrap, makes the label ask for its text's width, up
// to the width offered, where a wrapping label otherwise asks for no
// width of its own.
WrapOwnWidth bool
// Size, when set, is the text's size in place of the Role's. Reach for a
// Role first: a size of its own is for text that follows something
// other than the seven roles.
Size Measure
// contains filtered or unexported fields
}
Label is a run of chrome text at one of the seven type roles. Every other component uses it, which keeps the chrome family, the colour and the eliding rule in one place. A label wider than its column is cut short with "…", because one that grows pushes whatever is beside it off the screen, and then shows its whole text as a tooltip while the pointer rests on it (PTR-12).
func (*Label) Layout ¶
Layout is the label's text as it is laid out in a width, 0 for one unbroken line, for a component that draws over part of it, such as an underline under a few words. It is the text before MaxLines cuts it short.
func (*Label) ProvideAccessibility ¶
func (l *Label) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the label to screen readers as static text.
type LineData ¶
type LineData struct {
// Grow, above zero, gives the child this share of the width left over.
Grow float32
// Width, when set, holds the child to this width.
Width Measure
}
LineData is a line child's layout data, set with SetLayoutData, by value or by pointer.
type LineLayout ¶
type LineLayout struct {
// Gap is the room between one child and the next.
Gap Measure
// GrowLast makes the last shown child grow when no child is marked with
// Grow.
GrowLast bool
// ClipFixed cuts a child that does not grow to the room left in the
// line, and measures it again at that width.
ClipFixed bool
// FillsHint makes the width asked for the sum of the widths the children
// would get in the width offered, so a line with a grower asks for the
// whole width it is offered.
FillsHint bool
// InsetsUncounted leaves the panel's insets out of the sizes reported,
// and uses the width offered as it comes. Children are still placed
// inside the insets.
InsetsUncounted bool
// Top centres the children on the height of the tallest of them,
// measured from the top of the content, and does not cut them to the
// content's height.
Top bool
// NoShrink makes the least size the line reports the size it asks for,
// and lets a child keep its own height in a shorter line.
NoShrink bool
// AlignTop frames every child with its top at the top of the content,
// at the height it asks for at its width, uncut, as a button stays level
// with the first line of a field that grows downwards. It wins over Top.
// The sizes the line reports are unchanged.
AlignTop bool
// contains filtered or unexported fields
}
LineLayout lays the children that are not hidden out side by side, a gap apart. A child marked with Grow takes its share of the width the others leave, one marked with FixedWidth is held to that width, and any other keeps its own width, measured with no width offered. Each child is then asked for its height at the width it got, cut to the line's height when it is taller, and centred on the line's content height.
The line asks for the height of its tallest child at the width that child would get, and for the sum of its children's own widths. It does not read unison's flex layout data.
LayoutSizes and PerformLayout are exported, so a layout of an application's own can call them and add to them.
func NewLineLayout ¶
func NewLineLayout(ui *UI, gap Measure) *LineLayout
NewLineLayout returns a line's layout with a gap between the children.
func (*LineLayout) LayoutSizes ¶
func (l *LineLayout) LayoutSizes(target *unison.Panel, hint geom.Size) (minSize, prefSize, maxSize geom.Size)
LayoutSizes implements unison.Layout.
func (*LineLayout) PerformLayout ¶
func (l *LineLayout) PerformLayout(target *unison.Panel)
PerformLayout implements unison.Layout.
type Link ¶
type Link struct {
// Text is what the link says.
Text string
// Symbol is an optional meaning name drawn before the text.
Symbol string
// Role is the text's type role; RoleBody unless set.
Role TypeRole
// Explanation says in a sentence where following the link goes, for a
// destination its words alone do not describe. It is the tooltip and the
// accessible description.
Explanation string
// OnActivate runs when the link is followed.
OnActivate func()
// contains filtered or unexported fields
}
Link is an inline destination or action, announced to screen readers as a link, never as a button. Hover and keyboard focus both turn it the accent colour and underline it; it grows no chevron, ground or border of its own. Space, Return and Enter follow it, as in a browser.
func (*Link) Focus ¶
func (c *Link) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Link) Hovered ¶
func (c *Link) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Link) KeyboardFocus ¶
func (c *Link) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Link) PerformAccessibilityAction ¶
func (l *Link) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction follows the link for a screen reader.
func (*Link) Pressed ¶
func (c *Link) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Link) ProvideAccessibility ¶
func (l *Link) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the link by its words, with the explanation as its description.
func (*Link) SetLead ¶
SetLead draws p before the link's words in place of its symbol: a mark the application draws its own way, such as one that moves while something runs. It is part of the link: a press on it follows the link, and the pointer resting on it rests on the link, which the link arranges by taking over p's pointer callbacks. Each link needs a panel of its own. nil takes the lead away.
func (*Link) SetTooltip ¶
func (c *Link) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Link) TooltipWords ¶
func (c *Link) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type ListRow ¶
type ListRow struct {
// Form is the row's height.
Form RowForm
// Selected marks a chosen row.
Selected bool
// Current marks the row a list's own cursor is on, for a list that moves
// a cursor with the arrow keys rather than the focus.
Current bool
// Rule draws a hairline under the row; true unless turned off. A sub
// line and a compact row never draw one.
Rule bool
// Label is what a screen reader says for the row. A row made of several
// separate texts reads as a jumble without it.
Label string
// Interactive makes the row something to press: it takes the focus, tints
// under the pointer, draws the chevron, and answers the pointer, Return,
// Enter, Space and a screen reader's press, all with OnActivate.
Interactive bool
// NoOpensMark leaves the chevron off an interactive row that ends in a
// control of its own for the same purpose.
NoOpensMark bool
// OpensLabel says in words what pressing the row opens: the tooltip over
// the chevron, and the row's accessible description.
OpensLabel string
// OnActivate runs when an interactive row is pressed.
OnActivate func()
// Height, when set, is the row's height in place of the Form's. It is
// read on every layout, so a measure that reads the row's state, such as
// one taller with a second line, is followed.
Height Measure
// FitContent makes the row as tall as its tallest shown child at the
// width offered less the margins' width, plus the margins' height.
// Height wins over it.
FitContent bool
// FitRoom, with FitContent, is added to the content's height, in all,
// beside the margins' height. It is room inside the content's box rather
// than a margin: the children stay centred in the taller box, and a
// release in it activates the row as one on the content does. Nil adds
// nothing.
FitRoom Measure
// FitAtLeastForm, with FitContent, keeps the row at least as tall as its
// Form's height.
FitAtLeastForm bool
// Margins, when set, replace the row's own margins on all four sides;
// the chevron's room is still added on the right while the row opens
// something. With it set, a release counts anywhere in the row's box,
// margins included.
Margins unison.Border
// Place, when set, places the row's children itself, given the box
// inside the margins, in place of the row's own line. The row then asks
// for the width it is offered.
Place func(content geom.Rect)
// Arrange, when set, lays the row's children out in place of the row's
// own line, on the row's panel, whose border is the row's margins. The
// row asks for the least and preferred widths Arrange reports, and with
// FitContent takes Arrange's preferred height as its own, margins
// included, before FitRoom and FitAtLeastForm. Place and the slots win
// over it.
Arrange unison.Layout
// Leading, Title, Subtitle and Trailing are slots for a row that needs
// no arithmetic of its own. When any is set the row holds those panels
// and nothing else: Leading at its own size at the left, Title taking
// the width left with Subtitle under it, and Trailing at its own width
// at the right, a space apart, each centred on the row's height. A
// hidden slot takes no room and no gap.
Leading, Title, Subtitle, Trailing unison.Paneler
// Bar draws an accent bar this wide down the row's left edge while it is
// Selected; nil draws none.
Bar Measure
// Radius rounds the hover, selection and cursor tints and the ring; nil
// leaves them square.
Radius Measure
// RingAtEdge draws the ring just inside the row's edge, where it is
// otherwise a ring's width further in.
RingAtEdge bool
// RingHalfIn draws the ring half a ring's width inside the row's edge.
// RingAtEdge wins over it.
RingHalfIn bool
// RingOnAnyFocus shows the ring however the focus arrived, where it
// otherwise shows only for focus that came from the keyboard.
RingOnAnyFocus bool
// RingKeptOnPress keeps the keyboard focus, and its ring, on a row that
// holds it when the row is pressed, where a press otherwise ends it. A
// press on a row that does not hold the focus still gives it the focus
// without a ring.
RingKeptOnPress bool
// FocusRequestEndsOnBlur makes the row forget, when it loses the focus,
// a Focus() call made while it already held the focus, as KeyFocus.Lost
// does. Such a call changes nothing when it is made; without this, the
// row counts its next gain of the focus as one from the keyboard, with
// the ring, however that gain comes, such as a popover closing or code
// asking for the focus. A Focus() call that gives the row the focus at
// once is not affected, nor one made while the row could not take the
// focus, which still waits for the row's next gain.
FocusRequestEndsOnBlur bool
// NoHoverTint leaves the row untinted under the pointer.
NoHoverTint bool
// NoHoverTintDisabled leaves a disabled row untinted under the pointer,
// where it is otherwise tinted as an enabled one is.
NoHoverTintDisabled bool
// HoverWhole keeps the row hovered while the pointer is on anything
// inside it. unison tells only the innermost panel that the pointer
// arrived, so a row full of labels otherwise loses its tint over its own
// words.
HoverWhole bool
// HoverYields, with HoverWhole, leaves the row unhovered while the
// pointer is on a part with a hover of its own: the innermost panel under
// the pointer, or a panel between it and the row, that has a
// MouseEnterCallback or a MouseExitCallback, as a button, a link and a
// mark with a tooltip have. The row itself is not counted. Plain words
// and symbols, however deep inside the row, keep the row hovered.
HoverYields bool
// OnHover runs after the hover changed, once the event that changed it
// is over, and not at all when it changed back within that event.
OnHover func(over bool)
// PressOn is when a press activates the row: on the button's release
// inside the row (the default), or as the button goes down.
PressOn RowPress
// AnyButton lets every button do what the left one does.
AnyButton bool
// OnDoubleClick runs as the left button goes down for the second time;
// the release still activates the row.
OnDoubleClick func()
// OnPress runs as a button the row accepts goes down on it, after the
// focus is asked for (unless NoFocusOnPress), with where in the row and
// which button.
OnPress func(where geom.Point, button int)
// NoFocusOnPress leaves the focus where it is when the row is pressed;
// the row is still reached by Tab, and the press still activates it.
NoFocusOnPress bool
// OnDrag runs as the pointer moves with the button held, with where it
// is in the row's coordinates.
OnDrag func(where geom.Point)
// OnRelease runs first when the button is let go; true says the release
// was used, as the end of a drag is, and the row does not activate.
OnRelease func() (handled bool)
// OnKey is offered every key that reaches the row, after OnKeyDown and
// before the row's own handling: repeats, keys with modifiers, keys on a
// row that is not Interactive and keys that come up from a control inside
// the row among them. True says the key was used.
OnKey func(key unison.KeyCode, mods mod.Modifiers) bool
// OnKeyDown is offered every key that reaches the row before OnKey and
// the row's own handling, with whether the key is a repeat. True says the
// key was used. A row whose keys follow a rule of its own, such as
// acting on a repeat or with a modifier held, answers its keys here.
OnKeyDown func(key unison.KeyCode, mods mod.Modifiers, repeat bool) bool
// NoShiftActivate leaves Return, Enter and Space pressed with Shift to
// the panels the row sits in, where the row otherwise acts on them: a
// Region pages up on Shift+Space. OnKeyDown and OnKey are still offered
// them first.
NoShiftActivate bool
// OnFocus runs when the row gains the focus, with whether a press gave
// it, which is the opposite of what KeyboardFocus then answers; OnBlur
// when it loses it.
OnFocus func(byPointer bool)
OnBlur func()
// Description is the row's accessible description, on a row that shows
// no chevron; one that does keeps OpensLabel.
Description string
// Level is the row's one-based depth in a tree, 0 for a row in a flat
// list; Expandable and Expanded say whether it can open and has.
Level int
Expandable, Expanded bool
// contains filtered or unexported fields
}
ListRow is a row in a list: the ground, the rule under it, and what a row that can be pressed says about itself. What sits on it is the caller's; SlimRow is the arrangement nearly every list wants.
Hover and keyboard focus are separate marks, because the row under the pointer and the row the keyboard is on are different rows. A row that does something when pressed says so before it is pressed, with a chevron at its trailing edge, and a row that does nothing says nothing: a list of records and a pane of field names beside their values are both built from this, and when every row tints under the pointer the tint stops meaning anything.
func NewListRow ¶
NewListRow returns a slim row holding content, laid out left to right inside its margins, a space apart and centred on the row's height. A child that should take the width left over says so with its layout data.
func (*ListRow) Focus ¶
func (c *ListRow) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*ListRow) Hovered ¶
func (c *ListRow) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*ListRow) KeyboardFocus ¶
func (c *ListRow) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*ListRow) PerformAccessibilityAction ¶
func (r *ListRow) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens the row for a screen reader, which names the row it means rather than tabbing to it.
func (*ListRow) Pressed ¶
func (c *ListRow) Pressed() bool
Pressed reports whether the control is being pressed.
func (*ListRow) ProvideAccessibility ¶
func (r *ListRow) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the row by what it does: a list item when it can be pressed, its line of text when it has a label, and otherwise a grouping of what it holds. A row holding a control is a grouping too, label or not, since a screen reader is told nothing of what is inside a line of text, and the control would be gone from what it can reach.
func (*ListRow) SetTooltip ¶
func (c *ListRow) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*ListRow) TooltipWords ¶
func (c *ListRow) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Look ¶
type Look int
Look is how the components are drawn: in Kvit's own look, or in the look of a system, as Windows 11 or macOS draws its own controls. It is beside the Form, which says whose conventions the app follows; the look changes how a control is drawn and never what it does or says. docs/system-look-plan.md says what a look changes and what stays the theme's.
Kvit's own look is the default, and an app that does not choose draws as it always has. Only the button, the text field and the switch have a system look so far; every other component draws in Kvit's own look in any look, with the system look's focus ring.
func SystemLook ¶
func SystemLook() Look
SystemLook is the look of the system the app runs on: Windows' on Windows and the Mac's on a Mac. Linux has no look of its own yet, and keeps Kvit's until the owner decides which it draws in.
type Measure ¶
Measure is one of the values Interface derives from the interface size, chosen by name (SizeSpace, SizeViewMargin and the rest in names_gen.go), so a gap or a padding given as a Measure follows the interface size as it changes rather than keeping the value it had when the panel was built.
var ( SizeBarHeight Measure = (*tokens.Interface).BarHeight SizeBarHeightWide Measure = (*tokens.Interface).BarHeightWide SizeBody Measure = (*tokens.Interface).Body SizeBreadcrumbHeight Measure = (*tokens.Interface).BreadcrumbHeight SizeCaption Measure = (*tokens.Interface).Caption SizeChipHeight Measure = (*tokens.Interface).ChipHeight SizeColumnGap Measure = (*tokens.Interface).ColumnGap SizeControlHeight Measure = (*tokens.Interface).ControlHeight SizeDisplay Measure = (*tokens.Interface).Display SizeFloatingViewWidth Measure = (*tokens.Interface).FloatingViewWidth SizeFocusRingWidth Measure = (*tokens.Interface).FocusRingWidth SizeHairline Measure = (*tokens.Interface).Hairline SizeHeaderHeight Measure = (*tokens.Interface).HeaderHeight SizeHeadline Measure = (*tokens.Interface).Headline SizeHeightFloor Measure = (*tokens.Interface).HeightFloor SizeIconSize Measure = (*tokens.Interface).IconSize SizeIconSizeSmall Measure = (*tokens.Interface).IconSizeSmall SizePaneWidth Measure = (*tokens.Interface).PaneWidth SizePillHeight Measure = (*tokens.Interface).PillHeight SizeRadiusBar Measure = (*tokens.Interface).RadiusBar SizeRadiusCard Measure = (*tokens.Interface).RadiusCard SizeRadiusChip Measure = (*tokens.Interface).RadiusChip SizeRadiusControl Measure = (*tokens.Interface).RadiusControl SizeRadiusPill Measure = (*tokens.Interface).RadiusPill SizeRailWidth Measure = (*tokens.Interface).RailWidth SizeRowHeight Measure = (*tokens.Interface).RowHeight SizeRowHeightCompact Measure = (*tokens.Interface).RowHeightCompact SizeRowHeightSlim Measure = (*tokens.Interface).RowHeightSlim SizeRowHeightSub Measure = (*tokens.Interface).RowHeightSub SizeSidebarWidth Measure = (*tokens.Interface).SidebarWidth SizeSmall Measure = (*tokens.Interface).Small SizeSpace Measure = (*tokens.Interface).Space SizeSpaceLoose Measure = (*tokens.Interface).SpaceLoose SizeSpaceNear Measure = (*tokens.Interface).SpaceNear SizeSpaceSnug Measure = (*tokens.Interface).SpaceSnug SizeSpaceTight Measure = (*tokens.Interface).SpaceTight SizeSpaceWide Measure = (*tokens.Interface).SpaceWide SizeStackGap Measure = (*tokens.Interface).StackGap SizeStatusBarHeight Measure = (*tokens.Interface).StatusBarHeight SizeStrong Measure = (*tokens.Interface).Strong SizeTabHeight Measure = (*tokens.Interface).TabHeight SizeTagHeight Measure = (*tokens.Interface).TagHeight SizeTitle Measure = (*tokens.Interface).Title SizeViewMargin Measure = (*tokens.Interface).ViewMargin SizeWidthDrawn Measure = (*tokens.Interface).WidthDrawn SizeWidthFloor Measure = (*tokens.Interface).WidthFloor SizeWidthLaptop Measure = (*tokens.Interface).WidthLaptop )
One Measure for every value Interface derives from the interface size.
type MenuBar ¶
MenuBar is a main window's menus, built from the app's commands, with the platform's standard menus in its standard order (CMD-1 to CMD-8). A standard command goes in its standard menu at its standard place without being told where: Save in File, Copy in Edit, Settings last in Tools on the Windows form and in the app menu on the macOS form, Exit last in File on the Windows form and Quit last in the app menu on the macOS form. The app's own commands go in a standard menu with AddTo or in a menu of their own with AddMenu.
On the Windows form, which Linux takes, the bar is drawn by Kvit across the top of the window: File, Edit, View, the app's menus, Tools, Help, each with an access key. A press on a title opens its menu; Alt on its own or F10 puts the keyboard in the bar, and Alt with a title's letter opens that menu. On the macOS form on a Mac it is the system's menu bar: the app menu, File, Edit, Format, View, the app's menus, Window and Help. On the macOS form elsewhere, as in a test or the gallery, Kvit draws the macOS menus in the window, so the form can be seen on any system.
Window.SetMenuBar puts the bar in a window and makes the window answer the keys of every command on it.
func (*MenuBar) Add ¶
Add puts standard commands in their standard menus at their standard places in the app's form. A command of the app's own belongs in AddTo or AddMenu, and is left out with a warning.
func (*MenuBar) AddMenu ¶
AddMenu adds a menu of the app's own, after View and before Tools (or Window): title in sentence case, with its access key, "&Transaction".
func (*MenuBar) AddTo ¶
AddTo puts the app's own lines in one of the standard menus, as a group of their own: in View before the standard lines (the window's parts and panes come first, CMD-6), in File before Exit, in Tools before Settings, and after the standard lines elsewhere.
func (*MenuBar) Commands ¶
Commands are every command on the bar, standard and the app's own, each once, in menu order.
func (*MenuBar) Menus ¶
Menus are the bar's menus as the app's form arranges them, the empty ones left out.
func (*MenuBar) OpenMenu ¶
OpenMenu opens the menu under the title at index i, as a press on the title does.
func (*MenuBar) PerformAccessibilityAction ¶
func (b *MenuBar) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens or closes a menu for a screen reader.
func (*MenuBar) ProvideAccessibility ¶
func (b *MenuBar) ProvideAccessibility(bl *unison.AccessibilityBuilder)
ProvideAccessibility describes the bar and its menus' titles.
type MenuButton ¶
MenuButton is a button that opens a menu of commands refining its own action, drawn with a down-arrow after its words so the menu is expected (CMD-17). It lists at least three commands: one or two are buttons of their own, and a view's main actions are on the screen rather than in a menu.
func NewMenuButton ¶
func NewMenuButton(ui *UI, label string, items ...MenuItem) *MenuButton
NewMenuButton returns an ordinary button that opens a menu.
func (*MenuButton) Focus ¶
func (c *MenuButton) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*MenuButton) Hovered ¶
func (c *MenuButton) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*MenuButton) KeyboardFocus ¶
func (c *MenuButton) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*MenuButton) PerformAccessibilityAction ¶
func (b *MenuButton) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens the menu for a screen reader.
func (*MenuButton) Pressed ¶
func (c *MenuButton) Pressed() bool
Pressed reports whether the control is being pressed.
func (*MenuButton) ProvideAccessibility ¶
func (b *MenuButton) ProvideAccessibility(bl *unison.AccessibilityBuilder)
ProvideAccessibility describes the button as one that opens a menu.
func (*MenuButton) SetTooltip ¶
func (c *MenuButton) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*MenuButton) TooltipWords ¶
func (c *MenuButton) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type MenuItem ¶
type MenuItem struct {
// Command is what the line runs: its words, symbol, shortcut,
// explanation, tick and whether it can act now all come from the
// command, read as the menu opens, unless the fields below are set.
Command *Command
// Text is what the line says, in sentence case: kvit-ui writes it in
// title case on the macOS form (WRD-6). An "&" before a letter makes it
// the line's access key: "Open &folder…" is drawn with the f underlined
// and chosen by typing F while the menu is open. "&&" is an ampersand.
// The macOS form, which has no access keys, draws the words without the
// marker.
Text string
// Verbatim leaves Text as written on both forms, for a line naming the
// reader's own thing, such as a recent file; pass such words through
// PlainMenuText too.
Verbatim bool
// Asks marks a line that asks for more before acting: "…" is added to
// its words (WRD-4).
Asks bool
// Shortcut is the key shown at the right of the line, which is how a
// menu teaches that there is a faster way; the zero value shows none. A
// context menu on the macOS form shows none (CMD-11).
Shortcut Shortcut
// Key is a shortcut given as unison's key binding, shown as unison
// writes it; Shortcut is the form-aware way.
Key unison.KeyBinding
// Symbol is an optional meaning name drawn before the words. A line made
// from a Command takes the command's symbol if it has none, except a Radio
// line, which draws only a symbol set here.
Symbol string
// Picture is drawn before the words in place of Symbol, fitted inside the
// symbol's column with its shape kept: a line naming something with a
// picture of its own, such as a project's icon. It keeps its own colours,
// so a destructive line does not tint it, and a disabled line dims it. A
// mark that says a line's state takes its place, as it does a symbol's: a
// tick, the bullet or tick of the chosen Radio line, and a Mixed line's
// mark, or its lack of one on the Windows form. An unchosen Radio line has
// no mark, so it draws its picture. The system's own menu on macOS draws no
// symbols and no pictures.
Picture unison.Drawable
// Explanation is one sentence saying what choosing the line does, for a
// line whose words cannot say it: shown as its tooltip and told to a
// screen reader, never in place of the words.
Explanation string
// Danger draws a destructive line in the danger colour. A destructive
// line goes last, and the menu puts a separator before it (CMD-23), since
// a red line among black ones is the commonest colour-only distinction
// there is and misreading it costs the most.
Danger bool
// Checked marks an option that is on with a tick in place of its symbol.
Checked bool
// Radio marks the line as one of a set of options of which one is chosen:
// the chosen one, Checked, has a bullet on the Windows form and a tick on
// the macOS form (CMD-15). The bullet or tick stands in place of its Picture
// or Symbol, and the others, with no mark to show, draw theirs. A Radio line
// made from a Command does not take the command's symbol, so a set of options
// used as a list of places stays plain.
Radio bool
// Mixed marks an option that is on for only part of the selection: no
// mark on the Windows form, a dash on the macOS form (CMD-15).
Mixed bool
// TurnOn and TurnOff are an on-and-off line's words on the macOS form,
// where the line says what choosing it does: TurnOn while it is off,
// TurnOff while it is on, with no tick. The Windows form keeps Text and
// ticks it while Checked (WRD-12).
TurnOn, TurnOff string
// Default marks what double-clicking or Return on the item does, drawn
// in bold in a context menu on the Windows form (CMD-10, Q-33).
Default bool
// Disabled draws the line and does nothing when chosen. A context menu
// leaves a line that cannot act out instead (CMD-10), except Cut, Copy and
// Paste on the macOS form.
Disabled bool
// Separator makes the line a divider between groups instead.
Separator bool
// OnSelect runs when the line is chosen.
OnSelect func()
// Items make the line open a submenu of its own instead of acting: beside
// the line, when the pointer rests on it or on Right, Return or Space, and
// closed again by Left or Escape. The line draws a chevron where a
// shortcut would go.
Items []MenuItem
}
MenuItem is one line of a menu opened with ShowMenu.
type ModalPress ¶
type ModalPress int
ModalPress is what becomes of a press outside a modal popover.
const ( // ModalPressStops ends the press at the popover: it closes the popover, // or runs OnPressOutside, and presses nothing behind. ModalPressStops ModalPress = iota // ModalPressPasses closes the popover, or runs OnPressOutside, at once, // and where that closed the popover the same press goes on to what is // behind it. While the popover stays open the scrim takes the press. ModalPressPasses )
type Mods ¶
type Mods uint8
Mods are the modifier keys of a Shortcut, named for what they do on both forms rather than for one keyboard, so a shortcut is written once.
const ( // ModPrimary is the command key: Ctrl on the Windows form, Command on // the macOS form (KEY-3). ModPrimary Mods = 1 << iota // ModShift is Shift, which adds a related variant: Ctrl+Shift+Z redoes // what Ctrl+Z undid. ModShift // ModAlt is Alt on the Windows form and Option on the macOS form. On the // Windows form Alt with a letter or a digit belongs to access keys and is // never a shortcut (KEY-15). ModAlt // ModControl is the Control key itself on the macOS form, beside // Command, as in Ctrl-Cmd-F for full screen. On the Windows form it is // Ctrl, the same key as ModPrimary. ModControl )
type MoneyField ¶
type MoneyField struct {
NumberField
// Currency is the ISO 4217 code shown in the field; "" shows none, for a
// field where the currency is already clear.
Currency string
}
MoneyField is an amount of money: a number field that works in minor units, takes its decimal places from the currency, and shows the currency inside its right-hand end. The reader types 12.34 and MinorUnits is 1234, a whole number, which is what a ledger stores; money in floating point is where 0.1 + 0.2 is not 0.3 and a balance drifts by a penny nobody can find. The yen has no minor digits and the Bahraini dinar three, and a field that assumes two divides or multiplies those by a hundred. The currency is beside the amount rather than in a column heading, because a ledger can hold more than one.
func NewMoneyField ¶
func NewMoneyField(ui *UI, currency string, minorDigits int) *MoneyField
NewMoneyField returns an empty amount in a currency with minorDigits decimal places: 2 for most, 0 for the yen, 3 for the dinar.
func (*MoneyField) MinorUnits ¶
func (f *MoneyField) MinorUnits() (int64, bool)
MinorUnits is the amount as a whole number of minor units — pence, cents, sen — and false while the text is not a valid amount.
type Mover ¶
type Mover struct {
// EscapeAbandons makes Escape during a drag put the panel back where the
// drag began, in a Kvit window. Without it Escape does nothing to the
// drag.
EscapeAbandons bool
// AnyPressEnds makes a press of any button that arrives while a drag is
// under way end the drag first, leaving the panel where the drag brought
// it; the press is then handled as any other. Without it a second button
// pressed during a drag is passed on, and the drag goes on while the
// panel's own callback takes that press. Either way the drag is over when
// the left button is let go, wherever unison sends the release.
AnyPressEnds bool
// contains filtered or unexported fields
}
Mover lets the reader move a panel shown in a window's popup layer, such as a modal Popover with a title line of its own, by pressing in the band along its top and dragging. The point pressed stays under the pointer as far as the popup's bounds allow. Once moved, the panel keeps its place, measured from the corner of the bounds, when its content changes height or the window is resized, and is kept whole inside the bounds.
The popup's Place function passes what it would answer through Place. A surface that should open in the middle every time calls Reset when it opens; one that should open where the reader left it does not. A Dialog has a drag of its own and needs none of this.
func NewMover ¶
NewMover wraps p's pointer callbacks, so set any of p's own before calling it; band is the height of the band a drag starts in, from the panel's top, in the panel's coordinates. A press anywhere else, and with any button but the left, goes to the callback that was there before, and a control in the band takes its own presses.
type NetFlow ¶
type NetFlow struct {
unison.Panel
// Ins and Outs are what came in and went out over each period, indexed
// together; NotMeasured is a period nobody measured, drawn as a tick on
// the baseline rather than as a zero.
Ins, Outs []float64
// Periods name the columns, one each, in the same order.
Periods []string
// Maximum is the scale both directions are drawn against; 0 takes the
// largest value present.
Maximum float64
// RisingLabel, FallingLabel and NetLabel name the parts in a key above
// the plot; all empty draws no key.
RisingLabel, FallingLabel, NetLabel string
// RisingInk and FallingInk are the bars' colours: the first two
// categorical colours unless set, never a meaning colour by default,
// since success and danger mean finished and stalled everywhere else. A
// caller whose directions are good and bad news says so. NetInk is the
// line's; the primary text colour unless set.
RisingInk, FallingInk, NetInk Ink
// Label names the chart for a screen reader.
Label string
// PlotHeight is the plot's height without the key and the names; 64
// design pixels unless set.
PlotHeight Measure
// contains filtered or unexported fields
}
NetFlow is two opposed series over the same periods, on one baseline and one scale, with what they come to drawn as a line: what came in is drawn up from the baseline and what went out is drawn down, so which was larger in a period is a glance at where the two bars of a column meet. Two Sparks, one over the other, cannot say that however they are scaled, since each is drawn up from its own bottom edge and reading one against the other is comparing two bars an inch apart with no common line. Each column names its period underneath, and the names thin out to whatever spacing they fit in, counted back from the newest column so the end of the series is always named.
func NewNetFlow ¶
NewNetFlow returns a chart of what came in and went out over periods.
func (*NetFlow) ProvideAccessibility ¶
func (n *NetFlow) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the chart and says how many periods it holds and which way each direction is drawn.
type Notice ¶
type Notice struct {
unison.Panel
// Text is the condition; Detail, optional, says more.
Text, Detail string
// Tone is info, success, warning or danger.
Tone Tone
// Action is the words of the way out of the condition; "" for none.
Action string
// ActionHint says what pressing the action does, where its words cannot
// (kvit-cash): the action's tooltip.
ActionHint string
// Dismissible draws a close control.
Dismissible bool
// OnAction and OnDismiss run when the action or the close control is
// pressed.
OnAction, OnDismiss func()
// contains filtered or unexported fields
}
Notice is a message that stays: a banner across the top of a view saying something is wrong, out of date or waiting. A toast acknowledges something that finished; a notice is a condition still true. It can be dismissed only when dismissing it means something: "your licence expires in three days" can be, "this file could not be saved" cannot, because the condition outlives the reader's having seen it.
func (*Notice) ProvideAccessibility ¶
func (n *Notice) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the notice as its condition and detail.
type NumberField ¶
type NumberField struct {
Field
// Minimum and Maximum bound the value; no bound unless set.
Minimum, Maximum float64
// Decimals is how many decimal places the value has; 0 for a whole
// number.
Decimals int
}
NumberField is a number the reader types, right-aligned, as a Figure is, because a column of these is compared down the units digit. It checks what is typed as it is typed and says what is wrong through the field's Error, rather than refusing keys: a field that ignores a key gives no reason, and the commonest cause is a decimal separator the reader's locale writes differently from the one the field expects. So both are accepted: "3,50" typed on a German keyboard is 3.5.
The text is rounded to the field's decimal places when the reader leaves the field, not as they type, since reformatting under the caret moves it.
func NewNumberField ¶
func NewNumberField(ui *UI) *NumberField
NewNumberField returns an empty number field with no bounds.
func (*NumberField) SetText ¶
func (n *NumberField) SetText(s string)
SetText replaces the text and checks it.
func (*NumberField) Valid ¶
func (n *NumberField) Valid() bool
Valid reports whether the text is a number within the bounds.
func (*NumberField) Value ¶
func (n *NumberField) Value() (float64, bool)
Value is the number typed, and false while the text is not a number.
type Option ¶
type Option struct {
// Value is what the choice means to the caller.
Value string
// Label is what the segment, or the select's line, says, in sentence
// case: a segment is written in title case on the macOS form (WRD-6). It
// is also what a screen reader is told, whatever Symbol or Picture is set.
Label string
// Symbol is an optional meaning name drawn before the words of the
// option's line in a Select's list, as a MenuItem's is. The closed select
// draws the chosen option's words alone. Segmented and DualList ignore it.
Symbol string
// Picture is drawn before the words of the option's line in a Select's
// list in place of Symbol, as a MenuItem's is: a choice naming something
// with a picture of its own, such as a project's icon. The chosen line
// draws its bullet (Windows form) or tick (macOS form) in its place, and
// the system's own menu on macOS draws no pictures and no symbols. The
// closed select draws the chosen option's words alone. Segmented and
// DualList ignore it.
Picture unison.Drawable
}
Option is one choice in a Segmented control or a Select.
type Options ¶
type Options struct {
// SettingsPath is the settings file; "" keeps every choice for this run
// only, which is what a test wants.
SettingsPath string
// FontCacheDir is where the index of system fonts is kept; "" uses the
// user cache directory.
FontCacheDir string
// IgnoreDesktop leaves the desktop's appearance and locale out, so
// "system" is light, motion is on, numbers are written as under the C
// locale, with no digit grouping, and the form is the Windows form on
// every system. Screenshots and tests want the same result on every
// machine.
IgnoreDesktop bool
}
Options configure New.
type OwnSizeLayout ¶
type OwnSizeLayout struct {
// CountInsets adds the panel's insets to what the child asks, and takes
// their width off the width the child is asked at.
CountInsets bool
// HiddenGone makes a hidden child take no room.
HiddenGone bool
}
OwnSizeLayout gives a panel's first child the whole of its content and asks for what the child asks. A hidden child keeps its room, since its sizes are still asked, and a panel with no children asks for nothing.
func (OwnSizeLayout) LayoutSizes ¶
func (o OwnSizeLayout) LayoutSizes(target *unison.Panel, hint geom.Size) (minSize, prefSize, maxSize geom.Size)
LayoutSizes implements unison.Layout.
func (OwnSizeLayout) PerformLayout ¶
func (o OwnSizeLayout) PerformLayout(target *unison.Panel)
PerformLayout implements unison.Layout.
type Pane ¶
type Pane struct {
Panel
// Title names what the pane shows.
Title string
// CloseLabel is what the close control is called, on hover and to a
// screen reader: "Close record" for a pane holding one record, since the
// reader is closing the record rather than the furniture it arrived in.
CloseLabel string
// Closable draws the close control; true unless set, and off for a pane
// the reader cannot dismiss (kvit-cash).
Closable bool
// OnClose runs when the close control is pressed.
OnClose func()
// contains filtered or unexported fields
}
Pane is the side pane: detail about the one thing the reader has selected, beside the list they selected it from. It is the same width wherever it appears: a pane that is 320 pixels on one screen and 420 on another makes the list beside it reflow as the reader moves between them, which reads as the application losing its place. Put it over a view with WithPane; it slides in and out rather than appearing, following the reduced-motion setting.
func (*Pane) ProvideAccessibility ¶
func (p *Pane) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the pane by its title.
type Panel ¶
type Panel struct {
unison.Panel
// RuleTop, RuleBottom, RuleLeft and RuleRight draw a hairline along that
// edge. A panel between two others usually wants one on the side it
// abuts and none anywhere else.
RuleTop, RuleBottom, RuleLeft, RuleRight bool
// contains filtered or unexported fields
}
Panel is a region of the window with its own ground: a sidebar, a toolbar strip, the area behind a group of controls. A panel is part of the window's furniture and its edges are the window's edges, so it has no corner radius; a card is an object sitting on a surface, and has one.
type PhonePages ¶
type PhonePages interface {
Status() phone.Status
NewCode() (string, time.Time, error)
Unpair(id string) error
SetUpTailscale(done func(error))
RefreshTailscale()
}
PhonePages is what the Phone section of an app's settings shows and does: the app's phone pages (package phone), of which *phone.Server is one. Status, NewCode and Unpair are called on the interface's thread; RefreshTailscale on a goroutine of the section's own, since it waits for the tailscale command; SetUpTailscale calls done on a goroutine of its own.
type PhoneSettings ¶
type PhoneSettings struct {
unison.Panel
// Key is the settings key of the switch that serves the pages.
Key string
// contains filtered or unexported fields
}
PhoneSettings is the Phone section of an app's settings, for the pages the app serves to the owner's iPhone (docs/phone-pages.md), as a column of setting rows for a settings pane:
- Serve pages to your phone, a switch, with the pages' address under it once Tailscale passes the phone's requests to them;
- Tailscale, while it lacks something, with Connect Tailscale, or Check again for what the owner sets right in Tailscale itself;
- Pair a phone, with the code it shows and, beside it, a QR code of the address the phone's camera opens the pages with;
- each phone paired, with Unpair, which asks first.
The switch is the app's setting Key in UI.Settings, which the pages follow (phone.Server.Follow). The section reads the pages as it is made, on Refresh, which the app calls as its settings are shown, and on Changed, which the app calls from phone.Options.Changed on any goroutine.
func NewPhoneSettings ¶
func NewPhoneSettings(ui *UI, pages PhonePages, key string) *PhoneSettings
NewPhoneSettings returns the Phone section for pages, whose switch is the setting key in ui.Settings.
func (*PhoneSettings) Changed ¶
func (s *PhoneSettings) Changed()
Changed shows the pages as they stand now; it may be called on any goroutine, as phone.Options.Changed is.
func (*PhoneSettings) Confirming ¶
func (s *PhoneSettings) Confirming() *Popover
Confirming is the question Unpair is asking, nil while none is open.
func (*PhoneSettings) ProvideAccessibility ¶
func (s *PhoneSettings) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the section as a group by what it is for.
func (*PhoneSettings) Refresh ¶
func (s *PhoneSettings) Refresh()
Refresh reads Tailscale's state again, on a goroutine of its own, and shows the pages as they stand; the app calls it as its settings are shown.
type Pip ¶
type Pip struct {
unison.Panel
// Filled of Total dots are filled.
Filled, Total int
// Ink is the filled dots' colour; the accent unless set.
Ink Ink
// Label says what is counted; "3 of 5" unless set.
Label string
// contains filtered or unexported fields
}
Pip is a row of dots standing for a small count: three of five days recorded, two of four checks passed. It is for counts a reader takes in without counting, up to about seven; past that a Figure is faster to read. Filled and hollow dots rather than a bar, because a pip row answers "how many of these" and a bar "how far along".
func (*Pip) ProvideAccessibility ¶
func (p *Pip) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the row as a progress bar, "3 of 5".
type Popover ¶
type Popover struct {
unison.Panel
// Title names the popover for a screen reader.
Title string
// Width holds the popover to a width, its height following from it; nil
// takes the width its content asks for.
Width Measure
// OnClose runs after the popover closes.
OnClose func()
// OnEscape runs when Escape is pressed while the popover is open, in
// place of closing it; nil closes it.
OnEscape func()
// OnPressOutside runs when the pointer is pressed outside the popover,
// in place of closing it; nil closes it.
OnPressOutside func()
// PressOutsideIgnored makes a press outside the popover do nothing;
// OnPressOutside is not used.
PressOutsideIgnored bool
// ModalPress is what becomes of a press outside a popover opened with
// OpenModal, once it has closed the popover or run OnPressOutside: it
// goes no further (the default), or it goes on to what is behind.
ModalPress ModalPress
// MayClose, when set, is asked by Close, and by Escape and a press
// outside where they close the popover: false leaves it open, as while it
// shows work that cannot be stopped.
MayClose func() bool
// FirstFocus answers what takes the keyboard when the popover opens; nil,
// or answering nil, gives it to the first control inside.
FirstFocus func() *unison.Panel
// NoFocusBack leaves the focus alone when the popover closes, where Close
// otherwise gives it back to what held it when the popover opened.
NoFocusBack bool
// contains filtered or unexported fields
}
Popover is a small surface anchored to a control, holding something the reader can act on: a picker, a filter, a short form. It takes the keyboard focus and closes on Escape or on a press outside it, which is what sets it apart from a HoverCard: a surface a reader can type into has to be reachable and dismissible by keyboard, and one that only appears on hover can be neither. Closing gives the focus back to where it was before, unless the reader has put it somewhere else since.
func NewPopover ¶
NewPopover returns a closed popover holding content, stacked top to bottom a near space apart.
func (*Popover) Close ¶
func (p *Popover) Close()
Close takes the popover away and gives the focus back, unless NoFocusBack.
func (*Popover) Open ¶
func (p *Popover) Open(anchor unison.Paneler, place func(bounds geom.Rect, size geom.Size) geom.Rect)
Open shows the popover in the anchor's window, where place puts it, and gives it the keyboard focus. It does nothing outside a Kvit window.
func (*Popover) OpenModal ¶
func (p *Popover) OpenModal(anchor unison.Paneler, place func(bounds geom.Rect, size geom.Size) geom.Rect)
OpenModal shows the popover as Open does, over a scrim that takes every press, so nothing behind it can be used until it closes. ModalPress says whether the press that closes it from outside reaches what is behind.
func (*Popover) ProvideAccessibility ¶
func (p *Popover) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the popover as a dialog.
type Popup ¶
type Popup struct {
// Panel is what is shown.
Panel unison.Paneler
// Place gives where it goes, in the window's content coordinates, from
// the content's bounds and the panel's preferred size. It is asked on
// every layout, so the popup follows its anchor when the window changes.
Place func(bounds geom.Rect, size geom.Size) geom.Rect
// Modal lays a scrim over everything below it that takes every press,
// so the popup has to be answered first.
Modal bool
// OnEscape runs when Escape is pressed while this is the topmost popup
// that is not passive; nil leaves Escape alone.
OnEscape func()
// Passive is a popup that only informs, such as a tooltip: it never has
// the focus, so Escape passes it by and goes to the popup under it, or to
// the window when there is none.
Passive bool
// OnPressOutside runs when the pointer is pressed outside it. The press
// closes the popup and goes no further, so it never presses a button
// behind it, except on a control that opens a popup of its own, which
// opens in the same press (PTR-13, decided Q-43; see OpensPopup).
OnPressOutside func()
// PressPasses lets the press that runs OnPressOutside go on to what is
// under the pointer, whatever that is. It is for a field shown over the
// place it edits, such as a table's cell: a press on another cell closes
// this field and opens that one in the same press. A press that also
// closes a popup without it, such as a menu above the field, still goes
// no further.
PressPasses bool
// OpenedFrom, when set, is the part of the window the popup was opened
// from, such as a menu's button, in the window's content coordinates. A
// press there runs OnPressOutside and goes no further: reaching the
// button, it would open the popup again as soon as it closed.
OpenedFrom func() geom.Rect
// Anchor, when set, is what the popup belongs to: once it is no longer in
// the window, as when the page holding it is replaced, the popup goes too.
Anchor unison.Paneler
// Ambient is a popup that takes nothing from the window, as a teaching
// tip does: the window's keys, Escape and Tab go on working around it, a
// press outside it leaves it where it is, and a press inside it reaches
// its controls.
Ambient bool
// HoldsKeyboard keeps Tab and Shift+Tab among the popup's own controls
// while it is the topmost, as a popover does until it closes (KEY-8); a
// modal popup always does.
HoldsKeyboard bool
}
Popup is a surface shown above everything else in a Window: a tooltip, a popover, a dialog.
type Progress ¶
type Progress struct {
unison.Panel
// Value against Maximum, 1 unless set.
Value, Maximum float64
// Determinate says the total is known; false draws the moving band.
Determinate bool
// Label says what is happening.
Label string
// ShowPercent draws the share done beside the label; off unless set,
// since the label saying what is happening is what the reader needs
// (FDB-10).
ShowPercent bool
// Remaining is how long the work is expected to take still, said as
// "About 3 minutes left" beside the label; 0 says nothing (FDB-10).
Remaining time.Duration
// HaltText is the words of the button that stops the work: Cancel while
// stopping leaves no trace, Stop once what is done is kept (FDB-3,
// WRD-8); "" draws no button. OnHalt runs when it is pressed.
HaltText string
OnHalt func()
// Pausable draws Pause beside the bar, Resume while Paused, for work
// that cancelling would throw away (FDB-3); OnPause runs with the new
// state.
Pausable, Paused bool
OnPause func(paused bool)
// contains filtered or unexported fields
}
Progress is how far through something the application is. Which of two states it is in is the most useful thing on the bar: with a known total the fill says how much is done, and without one a band moves to say only that work is happening, since an unknown total drawn as a bar creeping towards the end is what makes people distrust progress bars. It carries a label saying what is happening: "47%" says how far, and not how far through what.
func NewProgress ¶
NewProgress returns a determinate bar at value of 1, labelled.
func (*Progress) ProvideAccessibility ¶
func (p *Progress) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the bar as its label and how far it is, or that it is under way.
type RadioGroup ¶
type RadioGroup struct {
unison.Panel
// Label names the group for a screen reader.
Label string
// Current is the chosen option's value.
Current string
// OnChoose runs when the reader chooses an option.
OnChoose func(value string)
// contains filtered or unexported fields
}
RadioGroup is one choice from a handful, all visible, each with room for a sentence saying what it means: "Follow the system" beside "Always dark" beside "Always light", each with a line under it. A Segmented control is for two to four short options whose words explain themselves, and a Select for a list too long to lay out. The arrow keys move within the group and choose, and Tab leaves it, which is what a screen reader user expects of a radio group and what a column of separate controls does not do. On the Windows form Ctrl and an arrow move without choosing, and Space chooses the option the keyboard is on (KEY-9).
func NewRadioGroup ¶
func NewRadioGroup(ui *UI, label string, options ...RadioOption) *RadioGroup
NewRadioGroup returns a group of options, none chosen.
func (*RadioGroup) Choose ¶
func (g *RadioGroup) Choose(value string)
Choose makes the option with a value the chosen one.
func (*RadioGroup) Options ¶
func (g *RadioGroup) Options() []RadioOption
Options are the group's options, in order.
func (*RadioGroup) ProvideAccessibility ¶
func (g *RadioGroup) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the group.
type RadioOption ¶
RadioOption is one choice in a RadioGroup, with an optional sentence under it saying what it means.
type Region ¶
type Region struct {
unison.Panel
// Padding is the space inside the scrolled area, around the content; the
// view margin unless set, which is what a body directly inside a window
// wants. A region inside a card that already has padding sets Px(0).
Padding Measure
// Horizontal lets the content be wider than the region and scroll
// sideways too.
Horizontal bool
// StripWhenScrolling keeps no strip for the vertical bar while all the
// content fits, so the content has the region's whole width until it
// scrolls: for a region that usually shows everything it holds, as a
// dialog's content does, whose layout should not change for a bar that
// is not there.
StripWhenScrolling bool
// contains filtered or unexported fields
}
Region is a body that takes the height it is given and scrolls what does not fit. Its scroll bars sit in strips of their own beside the content rather than over it, and the strips are kept whether or not a bar is showing: sizing the content to whether the bar shows is a loop for anything whose height depends on its width, and content that moves aside the moment a list grows past the fold is worse.
It answers the wheel with the distance the wheel was turned, the keys every desktop scrolling view answers (Page Up, Page Down, Home, End and the arrows) when nothing inside wanted them, and it brings whatever the keyboard has just reached into view.
func NewSettingsPage ¶
func NewSettingsPage(ui *UI, about *About, panes ...SettingsPane) *Region
NewSettingsPage returns an app's settings as the Windows form has them, which Linux takes (WIN-16): a page for the app's window, filling it as one scrolling column with each pane a section under its name, in order, and About last, at most a readable width wide. Each change takes effect as it is made, so there is no OK, Cancel or Apply (WIN-23). The same panes make the SettingsWindow of the macOS form, so an app writes its settings once; a pane's content is in one place at a time, the page or the window.
func (*Region) ScrollTo ¶
ScrollTo scrolls the content so y is at the top of the view, kept within the content's ends.
func (*Region) Scrolls ¶
Scrolls reports whether anything in the region is out of sight, which a caller may need in order to say so.
func (*Region) ViewHeight ¶
ViewHeight is the height of the part of the content in view.
type RowForm ¶
type RowForm int
RowForm is one of a list row's four heights. The height is chosen by what the row holds rather than by how many rows a view wants to fit: shrinking rows to fit more in is what made kvit-hub's earlier interface read as busy.
const ( // RowSlim is one line: a name, what it is, one phrase and one figure. RowSlim RowForm = iota // RowFull is a name over a description, with chips and figures beside. RowFull // RowSub is a line expanded under a row, indented under its parent. RowSub // RowCompact is a disclosure or a group heading. RowCompact )
type SearchField ¶
type SearchField struct {
Field
// Matches is how many things the filter left; below zero says nothing,
// for a filter whose result is not a countable list.
Matches int
// MatchedNoun is the word for one of them, "result" unless set.
MatchedNoun string
// MatchedNounPlural is the word for several; "" adds an s.
MatchedNounPlural string
// contains filtered or unexported fields
}
SearchField is a field that filters something. It differs from Field in what it does rather than how it looks: a magnifier makes it findable without reading the placeholder, a clear button appears only when there is something to clear, and Escape clears rather than reverting, which is what a reader expects of a filter. It also says how many things the filter left, because filtering is the one interaction whose whole outcome happens somewhere else on the screen, and a screen reader user typing into a filter that says nothing gets no feedback at all.
func NewSearchField ¶
func NewSearchField(ui *UI) *SearchField
NewSearchField returns an empty filter field.
func (*SearchField) MatchPhrase ¶
func (s *SearchField) MatchPhrase() string
MatchPhrase is what a screen reader is told the filter left: "1 transaction", "250,000 transactions", or "" when the count is not given.
type SectionHeading ¶
type SectionHeading struct {
// Text names the group.
Text string
// Count is how many rows the group holds; below zero draws none. A group
// of one is still counted, so the count does not come and go as the
// group changes size.
Count int
// Counted is the word for one of them; "" leaves the number bare.
Counted string
// CountedPlural is the word for several; "" adds an s to Counted.
CountedPlural string
// CountText is a count the caller has already written out, for a count
// that is not a number, such as "1 · +0 −0". It is drawn as written,
// beside the name, and replaces Count.
CountText string
// CountParts is a written count in inks of its own, such as the "+5" and
// "−0" of "+5 −0". The parts' words, joined as they are, take the place of
// CountText, and replace it when there are any; a part holds its own
// spaces.
CountParts []CountPart
// Kind says what sort of thing the group holds, beside the name. It is
// the part that gives way first when the bar is narrow.
Kind string
// Action is the hoisted action's words; "" for none.
Action string
// ActionSymbol draws the action as a symbol, keeping its words as the
// button's name and tooltip, for an action a symbol can carry.
ActionSymbol string
// ActionExplanation says in a sentence what running the action does.
ActionExplanation string
// Strong draws the name bold and the rule above in the strong border
// colour.
Strong bool
// Collapsible lets the heading open and close its group.
Collapsible bool
// Expanded is whether the group is open.
Expanded bool
// OnToggle runs after the heading opened or closed, with the new state.
OnToggle func(expanded bool)
// OnAction runs when the hoisted action is taken.
OnAction func()
// contains filtered or unexported fields
}
SectionHeading is a group heading: a filled bar with a disclosure chevron, the group's name, what it holds, the count with the word for what was counted, and the one action that applies to every row under it. It is a filled bar rather than a label with a rule running off to the right, because a rule between the words and the action reads as a divider between two unrelated things.
The hoisted action has to be true for every row under the heading; if it is not, the group is wrong and wants splitting. It is a control of its own, a link showing its words or an icon button showing a symbol, and it takes its own keys, so running it never also opens or closes the group. A heading that collapses joins the tab order and opens and closes on Return, Enter, Space and a screen reader's press, answering a key only while it holds the keyboard itself.
func NewSectionHeading ¶
func NewSectionHeading(ui *UI, label string) *SectionHeading
NewSectionHeading returns an open heading that does not collapse.
func (*SectionHeading) CountPhrase ¶
func (h *SectionHeading) CountPhrase() string
CountPhrase is the count at the right end: "1 account", "1,200 accounts", the grouped number alone when nothing was named, and "" when there is no count or the caller wrote one out in CountText or CountParts.
func (*SectionHeading) Focus ¶
func (c *SectionHeading) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*SectionHeading) Hovered ¶
func (c *SectionHeading) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*SectionHeading) KeyboardFocus ¶
func (c *SectionHeading) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*SectionHeading) Lead ¶
func (h *SectionHeading) Lead() unison.Paneler
Lead is the panel SetLead gave, nil for none.
func (*SectionHeading) PerformAccessibilityAction ¶
func (h *SectionHeading) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens or closes the group for a screen reader.
func (*SectionHeading) Pressed ¶
func (c *SectionHeading) Pressed() bool
Pressed reports whether the control is being pressed.
func (*SectionHeading) ProvideAccessibility ¶
func (h *SectionHeading) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the heading. unison treats a heading as a line of text and leaves its children out, so a heading that holds its action cannot be one: a heading that opens and closes is a button with its expanded state, the usual form of a disclosure, and a fixed heading with an action is a group named by the heading. Only a fixed heading with no action is a heading. A written count is spoken in the description, because Windows gives a button or a heading no value pattern, so a node's Value would never be read there.
func (*SectionHeading) SetLead ¶
func (h *SectionHeading) SetLead(p unison.Paneler)
SetLead draws p after the chevron and before the name: a picture of the group's own, such as a project's icon. It is part of the heading: a press on it presses the heading, the pointer resting on it rests on the heading, and a screen reader hears the heading's name and nothing of p. One taller than the bar is drawn smaller. Each heading needs a panel of its own. nil takes the lead away.
func (*SectionHeading) SetTooltip ¶
func (c *SectionHeading) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*SectionHeading) TooltipWords ¶
func (c *SectionHeading) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Segment ¶
type Segment struct {
Value float64
// Ink is the segment's colour; categorical colour i unless set.
Ink Ink
// Label says what the segment is, for a screen reader.
Label string
}
Segment is one part of a StackedBar.
type Segmented ¶
type Segmented struct {
unison.Panel
// Label names the choice for a screen reader, such as "Theme".
Label string
// Current is the Value of the chosen option.
Current string
// OnChoose runs after an option is chosen, with its value.
OnChoose func(value string)
// contains filtered or unexported fields
}
Segmented is one choice from two to five short options, all visible: a period (week, month, quarter, year) governing a whole screen, which should say what the screen is showing without being opened. Past about five options the segments grow too narrow for their words, and a select is the right control.
The chosen segment is filled with the accent, the colour that means selection, with its label in the colour that contrasts with the fill and bold, and no outline of its own. This is kvit-cash's form of the control: an outlined segment raised out of the strip read as three buttons rather than as one choice of three, and a raised shape is the shape of a control being pressed.
func NewSegmented ¶
NewSegmented returns a choice of options, the first chosen.
func (*Segmented) ProvideAccessibility ¶
func (s *Segmented) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the strip as a list of tabs.
type Select ¶
type Select struct {
// Label names the choice for a screen reader.
Label string
// Options are the choices.
Options []Option
// Current is the Value of the chosen option.
Current string
// Placeholder is what the select says while no option is chosen.
Placeholder string
// Symbol is an optional meaning name drawn before the chosen option's
// words in the compact form, naming what the choice is about, such as
// calendar for a period.
Symbol string
// Compact draws the select as a quiet button with the chosen option's
// words, for a filter stating its value, rather than as a full-width
// field.
Compact bool
// Plain draws the select as the chosen option's words and a small arrow,
// with no ground or border until the pointer is on it, for a value
// repeated down a list. It takes the width its layout gives it, its words
// stand PlainSelectInset in from its left edge, and words too long for the
// width are cut, with the arrow still shown. It wins over Compact.
Plain bool
// OnChoose runs after an option is chosen, with its value.
OnChoose func(value string)
// contains filtered or unexported fields
}
Select is a choice from a list too long to lay out: a font family, a currency, a folder. For a few mutually exclusive options worth seeing at once, Segmented is right: a three-item list hides two of the answers behind a press. The list opens as unison's menu, as the owner chose for menus, with the chosen option ticked; Up and Down change the choice without opening it. An option's Symbol or Picture is drawn before its words on its line in the list, and never in the closed select, which in every form draws the chosen option's words alone.
Compact draws the same choice as a quiet button: the optional Symbol before the chosen option's words, no field outline. It is the control for a filter that states its value, such as a ledger's period reading All history, where the full-width field would take the room the list it filters needs. Its words are read as a value, never as a command.
Plain draws the same choice as words in a row of a list, with a small arrow after them and a ground only under the pointer. It is the control for a value repeated down a list, where each row states one answer that reads with the row's name as a sentence and few rows get changed: there, Segmented repeats every answer on every row, outlined fields are heavier than what they say, and compact selects read as a column of buttons.
func (*Select) Focus ¶
func (c *Select) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Select) Hovered ¶
func (c *Select) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Select) KeyboardFocus ¶
func (c *Select) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Select) PerformAccessibilityAction ¶
func (s *Select) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens the list for a screen reader.
func (*Select) Pressed ¶
func (c *Select) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Select) ProvideAccessibility ¶
func (s *Select) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the select as a combo box with its choice as its value.
func (*Select) SetTooltip ¶
func (c *Select) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Select) TooltipWords ¶
func (c *Select) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type SettingRow ¶
type SettingRow struct {
unison.Panel
// Label names the setting.
Label string
// Description says in one short line what the setting does, "" for none.
Description string
// contains filtered or unexported fields
}
SettingRow is one setting on a settings page: its name and, where needed, one short line saying more, at the leading side, and the control that changes it at the trailing edge (LAY-6). A setting applies the moment it changes, with no OK, Cancel or Apply, so a setting that is on or off is a Switch (WIN-16, WIN-23). The description is one line; a longer explanation belongs behind a Hint (WRD-22). The row names its control for a screen reader when the control has no name of its own.
func NewSettingRow ¶
func NewSettingRow(ui *UI, label, description string, control unison.Paneler) *SettingRow
NewSettingRow returns a row for one setting.
func (*SettingRow) ProvideAccessibility ¶
func (r *SettingRow) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the row as a group by its setting.
type SettingsPane ¶
type SettingsPane struct {
// Name is a noun for what the pane covers, "General" or "Accounts":
// the pane's button, and the window's title while it is shown.
Name string
// Symbol is the meaning name of the symbol over the name.
Symbol string
// Content is what the pane holds.
Content unison.Paneler
}
SettingsPane is one pane of an app's settings: its name, the symbol drawn over the name, and what it holds, a column of SettingRows.
type SettingsPanes ¶
type SettingsPanes struct {
unison.Panel
// Panes are the panes, in the order their buttons show.
Panes []SettingsPane
// Current is the pane shown.
Current int
// OnShow runs when the reader shows another pane, so the app can open
// the settings on it the next time.
OnShow func(pane int)
// contains filtered or unexported fields
}
SettingsPanes are an app's settings in panes, as the macOS form has them (WIN-16): the panes' buttons in a row across the top, each a symbol over its name, and the pane shown under them. Each change takes effect as it is made, so there is no OK, Cancel or Apply (WIN-23). A SettingsWindow holds it; on the Windows form, which Linux takes, the same panes make a page in the app's window instead (NewSettingsPage).
func NewSettingsPanes ¶
func NewSettingsPanes(ui *UI, panes ...SettingsPane) *SettingsPanes
NewSettingsPanes returns the panes with the first one shown.
func (*SettingsPanes) ProvideAccessibility ¶
func (s *SettingsPanes) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility leaves the holder out: the row is a tab list, and the pane shown is what it controls.
func (*SettingsPanes) Title ¶
func (s *SettingsPanes) Title() string
Title is the name of the pane shown, in the form's case, as the window holding the panes is titled.
type SettingsWindow ¶
type SettingsWindow struct {
// Panes are what the window holds.
Panes *SettingsPanes
// contains filtered or unexported fields
}
SettingsWindow is the app's settings on the macOS form (WIN-16): a window of its own, opened by Settings… in the app menu, holding SettingsPanes. It is titled with the pane shown, takes the height of the pane shown, and cannot be resized; Command-W closes it. unison cannot take the minimise button off a window, which a Mac's settings window does not have. On the Windows form, which Linux takes, settings are a page in the app's window made of the same panes (Page), and Command runs the app's own way of showing it.
func NewSettingsWindow ¶
func NewSettingsWindow(ui *UI, panes ...SettingsPane) *SettingsWindow
NewSettingsWindow returns the settings window for panes, not yet open.
func (*SettingsWindow) Close ¶
func (s *SettingsWindow) Close()
Close closes the window, if it is open.
func (*SettingsWindow) Command ¶
func (s *SettingsWindow) Command(showPage func()) *Command
Command is the Settings command: on the macOS form it opens the window; on the Windows form it runs showPage, which shows the settings page in the app's window.
func (*SettingsWindow) Open ¶
func (s *SettingsWindow) Open() error
Open opens the window, or brings it to the front when it is open, with the pane last shown.
func (*SettingsWindow) Page ¶
func (s *SettingsWindow) Page(about *About) *Region
Page is the Windows form's settings page made of the window's panes, ending with about where it is given: what showPage, given to Command, puts in the app's window.
func (*SettingsWindow) Window ¶
func (s *SettingsWindow) Window() *Window
Window is the window while it is open, or nil.
type Shape ¶
type Shape int
Shape is a mark's second channel beside its colour: a state told only by being red says nothing to a reader who cannot tell red from amber.
type Shortcut ¶
Shortcut is a key and its modifiers, written once for both forms. A shortcut on KeyEqual is the key with the plus sign on it: it answers with or without Shift and on the keypad's plus, and is written as a plus, as Ctrl+Plus zooms in on every keyboard. KeyMinus answers on the keypad's minus too.
func Keys ¶
Keys returns a shortcut: Keys(unison.KeyS, ModPrimary) is Ctrl+S on the Windows form and Cmd-S on the macOS form.
func StdKeys ¶
func StdKeys(s StdCommand, f Form) []Shortcut
StdKeys are a standard command's keys in a form.
func (Shortcut) Binding ¶
func (s Shortcut) Binding(f Form) unison.KeyBinding
Binding is the shortcut as unison's key binding in a form, for a menu unison draws.
type ShownMenu ¶
type ShownMenu struct {
// Title names the menu.
Title string
// Items are its lines as shown.
Items []MenuItem
// Context says it is a context menu.
Context bool
}
ShownMenu is a menu open in a window, as ShownMenus gives it.
type Sidebar ¶
type Sidebar struct {
unison.Panel
// Collapsed draws the sidebar as its rail.
Collapsed bool
// contains filtered or unexported fields
}
Sidebar is the list of places down the left edge. Collapsed is the state a window puts it in when it is narrow: the rail, where every item is its symbol alone. Every SidebarItem in it takes the sidebar's state rather than being told one by one, which is what stops one item in a rail still drawing its label.
A SidebarHeading among the items names the group of places under it, and a SidebarItem holds the places inside it (SidebarItem.Add), which it shows while it is open. The sidebar's children are the rows shown: the places inside a closed item are not among them, and the rail shows the top level alone, without the headings.
The places scroll when they do not fit above the foot, which keeps its place: with the wheel, with a bar over their right-hand edge that is there only while there is something out of sight, and to wherever the keyboard goes. The rail scrolls without the bar, having no room for one.
func NewSidebar ¶
NewSidebar returns an expanded sidebar holding items, top to bottom.
func (*Sidebar) AddFooter ¶
AddFooter puts items at the foot of the sidebar, below the places, in order: Help, then Settings last, where the Windows form puts the settings command (WIN-16, CMD-3).
func (*Sidebar) ProvideAccessibility ¶
func (s *Sidebar) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the sidebar as the application's navigation: a list of places, or a tree where a place holds places inside it.
type SidebarHeading ¶
type SidebarHeading struct {
unison.Panel
// Text names the group.
Text string
// contains filtered or unexported fields
}
SidebarHeading names the group of places under it in a sidebar: "Folders" above the folders, "Tags" above the tags. It is words alone and takes no press and no key; the rail leaves it out.
func NewSidebarHeading ¶
func NewSidebarHeading(ui *UI, label string) *SidebarHeading
NewSidebarHeading returns a heading for the places that follow it.
func (*SidebarHeading) ProvideAccessibility ¶
func (h *SidebarHeading) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility gives a screen reader the heading's words.
type SidebarItem ¶
type SidebarItem struct {
// Text names the place.
Text string
// Symbol is the meaning name of the item's symbol.
Symbol string
// Selected marks the place the window is showing.
Selected bool
// Collapsed draws the item as part of the rail; its Sidebar sets it.
Collapsed bool
// Count is how many things are waiting there, drawn as a badge; below
// zero draws none, and zero draws no badge but is still announced.
Count int
// Counted is the word for one of the things counted, so a screen reader
// hears "Review, 1 decision"; "" says "items".
Counted string
// CountedPlural is the word for several; "" adds an s to Counted.
CountedPlural string
// CountInRail keeps the badge once the sidebar collapses, on the
// symbol's upper corner. Off by default: a rail is a strip of symbols,
// and an application whose rail has to keep a backlog in front of the
// reader turns it on.
CountInRail bool
// CountMax is the largest count the badge writes out, 99 unless set.
// Raise it where the place the item points at states the true figure,
// or the badge's "99+" and that figure disagree about the same thing.
CountMax int
// OnClick runs when the item is pressed.
OnClick func()
// Command, when set, is what the item runs, and gives its words and
// symbol where they are empty: the settings command at the foot of the
// sidebar is one.
Command *Command
// Expanded shows the places inside the item (Add).
Expanded bool
// OnToggle runs after the reader opened or closed the item, with the new
// state.
OnToggle func(expanded bool)
// contains filtered or unexported fields
}
SidebarItem is one place in the sidebar. The selected item is marked by a bar down its leading edge as well as by a tint: in the high-contrast theme the tint alone is a two-percent difference in lightness, invisible in a screenshot. The symbol, or a lead in its place (SetLead), is required because of the rail: collapsed, the label is gone and the symbol is the whole item, and an item with only words would vanish.
An item holds the places inside it (Add): a folder its folders. It then has a mark before its symbol that opens and closes it, and Right and Left open and close it from the keyboard, Right stepping into an open one and Left out to the item a place is inside. Each level stands a loose space further in. A closed item, and an item in the rail, takes the bar of the selected place when that place is inside it, so the reader sees where they are.
func NewSidebarCommand ¶
func NewSidebarCommand(ui *UI, c *Command) *SidebarItem
NewSidebarCommand returns an item that runs a command, named and drawn by it: the settings command at the foot of the sidebar is one (WIN-16).
func NewSidebarItem ¶
func NewSidebarItem(ui *UI, label, symbol string) *SidebarItem
NewSidebarItem returns an unselected item with no count.
func (*SidebarItem) Add ¶
func (it *SidebarItem) Add(places ...*SidebarItem)
Add puts places inside the item, after those it holds: a folder's folders. They are shown under it, a level further in, while the item is Expanded.
func (*SidebarItem) Clear ¶
func (it *SidebarItem) Clear()
Clear takes out the places inside the item.
func (*SidebarItem) Depth ¶
func (it *SidebarItem) Depth() int
Depth is how many items the item is inside: zero at the top level. Its sidebar works it out at layout.
func (*SidebarItem) Focus ¶
func (c *SidebarItem) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*SidebarItem) Hovered ¶
func (c *SidebarItem) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*SidebarItem) Items ¶
func (it *SidebarItem) Items() []*SidebarItem
Items are the places inside the item.
func (*SidebarItem) KeyboardFocus ¶
func (c *SidebarItem) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*SidebarItem) Lead ¶
func (it *SidebarItem) Lead() unison.Paneler
Lead is the panel SetLead gave, nil for none.
func (*SidebarItem) Name ¶
func (it *SidebarItem) Name() string
Name is what a screen reader is told: the label, and the count with its noun when there is one, "Review, 11 decisions".
func (*SidebarItem) PerformAccessibilityAction ¶
func (it *SidebarItem) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the item for a screen reader.
func (*SidebarItem) Pressed ¶
func (c *SidebarItem) Pressed() bool
Pressed reports whether the control is being pressed.
func (*SidebarItem) ProvideAccessibility ¶
func (it *SidebarItem) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the item as one place in the list, and says whether it is the selected one.
func (*SidebarItem) SetExpanded ¶
func (it *SidebarItem) SetExpanded(open bool)
SetExpanded opens or closes the item. The keyboard, when it is on a place inside an item that closes, moves to the item.
func (*SidebarItem) SetLead ¶
func (it *SidebarItem) SetLead(p unison.Paneler)
SetLead draws p in place of the item's symbol: a picture of the place's own, such as a project's icon. It is part of the item: a press on it presses the item, the pointer resting on it rests on the item, and a screen reader hears the item's label and nothing of p. Centred on where the symbol stands, in the sidebar and in the rail, it may be larger than the symbol and the label stays where it is, so names with a picture and names with a symbol line up; one too large to stop short of the label is drawn smaller. Each item needs a panel of its own. nil gives the place back to the symbol.
func (*SidebarItem) SetTooltip ¶
func (c *SidebarItem) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*SidebarItem) TooltipWords ¶
func (c *SidebarItem) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
func (*SidebarItem) Within ¶
func (it *SidebarItem) Within() *SidebarItem
Within is the item this one is inside, nil at the sidebar's top level.
type Signal ¶
type Signal struct {
unison.Panel
// Count is how many are in the state; zero or less hides the mark.
Count int
// Max is the largest count written out; 99 unless set.
Max int
// Ink is the state's colour, the application's own idea; the accent
// unless set.
Ink Ink
// Shape is square or circle; a diamond would turn the number with it.
Shape Shape
// Hollow draws the outline only, a third distinction without another hue.
Hollow bool
// Label says what the mark means, "2 agents running": the colour and the
// number do not say it.
Label string
// contains filtered or unexported fields
}
Signal is a mark saying what state something is in and how many things are in it. A dot says which state and carries no number; a badge always draws its digits, so a column of rows each with one thing running reads as a column of ones. A signal draws the number only past one: at one, the mark is the whole statement.
func (*Signal) ProvideAccessibility ¶
func (s *Signal) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the signal as its meaning, never as the bare number inside it.
type Slider ¶
type Slider struct {
// Label names the value, for a screen reader.
Label string
// Unit follows the value.
Unit string
// Precision is how many decimal places the value is drawn with.
Precision int
// Value is the value, From and To the range; 0 to 1 unless set.
Value, From, To float64
// Step is how far an arrow key moves it; a tenth of the range unless set.
Step float64
// OnChange runs as the value moves.
OnChange func(value float64)
// contains filtered or unexported fields
}
Slider is a value chosen from a continuous range by dragging: right where the reader is choosing a feel rather than a number, such as an opacity or a threshold judged by its result, and wrong where the exact value matters, since a particular number is hard to hit and cannot be typed; a Stepper or a NumberField is for that. The value is always drawn beside it, because a slider whose position is its only output makes the reader estimate.
The value stands to the right of the slider's box, so a slider in a row wants room after it.
func (*Slider) Focus ¶
func (c *Slider) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Slider) Hovered ¶
func (c *Slider) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Slider) KeyboardFocus ¶
func (c *Slider) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Slider) PerformAccessibilityAction ¶
func (s *Slider) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction moves the value for a screen reader.
func (*Slider) Pressed ¶
func (c *Slider) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Slider) ProvideAccessibility ¶
func (s *Slider) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the slider by its name and value, with the steps a screen reader can take.
func (*Slider) SetTooltip ¶
func (c *Slider) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Slider) TooltipWords ¶
func (c *Slider) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type SlimRow ¶
type SlimRow struct {
ListRow
// Name is what the row is about.
Name string
// Kind says what sort of thing it is, where the name does not.
Kind string
// Phrase says one thing about its state, muted, because it is context
// rather than identity.
Phrase string
// Figure is the number at the right, as the caller formatted it.
Figure string
// Unit follows the figure.
Unit string
// Measured is false for a value nobody measured, drawn as "—". A zero is
// a measurement.
Measured bool
// Symbol is an optional meaning name drawn before the name.
Symbol string
// contains filtered or unexported fields
}
SlimRow is the list row a reader sees most: one line holding a name, what it is, one phrase about it and one figure at the right. The order is fixed, and the fixed order is the point: a reader scanning down the left edge finds the name in the same place on every screen, and scanning down the right edge finds the number.
func NewSlimRow ¶
NewSlimRow returns a slim row for a name.
func (*SlimRow) Focus ¶
func (c *SlimRow) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*SlimRow) Hovered ¶
func (c *SlimRow) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*SlimRow) KeyboardFocus ¶
func (c *SlimRow) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*SlimRow) Pressed ¶
func (c *SlimRow) Pressed() bool
Pressed reports whether the control is being pressed.
func (*SlimRow) ProvideAccessibility ¶
func (s *SlimRow) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the row as the list row does, except that a row nobody presses is a named group rather than a line of text, so its figure is still read out as a part of it.
func (*SlimRow) SetTooltip ¶
func (c *SlimRow) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*SlimRow) TooltipWords ¶
func (c *SlimRow) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Slug ¶
type Slug struct {
unison.Panel
// Text is the identifier.
Text string
// Ground draws the inline-code ground; true unless turned off, for a slug
// in a table cell where a ground on every row reads as a column of boxes.
Ground bool
// contains filtered or unexported fields
}
Slug is an identifier: a reference, a short hash, a key, a ticket number. It is monospace, because what a reader does with an identifier is compare it with another, and two proportional strings of the same length are different widths. It is cut short in the middle rather than at the end, since the end of a hash is what tells it from its neighbours.
func (*Slug) ProvideAccessibility ¶
func (s *Slug) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the slug as the whole identifier, however it is cut short on the screen.
type Spark ¶
type Spark struct {
unison.Panel
// Values are the periods, oldest first; NotMeasured for a gap.
Values []float64
// Ink is the bars' colour; the accent unless set.
Ink Ink
// Maximum is the scale; the largest value unless set.
Maximum float64
// Label names the series for a screen reader.
Label string
// contains filtered or unexported fields
}
Spark is a series as a row of slim bars rising from one baseline: the recent shape of something, small enough to sit in a row. A period nobody measured is a hairline on the baseline, not a missing bar.
func (*Spark) ProvideAccessibility ¶
func (s *Spark) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the series and how many periods it holds.
type SplitButton ¶
type SplitButton struct {
unison.Panel
// Variants are the commands the button offers, the likeliest first; a
// toggle split button's styles.
Variants []*Command
// Current is the variant the main part runs, or the style in use.
Current int
// Toggle is a toggle split button's switch: a command whose Checked
// says whether the feature is on and whose Run turns it on or off. nil
// for a split button of variants.
Toggle *Command
// RememberLast makes the main part run the variant last chosen on the
// macOS form too.
RememberLast bool
// MenuLabel names the arrow for a screen reader and its tooltip.
MenuLabel string
// Form is how both parts look: ordinary, primary, quiet or flat. A
// toggle split button given the primary form is drawn ordinary, since
// a filled button cannot show whether its feature is on.
Form ButtonForm
// contains filtered or unexported fields
}
SplitButton runs one of several variants of a command: its main part runs the variant it shows, and its arrow opens a menu of them all, the one the main part runs marked as the default (CMD-17). On the Windows form the main part runs the variant last chosen (decided Q-46); on the macOS form it runs the likeliest, the first, unless RememberLast is set for a variant people repeat. The two parts are drawn as one control, one outline around both and a line between them, as a ChoiceButton is.
Made with NewToggleSplitButton it is a toggle split button instead, for a feature that is on or off and comes in styles, such as bullets: the main part turns the feature on and off and shows whether it is on, and the menu picks the style, the one in use marked, choosing one also turning the feature on (CMD-17).
func NewSplitButton ¶
func NewSplitButton(ui *UI, variants ...*Command) *SplitButton
NewSplitButton returns a split button offering variants.
func NewToggleSplitButton ¶
func NewToggleSplitButton(ui *UI, toggle *Command, styles ...*Command) *SplitButton
NewToggleSplitButton returns a toggle split button: toggle turns the feature on and off, and styles are the ways it can look, the one in use at Current.
func (*SplitButton) ProvideAccessibility ¶
func (s *SplitButton) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the pair as a group.
type SplitView ¶
type SplitView struct {
unison.Panel
// Vertical stacks the regions top to bottom rather than side by side.
Vertical bool
// Fill is the region that takes the room the others leave; the last
// unless set.
Fill int
// OnResize runs after the reader resized a region, by dragging a handle
// or with its arrow keys, with the region and its new size in design
// pixels, so an application can remember it.
OnResize func(pane, design int)
// contains filtered or unexported fields
}
SplitView is two or more regions the reader resizes against each other. The handle between two regions is a strip a space wide with a hairline down its middle, so the target is comfortable and the rule is still thin, and it takes the keyboard focus and moves with the arrow keys: a split a reader can only set with a mouse is a split a keyboard user is stuck with.
func NewSplitView ¶
NewSplitView returns the regions side by side, the last taking the room the others leave.
func (*SplitView) DesignSize ¶
DesignSize is a region's size along the split in design pixels.
type Spotlight ¶
type Spotlight struct {
unison.Panel
// Target is the part left lit; nil darkens everything, the state before
// the first step.
Target unison.Paneler
// Title and Detail are what is said about it.
Title, Detail string
// Padding is the room around the target inside the lit hole; a space
// unless set.
Padding Measure
// OnDismiss runs when the reader asks to leave, by Escape or a press.
OnDismiss func()
// contains filtered or unexported fields
}
Spotlight darkens a region except for one part of it and says something about that part. It is the primitive under a guided tour and deliberately only that: kvit-cash's first-run flow reads a fixed script while kvit-notes-pro's decides the next step from what the agent is doing, so a shared stepper would be wrong for one of them; what is shared is lighting a part, and each application brings its own reason to move on. Escape always closes it, and so does a press anywhere on the shade, since a reader who cannot get out of a tour force-quits the application.
func NewSpotlight ¶
NewSpotlight returns a spotlight on target, closed.
func (*Spotlight) ProvideAccessibility ¶
func (s *Spotlight) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the spotlight as a dialog saying its title and detail.
type StackData ¶
type StackData struct {
// Own keeps the child at its own width, at the stack's start.
Own bool
// End, with Own, puts the child at the stack's end instead.
End bool
// Wide exempts the child from the stack's MaxWidth.
Wide bool
// Left and Right are room kept clear before and after the child: it is
// measured at, and framed to, the stack's width less both. Nil is none.
Left, Right Measure
}
StackData is a stack child's layout data, set with SetLayoutData, by value or by pointer.
type StackLayout ¶
type StackLayout struct {
// Gap is the room between one child and the next.
Gap Measure
// MaxWidth holds each child to a width, at the stack's start, except a
// child whose data says Wide; nil is no limit. With it set, a child's
// Own and End are not consulted.
MaxWidth Measure
// SkipEmpty also leaves out a shown child that asks for no height, with
// no gap for it, and gives every child left out, hidden ones included, a
// frame of no height just below the last child placed. A child left at
// the frame it had lies over what is laid out there now and takes its
// presses.
SkipEmpty bool
// contains filtered or unexported fields
}
StackLayout lays the children that are not hidden out top to bottom, a gap apart. A hidden child gets no room and no gap, and its frame is left as it was. Every other child is asked for its size at the stack's content width and gets that whole width and the height it asks for there; the stack neither stretches nor shrinks a child's height.
A child says anything else about itself with StackData. The stack does not read unison's flex layout data, which Width, Sized and Centred set on the panels they make: such a panel in a stack gets the stack's whole width.
LayoutSizes and PerformLayout are exported, so a layout of an application's own can call them and add to them.
func NewStackLayout ¶
func NewStackLayout(ui *UI, gap Measure) *StackLayout
NewStackLayout returns a stack's layout with a gap between the children.
func (*StackLayout) LayoutSizes ¶
func (s *StackLayout) LayoutSizes(target *unison.Panel, hint geom.Size) (minSize, prefSize, maxSize geom.Size)
LayoutSizes implements unison.Layout.
func (*StackLayout) PerformLayout ¶
func (s *StackLayout) PerformLayout(target *unison.Panel)
PerformLayout implements unison.Layout.
type StackedBar ¶
type StackedBar struct {
unison.Panel
// Segments are the parts, left to right.
Segments []Segment
// Maximum is the scale; the sum of the segments unless set, which is
// right for a bar that is a breakdown of its own total.
Maximum float64
// Wide draws the taller form.
Wide bool
// Label names the bar for a screen reader.
Label string
// contains filtered or unexported fields
}
StackedBar is several quantities adding up to one total, in one bar, a gap apart: two fills that touch read as one fill with a colour change in it. A segment too small to see is drawn at the smallest visible width rather than dropped, because a bar whose parts do not add up to it misstates its own arithmetic.
func NewStackedBar ¶
func NewStackedBar(ui *UI, segments ...Segment) *StackedBar
NewStackedBar returns a bar of segments.
func (*StackedBar) ProvideAccessibility ¶
func (s *StackedBar) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the bar as its parts, "12 food, 5 rent".
type StatTile ¶
type StatTile struct {
Card
// Label names the figure; Value and Unit are the figure.
Label, Value, Unit string
// Measured is false for a figure nobody measured.
Measured bool
// HasChange draws Change with the Good direction.
HasChange bool
Change float64
Good Direction
// History is the recent shape; NotMeasured for a gap.
History []float64
// Caption is a line under it all.
Caption string
// contains filtered or unexported fields
}
StatTile is a card holding one figure, what it is, how it changed and its recent shape: the shape of most dashboard widgets. The parts are optional and their order fixed, because a dashboard of tiles is read one part at a time down a column, and a tile that orders them differently breaks that scan for every tile beside it.
func NewStatTile ¶
NewStatTile returns a tile for a labelled figure.
func (*StatTile) Focus ¶
func (c *StatTile) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*StatTile) Hovered ¶
func (c *StatTile) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*StatTile) KeyboardFocus ¶
func (c *StatTile) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*StatTile) Pressed ¶
func (c *StatTile) Pressed() bool
Pressed reports whether the control is being pressed.
func (*StatTile) ProvideAccessibility ¶
func (s *StatTile) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the tile as "Spending: 1,284 GBP", holding its parts.
func (*StatTile) SetTooltip ¶
func (c *StatTile) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*StatTile) TooltipWords ¶
func (c *StatTile) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type StatusBar ¶
type StatusBar struct {
unison.Panel
// Activity says what is happening now; "" leaves the left blank, which is
// the resting state. A bar that always has something to say trains the
// reader to stop looking at it.
Activity string
// Facts are the standing facts, at the right, separated by dots.
Facts []string
// Groups are the facts that do something.
Groups []StatusGroup
// GroupsFirst puts the groups at the left, before the activity, for a bar
// whose left end is the list of what is waiting rather than a sentence
// about what is running. The plain facts and the controls stay at the
// right either way.
GroupsFirst bool
// OnFact runs when a fact is pressed, on the bar or in the menu, with the
// index of its group and its index in the group.
OnFact func(group, fact int)
// contains filtered or unexported fields
}
StatusBar is the strip along the bottom of a window: on the left what the application is doing now, which changes, and on the right the standing facts about what is open, which do not. Mixing the two is what makes a status bar unreadable.
The right takes facts in three shapes: plain strings separated by dots, with nothing to press; named groups of facts, each fact a link that opens what it names; and whole controls at the end, for an action that is not a fact at all. A bar is one line in a window of any width, so its groups will eventually not fit. It shows the groups it has room for, left to right, and keeps the rest behind a link saying how many facts are not on the bar, which opens a menu of them: nothing is dropped, and nothing is silent about it.
func NewStatusBar ¶
NewStatusBar returns a bar with controls at its right end.
type StatusFact ¶
type StatusFact struct {
Text string
// Symbol is an optional meaning name drawn before the text.
Symbol string
// Explanation is the one sentence the words do not say: what state the
// thing is in, what pressing it opens.
Explanation string
// Mark is an optional panel drawn in place of the symbol, for a state
// the application draws its own way (Link.SetLead); each fact needs a
// panel of its own. A bar given a new one builds the fact again.
Mark unison.Paneler
}
StatusFact is one fact in a status bar group: something to press that opens what it names.
type StatusGroup ¶
type StatusGroup struct {
// Label names what the group is about; "" for a group that needs none.
Label string
Facts []StatusFact
}
StatusGroup is a named group of facts, such as "Waiting on you".
type StdCommand ¶
type StdCommand int
StdCommand names one of the commands every desktop app is expected to have under the same name and key.
const ( StdNone StdCommand = iota StdNew StdOpen StdSave StdSaveAs StdClose StdPrint StdUndo StdRedo StdCut StdCopy StdPaste StdDelete StdSelectAll StdFind StdFindNext StdReplace StdGoTo StdRename StdRefresh StdProperties StdFullScreen StdZoomIn StdZoomOut StdActualSize StdNewTab StdCloseTab StdReopenTab StdNextTab StdPreviousTab StdBack StdSettings StdHelp StdAbout StdQuit )
The standard commands.
type StdMenu ¶
type StdMenu int
StdMenu names one of the standard menus of a menu bar.
const ( MenuNone StdMenu = iota MenuApp MenuFile MenuEdit MenuFormat MenuView MenuTools MenuWindow MenuHelp )
The standard menus, in the order a menu bar shows those its form has: the app menu and Window only on the macOS form, Tools only on the Windows form.
func StdMenuOf ¶
func StdMenuOf(s StdCommand, f Form) StdMenu
StdMenuOf is the menu a standard command goes in on a form: Settings and About go in the app menu on the macOS form, and on the Windows form Settings goes last in Tools, Exit last in File, and About in no menu, since it is a section of the Settings page there (CMD-3).
type Stepper ¶
type Stepper struct {
unison.Panel
// Label names what the number is, such as "Interface size".
Label string
// Unit follows the number, in the muted colour.
Unit string
// Value is the number.
Value int
// From and To are the ends of the range; Step is how far a press moves.
From, To, Step int
// OnChange runs after a press changes the value, with the new value.
OnChange func(value int)
// Follow, when set, gives the value from whatever owns it, read before
// every layout, so the stepper shows the owner's value when it changes
// elsewhere.
Follow func() int
// contains filtered or unexported fields
}
Stepper is a number with a minus and a plus beside it: an interface size, a column count, a number of days. It is for a small whole-number range a reader adjusts by one or two, which is where a slider is wrong: a slider makes a precise value hard to hit and does not say what the value is.
func NewStepper ¶
NewStepper returns a stepper over a range, at its lowest value.
func (*Stepper) PerformAccessibilityAction ¶
func (s *Stepper) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction raises or lowers the value by a step.
func (*Stepper) ProvideAccessibility ¶
func (s *Stepper) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the stepper as a spin button with its value, range and step. unison reads a spin button as text and leaves its children out, so the minus and plus are offered as its decrement and increment actions instead.
type Suggestion ¶
type Suggestion struct {
Value, Label string
}
Suggestion is one thing a TypeAhead can offer: a value and the words shown for it, which are the value unless set.
type Switch ¶
type Switch struct {
// Text is what the switch turns on.
Text string
// Name names the switch for a screen reader where it has no Text, as in
// a SettingRow, which sets it.
Name string
// Checked is whether it is on.
Checked bool
// SmallScope marks an option of narrow reach, which the macOS form draws
// as a checkbox, without the On or Off the Windows form says beside a
// switch; it acts at once either way.
SmallScope bool
// OnChange runs after a press, with the new state.
OnChange func(checked bool)
// contains filtered or unexported fields
}
Switch is an option that is on or off and takes effect the moment it moves, where a Check is a value in a form that takes effect when the form is submitted: a settings row that applies at once is a switch, and a row of options above a Save button is checkboxes. The knob moves as well as the track filling, so the state is told by position as well as by colour.
The macOS form keeps the switch for a setting of large scope and draws any other on/off option as a checkbox, where the Windows form draws a switch for every option that applies at once (CTL-2): set SmallScope on one that governs a single thing, such as whether one agent is offered.
func (*Switch) Focus ¶
func (c *Switch) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Switch) Hovered ¶
func (c *Switch) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Switch) KeyboardFocus ¶
func (c *Switch) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Switch) PerformAccessibilityAction ¶
func (s *Switch) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction turns the switch over for a screen reader.
func (*Switch) Pressed ¶
func (c *Switch) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Switch) ProvideAccessibility ¶
func (s *Switch) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the switch as a box that is ticked or not.
func (*Switch) SetTooltip ¶
func (c *Switch) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Switch) TooltipWords ¶
func (c *Switch) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Tab ¶
type Tab struct {
// Text names the view, in sentence case: kvit-ui writes it in title
// case on the macOS form (WRD-6).
Text string
// Selected marks the tab whose view is showing.
Selected bool
// Count is how many things the view holds, drawn beside the name; below
// zero draws none.
Count int
// Explanation says in one sentence what the view shows, which two or
// three words on a tab cannot. It is the tooltip and the accessible
// description, and never a substitute for the name: a tab whose subject
// is only in its explanation cannot be chosen without hovering it.
Explanation string
// OnClick runs when the tab is pressed.
OnClick func()
// contains filtered or unexported fields
}
Tab is one tab in a row of them: a different view of the same thing. The selected tab is marked by an underline as well as by colour and weight, so the selection does not rest on colour alone, which is where that rule is most often broken: a coloured tab label looks obviously different to whoever drew it.
func (*Tab) Focus ¶
func (c *Tab) Focus()
Focus gives the control the keyboard focus, with its ring, as a Tab to it would. A control not in a window yet takes it once it is. A member of a group that is one stop in the Tab order, such as an unchosen tab, takes it too, and keeps it while it holds it.
func (*Tab) Hovered ¶
func (c *Tab) Hovered() bool
Hovered reports whether the pointer is over the control.
func (*Tab) KeyboardFocus ¶
func (c *Tab) KeyboardFocus() bool
KeyboardFocus reports whether the control holds the focus and it arrived from the keyboard, which is when its focus ring shows.
func (*Tab) PerformAccessibilityAction ¶
func (t *Tab) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction presses the tab for a screen reader.
func (*Tab) Pressed ¶
func (c *Tab) Pressed() bool
Pressed reports whether the control is being pressed.
func (*Tab) ProvideAccessibility ¶
func (t *Tab) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility announces a tab, with its count in its name, "Projects, 26 items", grouped as the reader groups digits, and says whether it is the selected one.
func (*Tab) SetTooltip ¶
func (c *Tab) SetTooltip(words func() string)
SetTooltip gives the control a tooltip of these words, asked each time it is about to show, with the timing every control's tooltip has; "" shows none. It replaces the tooltip a control has of its own, such as an icon button's label, and nil gives the control back its own.
func (*Tab) TooltipWords ¶
func (c *Tab) TooltipWords() string
TooltipWords are what the control's tooltip says now, "" for none.
type Table ¶
type Table struct {
unison.Panel
// Model is what the table shows.
Model TableModel
// Label names the table for a screen reader; "Table" unless set.
Label string
// EmptyTitle and EmptyDetail are what the table says when it has no
// rows, which is a thing to say rather than a blank grid to leave.
EmptyTitle, EmptyDetail string
// HiddenColumns are the model columns the reader has hidden.
HiddenColumns []int
// Order is the model columns in the order they are shown; nil is the
// model's order. The reader changes it by moving columns.
Order []int
// Widths are the columns the reader has resized, by model column, in
// design pixels.
Widths map[int]int
// SortColumn is the column the rows are ordered by, -1 for none, and
// SortAscending its direction. The header sets both when the reader
// sorts, and says so through OnSort.
SortColumn int
SortAscending bool
// HeaderChecked and HeaderPartial are what the box in a Check column's
// header shows: every row shown, or some of them. The application owns
// the answer, since what "every row" means changes with the filter.
HeaderChecked, HeaderPartial bool
// RowsOpen draws, in a strip of its own down the right-hand edge, the
// mark that says a press on a row opens something.
RowsOpen bool
// OpensColumn is the column holding the row's name, drawn in the link
// colour to say the row opens something; -1 for none. It is the
// alternative to RowsOpen, and the two are not drawn together.
OpensColumn int
// OpensLabel says in words what pressing a row opens, on the strip's
// tooltip.
OpensLabel string
// OnRowPressed runs on one press on a row, which is how a ledger row
// opens its record; OnRowActivated on a double press and on Return.
OnRowPressed, OnRowActivated func(row int)
// OnSort runs when the reader asks for a different order. The table has
// already moved its indicator; a handler that cannot sort puts
// SortColumn and SortAscending back.
OnSort func(column int, ascending bool)
// OnHeaderToggled runs when the box in a Check column's header is
// pressed, with the state asked for.
OnHeaderToggled func(checked bool)
// OnCellToggled runs when one row's box is pressed, with the state asked
// for. The table ticks nothing itself: the model does, and the table
// redraws from it, so a request that is refused leaves no tick behind.
OnCellToggled func(row, column int, checked bool)
// contains filtered or unexported fields
}
Table is a dense, configurable table over a model, for a list of any size: it draws the cells it shows and asks the model for nothing else, so a quarter of a million rows cost what a screenful costs.
The reader owns the columns: they sort, resize, move and hide them from the header, by pointer and by keyboard, and every one of those is also in the column menu, which is where a reader looks for what a control can do. The header is one stop in the tab order rather than one per column, with a cursor the arrow keys move, so a twelve-column table does not cost twelve presses of Tab to walk past. A row opens its record on one press, and a Check column draws a box per row with a box in its header for every row shown. The table sorts nothing and filters nothing itself: it says what the reader asked for, and the model, which is the application's, does it.
func NewTable ¶
func NewTable(ui *UI, model TableModel) *Table
NewTable returns a table over a model.
func (*Table) CopySelection ¶
CopySelection is the selected rows as tab-separated text, one row to a line, in the column order the reader is looking at, each value with its unit: a Money cell draws its currency beside the amount rather than inside it, and a copy of bare numbers from a workspace holding several currencies says nothing. Ctrl+C puts it on the clipboard.
func (*Table) CurrentRow ¶
CurrentRow is the row the keyboard is on, or -1.
func (*Table) FocusRow ¶
FocusRow puts the keyboard on a row: the row is scrolled into view and the table takes the focus. A surface raised from a row uses it to hand the focus back to the row that raised it when it closes, which is the only way the reader keeps their place.
func (*Table) IsRowSelected ¶
IsRowSelected reports whether a row is selected.
func (*Table) MoveColumnBy ¶
MoveColumnBy moves a column one shown column left for -1 or right for 1.
func (*Table) Refresh ¶
func (t *Table) Refresh()
Refresh redraws the table after the model's values changed and its rows did not.
func (*Table) Reset ¶
func (t *Table) Reset()
Reset is what to call after the model's rows changed, by a filter or a reload: the selection and the keyboard's row are cleared, since the rows they named are gone, and the view is kept within the rows there are now.
func (*Table) ResizeColumnBy ¶
ResizeColumnBy widens a column by some pixels, or narrows it for a negative amount, never below 48 design pixels: a column narrowed to nothing is a column the reader cannot find again to widen.
func (*Table) ScrollTo ¶
ScrollTo scrolls the rows so x and y are at the view's top left, kept within their ends.
func (*Table) SelectedRows ¶
SelectedRows are the selected rows, in order.
type TableColumn ¶
type TableColumn struct {
// Title names the column in its header.
Title string
// Width is the column's width at rest, in design pixels; 120 unless set.
Width int
// Kind is how its cells are drawn.
Kind CellKind
// Unsortable says the column cannot order the rows.
Unsortable bool
}
TableColumn says what one column of a table model is: its title, its width at rest, the kind of cell that draws it, and whether it can order the rows. A view's own column order, widths and hidden set are the view's state rather than the model's, since two windows onto one model may show different columns.
type TableModel ¶
type TableModel interface {
// Rows is how many rows there are to show, which after a filter is fewer
// than the model holds.
Rows() int
// Columns describes the columns, in the model's order.
Columns() []TableColumn
// Cell is what one cell holds.
Cell(row, column int) CellValue
}
TableModel is what a Table shows. The models belong to the applications, because what is in a row is the application's business; the library ships the view. The model does the filtering and the sorting and reports the rows it now has, so the view never holds a row: it asks for the cells it draws.
type TableRowNamer ¶
TableRowNamer is a TableModel with its own sentence for a whole row, which a screen reader says as each cell's description. Without one, the row is named by what its text-bearing columns hold, in column order, which for a ledger is the date, the payee and the amount.
type Tag ¶
type Tag struct {
unison.Panel
// Text is the tag.
Text string
// Tint is the colour the reader chose; the zero value is the neutral
// chip ground.
Tint palette.Color
// Tinted says Tint is set.
Tinted bool
// Removable draws a close control, which calls OnRemove.
Removable bool
// OnRemove runs when the close control is pressed.
OnRemove func()
// contains filtered or unexported fields
}
Tag is a label a person put there: a tag, a category, a folder. A chip is chrome saying what something is; a tag is content the reader wrote, with a colour the reader chose from tokens.ColorPalette, which is the same in every theme because the reader picked it. Its words take a colour that contrasts with whatever was picked.
func (*Tag) ProvideAccessibility ¶
func (t *Tag) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the tag as its words and its colour's name, never the colour's value: "#8a5cc0" tells a reader nothing.
type TextArea ¶
type TextArea struct {
Field
// Plain draws a document filling a pane: no ground and no outline, since
// a whole-pane rectangle drawn as a field says there is something beside
// it. It still draws the focus ring and takes the error message.
Plain bool
// Mono draws the text in the monospace family, for source text and
// anything where a column has to line up.
Mono bool
// Underlay draws behind the words, such as a wash behind a marked
// passage. It is given a function answering where a rune index is: the
// top-left of the caret before it and the line's height.
Underlay func(gc *unison.Canvas, at func(index int) geom.Rect)
// Fit makes the area ask for exactly the size of its text, for read-only
// text shown whole inside a scrolling region; FitNone asks for three
// rows whatever it holds.
Fit TextFit
}
TextArea is several lines of text the reader types, or reads and selects: a message, a note, a commit description, a file's own source. Its outline and its error are a Field's, for the same reasons; like a Field, the editing is unison's.
func NewTextArea ¶
NewTextArea returns an empty text area, three rows tall to start.
type TextFit ¶
type TextFit int
TextFit is how a text area's size follows its text.
const ( // FitNone asks for three rows to start, whatever the area holds. FitNone TextFit = iota // FitText asks for the text's height at the width offered, and for the // text's width when the text does not wrap. FitText // FitTextAtLeastOffered asks for the size of the text on unwrapped // lines, and for the width offered when that is wider. FitTextAtLeastOffered )
type Timeline ¶
type Timeline struct {
unison.Panel
// Label names the history for a screen reader.
Label string
// Entries are the events, newest first.
Entries []TimelineEntry
// contains filtered or unexported fields
}
Timeline is what happened to something, newest first: a reader opening a history is asking what happened recently, and making them scroll to the bottom to find out is the commonest thing a history gets wrong. Each entry says who did it as well as what and when; where an agent and a person both change the same things, who is the column that makes a history worth reading. With nothing in it, it says so.
func NewTimeline ¶
func NewTimeline(ui *UI, label string, entries ...TimelineEntry) *Timeline
NewTimeline returns a history of entries, newest first.
func (*Timeline) ProvideAccessibility ¶
func (t *Timeline) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the history as a list whose items say when, what and who.
type TimelineEntry ¶
TimelineEntry is one thing that happened: when, what, who did it, an optional line of detail, and a tone for how it went.
type Tip ¶
type Tip struct {
unison.Panel
// ID names the tip in the settings file, which keeps whether it was
// seen.
ID string
// Title says what the feature is; Text says what it does for the reader.
Title, Text string
// Action is the words of the tip's one action, "" for none.
Action string
// OnAction runs when the action is taken, after the tip closes;
// OnClose when the tip closes by its close button or its target moving.
OnAction, OnClose func()
// contains filtered or unexported fields
}
Tip teaches one feature that is not obvious, or is new, beside what it explains (HLP-4, decided Q-48): a card with a title, a sentence or two, a close button and at most one action. It covers and blocks nothing: the window goes on working around it, Escape and Tab pass it by, and a press elsewhere leaves it. Inside a scrolling region it closes as soon as what it points at moves. Once closed it is not shown again: the settings file keeps its ID, and ResetTips brings every tip back. Spotlight is for a guided tour.
func (*Tip) ProvideAccessibility ¶
func (t *Tip) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the tip as its title and words.
func (*Tip) ShowBeside ¶
ShowBeside shows the tip pointing at what it explains: above it where it fits, below it otherwise. A tip already seen is not shown, and false says so.
func (*Tip) ShowInWindow ¶
ShowInWindow shows a tip about nothing in particular, centred at the bottom of the window. A tip already seen is not shown, and false says so.
type TipFocus ¶
type TipFocus int
TipFocus is how a Tooltip learns that the keyboard is on its panel.
type Toast ¶
type Toast struct {
unison.Panel
// Text is the message.
Text string
// Tone is info, success, warning or danger.
Tone Tone
// Action is the words of the one action; "" for none.
Action string
// Timeout is how long a toast without an action stays; 4 s unless set.
Timeout time.Duration
// OnAction runs when the action is taken; OnDismiss when the toast goes,
// by its timeout or its close control.
OnAction, OnDismiss func()
// contains filtered or unexported fields
}
Toast is a message that appears, says one thing and goes away: a confirmation of something that already happened, saved, copied, three rows archived, and the undo that goes with it. A toast is never the only route to a decision, which would disappear after four seconds. One with an action stays until it is dismissed: an undo that times out mid-read is one the reader cannot use. It is announced to a screen reader when shown.
func (*Toast) ProvideAccessibility ¶
func (t *Toast) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility reads the toast as its message, with its action.
type Tone ¶
type Tone int
Tone is what a chip's colour means, rather than the colour itself, which is what keeps one call site right in all four themes.
type ToolGroup ¶
type ToolGroup int
ToolGroup is where on a toolbar a command sits.
const ( // ToolLeading is the start of the bar, where its commands begin. ToolLeading ToolGroup = iota // ToolCentre is the middle, for navigation or a title. ToolCentre // ToolTrailing is the end, beside the More button: Help, Settings and // the view commands on the Windows form, and the one primary action on // the macOS form (CMD-18). ToolTrailing )
type Toolbar ¶
type Toolbar struct {
unison.Panel
// Label names the toolbar for a screen reader: "Statement".
Label string
// Words shows each command's words beside its symbol, where there is
// room, on the Windows form (CMD-22). A command without a symbol always
// shows its words.
Words bool
// contains filtered or unexported fields
}
Toolbar is a strip of the commands for a window's main tasks, at the top of a main window, made from the app's commands (CMD-18). On the Windows form a window with few commands may have a toolbar with a More menu instead of a menu bar (CMD-1).
Commands are added in order of importance. When the bar is too narrow, first the words beside the symbols go to the tooltips, and then the least important commands move into a More menu at the trailing end, which exists only then, so every command stays reachable at any width (CMD-19, CMD-22). The window a toolbar is shown in answers its commands' keys for as long as it is shown there, after the commands added to the window itself.
func NewToolbar ¶
NewToolbar returns an empty toolbar.
func (*Toolbar) AddMenu ¶
AddMenu puts a button that opens a menu in a group: name and symbol are the button's, in the More menu a submenu's.
func (*Toolbar) ProvideAccessibility ¶
func (t *Toolbar) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the strip as a toolbar.
type Tooltip ¶
type Tooltip struct {
// Focus is how the tooltip learns that the keyboard is on the panel.
Focus TipFocus
// Keyboard, with TipFocusWatched, answers whether the focus just gained
// came from the keyboard. Nil uses the rule Kvit's controls use: a key
// moved the focus or Focus() asked for it, and a press did not.
Keyboard func() bool
// FocusAtOnce shows the tooltip for the keyboard without the half-second
// pause.
FocusAtOnce bool
// Stays keeps the tooltip shown for as long as the pointer rests or the
// keyboard stays. Without it the tooltip also goes after the time it
// takes to read, at least three seconds, and when a button goes down on
// the panel.
Stays bool
// HoverTold leaves it to the caller to say, with SetHovered, whether the
// pointer is on the panel, and the panel's own pointer callbacks are not
// used for it: for a panel that counts the pointer on anything inside it
// as on itself, as a ListRow with HoverWhole does, from its OnHover.
HoverTold bool
// contains filtered or unexported fields
}
Tooltip is a tooltip on any panel, given with AddTooltip: shown beside the panel half a second after the pointer comes to rest on it or the keyboard reaches it, placed and drawn as a control's own tooltip is. With every field at its zero value it behaves as a control's own does: the keyboard focus is watched, and the tooltip goes after long enough to read it and when the panel is pressed.
Its words are read when it shows and not again while it is up. A tooltip may name something and may not be the only place its meaning lives.
func AddTooltip ¶
AddTooltip gives a panel a tooltip whose words are asked each time it is about to show; "" shows none. It wraps the panel's pointer and focus callbacks and calls the ones it replaced first, so set the panel's own before calling it. On a Kvit control the control's own tooltip no longer shows. It shows nothing outside a Kvit window.
func (*Tooltip) Hide ¶
func (t *Tooltip) Hide()
Hide takes the tooltip away, and cancels one about to show. It shows again the next time the pointer arrives or the keyboard does.
func (*Tooltip) SetFocused ¶
SetFocused says whether the keyboard is on the panel, for a tooltip whose Focus is TipFocusTold: typically called from the panel's own focus callbacks with whether its focus ring shows.
func (*Tooltip) SetHovered ¶
SetHovered says whether the pointer is on the panel, for a tooltip with HoverTold: it shows half a second after the pointer arrived.
type Tree ¶
type Tree struct {
unison.Panel
// Label names the tree for a screen reader.
Label string
// Model is what the tree shows.
Model TreeModel
// OnChoose runs when the reader moves to a node.
OnChoose func(path []int)
// OnActivate runs when the reader presses Return on a node with no
// children, or presses one twice.
OnActivate func(path []int)
// contains filtered or unexported fields
}
Tree is a nested list the reader opens and closes: folders, an outline, a hierarchy of accounts. What a shared tree has to get right is the keyboard: Right opens a node and then steps into it, Left closes it or steps out to its parent, and Home and End go to the ends, so depth is never a wall a keyboard user has to arrow through a row at a time. Indentation is a loose space a level, so a deep tree stays in proportion at every interface size. It draws only the rows in view, and scrolls with the wheel.
func (*Tree) IsExpanded ¶
IsExpanded reports whether the node at path is open.
func (*Tree) PerformAccessibilityAction ¶
func (t *Tree) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction moves to, opens or closes a node for a screen reader.
func (*Tree) ProvideAccessibility ¶
func (t *Tree) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the tree and the rows in view, each with its level and whether it is open, the focus on the reader's node.
func (*Tree) Refresh ¶
func (t *Tree) Refresh()
Refresh works out the rows again after the model changed.
func (*Tree) SetExpanded ¶
SetExpanded opens or closes the node at path.
type TreeModel ¶
type TreeModel interface {
// Children is how many children the node at path has.
Children(path []int) int
// Label names the node at path.
Label(path []int) string
}
TreeModel is what a Tree shows, for a tree whose size is not known in advance, such as the folders of a notes vault: the tree asks only about the nodes it shows. A node is named by its path, the index of each node on the way down from the top; the empty path is the root above the top level.
type TreeNode ¶
TreeNode is one node of a tree written out in full, for a tree whose shape is fixed: account groups, a category hierarchy, the sections of a settings page.
type TreeNodes ¶
type TreeNodes []TreeNode
TreeNodes is a TreeModel over nodes written out in full.
type Trend ¶
type Trend struct {
unison.Panel
// Points are the values, oldest first; NotMeasured for a gap.
Points []float64
// MinimumY and MaximumY are the scale's ends.
MinimumY, MaximumY float64
// Ink is the line's colour; the accent unless set.
Ink Ink
// Label and Unit say what the line is.
Label, Unit string
// Gridlines is how many horizontal lines, at least two; 3 unless set.
Gridlines int
// Second is an optional second series, dashed, in SecondInk (the
// second categorical colour unless set), named SecondLabel.
Second []float64
SecondInk Ink
SecondLabel string
// Overlay draws over the plot after the lines, given the plot's box, so
// an annotation lines up with the same arithmetic the lines use.
Overlay func(gc *unison.Canvas, plot geom.Rect)
// contains filtered or unexported fields
}
Trend is a line over periods against a stated scale, with gridlines and their values down the left, and an optional second series drawn dashed so the two do not rest on hue alone. Under the pointer it shows the value of the period there. With no periods it says so rather than drawing an empty axis.
func (*Trend) ProvideAccessibility ¶
func (t *Trend) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility names the line, its periods and its scale.
type TypeAhead ¶
type TypeAhead struct {
Field
// Source is everything that could be matched.
Source []Suggestion
// AllowNew offers to make what was typed when nothing matches it exactly.
AllowNew bool
// MaximumSuggestions caps the matches shown; 8 unless set.
MaximumSuggestions int
// OnChoose runs with the value chosen, or the words typed when a new one
// is made.
OnChoose func(value string)
// Rank, when set, chooses the matches for what is typed and puts them in
// order, best first, for a list whose order is its own, such as notes
// ranked by how well their names match; the list still shows at most
// MaximumSuggestions of them.
Rank func(typed string, source []Suggestion) []Suggestion
// contains filtered or unexported fields
}
TypeAhead is a field that offers matches as the reader types, for a list too long to read where the reader already knows roughly what they want; a Select is for a list they will read. Whether the reader may make something new, a value that is in no list yet, is the property that matters, and it is a required argument rather than a default: a tag picker should let the reader make a tag, while a category picker should not, since a typo would make a second category beside the right one.
The list shows only while the field holds the keyboard, so a field filled by the application opens nothing nobody asked for. It opens below the field, or above it where there is no room below. Up and Down move its cursor and Return takes the match; the caret stays in the field throughout.
func NewTypeAhead ¶
func NewTypeAhead(ui *UI, label string, allowNew bool, source ...Suggestion) *TypeAhead
NewTypeAhead returns an empty type-ahead over source. allowNew says whether the reader may make a value that is not in it.
func (*TypeAhead) Matches ¶
func (a *TypeAhead) Matches() []Suggestion
Matches are the suggestions whose words hold what is typed, ignoring case, in the order of the source, or as Rank has them, at most MaximumSuggestions of them.
func (*TypeAhead) SetText ¶
SetText replaces the text and shuts the list until the reader types: a field filled by the application, as a record pane fills its fields, opens no list that nobody asked for.
func (*TypeAhead) SetTrailing ¶
SetTrailing puts one control inside the field at its right-hand end, such as the button that acts on the chosen value, and the field holds back the room it takes. A button after the field the width of its own label grows with the value and pushes whatever follows it along.
type TypeRole ¶
type TypeRole int
TypeRole names one of the interface's seven type roles: what a run of chrome text is, rather than how big it is.
const ( RoleBody TypeRole = iota // 12 px at the default size: row text, prose RoleCaption // 10: kind tags, counts RoleSmall // 11: chip labels, sub-lines RoleStrong // 13: a name, an emphasised row RoleTitle // 15: a section heading RoleHeadline // 17: a pane title, the wordmark RoleDisplay // 20: a page title )
The seven roles, smallest first.
type UI ¶
type UI struct {
Theme *tokens.Theme
Interface *tokens.Interface
Typography *tokens.Typography
Fonts *text.Fonts
Settings *settings.Store // nil when Options.SettingsPath is empty
Appearance *platform.Appearance // what the desktop says
// Locale is the language and region numbers are written for; see
// Number. language.Und groups no digits, as the C locale does.
Locale language.Tag
// AppName is the app's short name, as About, Help and the macOS form's
// Quit name it: "Kvit Notes". "" leaves the name out.
AppName string
// HelpRoot is the folder holding the app's help pages, the HTML files
// HelpLink opens.
HelpRoot string
// FullKeyboardAccess says Tab reaches every control on the macOS form;
// false keeps it to text fields and lists, as the Mac does with its
// Keyboard navigation setting off (KEY-10, decided Q-16). It is read
// from the Mac, and true elsewhere and with IgnoreDesktop.
FullKeyboardAccess bool
// UnderlineAccessKeys underlines the access keys on the Windows form at
// all times, rather than only while Alt is held, as Windows does with
// its "Underline access keys" setting on (KEY-15). It is read from
// Windows, and false elsewhere and with IgnoreDesktop.
UnderlineAccessKeys bool
// contains filtered or unexported fields
}
UI is one application's design values and fonts: the theme, the interface metrics and the document typography, read from and saved to the settings file, following the desktop's appearance, and applied to unison so its own widgets draw in the same colours.
func New ¶
New sets up the design values and fonts. It can be called before unison.Start; the theme is applied to unison's colours straight away and again whenever it changes.
func (*UI) Chrome ¶
Chrome is the text style of one of the interface's type roles, at the current interface size, in the chrome's family and the given colour.
func (*UI) CommandCase ¶
CommandCase is a label of the kind the macOS form writes in title case, a menu line, a button, a tab, a segment or a column heading, in the app's form: title case on the macOS form, as written on the Windows form.
func (*UI) CountPhrase ¶
CountPhrase is a count with the noun for what it counts: "1 transaction", "250,000 transactions". plural is the noun for several; "" adds an s to singular, which is right for most English nouns and wrong for "entry", so a noun that pluralises some other way passes its own. A negative count says nothing at all, which is right for something that is not a countable list.
func (*UI) DecimalSeparator ¶
DecimalSeparator is the character the reader's locale writes between the whole part of a number and its fraction: "." in en-US and under the C locale, "," in de-DE.
func (*UI) Form ¶
Form is the form the app's windows follow now. Components read it at layout and draw time, as they read colours and sizes.
func (*UI) KeyTurn ¶
KeyTurn reports whether a window is handling a key press now, so that focus gained now was moved by a key. It is false for a press of the pointer and for the focus a window hands its first control when it opens.
func (*UI) Look ¶
Look is the look the app's windows are drawn in now. Components read it at layout and draw time, as they read colours and sizes.
func (*UI) MenuLines ¶
MenuLines are a menu's lines as they would be shown now in the app's form, as a context menu when context is set; see menuLines. The checks in uitest read menus through it.
func (*UI) Notify ¶
Notify posts a notification through the tray, unless one of the app's windows is in front: the reader is looking at the app, and a notification would only interrupt what they are doing (MSG-10). It reports whether it posted. A notification is for something that happened in the background, never the result of what the reader just did.
func (*UI) Number ¶
Number writes a whole number with its digits grouped the way the reader's locale groups them: "250,000" in en-US, "250.000" in de-DE, and "250000" under the C locale. A six-figure count run together is read digit by digit.
func (*UI) OnChanged ¶
func (u *UI) OnChanged(fn func())
OnChanged calls fn after the theme, the interface size or the typography changed and unison has been told; a component that caches anything derived from them drops it here. fn is kept for as long as the UI, and with it whatever it holds, so a component made and thrown away many times over the UI's life uses OnChangedWhile.
func (*UI) OnChangedWhile ¶
OnChangedWhile calls fn after the theme, the interface size or the typography changed, as OnChanged does, for as long as alive reports true, and then lets go of both. It is for a component made and thrown away many times over the UI's life, such as an editor drawing one turn of a conversation: the component holds itself weakly in fn and reports in alive whether it is still in use.
func (*UI) OnPointer ¶
func (u *UI) OnPointer(w *unison.Window, owner *unison.Panel, f func(where geom.Point, inside bool))
OnPointer has a window tell f where the pointer is after every move, in the window's root coordinates, for as long as owner is alive; inside is false once the pointer has left the window. unison tells only the innermost panel under the pointer that the pointer arrived or left, so a panel that has to know the pointer is on anything inside it listens here, and asks PointerOn or PointerOver.
A second call for the same owner replaces its listener. The window holds the owner weakly and f strongly, so f must not hold the owner, or a component the owner is part of, except through a weak pointer: otherwise the owner is never dropped. The pointer is also reported as gone and back when it crosses from one panel to the next, so a listener that acts on a change does so once the event is over.
func (*UI) Refresh ¶
func (u *UI) Refresh()
Refresh draws every window again, so the controls and menu lines made from commands show whether each can act now. An app calls it when something changes what its commands can do other than a command running, such as data arriving in the background; a command that runs redraws by itself.
func (*UI) ResetTips ¶
func (u *UI) ResetTips()
ResetTips brings every tip back, as a setting a reader can use does.
func (*UI) SetContextMenu ¶
func (u *UI) SetContextMenu(p unison.Paneler, menu func(where geom.Point) (title string, items []MenuItem))
SetContextMenu gives a panel a context menu: what menu returns opens at the pointer on a right-click on the panel or anything inside it, and on the Menu key or Shift+F10 while the keyboard is in it, under the panel holding the focus, or where that panel's ContextMenuAnchor says. menu is given the point in the panel's coordinates; no items opens nothing.
func (*UI) SetForm ¶
SetForm makes the app's windows follow a form, and lays them out and draws them again. An app leaves it at the system's; tests and the gallery set it to draw a screen in either form on any system.
func (*UI) SetLook ¶
SetLook draws the app's windows in a look, and lays them out and draws them again. An app that wants the system's look sets SystemLook(); tests and the gallery set any look on any system.
func (*UI) ShortcutText ¶
ShortcutText is how a shortcut is written in the app's form: "Ctrl+Shift+S" on the Windows form, "⇧⌘S" on the macOS form.
func (*UI) ShowMenu ¶
ShowMenu opens a menu of items under anchor, and returns the function that closes it. On Windows and Linux it is the Kvit menu, drawn in the window's popup layer, with symbols, a destructive line in the danger colour, explanations as tooltips, and the arrow keys, Home, End, Return and Escape. On macOS it is the system's own menu, which draws only the words, the tick and the shortcut.
func (*UI) ShowMenuAt ¶
func (u *UI) ShowMenuAt(owner unison.Paneler, part geom.Rect, title string, items []MenuItem) (closeMenu func())
ShowMenuAt opens a menu of items with its top left corner at the bottom left of one part of owner, given in owner's own coordinates, such as one column of a table's header or the point a right-click landed on, and returns the function that closes it. A menu with no room below opens above, and one with no room to the right is pulled back inside the window.
func (*UI) ShowTooltip ¶
ShowTooltip shows a tooltip beside an anchor until the returned function is called, placed as a control's own tooltip is. A tooltip may name something and may not be the only place its meaning lives: a control explained only by its tooltip is unusable on a keyboard, a screen reader or a touch screen. It does nothing outside a Kvit window.
func (*UI) StdName ¶
func (u *UI) StdName(s StdCommand) string
StdName is a standard command's name in a form, without its ellipsis. Help, About and the macOS form's Quit name the app: "Kvit Notes help", "Quit Kvit Notes".
func (*UI) TopicURL ¶
TopicURL is where the topic is: a file URL to its page in UI.HelpRoot, with its anchor.
func (*UI) WatchKeys ¶
WatchKeys makes a window report its key presses to KeyTurn, and draw the focus ring of whichever Kvit control holds its keyboard focus. A Kvit window, and any window a Kvit control is laid out in, is watched already; this is for a panel of an application's own in any other unison window. Calling it again for the same window does nothing.
The watch wraps the window's KeyDownCallback and calls the one it replaced. An application that sets its own afterwards has to call the one it replaces.
type UndoStack ¶
type UndoStack struct {
// contains filtered or unexported fields
}
UndoStack is the app's edits that can be undone, each named for what it did (FDB-7, WRD-11): the Edit menu's lines read "Undo delete transaction" and "Redo delete transaction", and a toast's or a ConfirmInPlace's undo takes back the edit it reports. Every edit since the document was opened can be undone; Clear forgets them when another document opens.
func (*UndoStack) Add ¶
Add records an edit the reader just made, named in sentence case for what it did ("Delete transaction"), with how to take it back and do it again. It forgets the edits that were undone, which cannot be redone after a new one.
func (*UndoStack) Clear ¶
func (s *UndoStack) Clear()
Clear forgets every edit, as opening another document does.
func (*UndoStack) Commands ¶
Commands are the standard Undo and Redo commands for the stack, for the Edit menu: named for the edit they reverse, and done by a focused text field itself while it has an edit of its own to take back.
func (*UndoStack) Confirm ¶
func (s *UndoStack) Confirm(words string) *ConfirmInPlace
Confirm returns a ConfirmInPlace saying what the last edit did, with an undo that takes it back.
type ViewHead ¶
type ViewHead struct {
unison.Panel
// Title names the view, and is the heading a screen reader announces.
Title string
// Count is how many things the view holds; below zero shows no count.
Count int
// Counted is the word for one of the things counted, "item" unless set.
// A count with no noun beside it does not say what was counted.
Counted string
// CountedPlural is the word for several; "" adds an s to Counted.
CountedPlural string
// Subtitle is a sentence under the title. It wraps where a row label is
// cut short, because cutting the end off an explanation loses the half
// that explains.
Subtitle string
// Padding is how far the content sits in from the left and right edges
// of the region the head belongs to; the view margin unless set.
// Everything else in a region is inset by that margin, and a head that
// left it to each caller sat against the edge wherever a caller forgot.
Padding Measure
// contains filtered or unexported fields
}
ViewHead is the strip at the top of a view: what the view is, how much is in it, and the controls that act on the whole of it. It belongs to whatever the window is showing, where the window's own header belongs to the window, and it is where a filter, a sort control and a count go, so a reader looking for how to narrow a view down looks in the same place on every screen.
func NewViewHead ¶
NewViewHead returns a head with a title and, at its right, the controls that act on the whole view, a space apart.
func (*ViewHead) CountPhrase ¶
CountPhrase is the count as the head shows it, "1,284 transactions", or "" when there is no count.
func (*ViewHead) ProvideAccessibility ¶
func (h *ViewHead) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility announces the head as the view's heading.
type Window ¶
type Window struct {
*unison.Window
// SidebarVisible false hides the sidebar entirely, which is a reader's
// choice, where a collapsed one is the window being narrow.
SidebarVisible bool
// SidebarExpandsOnHover opens the rail while the pointer rests on it or
// the keyboard is inside it; on unless an application has a reason.
SidebarExpandsOnHover bool
// AllowClose, when set, is asked before the window closes, by its close
// button, Close, Exit or Quit: true lets it close, false keeps it open,
// as when the reader cancels the question about unsaved changes. An app
// that saves by itself saves here and returns true (WIN-19).
AllowClose func() bool
// OnKeyDown is offered every key press before the focused control, for
// the application's own shortcuts; true says it used the key. It is
// here rather than in the window's KeyDownCallback, which Kvit uses to
// tell keyboard focus from the rest.
OnKeyDown func(key unison.KeyCode, mods mod.Modifiers, repeat bool) bool
// contains filtered or unexported fields
}
Window is the application shell: a window with a header, an optional sidebar, a body and a status bar. Those four are assembled slightly differently in each application and the differences are all accidents. What it fixes in particular is the reflow: the sidebar collapses to its rail below the laptop width, and the window has a floor at the narrowest and shortest size the chrome holds, so a view never has to work out for itself when it is too narrow. The widths scale with the interface size: at twice the size the same screen needs twice the width.
A rail is a strip of symbols with no words, and a reader who meets one cannot tell what the marks are. So while the pointer rests on the rail, or the keyboard is anywhere inside it, it opens to the full sidebar, over the body rather than pushing it aside, so the screen being read does not move underneath the reader.
func NewWindow ¶
NewWindow returns a shell window, the design width wide and 960 design pixels tall, with nothing in it yet.
func (*Window) AccessKeys ¶
AccessKeys are the access keys of the controls in the window's keyboard scope, the topmost dialog when one is open, on the Windows form; none on the macOS form. A key the menu bar's titles use is not given to a control.
func (*Window) AddCommands ¶
AddCommands makes the window answer the commands' keys: a key runs its command wherever the window has the focus, and does nothing, silently, while the command cannot act (KEY-2). A command is refused, with a warning, when one of its keys in either form is already another command's, a standard command's that it is not (KEY-5), or one the system or the access keys own (KEY-3, KEY-4); the error lists every refusal. A refused command is still added for its other keys, and still runs from its menu line and buttons.
A key a text field uses, typing and moving the caret, goes to a focused text field rather than to a command. A standard command a focused control can carry out itself, such as Copy in a text field or Select all in a list, is done by the control.
func (*Window) Commands ¶
Commands are the commands the window answers the keys of, in the order they were added.
func (*Window) DocumentTitle ¶
DocumentTitle is the title the window's document gives it in the app's form, as SetDocument says.
func (*Window) FitToScreen ¶
func (w *Window) FitToScreen()
FitToScreen moves and shrinks the window as little as it takes to show whole on the usable area of its screen, the area the task bar and the menu bar leave.
func (*Window) FullScreen ¶
FullScreen reports whether the window fills the screen.
func (*Window) FullScreenCommand ¶
FullScreenCommand is the standard Full screen command for the window: a switch, shown ticked on its View menu line while on, on F11 on the Windows form and Ctrl-Cmd-F on the macOS form.
func (*Window) Narrow ¶
Narrow reports whether the window is below the narrowest width the chrome is laid out for.
func (*Window) OffSurface ¶
OffSurface are the commands the window runs, by their keys or from a button, that are on none of its command surfaces: not on its menu bar, not in its sidebar, and not on a toolbar in it or in that toolbar's More menu. Every command belongs on a visible surface (CMD-1); one reached only by a key, a button or a context menu cannot be found.
func (*Window) RememberFrame ¶
RememberFrame keeps the window's place and size in the settings file under key whenever the reader moves or resizes it, and puts it back where it was left when called again at the next start, fitted to the screen's usable area so a window from a larger screen still shows whole (WIN-14). With no settings file it only fits the window to the screen.
func (*Window) SetDocument ¶
SetDocument titles the window for the document it shows (WIN-12): on the Windows form, which Linux takes, "Report - Kvit Cash", the document and then the app's name, with an asterisk before the document while it has unsaved changes (WIN-20, decided Q-13); on the macOS form the document alone. "" titles it with the app's name.
func (*Window) SetEdited ¶
SetEdited marks the document as having unsaved changes, or clears the mark once it is saved (WIN-20).
func (*Window) SetFullScreen ¶
SetFullScreen fills the screen with the window, or puts it back where it was (WIN-15). It starts and ends only when the reader asks, by the standard Full screen command (F11 on the Windows form, Ctrl-Cmd-F on the macOS form). unison has no full-screen mode of its own, so the window covers the whole screen with its frame still drawn; on a Mac the window's green button also takes it into the system's full screen.
func (*Window) SetMenuBar ¶
SetMenuBar puts a menu bar in the window, across the top on the Windows form and in the system's menu bar on the macOS form on a Mac, and makes the window answer the keys of every command on it.
func (*Window) SetSidebar ¶
SetSidebar puts the sidebar down the left. A *Sidebar is drawn as its rail whenever the window says so; anything else can ask SidebarCollapsed.
func (*Window) SetStatusBar ¶
SetStatusBar puts the status bar across the bottom.
func (*Window) Show ¶
Show puts a popup above everything in the window and returns the function that takes it away again. Popups shown later are above those shown before.
func (*Window) ShownMenus ¶
ShownMenus are the Kvit menus open in the window now, the topmost last.
func (*Window) ShowsAccessKeys ¶
ShowsAccessKeys reports whether the window underlines its access keys now: while Alt is held, or at all times where the system says so, on the Windows form.
func (*Window) SidebarCollapsed ¶
SidebarCollapsed reports whether the sidebar is drawn as its rail now.
func (*Window) SidebarExpanded ¶
SidebarExpanded reports whether the rail is open over the body now.
func (*Window) SidebarNarrow ¶
SidebarNarrow reports whether the window is narrow enough that the layout keeps room for the rail rather than the sidebar. It does not change when the rail opens.
Source Files
¶
- accesskey.go
- badge.go
- beforeafter.go
- benchmark.go
- breadcrumb.go
- button.go
- card.go
- cell.go
- check.go
- chipbutton.go
- choicebutton.go
- command.go
- commandkeys.go
- confirminplace.go
- control.go
- data.go
- dialog.go
- dialogaccept.go
- dialogmove.go
- disclosure.go
- divider.go
- doc.go
- draw.go
- duallist.go
- emptystate.go
- feedback.go
- field.go
- fieldcaret.go
- fieldword.go
- figure.go
- floatingview.go
- form.go
- formrow.go
- header.go
- helplink.go
- history.go
- icon.go
- iconbutton.go
- ink.go
- keyfocus.go
- label.go
- layer.go
- layout.go
- lead.go
- line.go
- link.go
- linklead.go
- listrow.go
- look.go
- marks.go
- menu.go
- menubar.go
- menubutton.go
- morelayouts.go
- mover.go
- names_gen.go
- netflow.go
- notify.go
- numberfield.go
- numbers.go
- pane.go
- panel.go
- parttip.go
- phonesettings.go
- pointer.go
- popover.go
- progress.go
- radiogroup.go
- region.go
- roving.go
- scrollbar.go
- searchfield.go
- sectionheading.go
- segmented.go
- select.go
- settings.go
- settingswindow.go
- shortcut.go
- sidebar.go
- slider.go
- slimrow.go
- spill.go
- splitview.go
- spotlight.go
- stack.go
- statusbar.go
- stepper.go
- switch.go
- tab.go
- table.go
- tablebody.go
- textarea.go
- timeline.go
- tip.go
- toolbar.go
- tooltip.go
- tree.go
- typeahead.go
- typeselect.go
- ui.go
- undo.go
- viewhead.go
- wheel.go
- window.go
- windowkeys.go
- windowof.go
- windowstate.go
- wording.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
kvit-ui-gallery
command
Command kvit-ui-gallery shows every kvit-ui component with its states, in each theme and at each interface size.
|
Command kvit-ui-gallery shows every kvit-ui component with its states, in each theme and at each interface size. |
|
Package icons names every symbol the Kvit apps draw.
|
Package icons names every symbol the Kvit apps draw. |
|
Package palette is the colour arithmetic the design values are checked with: sRGB colours, OKLab and OKLCH, perceptual distance, simulation of the three colour-vision deficiencies, WCAG contrast, and the rules a chart ramp has to meet.
|
Package palette is the colour arithmetic the design values are checked with: sRGB colours, OKLab and OKLCH, perceptual distance, simulation of the three colour-vision deficiencies, WCAG contrast, and the rules a chart ramp has to meet. |
|
Package phone serves a Kvit app's pages to the owner's phone: the parts every app's phone pages share, around the pages the app draws itself.
|
Package phone serves a Kvit app's pages to the owner's phone: the parts every app's phone pages share, around the pages the app draws itself. |
|
phonetest
Package phonetest helps an app's tests of its phone pages (package phone): a phone paired with the pages, a Tailscale that answers as a signed-in PC, headless Chrome to run the pages' script in, and pictures of pages as an iPhone shows them, in the light and the dark theme.
|
Package phonetest helps an app's tests of its phone pages (package phone): a phone paired with the pages, a Tailscale that answers as a signed-in PC, headless Chrome to run the pages' script in, and pictures of pages as an iPhone shows them, in the light and the dark theme. |
|
webpush
Package webpush sends notifications to a browser with the Web Push standard, which is how a Kvit app reaches its pages on the owner's iPhone (docs/phone-pages.md).
|
Package webpush sends notifications to a browser with the Web Push standard, which is how a Kvit app reaches its pages on the owner's iPhone (docs/phone-pages.md). |
|
Package platform reports what the desktop says about appearance: dark or light, high contrast, and reduced motion.
|
Package platform reports what the desktop says about appearance: dark or light, high contrast, and reduced motion. |
|
Package settings keeps per-user application settings in one JSON file: theme, interface size, typography, option states.
|
Package settings keeps per-user application settings in one JSON file: theme, interface size, typography, option states. |
|
Package text lays out and draws styled text for the Kvit components: it finds fonts on the system and falls back to another font for any character the chosen one lacks, shapes each run with HarfBuzz (kerning, ligatures, emoji sequences, other scripts), breaks lines by the Unicode rules, orders mixed-direction runs for display, answers where a caret goes and which character a point is over, and draws the result on a unison canvas.
|
Package text lays out and draws styled text for the Kvit components: it finds fonts on the system and falls back to another font for any character the chosen one lacks, shapes each run with HarfBuzz (kerning, ligatures, emoji sequences, other scripts), breaks lines by the Unicode rules, orders mixed-direction runs for display, answers where a caret goes and which character a point is over, and draws the result on a unison canvas. |
|
Package tokens holds the design values every Kvit app draws with: the colours of four themes (Theme), the chrome's type scale and geometry, all derived from one interface size (Interface), and the document's text settings (Typography).
|
Package tokens holds the design values every Kvit app draws with: the colours of four themes (Theme), the chrome's type scale and geometry, all derived from one interface size (Interface), and the document's text settings (Typography). |
|
tools
|
|
|
appicon
command
Command appicon draws the gallery's icon, cmd/kvit-ui-gallery/icons/kvit-ui-gallery.svg, at the sizes the program carries it: the PNGs the window title takes (cmd/kvit-ui-gallery/icons/kvit-ui-gallery-<size>.png, which identity.go embeds) and the Windows icon (cmd/kvit-ui-gallery/winres/kvit-ui-gallery.ico, which winres/make-syso.sh compiles into the executable).
|
Command appicon draws the gallery's icon, cmd/kvit-ui-gallery/icons/kvit-ui-gallery.svg, at the sizes the program carries it: the PNGs the window title takes (cmd/kvit-ui-gallery/icons/kvit-ui-gallery-<size>.png, which identity.go embeds) and the Windows icon (cmd/kvit-ui-gallery/winres/kvit-ui-gallery.ico, which winres/make-syso.sh compiles into the executable). |
|
gen-names
command
Command gen-names writes names_gen.go: one Ink for every colour of tokens.Tokens and one Measure for every value Interface derives from the interface size, so a component can be given a colour or a gap by name and keep following the theme and the size.
|
Command gen-names writes names_gen.go: one Ink for every colour of tokens.Tokens and one Measure for every value Interface derives from the interface size, so a component can be given a colour or a gap by name and keep following the theme and the size. |
|
tokens-to-css
command
Command tokens-to-css writes ux/tokens.css: the design values as CSS variables, for drawing a screen as a static HTML page before it is built, so a drawing is judged in the colours and sizes the application will use.
|
Command tokens-to-css writes ux/tokens.css: the design values as CSS variables, for drawing a screen as a static HTML page before it is built, so a drawing is judged in the colours and sizes the application will use. |
|
Package uitest opens Kvit components and screens headlessly for tests: in a Kvit window, in a chosen theme and interface size, with a screen reader's view of what is shown, and with the library's rules checked on a program's own source.
|
Package uitest opens Kvit components and screens headlessly for tests: in a Kvit window, in a chosen theme and interface size, with a screen reader's view of what is shown, and with the library's rules checked on a program's own source. |