Documentation
¶
Overview ¶
Package look sets the platform look of a gowt app: the window material, macOS 26 Liquid Glass, Windows 11 corners and dark content. Every call does nothing on a system without the feature.
Index ¶
- Constants
- func BottomPanelHeight(w *gowt.Window) int
- func BottomPanelVisible(w *gowt.Window) bool
- func Classic()
- func DragsWindow(c Container)
- func FocusSearch(w *gowt.Window) bool
- func GlassBorder() gowt.Option
- func GlassButton() gowt.Option
- func InspectorVisible(w *gowt.Window) bool
- func InspectorWidth(w *gowt.Window) int
- func OnBottomPanelChange(w *gowt.Window, f func(visible bool, height int))
- func OnInspectorChange(w *gowt.Window, f func(visible bool, width int))
- func OnSidebarChange(w *gowt.Window, f func(visible bool, width int))
- func OnSidebarResize(w *gowt.Window, f func(visible bool, width int))
- func SetBackdrop(w *gowt.Window, b Backdrop)
- func SetBottomPanel(w *gowt.Window, content, panel Container, height int)
- func SetBottomPanelFloating(w *gowt.Window, on bool)
- func SetBottomPanelHeight(w *gowt.Window, height int)
- func SetBottomPanelVisible(w *gowt.Window, on bool)
- func SetContentFullHeight(w *gowt.Window, on bool)
- func SetDarkContent(a *gowt.App, on bool)
- func SetFullSizeContent(w *gowt.Window, on bool)
- func SetGlass(c Container, on bool)
- func SetGlassBorder(c Container, on bool)
- func SetGlassFocusRing(c Container, on bool)
- func SetGlassGroup(c Container, spacing float64)
- func SetGlassRadius(c Container, r float64)
- func SetGlassTint(c Container, tint gowt.RGBA)
- func SetInspector(w *gowt.Window, content, inspector Container, width int)
- func SetInspectorContentFullHeight(w *gowt.Window, on bool)
- func SetInspectorEdgeLineVisible(w *gowt.Window, visible bool)
- func SetInspectorFixed(w *gowt.Window, on bool)
- func SetInspectorFullHeight(w *gowt.Window, on bool)
- func SetInspectorVisible(w *gowt.Window, on bool)
- func SetInspectorWidth(w *gowt.Window, width int)
- func SetMaterial(c Container, on bool)
- func SetPanesOverlay(w *gowt.Window, on bool)
- func SetRoundedCorners(w *gowt.Window, on bool)
- func SetSidebar(w *gowt.Window, sidebar, content Container, width int)
- func SetSidebarFullHeight(w *gowt.Window, on bool)
- func SetSidebarMinWidth(w *gowt.Window, width int)
- func SetSidebarVisible(w *gowt.Window, on bool)
- func SetSidebarVisibleAnimated(w *gowt.Window, on bool)
- func SetSidebarWidth(w *gowt.Window, width int)
- func SetTitleVisible(w *gowt.Window, visible bool)
- func SetToolbar(w *gowt.Window, items ...ToolbarItem) bool
- func SidebarVisible(w *gowt.Window) bool
- func SidebarWidth(w *gowt.Window) int
- func TitleToolbarHeight(w *gowt.Window) int
- func ToolbarItemWidth(w *gowt.Window, id string) int
- type Backdrop
- type Container
- type ToolbarItem
Constants ¶
const Capsule = -1
Capsule is the radius for SetGlassRadius that rounds the corners fully: half the shorter side, followed on every resize.
Variables ¶
This section is empty.
Functions ¶
func BottomPanelHeight ¶
BottomPanelHeight is the panel height in points, also while it is hidden; 0 without SetBottomPanel.
func BottomPanelVisible ¶
BottomPanelVisible reports whether the panel of a SetBottomPanel window is shown; false without one.
func Classic ¶
func Classic()
Classic asks macOS 26 and newer to keep the look of earlier releases instead of Liquid Glass (the UIDesignRequiresCompatibility key). Call it before gowt.Run. Other systems ignore it. Without an Info.plist the key can only be set at run time and macOS may not read it there; building with -ldflags=-macsdk=15.0 records an older SDK in the binary, which is reliable.
func DragsWindow ¶
func DragsWindow(c Container)
DragsWindow makes c a window drag area for a custom title bar (see SetFullSizeContent): a left press on c or on its labels and plain panels moves the window as a title bar would, and a double click zooms (macOS follows the AppleActionOnDoubleClick setting, including minimize and none) or maximizes and restores. On Windows and Linux the double click is a plain maximize toggle, not the window manager's own title bar action, and the move itself is left to the window manager, so details such as edge snapping differ between desktops. Buttons, text fields and other controls, and Canvas, keep their clicks. Children are taken as they are when DragsWindow runs, so call it after building c. macOS, Windows and Linux (X11 and Wayland through GTK 3).
func FocusSearch ¶
FocusSearch focuses the search field of the toolbar SetToolbar made for w (the item with OnSearch), for an app that binds Cmd+F; it selects the text there and reports whether there is such a field. On macOS the field is the NSSearchToolbarItem: a collapsed one expands first and takes the focus on the toolbar's next layout. Elsewhere it is the search Text of the bar SetToolbar builds. UI thread only.
func GlassBorder ¶
GlassBorder is SetGlassBorder(true) for a glass button; it works with GlassButton and gowt.Circle in either order.
func GlassButton ¶
GlassButton gives a push button (not Check, Radio, Toggle or Arrow) the Liquid Glass bezel on macOS 26 and newer; elsewhere the button is unchanged.
func InspectorVisible ¶
InspectorVisible reports whether the inspector of a SetInspector window is shown; false without one.
func InspectorWidth ¶
InspectorWidth is the inspector width in points, also while it is hidden; 0 without SetInspector.
func OnBottomPanelChange ¶
OnBottomPanelChange runs f after the panel of a SetBottomPanel window was shown, hidden or resized: by SetBottomPanelVisible, SetBottomPanelHeight and arrow keys on its edge, and once at the end of a drag.
func OnInspectorChange ¶
OnInspectorChange runs f after the inspector of a SetInspector window was shown, hidden or resized: by SetInspectorVisible, SetInspectorWidth and arrow keys on its edge, and once at the end of a drag.
func OnSidebarChange ¶
OnSidebarChange runs f after the sidebar of a SetSidebar window was shown, hidden or resized: by SetSidebarVisible, SetSidebarWidth and arrow keys on its edge, and once at the end of a drag.
func OnSidebarResize ¶
OnSidebarResize runs f on every step of a sidebar drag, every arrow-key step and every frame of SetSidebarVisibleAnimated; OnSidebarChange keeps reporting only the settled state.
func SetBackdrop ¶
SetBackdrop sets the window material. A value the OS cannot show falls back to the nearest one it can; Linux ignores it.
func SetBottomPanel ¶
SetBottomPanel puts a panel under the content of w, height points high, for a console or a code pane below a canvas. It shares the layout of SetSidebar and SetInspector: content is the same content, and the panel spans its width, between a sidebar and an inspector, down to the bottom window edge, with a hairline in the system separator colour along its top. On macOS 26 the panel is the inspector's edge-to-edge glass, and under a floating sidebar the glass runs on to the window's left edge, as AppKit extends a split item beneath the sidebar; the panel's children stay right of the sidebar. The panel gets the SetMaterial material, so a SetMaterial on it is turned off. Older macOS shows the flush material; Windows and Linux the SetMaterial background, flush with the content, with the hairline in the sash gap above it.
The user resizes the panel by dragging its top edge, which stops at 60 points and leaves the content at least 100. Read and change that with BottomPanelVisible, SetBottomPanelVisible, BottomPanelHeight and SetBottomPanelHeight, and keep it between runs with OnBottomPanelChange.
func SetBottomPanelFloating ¶
SetBottomPanelFloating floats the bottom panel in a panes overlay window (the default); false fills the central column edge to edge, square, like a non-overlay panel.
func SetBottomPanelHeight ¶
SetBottomPanelHeight sets the panel height in points, at least 60; a hidden panel comes back at it.
func SetBottomPanelVisible ¶
SetBottomPanelVisible shows or hides the panel of a SetBottomPanel window; hidden, the content takes its height.
func SetContentFullHeight ¶
SetContentFullHeight opts into a macOS content column that runs to the window's top edge, under the transparent title bar and toolbar, so a bordered card reaches the very top; the sidebar children stay below the strip. Call before or after SetSidebar; false restores the default. Other systems ignore it.
func SetDarkContent ¶
SetDarkContent on Windows turns on the dark theme of the window content (scroll bars, tables, trees, buttons) through undocumented uxtheme exports. Call before creating windows; it does not switch live. GTK and AppKit theme the content themselves, so it does nothing there.
func SetFullSizeContent ¶
SetFullSizeContent lets the window content extend under the title bar, which becomes transparent, so backgrounds and glass run under it. The window layout (Grid, Row, Form) gets the title bar and toolbar height as extra top margin, kept in step on resize, SetToolbar and full screen; other layouts need their own margin. macOS only; elsewhere it does nothing.
func SetGlass ¶
SetGlass puts a Liquid Glass surface behind the container's content, with rounded corners; the container and the controls under it, also those created later, stop painting their own background as in a SetSidebar sidebar, and lists, tables and trees get the source-list style. It needs macOS 26; older macOS shows a blurred material, other systems nothing.
func SetGlassBorder ¶
SetGlassBorder draws a hairline around the glass SetGlass puts behind c: one device pixel in the system separator colour, following the corner radius. On a white content panel a glass capsule is otherwise almost invisible. The colour follows light and dark mode and the stroke follows resizes. It can come before SetGlass. A panel in a SetGlassGroup gets none. Other systems and macOS before 26: nothing happens.
func SetGlassFocusRing ¶
SetGlassFocusRing turns the glass stroke of c into a ring in the keyboard focus colour (NSColor.keyboardFocusIndicatorColor, the accent colour) while c or any control inside it has keyboard focus, as a text field has one; on blur the SetGlassBorder stroke is back. It follows the corner radius, resizes (AutoGrow too), the accent colour and light and dark mode. Two points wide, inside the glass: the glass is clipped to its corners. macOS 26 only; elsewhere nothing happens. macOS 26 Messages shows no such ring on its composer, so this is opt-in.
func SetGlassGroup ¶
SetGlassGroup makes the glass surfaces (SetGlass) of the direct children of c share one NSGlassEffectContainerView, so surfaces closer than spacing points merge into one shape. Call it before the children get their glass. macOS 26 only; elsewhere it does nothing.
func SetGlassRadius ¶
SetGlassRadius sets the corner radius in points of the glass SetGlass puts behind c, 12 by default; Capsule makes the shorter side a half circle. It can come before SetGlass and stays when the glass is turned off and on. For a field that grows over several lines use a fixed radius of half the one-line height, as the iPad composer does: Capsule would turn a tall field into an oval. Other systems have no glass: nothing happens.
func SetGlassTint ¶
SetGlassTint tints the glass of c so the content under it shows through less: macOS 26 sets the NSGlassEffectView tintColor, older macOS a denser material; the tint survives a glass reinstall.
func SetInspector ¶
SetInspector puts an inspector on the right of w, width points wide, the trailing counterpart of SetSidebar: content fills the rest, or the room between a SetSidebar sidebar and the inspector. It replaces the window layout, so w must hold just the content, the inspector and a SetSidebar sidebar. On macOS 26 the inspector is edge-to-edge Liquid Glass alongside the content, as AppKit draws an NSSplitViewController inspector: flush with the top, right and bottom window edges and running under the toolbar, its children starting below it. Older macOS shows a flush material; Windows a plain panel, Linux a plain panel that takes the window background as its own, so a NoBackground StyledText on it shows the pane rather than the theme's white base. Without a sidebar there, the window also gets full-size content, and on Windows and Linux the SetToolbar items as a bar above the content.
The user resizes the inspector by dragging its left edge, which stops at 160 points and leaves the content at least 200. Read and change that with InspectorVisible, SetInspectorVisible, InspectorWidth and SetInspectorWidth, and keep it between runs with OnInspectorChange.
func SetInspectorContentFullHeight ¶
SetInspectorContentFullHeight opts into an inspector whose composite starts at the window's top edge, under the title bar and toolbar, like SetContentFullHeight for the central content. Call it before or after SetInspector; false restores the default top inset. Other systems ignore it.
func SetInspectorEdgeLineVisible ¶
SetInspectorEdgeLineVisible shows or hides only the native full-height line at the inspector's leading edge. The default is true. Call before or after SetInspector; the setting survives later layouts. Other systems keep the setting but have no such line to change.
func SetInspectorFixed ¶
SetInspectorFixed keeps the inspector width where it is: its edge no longer drags, the arrow keys on it do nothing and the pointer keeps its shape there. SetInspectorWidth still sets the width. It can come before SetInspector, and a later SetInspector keeps the state.
func SetInspectorFullHeight ¶
SetInspectorFullHeight is SetSidebarFullHeight for the inspector: the glass runs flush with the window's top, trailing and bottom edges, no floating inset or corners. False restores the inset.
func SetInspectorVisible ¶
SetInspectorVisible shows or hides the inspector of a SetInspector window; hidden, the content takes its width.
func SetInspectorWidth ¶
SetInspectorWidth sets the inspector width in points, at least 160; toolbar items that do not fit overflow into the strip's More menu. A hidden inspector comes back at it.
func SetMaterial ¶
SetMaterial puts the material of a SetSidebar sidebar and a SetInspector inspector behind the container's content, flush with its edges and with square corners, for a pane of a Split such as a code panel under a canvas; SetGlass gives a rounded card instead. macOS 26: the edge-to-edge Liquid Glass of the inspector, clipped to the container. Older macOS: the blurred material the sidebar and inspector fall back to. As with SetGlass, the container and the controls under it, also those created later, stop painting their own background. Windows: the Fluent window background (Layer) of the sidebar and inspector panels; Linux: the GTK window background. There the controls inside keep their own background: give a StyledText gowt.NoBackground. In a Split, the sash beside the container draws a hairline in the separator colour, the thin divider of an NSSplitView, on every system.
func SetPanesOverlay ¶
SetPanesOverlay opts into floating panes over content on macOS 26; other systems keep their layout. The content then runs the whole client area: panes, bottom panel and toolbar draw over it in glass.
func SetRoundedCorners ¶
SetRoundedCorners forces rounded (true) or square (false) window corners on Windows 11; other systems and older Windows builds ignore it. Windows 11 rounds top-level windows by default.
func SetSidebar ¶
SetSidebar lays w out the way Finder and System Settings are: sidebar on the left, width points wide, content filling the rest. It replaces the window layout, so w must hold just these two, or these and the inspector of SetInspector, called before or after with the same content. On macOS 26 the sidebar floats: Liquid Glass with rounded corners, inset from the window edges and running under the traffic lights; the window gets full-size content, sidebar children and content start below the title bar and toolbar, and the items and title of SetToolbar start past the sidebar. Older macOS shows a flush sidebar material; Windows and Linux put two plain panels side by side, with the SetToolbar items as a bar above the content. A background on w itself paints over the macOS sidebar glass; colour the content instead.
The user resizes the sidebar by dragging its edge, which stops at 88 points. Read and change that with SidebarVisible, SetSidebarVisible, SidebarWidth and SetSidebarWidth, and keep it between runs with OnSidebarChange.
func SetSidebarFullHeight ¶
SetSidebarFullHeight opts into a flush macOS sidebar: glass to the window edges; a top-aligned native scrolls under the toolbar, the other children stay below it (in overlay, all of them). Call before or after SetSidebar; false restores the default. Other systems ignore it.
func SetSidebarMinWidth ¶
SetSidebarMinWidth sets the narrowest sidebar of a SetSidebar window, never below 88 points; a smaller width is raised to it, and 0 restores the built-in minimum. Drag, SetSidebarWidth and the window minimum use it.
func SetSidebarVisible ¶
SetSidebarVisible shows or hides the sidebar of a SetSidebar window; hidden, the content takes the whole width and the Sidebar toolbar items move to the start of the toolbar.
func SetSidebarVisibleAnimated ¶
SetSidebarVisibleAnimated shows or hides the sidebar of a SetSidebar window over about 190 ms, easing out; another call restarts from the width on screen. SetSidebarVisible stays instant and cancels it, and SidebarWidth reports the stored width once the animation ends.
func SetSidebarWidth ¶
SetSidebarWidth sets the sidebar width in points; the width is at least 88, as far as the window knows it yet. A hidden sidebar comes back at it.
func SetTitleVisible ¶
SetTitleVisible hides the native document title or look widget toolbar label without changing Window.SetTitle. The document name stays available to QA and accessibility, and later title updates keep it hidden.
func SetToolbar ¶
func SetToolbar(w *gowt.Window, items ...ToolbarItem) bool
SetToolbar puts a native unified toolbar (NSToolbar) on the window, replacing an earlier one; with no items it removes the toolbar. On macOS 26 the items are Liquid Glass. It reports whether the native toolbar exists. Where it does not (Windows, Linux), a window laid out by SetSidebar or SetInspector, before or after this call, gets the items as a bar of gowt widgets at the top of its content column: flat icon buttons, the window title, a search field, in the content's colour. A window without either gets nothing there; build your own gowt.ToolBar in that case. Use it together with SetFullSizeContent only if the content leaves room for the bar.
func SidebarVisible ¶
SidebarVisible reports whether the sidebar of a SetSidebar window is shown; false without one.
func SidebarWidth ¶
SidebarWidth is the sidebar width in points, also while it is hidden; 0 without SetSidebar.
func TitleToolbarHeight ¶
TitleToolbarHeight returns the current height of the title bar and toolbar strip in points on macOS. It reads the native layout at call time, including after SetToolbar, a resize or a pane Show/Hide. It returns 0 on other platforms and where no full-size content strip exists.
func ToolbarItemWidth ¶
ToolbarItemWidth returns the current width of the native AppKit item viewer for id on macOS. It reads the current frame on every call, without a cache: after SetToolbar, a theme change or resize the next call reports the newly laid-out frame. It returns 0 before a native frame is available, when id is absent, and on other platforms.
Types ¶
type Container ¶
Container is a gowt container that has a composite: Panel, Window, Group, Split and CoolBar.
type ToolbarItem ¶
type ToolbarItem struct {
Title string // label and tooltip
Icon *gowt.Image // custom image on Windows and Linux; the native macOS toolbar keeps Symbol
IconSVG []byte // monochrome SVG, drawn in the bar's text colour on Windows and Linux
Symbol string // SF Symbol name such as "plus" or "square.and.arrow.up"; used after Icon and IconSVG
OnClick func()
Space bool // flexible space; the other fields are ignored
// Group makes the item one capsule of segments, such as the back and forward pair; each segment
// has its own Title, Symbol and OnClick, and the item's own Symbol and OnClick are not used.
Group []ToolbarItem
Nav bool
// Sidebar places the item over the sidebar of a SetSidebar window, ending at the sidebar edge: on
// macOS in the title bar, level with the traffic lights (Finder, Mail), on Windows and Linux in a row
// at the top of the sidebar. Without SetSidebar it is an ordinary item.
Sidebar bool
// SidebarLead packs a Sidebar item at the leading edge of the sidebar zone, right after the window
// buttons, instead of ending at the sidebar edge. When any Sidebar item of the toolbar has it, the
// Sidebar cluster starts at the leading edge.
SidebarLead bool
// Plain draws the item as a bare icon without the bordered capsule, also over the sidebar.
Plain bool
// SidebarEnd places the item just past the right edge of the sidebar, before the window title: a
// bare icon without the bordered capsule the Sidebar items keep, following the edge on a drag or
// resize. With the sidebar hidden it sits at the leading edge, as the way back. On Windows and
// Linux it ends the row at the top of the sidebar; without SetSidebar it is an ordinary item.
SidebarEnd bool
// Center places the item in the middle of the content column, between the sidebar edge and the
// inspector divider (the window middle without either): on macOS fitted there like the sidebar
// spacers, on Windows and Linux centered in the bar, which spans the content column. A Space item
// is still the flexible separator inside a zone.
Center bool
// Inspector places the item over the inspector of a SetInspector window, starting at its left edge
// and following it; with the inspector hidden it sits at the right end. On macOS it comes after an
// NSTrackingSeparatorToolbarItem, on Windows and Linux in a row at the top of the inspector. Without
// SetInspector it is an ordinary item. Within the inspector, a Space item separates the leading
// items from the trailing ones, as it does in the content zone.
Inspector bool
// Text, when set, makes a push item a bordered button showing this text instead of a symbol and
// following its changes, such as a zoom level "100%"; Title stays the tooltip.
Text rx.Reader[string]
// Small gives a push item, a text item, a Group or a search field the small control size
// (NSControlSizeSmall, an 11-point font on macOS); elsewhere smaller icons and text. On macOS a
// Small push item draws its symbol 12 pt (baked into the image, the item has no control size) or
// an 11-point bordered text button; items over the sidebar keep the bordered capsule.
Small bool
// OnSearch makes the item a search field (NSSearchToolbarItem) with Title as the placeholder. It
// gets the text after a typing pause, on Return and on clearing.
OnSearch func(text string)
// ID names the item for the QA driver (qa.ID), as gowt.ID names a widget.
ID string
// Enabled, when set, enables and disables a push item or a Group segment as it changes, for as
// long as the toolbar stays; nil keeps the item enabled.
Enabled rx.Reader[bool]
}
ToolbarItem is one entry of the window toolbar.