Documentation
¶
Overview ¶
Package kit is how the MyGo apps of one author look and move: the theme, the window's frame, the surfaces pages are made of and the controls drawn differently from MyGo's. DESIGN.md says when to use which.
Index ¶
- Constants
- Variables
- func Apply(c *ui.Context)
- func Card(c *ui.Context, body func()) ui.Element
- func Empty(c *ui.Context, icon *ui.SVG, title, detail string, actions func()) ui.Element
- func Figure(e ui.Element) ui.Element
- func Heading(c *ui.Context, s string) ui.Element
- func Icon(shapes string) *ui.SVG
- func IconButton(c *ui.Context, key string, glyph *ui.SVG, label, tip string) ui.Element
- func Muted(c *ui.Context, s string) ui.Element
- func NarrowPage(c *ui.Context, body func()) ui.Element
- func NavItem(c *ui.Context, id string, icon *ui.SVG, label string, chosen bool, ...) ui.Element
- func Page(c *ui.Context, body func()) ui.Element
- func PageTitle(c *ui.Context, s string, back *Back) ui.Element
- func Panel(c *ui.Context, rows func()) ui.Element
- func Segmented(c *ui.Context, id string, selected *int, labels ...string) ui.Element
- func SettingRow(c *ui.Context, label, detail string, control func()) ui.Element
- func Shell(c *ui.Context, sidebar, page func())
- func SidebarHeader(c *ui.Context, name, detail string) ui.Element
- func Surface(e ui.Element, t *ui.Theme) ui.Element
- func Title(c *ui.Context, s string) ui.Element
- func Top(c *ui.Context) float32
- func Window(o mygo.WindowOptions) mygo.WindowOptions
- type Back
Constants ¶
const ( SidebarWidth = 220 // PageSide is the room beside a page's content. PageSide = 32 // TitleSize is the size of a page's title. TitleSize = 24 // PanelRadius rounds cards and panels; controls inside them take the // theme's smaller one. PanelRadius = 10 // RowMinHeight is a setting row's height with a one-line label. RowMinHeight = 56 // ContentWidth is the widest a NarrowPage's content grows, so that a // row's label and its control stay within one glance. ContentWidth = 1120 )
Sizes, in DIPs.
const ( TintDuration = 120 * time.Millisecond EnterDuration = 180 * time.Millisecond ResizeDuration = 200 * time.Millisecond )
How long the transitions take. Menus, popups, dialogs and toasts move as MyGo moves them.
Variables ¶
var ( // Flow moves what a row coming or going pushes around. Flow = ui.ElementTransition{Animation: &resize, Position: true, Size: true} // RowMotion is Flow for the row itself. RowMotion = ui.ElementTransition{Animation: &resize, Position: true, Size: true, Enter: &ui.Motion{Collapse: true}, Exit: &ui.Motion{Collapse: true}} // Tint fades a color that follows the pointer or a state. It is short, // as the pointer crosses many items on its way to one. Tint = ui.ElementTransition{Colors: true, Duration: TintDuration} // PageEnter brings a page up into place, as Windows' Settings do. The // page before it goes at once, so that two never show together. PageEnter = ui.ElementTransition{Colors: true, Duration: EnterDuration, Enter: &ui.Motion{Y: 12}} )
The only transitions. An element that comes and goes needs a Key, as do its siblings after it.
Functions ¶
func Apply ¶
Apply sets the window's theme: Windows 11's surfaces, translucent so that Mica shows through, and text colors that reach 4.5:1 on them. Call it first in the view.
func Empty ¶
Empty stands where a page or a list has nothing to show: an icon, a title saying what is missing, a sentence on what brings it when detail is not empty, and the actions that do, the first a ui.PrimaryButton.
func Figure ¶
Figure shows a number that changes in place with digits of one width, so that it holds its width.
func IconButton ¶
IconButton is a button that shows only glyph, with no face until the pointer is over it. label names it to assistive technology and to tests, and shows as its tooltip unless tip says more.
func NarrowPage ¶
NarrowPage is a Page whose content grows no wider than ContentWidth, for pages of settings, whose rows read badly when far apart.
func NavItem ¶
func NavItem(c *ui.Context, id string, icon *ui.SVG, label string, chosen bool, extra func()) ui.Element
NavItem is an item of a ui.Sidebar. The chosen one is tinted with the accent and marked with a pill, as Windows' Settings mark theirs; MyGo would fill it with the accent while the list has the focus. extra adds to the item's end, as a badge.
func Page ¶
Page is a page that scrolls, its content one column as wide as the window. Pages that hold a table or an editor lay out their own, with a header row padded Top(c), PageSide.
func PageTitle ¶
PageTitle heads a page: in the same place on every page, as tall as a row of buttons beside it, after the page it opened from when back is not nil, as Windows' Settings show where a page is. Escape and Alt+Left then lead back too; a dialog or menu that is open takes Escape first.
func Segmented ¶
Segmented is ui.Segmented with a thumb that slides to the segment chosen. id tells it from the other controls in the window.
func SettingRow ¶
SettingRow is a label, with a sentence below it when detail is not empty, and a control at its end. One that comes and goes needs a Key, as do those below it in its panel.
func Shell ¶
Shell lays out a main window: the sidebar, which runs to the top edge, and beside it the page, under the system's window buttons. The band the buttons are in moves the window.
func SidebarHeader ¶
SidebarHeader names the app at the top of the sidebar, and moves the window.
func Surface ¶
Surface styles a raised box: a fill one step above the page and no outline, but a ring. In the light the ring is dark, with a faint shadow, where a white surface on a near-white page would not show; in the dark it is a little lighter than the surface, as a shadow would not show.
func Window ¶
func Window(o mygo.WindowOptions) mygo.WindowOptions
Window gives a main window its frame: no title bar, the system's window buttons over the page, and Mica behind it.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package desk is what the apps do with the desktop around their windows: the theme they show, the main window and the tray icon.
|
Package desk is what the apps do with the desktop around their windows: the theme they show, the main window and the tray icon. |
|
Package kittest checks in an app's tests that its pages keep to the kit.
|
Package kittest checks in an app's tests that its pages keep to the kit. |