Documentation
¶
Index ¶
- func GlassSupported() bool
- func LiquidGlassSupported() bool
- func Main()
- func NativeAppearanceSupported() bool
- func NativeApplicationMenu() bool
- func Screenshot(content core.Widget, width, height int, path string) error
- func ScreenshotAtScale(content core.Widget, width, height int, scale float32, path string) error
- func SetApplicationMenu(items ...MenuItem) error
- func SetIcon(artwork []byte) error
- func SetIdleMemoryReclaim(enabled bool)
- func SetNativeAppearance(value Appearance) error
- func SocketDir() string
- type Appearance
- type Element
- type GlassOptions
- type GlassStyle
- type MenuAction
- type MenuBar
- type MenuDisplay
- type MenuItem
- type MenuRole
- type Options
- type Snapshot
- type TrafficLightLayout
- type Window
- func (w *Window) Activate(token string)
- func (w *Window) Close()
- func (w *Window) Closed() bool
- func (w *Window) Focused() bool
- func (w *Window) Frameless() bool
- func (w *Window) Maximized() bool
- func (w *Window) Minimize()
- func (w *Window) Raise()
- func (w *Window) Resize(width, height int) error
- func (w *Window) SetTrafficLightLayout(layout TrafficLightLayout)
- func (w *Window) Size() (width, height int)
- func (w *Window) TakeEditAction() (core.EditAction, bool)
- func (w *Window) TitleBarArea(x, y, width, height float32)
- func (w *Window) ToggleMaximize()
- func (w *Window) WaylandDisplay() unsafe.Pointer
- type WindowInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GlassSupported ¶ added in v0.1.7
func GlassSupported() bool
GlassSupported reports whether this build supports a native glass backdrop. Headless screenshots cannot include the native compositor's effects.
func LiquidGlassSupported ¶ added in v0.1.7
func LiquidGlassSupported() bool
LiquidGlassSupported reports whether this build and OS support NSGlassEffectView. Otherwise Glass uses NSVisualEffectView on macOS.
func Main ¶
func Main()
Main runs the platform event loop. The process exits after the last window closes. With KEEL_AUTOMATION set it also serves automation requests, or only those with KEEL_HEADLESS=1; see automation.go.
func NativeAppearanceSupported ¶ added in v0.1.6
func NativeAppearanceSupported() bool
NativeAppearanceSupported reports whether SetNativeAppearance can change native application chrome. Go-rendered content still uses the application's theme.
func NativeApplicationMenu ¶ added in v0.1.6
func NativeApplicationMenu() bool
NativeApplicationMenu reports whether this build has a native menu backend.
func Screenshot ¶
Screenshot renders content as a window would, off-screen at 2× scale, and writes a PNG. Width and height are in dp.
func ScreenshotAtScale ¶
ScreenshotAtScale renders the first frame at an explicit pixel density. Dimensions are in dp; scale must be finite and positive.
func SetApplicationMenu ¶ added in v0.1.6
SetApplicationMenu installs a menu without retaining a controller. Use NewMenuBar and Install when the menu will be updated dynamically.
func SetIcon ¶ added in v0.0.7
SetIcon sets the app's icon from full-bleed square PNG artwork, as in a keel project's appicon.png: macOS shows it in the Dock with Apple's plate and shadow; Windows on every window's title bar and taskbar button; Linux X11 on every window (_NET_WM_ICON). Wayland and the browser take their icon from the installed .desktop entry and the page, so SetIcon does nothing there. It applies to open windows and to those opened later; call it before Open, or any time to change the icon.
func SetIdleMemoryReclaim ¶ added in v0.1.6
func SetIdleMemoryReclaim(enabled bool)
SetIdleMemoryReclaim enables process-wide reclamation of unused Go heap pages after all Keel windows have been quiet for two seconds. It defaults to false. Reclamation requires at least 32 MiB of unused, unreturned heap pages and is limited to once per 30 seconds. It does not redraw windows or change GOGC.
This runs a Go collection and returns free pages to the OS. It can briefly pause other goroutines, including non-UI workloads. Applications with latency sensitive background work should leave it disabled. Disabling cancels pending work, but cannot undo a reclamation already in progress.
func SetNativeAppearance ¶ added in v0.1.6
func SetNativeAppearance(value Appearance) error
SetNativeAppearance chooses native chrome without replacing a custom Go palette. System restores OS-controlled appearance. Unsupported platforms keep their existing native chrome; query NativeAppearanceSupported if needed.
Types ¶
type Appearance ¶ added in v0.1.6
type Appearance string
Appearance describes system preference or an explicit native chrome style. Application palette selection remains independent, e.g. theme.Apply(custom).
const ( AppearanceSystem Appearance = "system" AppearanceLight Appearance = "light" AppearanceDark Appearance = "dark" )
func SystemAppearance ¶ added in v0.1.6
func SystemAppearance() Appearance
SystemAppearance reads the platform preference, falling back to Light when unavailable. Linux portal updates are cached so rendering never waits on D-Bus.
type Element ¶
type Element struct {
Ref string `json:"ref"`
Role string `json:"role"` // see roleOf
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"` // textbox content, select choice, progress
Checked *bool `json:"checked,omitempty"` // checkbox, radio, switch
Selected *bool `json:"selected,omitempty"` // tab, row, option; a button only when selected
Disabled bool `json:"disabled,omitempty"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
Element is one node of a window's semantic tree, as reported to agents.
type GlassOptions ¶ added in v0.1.7
type GlassOptions struct {
Style GlassStyle
// CornerRadius is in dp. Zero uses the system's default glass curvature.
CornerRadius float32
}
GlassOptions configures a glass backdrop covering the window content area. The backdrop samples content behind the window, not pixels drawn by Gio. Opaque content hides it; transparent content exposes it.
type GlassStyle ¶ added in v0.1.7
type GlassStyle uint8
GlassStyle selects the macOS backdrop material.
const ( GlassRegular GlassStyle = iota // Liquid Glass on macOS 26+, vibrancy on older systems. GlassClear // More transparent Liquid Glass; vibrancy on older systems. GlassFrosted // NSVisualEffectView on all supported macOS versions. )
type MenuAction ¶ added in v0.1.6
type MenuAction string
MenuAction forwards a standard editing command to the focused native view. OnSelect, when supplied, overrides the action. Go editors consume actions through core.NextEditAction; AppKit also forwards to the focused native view.
const ( MenuCopy MenuAction = "copy" MenuCut MenuAction = "cut" MenuPaste MenuAction = "paste" MenuSelectAll MenuAction = "select-all" MenuUndo MenuAction = "undo" MenuRedo MenuAction = "redo" )
type MenuBar ¶ added in v0.1.6
type MenuBar struct {
// contains filtered or unexported fields
}
MenuBar owns a portable application menu model. Install uses AppKit on macOS, Win32 menus on Windows, and Keel-rendered window menus on Linux X11/Wayland. Items can also drive an application's own Go menu renderer.
func NewMenuBar ¶ added in v0.1.6
func (*MenuBar) Invoke ¶ added in v0.1.6
Invoke activates an enabled leaf item from UI code, e.g. a custom menu view. It returns false for missing/disabled items or unavailable native edit actions.
func (*MenuBar) Items ¶ added in v0.1.6
Items returns a deep copy, including Go callbacks for custom renderers.
type MenuDisplay ¶ added in v0.1.6
type MenuDisplay uint8
MenuDisplay selects how an installed application menu is shown in this window.
const ( MenuDisplayAuto MenuDisplay = iota // AppKit/Win32 menus, in-window menus on Linux. MenuDisplayWindow // Keel-drawn menu; useful for custom title bars and testing. MenuDisplayHidden // Application provides its own renderer; shortcuts remain available. )
type MenuItem ¶ added in v0.1.6
type MenuItem struct {
ID, Title, Shortcut string
Disabled, Checked, Separator bool
Role MenuRole
Action MenuAction
Children []MenuItem
OnSelect func()
}
MenuItem describes a top-level menu, submenu, action or separator. IDs are optional, but explicit IDs permit UpdateItem and Invoke. Items are copied; callers may reuse slices. Callbacks run serially with other UI callbacks.
type MenuRole ¶ added in v0.1.6
type MenuRole string
MenuRole assigns a macOS system menu slot without prescribing its contents.
type Options ¶
type Options struct {
MenuDisplay MenuDisplay
Title string
Width, Height int
// MinWidth and MinHeight constrain the client area in dp; zero leaves an axis unconstrained.
MinWidth, MinHeight int
Content core.Widget
// Overlay is drawn over the whole window, above Content, for hand-written
// Gio content; el views declare overlays with cx.Overlay instead. It should
// take no space while it has nothing to show.
Overlay core.Widget
// Shortcuts maps accelerators to callbacks while the window has focus, e.g.
// "mod+," (Cmd on macOS, Ctrl elsewhere), "ctrl+shift+s", "esc".
Shortcuts map[string]func()
OnClose func()
// OnResize receives the actual client-area size in dp, on the first frame
// and when it changes. It runs on the UI update queue.
OnResize func(width, height int)
// Frameless hides the system title bar so the content can draw its own,
// e.g. a kit.TitleBar; the content then starts at the window's top edge.
Frameless bool
// NativeTrafficLights keeps AppKit's standard window buttons visible over
// frameless content on macOS. Reserve the top-left titlebar area in Content.
// Other platforms ignore this option.
NativeTrafficLights bool
TrafficLightLayout *TrafficLightLayout
// Glass enables a native macOS glass backdrop. Leave the desired glass
// areas transparent in Content. Other platforms keep the theme background.
Glass *GlassOptions
}
Options configures a window. Width and Height are in dp; zero uses 640×480.
type Snapshot ¶
type Snapshot struct {
Window WindowInfo `json:"window"`
Elements []Element `json:"elements"`
}
Snapshot is a window and its elements.
type TrafficLightLayout ¶ added in v0.1.5
type TrafficLightLayout struct {
Height, Left, OffsetY, Spacing float32
}
TrafficLightLayout positions macOS's standard window buttons in dp. Buttons retain their system size, rendering and native behavior. Height is the custom titlebar height; buttons are centered vertically in it. Left is the first button's left inset. OffsetY moves the center down (or up when negative). Spacing is the distance between button centers; zero keeps AppKit's spacing. A nil layout in Options keeps AppKit's default placement.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
func Open ¶
Open creates and shows a centered window where the platform supports it. Call it before Main or from any callback. It panics on an invalid shortcut, which is a programming error.
func (*Window) Activate ¶ added in v0.0.4
Activate brings the window to the front with an activation token that another program granted, such as notification.Activation.Token after a system notification was clicked. Window managers let a token through their focus-stealing prevention, where a plain Raise may only flash the taskbar. On Wayland the token goes to xdg-activation; on X11 it is a startup ID. Elsewhere, with an empty token, or if the platform refuses, Activate is Raise.
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window as if the user clicked its close button.
func (*Window) Minimize ¶
func (w *Window) Minimize()
Minimize hides the window in the Dock or taskbar.
func (*Window) Resize ¶ added in v0.1.6
Resize requests a client-area size in dp. It is safe from callbacks and background goroutines. The platform may constrain the request; Size and OnResize report the actual size on the next frame. Closed windows are ignored.
func (*Window) SetTrafficLightLayout ¶ added in v0.1.5
func (w *Window) SetTrafficLightLayout(layout TrafficLightLayout)
SetTrafficLightLayout updates native button placement without recreating the window. It is safe from callbacks or background goroutines; the change is applied on the next frame. NativeTrafficLights must be enabled in Options.
func (*Window) Size ¶ added in v0.1.6
Size returns the most recently observed client-area width and height in dp. Before the first frame it returns the requested initial size. It is safe from callbacks and background goroutines, and includes window menus/decorations drawn by Keel. The operating system's external frame is excluded.
func (*Window) TakeEditAction ¶ added in v0.1.6
func (w *Window) TakeEditAction() (core.EditAction, bool)
TakeEditAction implements the focused-editor bridge used by core.NextEditAction. Call from UI code; editors normally use core.NextEditAction instead.
func (*Window) TitleBarArea ¶
func (*Window) ToggleMaximize ¶
func (w *Window) ToggleMaximize()
ToggleMaximize maximizes the window (zooms it on macOS), or restores it when it is maximized.
func (*Window) WaylandDisplay ¶ added in v0.0.4
WaylandDisplay is this window's wl_display on Linux Wayland, nil elsewhere or before the window is shown. Pass it to native/clipboard's UseWaylandDisplay to read the clipboard while this window has focus.
Source Files
¶
- activation_linux.go
- activation_startup.go
- activation_wayland.go
- appearance.go
- appearance_linux.go
- application_menu.go
- application_menu_edit.go
- application_menu_linux.go
- application_menu_view.go
- automation.go
- automation_server.go
- decorations.go
- decorations_unix.go
- development.go
- glass.go
- glass_other.go
- icon.go
- icon_linux.go
- icon_x11.go
- memory.go
- motion_other.go
- position_other.go
- root.go
- screenshot.go
- scroll_wayland.go
- scroll_wayland_report.go
- shortcut.go
- size.go
- titlebar_other.go
- window.go