Documentation
¶
Overview ¶
Package macos is NSGo's AppKit backend: one flipped, layer-backed NSView per node, styled through its CALayer, with text the engine laid out with CoreText drawn on the main thread and images decoded off it, and an optional NSVisualEffectView material behind the window's content. Alerts are sheets of visible windows or standalone modal dialogs; Escape, Cmd-[, Option-Left and the mouse's back button go back. It calls AppKit through purego, so it builds without cgo.
Index ¶
- Constants
- func Run(app engine.App, opts Options)
- func RunQuickLook(makeApp func(path, url string) (engine.App, engine.HostOptions), opts Options)
- func RunQuickLookThumbnail(makeApp func(QuickLookThumbnailRequest) (engine.App, engine.HostOptions), ...)
- type Options
- type QuickLookThumbnailRequest
- type View
Constants ¶
const QuickLookExtensionPrincipalClass = "NSGoQuickLookController"
QuickLookExtensionPrincipalClass is the NSExtensionPrincipalClass declared in QuickLookPreview.appex's Info.plist and registered at run time by RunQuickLook.
const QuickLookThumbnailPrincipalClass = "NSGoQuickLookThumbnailProvider"
QuickLookThumbnailPrincipalClass is the NSExtensionPrincipalClass declared in QuickLookThumbnail.appex's Info.plist and registered at run time by RunQuickLookThumbnail.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run runs app and the event loop until the app ends, by its shutdown mode or by quitting. The app opens its windows, panels and tray icons itself (core.RootOptions.Windows); opts' size, title and material are its main window's. Call it from main. It returns once the app's graph is gone and its storage written, leaving the process to the caller, as NSH's run_app does.
func RunQuickLook ¶
RunQuickLook registers NSGoQuickLookController (an NSViewController conforming to QLPreviewingController) and hands the process to Foundation's NSExtensionMain. Each previewed file mounts an embedded NSGo View inside the controller's root view.
func RunQuickLookThumbnail ¶
func RunQuickLookThumbnail(makeApp func(QuickLookThumbnailRequest) (engine.App, engine.HostOptions), opts Options)
RunQuickLookThumbnail registers NSGoQuickLookThumbnailProvider (a QLThumbnailProvider) and hands the process to Foundation's NSExtensionMain. Each thumbnail mounts an embedded NSGo View in a window that never shows, at the request's largest size, and replies with what its layers draw.
Types ¶
type Options ¶
type Options struct {
Title string
Width, Height driver.Points
// Hidden opens the main window without showing it (nsgo.StartHidden).
Hidden bool
// ID names the app's directories and storage (engine.AppDirs).
ID string
// Updates is the build's update channel and defaults.
Updates updates.Config
// Components are the native components Native elements name.
Components driver.NativeComponents
// Material is the material behind the app's views, where they draw
// nothing opaque (nsgo.WindowMaterial).
Material driver.WindowMaterial
// Transparent, NoShadow and SkipTaskbar are the main window's (nsgo.WindowTransparent, nsgo.WindowNoShadow, nsgo.SkipTaskbar).
Transparent, NoShadow, SkipTaskbar bool
// Frame is where the main window opens (nsgo.WindowFrame).
Frame driver.WindowFrame
// Constraints limit the main window (nsgo.WindowConstraints).
Constraints driver.WindowConstraints
// Perf shows the performance monitor over the app: frame rate, frame
// and commit costs, CPU, GPU and memory.
Perf bool
// Fonts are font files under the app's resources, registered before
// the first view.
Fonts []string
// Appearance is the appearance the app starts in.
Appearance driver.Appearance
// HideDock starts the app out of the Dock and the app switcher, as a
// tray app (nsgo.HideDock); desktop.SetDockVisible changes it.
HideDock bool
// LaunchedAtLogin marks a launch by the macOS 11/12 LaunchAgent.
LaunchedAtLogin bool
// Host is what an embedding host gives the view (NewView).
Host engine.HostOptions
}
Options configure the window.
type QuickLookThumbnailRequest ¶
QuickLookThumbnailRequest is a file QuickLook asks a thumbnail of: its path and URL, the largest size in points the thumbnail may take and the pixels a point it is drawn at.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is an app in an NSView of an embedding host's window, which the host's own event loop runs (NewView).
func NewView ¶
NewView makes an NSView showing app, for a host that runs AppKit's loop itself. Its engine starts once the view is in a window, so settings made before that are in the app's first frame. Call it on the main thread; several views may show at once, in one window or several.
func (*View) Close ¶
func (v *View) Close()
Close stops the app and frees the view, which the host removes from its window. Calling it again does nothing.
func (*View) SetHostEnvironment ¶
func (v *View) SetHostEnvironment(env engine.HostEnvironment)
SetHostEnvironment sets what the host sets over the system's environment: its locale, text size and appearance, which AppKit's own chrome in the view takes too.
Source Files
¶
- access.go
- animate.go
- app.go
- audiooutput.go
- automation_off.go
- awake.go
- axscroll.go
- canvasnode.go
- capture.go
- childwindow.go
- clipboard.go
- content.go
- cursor.go
- desktop.go
- dev_geometry.go
- dev_window_frame_off.go
- device.go
- direction.go
- display.go
- edge.go
- effect.go
- features.go
- focus.go
- frontmost.go
- fullscreen.go
- gesture.go
- gpu.go
- hotkey.go
- input.go
- inputsource.go
- keycodes.go
- login.go
- look.go
- macos.go
- material.go
- media.go
- menuicon.go
- nowplaying.go
- paneldock.go
- panelframe.go
- panels.go
- paste.go
- perf.go
- permissionguide.go
- permissionguide_layout.go
- permissions.go
- pointer_transform.go
- pointerlock.go
- quicklook.go
- quicklook_extension.go
- quicklook_thumbnail.go
- quit.go
- rasterscale.go
- sandbox.go
- savepreflight.go
- scan.go
- scroll.go
- selection.go
- services.go
- shader.go
- switch.go
- taskprogress.go
- testinput.go
- testwindow.go
- touch_geometry.go
- tray.go
- updates.go
- webinput.go
- webtracking.go
- wheel.go
- windowpointer.go
- zoom.go