Documentation
¶
Overview ¶
Package apple holds what the AppKit and UIKit backends share, called through purego without cgo: CoreFoundation strings, CoreGraphics colors and canvases, layer styles and transitions, the CoreText text engine, which prepares and lays text out on the engine goroutine for the main thread to draw, and image views, which load and decode off it.
Index ¶
- Variables
- func AnimateIn(layer objc.ID, a driver.ModalAnimation, distance float64, reduceMotion bool, ...)
- func AppGroupContainer(group string) (string, error)
- func AppleSignInAvailable() bool
- func ApplyAnimated[V comparable](a *driver.Animator, viewOf func(driver.NodeID) V, ...)
- func AudioAvailable() bool
- func BackdropFilters(filters []driver.Filter) objc.ID
- func BundleName(lang string) string
- func Bytes(data objc.ID) []byte
- func CFString(s string) uintptr
- func CGColor(c driver.Color) uintptr
- func CallBlock(block objc.ID, args ...uintptr) uintptr
- func CaptureUncaughtExceptions(record func(string)) func()
- func CheckAppStore(c updates.Config, mac bool, id uint32, dispatch func(driver.Event))
- func Class(name string) objc.Class
- func ClearBackgroundAnimation(layer objc.ID)
- func ClearBoundAnimations(layer objc.ID, bound uint16)
- func ClipHolder(layer objc.ID, vs *driver.ViewStyle, scrolls bool)
- func CloseNotification(id string)
- func CloudStorageAvailable() bool
- func CodeFromMetadata(objects objc.ID, r driver.ScanRequest) *driver.ScannedCode
- func CollectText(native objc.ID, out *[]string, text func(objc.ID) (string, bool))
- func CommonModes() objc.ID
- func CompletePictureInPictureRestore(token uint32)
- func ConfigureDownloads(dataDir, identifier string, background bool)
- func ContentTypes(r driver.FilesRequest) objc.ID
- func CroppedPNG(image uintptr, region CGRect) ([]byte, error)
- func CustomAccessibilityAction(action objc.ID, actions []driver.AccessibilityAction, ...) bool
- func DiskSpace(path string, count uint32, separate bool, dispatch func(driver.Event))
- func DrawTopDown(ctx uintptr, height float64, flip bool, draw func(baseUp bool))
- func EdgeBlur(s driver.Side, d driver.EdgeEffect) objc.ID
- func EnableCanvas()
- func Encode(data []byte, maxPixels int, jpeg bool, quality float32) ([]byte, driver.Size, error)
- func FadeImage(s driver.Side) uintptr
- func FillRects(ctx uintptr, rects []CGRect, color uintptr)
- func FitBackdrop(backdrop objc.ID, vs *driver.ViewStyle, w, h float64)
- func FollowBounds(layer objc.ID)
- func Font(f driver.Font) uintptr
- func ForEach(collection objc.ID, fn func(objc.ID))
- func ForgetBorders(layer objc.ID)
- func ForgetDecor(layer objc.ID)
- func ForgetHolder(layer objc.ID)
- func ForgetTransform(layer objc.ID)
- func GPUSupported() bool
- func GaussianBackdrop(radius float64) objc.ID
- func Global(path, name string) objc.ID
- func GoJSON(o objc.ID) any
- func GoString(ns objc.ID) string
- func HandleAppleSignIn(it *driver.MountItem, anchor objc.ID, dispatch func(driver.Event))
- func HandleAuthSession(id uint32, r driver.AuthRequest, anchor func() objc.ID, ...)
- func HandleBiometric(it *driver.MountItem, dispatch func(driver.Event))
- func HandleDownloadEvents(identifier string, completion objc.ID) bool
- func HandlePurchase(it *driver.MountItem, anchor objc.ID, dispatch func(driver.Event))
- func HandleSpeak(id uint32, r driver.SpeakRequest, dispatch func(driver.Event))
- func HandleSpeech(id uint32, r driver.SpeechRequest, dispatch func(driver.Event))
- func HandoffBackground(from, to objc.ID)
- func HeldTransformMethods() []objc.MethodDef
- func HolderMask(layer objc.ID) objc.ID
- func ImageInfo(it *driver.MountItem, dispatch func(driver.Event))
- func ImageSize(image uintptr) (width, height int)
- func InLayoutGhost(ghosts []*LayoutGhost, native objc.ID) bool
- func JSONObject(v any) objc.ID
- func KeepCanvasImage(owner any, key string)
- func KernStorage(storage objc.ID, n uint, spacing driver.Points)
- func KeyEvent(kind, flags uint, timestamp float64, window int, chars, ignoring string, ...) objc.ID
- func KeyNames(name string, flags uint) []string
- func LanguageAttr() objc.ID
- func LayerBounds(layer, root objc.ID) (driver.Bounds, bool)
- func LayerGeometry(layer, root objc.ID) (driver.Matrix3D, driver.Size, bool)
- func LayerGeometryAnimating(layer objc.ID) bool
- func LayerGeometryEnding(layer objc.ID) bool
- func LayersAnimating(observer *driver.GeometryObserver, views NativeViews) bool
- func LayersEnding(views NativeViews) bool
- func LayoutBorders(layer objc.ID)
- func LayoutDecor(layer objc.ID)
- func LinkFrameTime(link objc.ID) time.Time
- func LocalNetworkGated() bool
- func LocalNetworkStatus() int
- func Locale() (tag string, rtl bool)
- func LocaleSettings() driver.LocaleSettings
- func MainQueue() objc.ID
- func MediaTime() time.Duration
- func MetadataKind(t string) (driver.CodeKind, bool)
- func MetadataTypes(r driver.ScanRequest) []string
- func Modifiers(flags uint) driver.Modifiers
- func MoveBorders(layer, host objc.ID)
- func Msg(id objc.ID, sel objc.SEL, args ...uintptr) uintptr
- func MsgBool(id objc.ID, sel objc.SEL, args ...uintptr) bool
- func NSData(b []byte) objc.ID
- func NSString(s string) objc.ID
- func NeedsClipHolder(vs *driver.ViewStyle) bool
- func NewChildContainer(host, class objc.ID, layerBacked bool, child func(objc.ID) bool) objc.ID
- func NewPhotoCapture(device objc.ID) (session, output objc.ID, why string)
- func NewScanCapture(device objc.ID, r driver.ScanRequest) (session, output objc.ID, why string)
- func NotificationPermission(ask bool, answer func(int))
- func NotificationsAvailable() bool
- func NotificationsUsed() bool
- func OSVersion() driver.OSVersion
- func Observe(center, name objc.ID, fn func(note objc.ID)) (stop func())
- func ObserveProcessPower(changed func()) func()
- func OnMain(fn func())
- func OpenAudioOutput(conf driver.AudioOutputConfig) (driver.AudioOutput, error)
- func OptionalNSString(s string) objc.ID
- func PNG(data []byte) ([]byte, driver.Size, error)
- func PNGImage(image uintptr) ([]byte, error)
- func PictureInPictureRestoreCompletion(token uint32) func()
- func PinLanguage(lang string)
- func Play(ctx uintptr, ops []driver.DrawOp, host CanvasHost)
- func PlayOver(ctx uintptr, ops []driver.DrawOp, split driver.CanvasSplit, host CanvasHost)
- func PointerMatrix(layer objc.ID) driver.Matrix3D
- func PreparePicked(r driver.PickRequest, f driver.PickedFile) driver.PickedFile
- func ProcessMemory() (uint64, bool)
- func ProcessPower() (driver.ThermalState, driver.LowPowerMode)
- func PurchasesAvailable() bool
- func RGBAImage(pix []byte, w, h int) uintptr
- func RaiseThread()
- func RasterStep(scale float32) float64
- func RasterizeDrawing(d *driver.Drawing, width, height, scale float64) uintptr
- func RegisterClass(name string, super objc.Class, protocols []*objc.Protocol, ...) objc.Class
- func RegisterFont(data []byte) error
- func RegisterFonts(paths []string)
- func Release(ref uintptr)
- func ReleaseCanvasImage(owner any, key string)
- func ReleaseCanvasImages(owner any)
- func ReleaseOffscreen(id uint64)
- func RenderDrawing(d *driver.Drawing, size driver.Size, scale float64) (*image.RGBA, error)
- func ReportLayerGeometry(observer *driver.GeometryObserver, root objc.ID, views NativeViews) bool
- func RequestLocalNetwork(answer func(int))
- func RequestReview(scene objc.ID)
- func RestyleLayer(layer objc.ID, shown, vs *driver.ViewStyle, view objc.ID, bound uint16)
- func Retain(ref uintptr) uintptr
- func ReviewAvailable() bool
- func RotateLayer(layer objc.ID, radians float64)
- func SaveType(name string) objc.ID
- func ScanCamera() objc.ID
- func Sel(name string) objc.SEL
- func SendSuper[T any](self objc.ID, cmd objc.SEL, args ...any) T
- func SendSuperPoint(self objc.ID, cmd objc.SEL, p CGPoint) objc.ID
- func SetCenterBadge(count uint32) bool
- func SetImageCacheLimit(maxBytes int64)
- func SetKern(attrs objc.ID, spacing driver.Points)
- func SetManualNowPlaying(active bool)
- func SetNotificationPress(press func(id string))
- func SetPurchaseUpdates(fn func(driver.Event))
- func SetSublayerTranslation(layer objc.ID, dx, dy float64)
- func SetTransform(layer objc.ID, t driver.Transform)
- func ShapedCorners(vs *driver.ViewStyle) bool
- func ShowNotification(n driver.Notification, answer func(bool))
- func SpeakAvailable() bool
- func SpeechAvailable() bool
- func StartCapture(session objc.ID, running, failed func()) (stop func())
- func StartImages[V any](pending []V, scale float64, current func(V) bool, start func(V, float64)) []V
- func StartScanCapture(session objc.ID, failed func()) (stop func())
- func StyleLayer(layer objc.ID, was, vs *driver.ViewStyle, view objc.ID)
- func StyleLayerBound(layer objc.ID, was, vs *driver.ViewStyle, view objc.ID, bound uint16)
- func Subviews(view objc.ID) []objc.ID
- func Super(self objc.ID, cmd objc.SEL, args ...any)
- func Tint(ctx uintptr, r CGRect, c driver.Color)
- func TranslateCTM(ctx uintptr, x, y float64)
- func UTType() objc.ID
- func UsesFilters(vs *driver.ViewStyle) bool
- func WatchNotifications()
- func WebCookies(id uint32, r driver.WebCookiesRequest, dispatch func(driver.Event))
- func WithoutAnimation(fn func())
- func YieldFrame()
- func Z(order float64) float64
- type Audio
- type BackdropTint
- type CAFrameRateRange
- type CGPoint
- type CGRect
- type CGSize
- type CanvasHost
- type CanvasLayer
- type Discovery
- type Effect
- type EffectHost
- type EffectTarget
- type Effects
- func (effects *Effects[V]) CaptureStart(v V, host EffectHost[V])
- func (effects *Effects[V]) Draw(host EffectHost[V])
- func (effects *Effects[V]) End(v V)
- func (effects *Effects[V]) Get(v V) *Effect
- func (effects *Effects[V]) Invalidate()
- func (effects *Effects[V]) Set(v V, sh *driver.Shader, host EffectHost[V])
- type GPULayer
- type GPUProbe
- type ImageView
- func (iv *ImageView) Close()
- func (iv *ImageView) Configure(c *driver.ImageConfig)
- func (iv *ImageView) Draw(ctx uintptr)
- func (iv *ImageView) HitTest(p driver.Point) (hit, animated bool)
- func (iv *ImageView) Layout(size CGSize)
- func (iv *ImageView) SetStyle(vs *driver.ViewStyle)
- func (iv *ImageView) Start(ratio float64)
- type Keychain
- type Layout
- func (l *Layout) Attachment(i int) (driver.Bounds, bool)
- func (l *Layout) CaretRect(c driver.Caret) (driver.Bounds, bool)
- func (l *Layout) ContentFrame(w, h float64, box CGRect) CGRect
- func (l *Layout) Draw(ctx uintptr, viewHeight float64, box CGRect, baseUp bool)
- func (l *Layout) DrawBackgrounds(ctx uintptr, at CGRect)
- func (l *Layout) HitTest(p driver.Point) driver.Caret
- func (l *Layout) IndexAt(p CGPoint, box CGRect) int
- func (l *Layout) OffsetAt(p CGPoint, box CGRect) int
- func (l *Layout) RangeRects(start, end int, out []driver.Bounds) []driver.Bounds
- func (l *Layout) Release()
- func (l *Layout) SelectionRects(start, end int, box CGRect) []CGRect
- func (l *Layout) TextLines() []driver.TextLine
- type LayoutBatch
- type LayoutGhost
- type LayoutHost
- type LayoutMotion
- type NSRange
- type NativeViews
- type NetworkWatcher
- type Picture
- type PictureInPicture
- func (p *PictureInPicture) Close(done func())
- func (p *PictureInPicture) Command(command uint32)
- func (p *PictureInPicture) Configure(c driver.PictureInPictureConfig)
- func (p *PictureInPicture) ContinuesInBackground() bool
- func (p *PictureInPicture) Dirty()
- func (p *PictureInPicture) DrawFrame(tree objc.ID, scale float64) bool
- func (p *PictureInPicture) HoldAudio(session driver.AudioSession)
- func (p *PictureInPicture) Layer() objc.ID
- type ScrollEdge
- type Sensors
- type ShaderLayer
- type TextEngine
- type Video
- func (v *Video) ClearHitTestAlpha()
- func (v *Video) Close()
- func (v *Video) Configure(c *driver.VideoConfig)
- func (v *Video) HitTestAlpha(p driver.Point) bool
- func (v *Video) Layout()
- func (v *Video) PictureInPictureCommand(command uint32)
- func (v *Video) SampleHitTestAlpha() bool
- func (v *Video) Seek(position time.Duration)
- func (v *Video) SetHolder(holder objc.ID)
- func (v *Video) SetPictureInPictureOwner(owner *PictureInPicture, wake func())
- func (v *Video) UpdatePictureInPictureFrame(background bool) bool
- func (v *Video) View() objc.ID
- type Web
Constants ¶
This section is empty.
Variables ¶
var GameServicesAvailable = sync.OnceValue(func() bool { if _, err := purego.Dlopen(gameKitPath, purego.RTLD_LAZY|purego.RTLD_GLOBAL); err != nil { return false } return Class("GKLocalPlayer") != 0 })
GameServicesAvailable is Environment.CanUseGameServices: whether GameKit loads on this macOS, iOS or tvOS device and exposes GKLocalPlayer.
var HoldTransforms func(layer objc.ID)
HoldTransforms, when a backend sets it, gives layer the class of HeldTransformMethods as SetTransform first holds a transform for it. Only layers that hold one take that class: AppKit sets each layer's transform as it places its view, and the override's call into Go cost every frame change a few microseconds.
Functions ¶
func AnimateIn ¶
func AnimateIn(layer objc.ID, a driver.ModalAnimation, distance float64, reduceMotion bool, done func())
AnimateIn presents a modal's layer as a asks: sliding up from distance points below, or fading in, and calls done once the entrance finishes (at once when there is no animation). Reduced motion fades instead of sliding.
func AppGroupContainer ¶
AppGroupContainer returns the shared container granted by the bundle's signature. Call on the main thread, as other bundle startup work does.
func AppleSignInAvailable ¶ added in v0.2.0
func AppleSignInAvailable() bool
AppleSignInAvailable is Environment.SignInWithApple: every macOS, iOS and tvOS NSGo runs on has AuthenticationServices, which loads only once a request starts.
func ApplyAnimated ¶
func ApplyAnimated[V comparable](a *driver.Animator, viewOf func(driver.NodeID) V, values func(V) *driver.AnimatedValues, restyle, redrawText, redrawCanvas func(V), component func(V) driver.NativeComponent, repin func())
ApplyAnimated delivers changed values to the views still on a surface. Styles and text update before canvases and native props, then sticky cells follow their animated insets.
func AudioAvailable ¶
func AudioAvailable() bool
AudioAvailable is Environment.Audio: every macOS and iOS NSGo runs on has AVFoundation, which loads only once a sound or a player does.
func BackdropFilters ¶ added in v0.2.0
BackdropFilters returns a CABackdropLayer's filters for filters: their widest blur, then their color filters as one matrix, the order Windows draws them in; 0 when they change nothing. CAFilter's colorMatrix reads the matrix as a CAColorMatrix under inputColorMatrix and ignores Core Image's inputRVector keys. Drop shadows are left out, as CSS's backdrop-filter has no shadow to draw. The array is autoreleased.
func BundleName ¶
BundleName returns the app's name in lang as its bundle's InfoPlist.strings says it, in the localization that suits lang best; "" when the bundle names it in none.
func CallBlock ¶
CallBlock calls a block another language made, such as a Swift closure Objective-C passed NSGo, with up to six object, pointer or integer arguments, and returns its result's register. purego's Block.Invoke calls only the blocks it made.
func CaptureUncaughtExceptions ¶
func CaptureUncaughtExceptions(record func(string)) func()
CaptureUncaughtExceptions saves exceptions that reach Foundation's uncaught exception handler and chains to the previous handler.
func CheckAppStore ¶
CheckAppStore is the shared Apple path for updater.Check: capture the installed bundle's identity, version and storefront country on the main thread, then query the store off it. The Mac's lookup selects Mac software.
func ClearBackgroundAnimation ¶
ClearBackgroundAnimation cancels any running background color transition on layer.
func ClearBoundAnimations ¶
ClearBoundAnimations removes active style transitions on layer (and its border or cover sublayers) for properties named in bound, leaving transitions on unbound properties running.
func ClipHolder ¶ added in v0.2.0
ClipHolder clips layer, the layer of the view holding a view's children, to the box and corners of vs, the view's style, inside its border (driver.ViewStyle.ClipBox); nil or a style that does not clip leaves the children unclipped, or clipped to the holder's bounds for a scroll view's container (scrolls), as NSClipView clips. Corners of different radii and a border take a shape mask over the current bounds; a scroll holder calls this again after committing a new bounds origin. A mask an effect set in its place, hiding the children, stays until the effect puts back HolderMask. A holder that is not a scroll view's container also takes the view's perspective (ChildPerspective), clipping or not, which would otherwise stop at the holder.
func CloseNotification ¶
func CloseNotification(id string)
CloseNotification removes the notification called id, shown or still to show, and every one the app's notification center holds when id is empty, those earlier runs left included. A macOS app that never used notifications has none to close, and closing leaves its center untouched, as an app clearing them each time it comes to the front would otherwise make its Dock badge wait for the user to allow badges.
func CloudStorageAvailable ¶
func CloudStorageAvailable() bool
CloudStorageAvailable is Environment.CloudStorage on Apple platforms: true when NSFileManager.defaultManager.ubiquityIdentityToken is non-nil, meaning the user is signed into iCloud and the app has iCloud access. This check never blocks on network I/O.
func CodeFromMetadata ¶
func CodeFromMetadata(objects objc.ID, r driver.ScanRequest) *driver.ScannedCode
CodeFromMetadata returns the first requested code with a text value.
func CollectText ¶
CollectText collects visible text in native subtree order. text reports whether a managed view is text, including text with an empty label.
func CommonModes ¶
CommonModes returns NSRunLoopCommonModes. Run loop sources compare modes by identity, so an equal string of another object is a mode of its own that never runs.
func CompletePictureInPictureRestore ¶
func CompletePictureInPictureRestore(token uint32)
CompletePictureInPictureRestore acknowledges an engine restoration after its mount batch has applied, even if that batch removed the view.
func ConfigureDownloads ¶
ConfigureDownloads connects the app-wide transfer channel. Background sessions reconnect at launch when a previous transfer left a journal. Call on the main thread before starting the app's engine.
func ContentTypes ¶
func ContentTypes(r driver.FilesRequest) objc.ID
ContentTypes returns the UTTypes of the files r offers, for NSOpenPanel and UIDocumentPickerViewController: every file, as public.data, when r names none or one the system has no type for.
func CroppedPNG ¶
CroppedPNG encodes a region of an already composited CGImage in sRGB.
func CustomAccessibilityAction ¶
func CustomAccessibilityAction(action objc.ID, actions []driver.AccessibilityAction, perform func(string) bool) bool
CustomAccessibilityAction resolves VoiceOver's label to the action's name. An action without a label uses its name as the spoken label.
func DiskSpace ¶
DiskSpace answers a volume capacity request. The mount loop starts this off the main thread. tvOS and watchOS offer one available-space figure.
func DrawTopDown ¶
DrawTopDown runs draw with ctx's state saved and its y axis pointing down over a layer height tall; flip turns a y-up context, which Core Animation gives a layer whose contents are not flipped, top down. Core Graphics offsets shadows in the context's base space, which points down when Core Animation flipped the context and up when flip did: draw learns which as baseUp.
func EdgeBlur ¶
EdgeBlur returns a CABackdropLayer's filters for effect d at side s: a blur growing toward a soft side, or an even one.
func EnableCanvas ¶
func EnableCanvas()
EnableCanvas wires offscreen-canvas decoding for ImageView so offscreen rendering (and Play) link only into apps that use canvases or offscreens.
func Encode ¶
Encode decodes data upright, scales it so its longer side has at most maxPixels (0: its size) and encodes it as a PNG, or as a JPEG of quality when jpeg. It returns the bytes and their size in pixels.
func FadeImage ¶
FadeImage returns a new CGImage of a soft edge's fade at side s, 64 pixels along the band and 1 across: opaque at the side, clear at the other end, for a variable blur to stretch over its band as its mask. The caller releases it.
func FitBackdrop ¶
FitBackdrop lays backdrop, the blur of a view of style vs and size w by h, under the rim, on the view's curve: inside the border by whole points, as a blur on a fraction of a point lands between pixels, the fill closing the seam.
func FollowBounds ¶
FollowBounds keeps a layer's decoration on its box after its bounds origin moved, as a scroll view's does when it scrolls.
func Font ¶
Font returns a CTFont (an NSFont or UIFont) for f: the system face unless f names a family. The caller releases it.
Fonts are immutable and few, so they are built once and handed out again by reference. Building one is seven CoreText calls through purego; a frame of a table asks for the same font forty times.
func ForgetBorders ¶
ForgetBorders forgets the borders of a layer that is going away.
func ForgetDecor ¶
ForgetDecor forgets the decoration of a layer that is going away.
func ForgetHolder ¶ added in v0.2.0
ForgetHolder releases what ClipHolder made for a holder going away.
func ForgetTransform ¶
ForgetTransform forgets the transform SetTransform gave a layer that is going away.
func GPUSupported ¶
func GPUSupported() bool
GPUSupported reports whether the machine has a Metal device for gpu.View. Call it on the main thread.
func GaussianBackdrop ¶ added in v0.2.0
GaussianBackdrop returns a CABackdropLayer's filters for an even blur of radius points, the standard deviation as CSS's blur() has it: hard scroll edges and backdrop blurs. The array is autoreleased.
func Global ¶
Global reads the global object, such as an NSString constant, that framework at path exports as name; 0 when it has none.
func GoJSON ¶
GoJSON returns Foundation's object o as Go's decoded JSON: maps, slices, strings, float64, bool or nil.
func HandleAppleSignIn ¶ added in v0.2.0
HandleAppleSignIn carries out an ItemSignInWithApple, its sheet shown over anchor, the window of the surface that asked, or an ItemAppleCredentialState, on the main thread, answering through dispatch.
func HandleAuthSession ¶ added in v0.2.0
func HandleAuthSession(id uint32, r driver.AuthRequest, anchor func() objc.ID, dispatch func(driver.Event))
HandleAuthSession carries out r for auth session id on the main thread: a start checks the session can catch the redirect and reports it, an open shows the URL over the window anchor returns, and a cancel ends it. dispatch runs on any goroutine.
func HandleBiometric ¶
HandleBiometric carries out a biometric request on the main thread and dispatches its answer to the engine.
func HandleDownloadEvents ¶
HandleDownloadEvents retains UIKit's background-session completion block until the session's events and file publications have finished. It reports whether the session identifier belongs to NSGo's transfer host.
func HandlePurchase ¶ added in v0.2.0
HandlePurchase carries out an ItemPurchase, answering through dispatch.
func HandleSpeak ¶ added in v0.2.0
func HandleSpeak(id uint32, r driver.SpeakRequest, dispatch func(driver.Event))
HandleSpeak carries out an ItemSpeak of utterance or request id, on the main thread, reporting EventSpeak through dispatch.
func HandleSpeech ¶
func HandleSpeech(id uint32, r driver.SpeechRequest, dispatch func(driver.Event))
HandleSpeech carries out an ItemSpeech for session id, on the main thread, reporting EventSpeech through dispatch.
func HandoffBackground ¶
HandoffBackground copies from's currently displayed background color (presentation color while transitioning, else model color) onto to without animation so a background transition on to starts from what the tint showed rather than from transparent.
func HeldTransformMethods ¶
HeldTransformMethods are the methods of a CALayer subclass that keeps the transform SetTransform gave it: AppKit sets its views' layers back to its own transform whenever it syncs their geometry.
func HolderMask ¶ added in v0.2.0
HolderMask is the mask ClipHolder keeps on layer, 0 for none: what an effect that hid the holder's children puts back.
func ImageInfo ¶
ImageInfo answers an ItemImageInfo on a goroutine of its own: it loads the source, keeping its bytes for the views that show it next, and dispatches EventImageInfo with the size ImageIO reads, upright, or an SVG's in whole points.
func InLayoutGhost ¶
func InLayoutGhost(ghosts []*LayoutGhost, native objc.ID) bool
InLayoutGhost reports whether native is inside a removed view still drawing its exit.
func JSONObject ¶
JSONObject returns v as Foundation's objects, autoreleased, or 0 for nil or a value JSON cannot encode.
func KeepCanvasImage ¶
KeepCanvasImage pins key in the canvas and encoded image caches on behalf of owner so it is never evicted while kept; main thread only.
func KernStorage ¶
KernStorage gives the n UTF-16 units of a text view's storage the letter spacing of SetKern.
func KeyEvent ¶ added in v0.2.0
func KeyEvent(kind, flags uint, timestamp float64, window int, chars, ignoring string, repeat bool, code uint16) objc.ID
KeyEvent makes an AppKit key event of kind (NSEventTypeKeyDown or NSEventTypeKeyUp) for window, typing chars and ignoring without modifiers. AppKit must be loaded.
isARepeat and keyCode are the selector's last arguments and go on the stack, past the integer registers. Apple's arm64 ABI packs them by their natural size into one word, isARepeat in its low byte and keyCode from its third, which purego, giving each variadic argument a word of its own, would not; the x86-64 ABI gives each its own word, as purego does.
func KeyNames ¶
KeyNames returns the names core.NormalizeKey gives a key press: the key named name with the modifier flags AppKit and UIKit share, first with Command as "mod", then as "meta".
func LanguageAttr ¶
LanguageAttr is CoreText's kCTLanguageAttributeName, which selects language-specific Han glyph forms, fallback fonts and line breaking.
func LayerBounds ¶
LayerBounds measures the border box through Core Animation's presentation hierarchy, including transforms and moving native scroll containers.
func LayerGeometry ¶
LayerGeometry retains the native viewport's presentation transform and size.
func LayerGeometryAnimating ¶
LayerGeometryAnimating asks only about animations that move the border box; an opacity-only animation needs no geometry refresh.
func LayerGeometryEnding ¶
LayerGeometryEnding reports finite geometry animations that an app test waits for, leaving endless keyframes out of its settling barrier.
func LayersAnimating ¶
func LayersAnimating(observer *driver.GeometryObserver, views NativeViews) bool
LayersAnimating reports whether, while observer observes, a view's layer still animates its geometry.
func LayersEnding ¶
func LayersEnding(views NativeViews) bool
LayersEnding reports whether a view's layer runs a finite geometry animation, which a test waits for.
func LayoutBorders ¶
LayoutBorders fits a layer's per-side borders to its bounds after its frame changed.
func LayoutDecor ¶
LayoutDecor fits a layer's decoration to its bounds after its frame changed.
func LinkFrameTime ¶
LinkFrameTime returns when the frame of a display link (a CADisplayLink, or the one an NSView makes) will show, its targetTimestamp, on time.Now's base: a frame's time for engine.Engine.FrameAt, from within the link's callback.
func LocalNetworkGated ¶
func LocalNetworkGated() bool
LocalNetworkGated says the system keeps the local network from the app: macOS does from 15, for apps that answer for themselves.
func LocalNetworkStatus ¶
func LocalNetworkStatus() int
LocalNetworkStatus is what the app knows of Local Network access without asking: not gated where the system keeps none from it, what a request in this run learned, and unknown before one has, as the system never tells it. Any goroutine.
func Locale ¶
Locale returns the user's locale as a BCP 47 tag, and whether their first preferred language is written right to left.
NSLocale says the languages the process launched with, which a language PinLanguage kept replaces until the next launch; the user's languages are read from their defaults instead, so following them again takes effect at once. A language the user chose for the app in System Settings stays theirs.
func LocaleSettings ¶
func LocaleSettings() driver.LocaleSettings
LocaleSettings returns the regional preferences the user set in Language & Region: the first day of the week (NSCalendar's), the hours of NSDateFormatter's format for the j template, which 24-hour time changes, and NSLocale's measurement system.
func MediaTime ¶
MediaTime returns Core Animation's clock: the time since the system started, on which display links and NSEvent timestamps count too.
func MetadataKind ¶
MetadataKind is the kind of code of an AVMetadataObjectType, and whether it is one.
func MetadataTypes ¶
func MetadataTypes(r driver.ScanRequest) []string
MetadataTypes are the AVMetadataObjectTypes r reads.
func MoveBorders ¶
MoveBorders rehomes a per-side border above a backdrop's layer while keeping the view's children above it. Passing zero puts it back on layer.
func Msg ¶
Msg sends sel to id with up to six arguments and a result that are objects, selectors, pointers, integers or booleans, through purego.SyscallN. objc.Send and ID.Send work each call out with reflection, which costs several times the message itself; what runs for every changed view of every frame sends with Msg.
func NeedsClipHolder ¶ added in v0.2.0
NeedsClipHolder reports whether a view that clips draws outside where it clips its children: an outer shadow, a React Native shadow, an outline or a border, which the children stay inside of (driver.ViewStyle.ClipBox). Core Animation clips those with the children when a layer sets masksToBounds or a mask, so the backends clip such a view's children in a holder view of their own and leave the styled layer unclipped, as CSS keeps a box's own shadows and outline outside its overflow clip and clips inside its border.
func NewChildContainer ¶
NewChildContainer moves the host's managed children into a native view. A layer-backed AppKit container asks for a layer at creation.
func NewPhotoCapture ¶
NewPhotoCapture configures a session to take photos with device, for macOS's TakePhoto, which shows the scanner's camera. The caller owns the returned session and photo output.
func NewScanCapture ¶
NewScanCapture configures a session to read the requested metadata types. The caller owns the returned session and metadata output.
func NotificationPermission ¶
NotificationPermission answers with whether the app may show notifications (driver.NotificationsNotAsked, ...), asking the user first when ask is set and the user was not asked yet. answer runs on any goroutine.
func NotificationsAvailable ¶ added in v0.2.0
func NotificationsAvailable() bool
NotificationsAvailable reports whether the process has a notification center, which also shows the notifications it schedules after the process ends: Environment.ScheduledNotifications. It leaves the center untouched, as the environment is read before the app uses notifications.
func NotificationsUsed ¶ added in v0.2.0
func NotificationsUsed() bool
NotificationsUsed reports whether the app checked or asked for the notification permission or showed a notification, in this run or an earlier one, without touching the center: a bundled macOS app whose process touched it has its Dock badge shown only while the user allows its badges.
func Observe ¶
Observe calls fn on the main thread each time center posts name, until stop is called.
func ObserveProcessPower ¶
func ObserveProcessPower(changed func()) func()
ObserveProcessPower calls changed on the main thread whenever Foundation reports a power constraint changed, until the returned function stops it.
func OnMain ¶
func OnMain(fn func())
OnMain runs fn on the main thread after what is queued there already. It never waits, so any goroutine may call it.
func OpenAudioOutput ¶
func OpenAudioOutput(conf driver.AudioOutputConfig) (driver.AudioOutput, error)
OpenAudioOutput opens a unit without activating the device or holding the process's audio session.
func OptionalNSString ¶
OptionalNSString returns a string, or nil for an empty accessibility attribute.
func PNGImage ¶ added in v0.2.0
PNGImage encodes an already composited CGImage as a PNG. The caller keeps ownership of image; this function does not retain or release it.
func PictureInPictureRestoreCompletion ¶
func PictureInPictureRestoreCompletion(token uint32) func()
PictureInPictureRestoreCompletion reserves the native completion for a mount batch. Owner deletion during that batch cannot cancel it.
func PinLanguage ¶
func PinLanguage(lang string)
PinLanguage keeps lang, the language the app forces, for what the system says in the app from its next launch: the bundle's name in the menu bar, the items it adds to menus, its panels and its controls' words, which follow the languages of the launch and not the app's. "" lets them follow the user's languages again, unless the user chose the app's language in System Settings since. A pseudo locale has no localization of the system's, and pins nothing; neither does a process outside a bundle.
func Play ¶
func Play(ctx uintptr, ops []driver.DrawOp, host CanvasHost)
Play draws ops into ctx, a view's context with its y axis pointing down, as a web canvas would: CoreGraphics adds path points through the transform current when they are added, as the canvas does, and a fill, stroke or clip keeps the path.
func PlayOver ¶
func PlayOver(ctx uintptr, ops []driver.DrawOp, split driver.CanvasSplit, host CanvasHost)
PlayOver plays ops as Play does, but over their static part drawn already (a CanvasLayer): the ops before split.At that split skips set only the state.
func PointerMatrix ¶ added in v0.2.0
PointerMatrix returns the transform currently drawn by layer, around its top left. Presentation values include style transitions and additive keyframes, which a view's layout coordinates do not know.
func PreparePicked ¶
func PreparePicked(r driver.PickRequest, f driver.PickedFile) driver.PickedFile
PreparePicked returns f as r asks for it: its type and size as it shows filled in, encoded again as PNG or JPEG when r needs it.
func ProcessMemory ¶
ProcessMemory returns the process' physical footprint in bytes: the dirty and compressed memory it owns, what Activity Monitor shows and what the system judges it by under memory pressure (unlike the resident size, it leaves out the frameworks' clean pages every process maps).
func ProcessPower ¶
func ProcessPower() (driver.ThermalState, driver.LowPowerMode)
ProcessPower reads Foundation's current thermal state and Low Power Mode.
func PurchasesAvailable ¶ added in v0.2.0
func PurchasesAvailable() bool
PurchasesAvailable is Environment.Purchases: whether the bundle has the library, which loads on macOS 12, iOS 15 and tvOS 15 and later. Loading it starts listening to Transaction.updates, as StoreKit asks apps to from their launch.
func RGBAImage ¶
RGBAImage returns a CGImage of a copy of pix, premultiplied RGBA rows of w pixels, or 0. The caller releases it with Release.
func RaiseThread ¶
func RaiseThread()
RaiseThread gives the calling OS thread the main thread's quality of service, as NSH gives its engine thread. The engine's thread turns input into frames; at the default class the system may run it on efficiency cores, and the quotes benchmark's commits took about 15% longer and varied with the machine's load.
func RasterStep ¶
RasterStep is how many times its pixels a layer scaled by scale draws its content at: 1 up to its own size, then in steps of a half up to 4, so its text and drawings stay sharp while a zoom redraws them only as it passes a step.
func RasterizeDrawing ¶
RasterizeDrawing renders d's top-down operations over width × height logical points at scale pixels per point into a new retained CGImage with transparent background, returning 0 when d has no operations or the size is invalid. The caller must call Release on a non-zero result.
func RegisterClass ¶
func RegisterClass(name string, super objc.Class, protocols []*objc.Protocol, methods []objc.MethodDef) objc.Class
RegisterClass registers an Objective-C class whose methods may call SendSuper. A selector defined twice panics naming it: the runtime refuses the second method with only its index, and the class is registered at launch, so every app would fail to start.
func RegisterFont ¶
RegisterFont registers font file data with CoreText for the process, as the app runs: text prepared from then on finds its families.
func RegisterFonts ¶
func RegisterFonts(paths []string)
RegisterFonts registers the app's font files, paths under its resources, with CoreText for the process, so text finds them by their families. Call it before the first view.
func ReleaseCanvasImage ¶
ReleaseCanvasImage releases one pin of key held by owner, trimming excess unkept entries once key is no longer pinned; main thread only.
func ReleaseCanvasImages ¶
func ReleaseCanvasImages(owner any)
ReleaseCanvasImages releases every pin held by owner as its surface closes; main thread only.
func ReleaseOffscreen ¶
func ReleaseOffscreen(id uint64)
ReleaseOffscreen drops the cached CGImage for offscreen resource id.
func RenderDrawing ¶
RenderDrawing plays a recording into owned RGBA pixels without a window. Its synchronous image resolver has no access to the view caches or main queue.
func ReportLayerGeometry ¶
func ReportLayerGeometry(observer *driver.GeometryObserver, root objc.ID, views NativeViews) bool
ReportLayerGeometry sends observer the presented geometry of each view's layer in root's coordinates, when it observes, and reports whether a layer still animates its geometry, so the surface keeps its frames coming.
func RequestLocalNetwork ¶
func RequestLocalNetwork(answer func(int))
RequestLocalNetwork asks for Local Network access and calls answer with the status, on the main thread: granted once the probe finds its own instance, denied once DNS-SD refuses it, and unknown when the user has not answered within localNetworkWait. Each request probes again, as the user may change the setting at any time; a request while one probes waits for its answer. Without NSLocalNetworkUsageDescription in the Info.plist it logs the key and answers unavailable. Main thread.
func RequestReview ¶
RequestReview asks StoreKit to show a rating prompt on the main thread. Pass the calling surface's foreground-active scene on iOS and zero on macOS.
func RestyleLayer ¶
RestyleLayer draws vs with a layer that shows shown, the style StyleLayer last drew there; with none it draws vs at once. When the two differ only in opacity and transform, as an animation's frames do, it sets just those: drawing every property again remade its colors, shadow, filters and gradients each frame, and the window server drew them all again. bound names the properties currently driven by animated values or appearance motions, whose transitions are skipped.
func ReviewAvailable ¶
func ReviewAvailable() bool
ReviewAvailable reports whether this system has a StoreKit rating prompt.
func RotateLayer ¶
RotateLayer turns layer by radians around its anchor point.
func SaveType ¶
SaveType returns the UTType of a file named name, for a save dialog to keep its extension, or 0 for a name without one.
func ScanCamera ¶
ScanCamera returns the default video capture device, when available.
func SendSuper ¶
SendSuper sends cmd to the superclass of the NSGo class self is an instance of, whatever subclass the runtime gave self since.
func SendSuperPoint ¶
SendSuperPoint is SendSuper for a method that takes one point and returns an object, as hitTest: does. SendSuper registers a function and works the point's layout out with reflection at every call, several times what the method costs, and a hit test calls it for every view under the pointer. This sends through one function registered once, with the point as the two doubles every 64-bit Apple target passes it as.
func SetCenterBadge ¶
SetCenterBadge sets the badge through the center, as iOS 16 and later do, and reports whether it could.
func SetImageCacheLimit ¶
func SetImageCacheLimit(maxBytes int64)
SetImageCacheLimit sets the encoded image byte budget for both imageload's shared byte cache and Apple's canvas image cache, clamping negative values to zero and evicting excess unkept entries immediately; main thread only.
func SetKern ¶
SetKern gives a mutable dictionary of AppKit's or UIKit's text attributes the letter spacing of a core.Text, NSKernAttributeName being kCTKernAttributeName. A kern of 0 would turn the font's own kerning off, so 0 sets none.
func SetManualNowPlaying ¶
func SetManualNowPlaying(active bool)
SetManualNowPlaying suspends automatic publication by controlled macOS videos while a manual publication owns the system's controls.
func SetNotificationPress ¶
func SetNotificationPress(press func(id string))
SetNotificationPress sends the presses of notifications to press, those heard before it first.
func SetPurchaseUpdates ¶ added in v0.2.0
SetPurchaseUpdates has fn hear the transactions the store updates outside a purchase, as EventPurchaseUpdate, those it delivered before first.
func SetSublayerTranslation ¶
SetSublayerTranslation moves layer's sublayers by (dx, dy) points, as a scroll view shows an offset its bounds do not have yet.
func SetTransform ¶
SetTransform sets a layer's transform to t around its transform origin: its center, moved by its style's Origin.
func ShapedCorners ¶ added in v0.2.0
ShapedCorners reports whether vs's rounded corners differ in radius, which a layer's own corner radius cannot draw and a shape mask does.
func ShowNotification ¶
func ShowNotification(n driver.Notification, answer func(bool))
ShowNotification shows n, or schedules it for its At, replacing a notification of its ID, delivered or pending, and answers with whether the center took it: not without the permission. answer runs on any goroutine.
func SpeakAvailable ¶ added in v0.2.0
func SpeakAvailable() bool
SpeakAvailable is Environment.Speak: every macOS, iOS and tvOS NSGo runs on has AVSpeechSynthesizer, which loads only once the app speaks.
func SpeechAvailable ¶
func SpeechAvailable() bool
SpeechAvailable is Environment.Speech: every macOS and iOS NSGo runs on has the Speech framework, which loads only once a session starts.
func StartCapture ¶
StartCapture is StartScanCapture that also runs running on main once the session runs.
func StartImages ¶
func StartImages[V any](pending []V, scale float64, current func(V) bool, start func(V, float64)) []V
StartImages starts the current views queued by a mount batch and clears the retained queue before reusing its storage for the next batch.
func StartScanCapture ¶
StartScanCapture takes ownership of session and starts it off the main thread. Stop releases the session after startup returns, so a quick cancellation cannot leave the camera running. Failed runs on main.
func StyleLayer ¶
StyleLayer draws vs with a view's CALayer. An NSView whose layer it is takes the layer's shadow, as AppKit copies a view's shadow onto its layer. A style with a transition animates what it lists from the values shown; was is the style last drawn, nil for none.
func StyleLayerBound ¶
StyleLayerBound draws vs with layer like StyleLayer, skipping Core Animation transitions for properties named in bound (AnimatedValues.Set) so bound animated values keep moving immediately while unbound properties run vs.Transition.
func Tint ¶
Tint paints c over what ctx holds in r, where it holds anything: a text's bound color over all of its glyphs.
func TranslateCTM ¶
TranslateCTM moves ctx's origin by x, y.
func UsesFilters ¶
UsesFilters reports whether vs gives its layer Core Image filters.
func WatchNotifications ¶
func WatchNotifications()
WatchNotifications makes NSGo the center's delegate; calling it again changes nothing. Call it as the app starts, before it finishes launching, so the press that launched it is heard; macOS calls it then only for an app that used notifications before (NotificationsUsed), so one that only sets a Dock badge never touches the center.
func WebCookies ¶
func WebCookies(id uint32, r driver.WebCookiesRequest, dispatch func(driver.Event))
WebCookies carries out an ItemWebCookies in WKWebsiteDataStore's default store, whose WKHTTPCookieStore every web view but an Incognito one reads: it sets the cookies, lists them or removes every type of website data, and answers once WebKit has. The store exists without a web view, and WebKit writes it to disk, so a cookie with an expiry outlives the app. A target without WebKit, tvOS, has no store.
func WithoutAnimation ¶
func WithoutAnimation(fn func())
WithoutAnimation runs fn with Core Animation's implicit animations off, so layers a backend adds itself change at once.
func YieldFrame ¶
func YieldFrame()
YieldFrame passes the main goroutine through Go's scheduler. A frame clock calls it once a tick, on the main thread, which is enough for frames up to yieldWithin apart; between slower ones, a 60 Hz display's or a slowed animation's, a timer yields every yieldEvery until frames come that close again or stop.
Types ¶
type Audio ¶
type Audio struct {
// contains filtered or unexported fields
}
Audio is one engine's sounds and players, the audio package's on macOS and iOS (docs/architecture/audio.md), as NSH's speaker: a surface makes it with its first ItemAudio and closes it as it closes, so an app that makes no sound never opens the output. Its methods run on the main thread; sounds are read and decoded on goroutines of their own, whose results hop back there.
Sounds decode once, at their load, into an AVAudioPCMBuffer, through an AVAudioFile over a temporary file of their bytes as AVAudioFile reads only files, and play from memory on the engine's one AVAudioEngine: each playback is a voice, an AVAudioPlayerNode through an AVAudioUnitVarispeed, which gives the rate, and a mixer of its own, which gives the volume and stereo pan, as an effect between a player and the main mixer keeps the player's own mixing properties from it. Voices are reused once their buffer played, by sounds of their format; at the playback limit the oldest eligible voice stops. The engine starts at a playback, again after the system stopped it, as for a device change, and pauses a moment after the last playback ends, so the output is not held open; one that cannot start is silence, never an error.
Players are AVPlayers without a layer, as Video's, made at their first preload or play: their load is polled until the item is ready or fails, as a paused player reports no time, their position comes from a periodic time observer, their end from AVPlayerItemDidPlayToEndTimeNotification and a stop no command asked for from AVPlayerRateDidChangeNotification, besides the time observer. On iOS each holds the shared audio session (internal/audiosession) at the level its AudioSession asks for while it plays, and playing sounds hold it ambient; an interruption of the session pauses the players as it begins, and they stay paused as it ends.
func NewAudio ¶
NewAudio returns an engine's sounds and players, reporting EventAudio through dispatch.
func (*Audio) Close ¶
func (a *Audio) Close()
Close stops every playback and player and frees the sounds; nothing is reported after it. Calling it again does nothing.
func (*Audio) Handle ¶
func (a *Audio) Handle(id uint32, r *driver.AudioRequest)
Handle carries out an ItemAudio for sound or player id, on the main thread.
func (*Audio) PausePlayers ¶
func (a *Audio) PausePlayers()
PausePlayers pauses the players playing, as the system would: what an iOS app does as it leaves the foreground, as NSH's do, and as an interruption begins.
type BackdropTint ¶
type BackdropTint struct {
// contains filtered or unexported fields
}
BackdropTint tracks and paints a view's background color on its backdrop's tint layer (macOS's tint view or iOS's UIVisualEffectView contentView), following background transitions and animated background values while leaving an active tint transition alone on frames that animate other properties.
func (*BackdropTint) Reset ¶
func (t *BackdropTint) Reset()
Reset forgets the tint's styled state after the backdrop is removed or rebuilt, so the next style paints immediately without starting a transition.
func (*BackdropTint) Style ¶
Style updates layer with vs.Background, with the same transition and presentation-value retargeting as a view's own layer. Only color changes touch layer, so frames animating other properties leave an active tint transition alone. When animatedBackground is true, the bound background value takes over immediately and cancels any running background transition.
type CAFrameRateRange ¶
type CAFrameRateRange struct {
Minimum, Maximum, Preferred float32
}
CAFrameRateRange is the display link's range, in Hz.
func (CAFrameRateRange) Clamped ¶
func (r CAFrameRateRange) Clamped(screen float32) CAFrameRateRange
Clamped limits the request to rates the screen can show.
type CGPoint ¶
type CGPoint struct {
X, Y float64
// contains filtered or unexported fields
}
CGPoint, CGSize and CGRect match CoreGraphics' layouts on 64-bit Apple platforms.
type CGRect ¶
func BoundsRect ¶
BoundsRect returns a Core Graphics rectangle for the driver's box.
func Damaged ¶
Damaged is the area of a canvas to draw again after its animated arguments played before now play after (driver.CanvasDamage), 2 points wider for anti-aliasing and rounded out to whole points; whole is set where only drawing all of it is right. An empty area draws nothing.
func IntersectRects ¶
IntersectRects returns the overlap of a and b, which has no size when neither extends inside the other.
func KeptContent ¶
KeptContent returns the frame for the content layer of a text, laid at laid, whose content needs need (ContentFrame): laid grown to hold need while that is no more than four times need's area, else need. Core Animation makes a new backing store for each new size of a layer, and a number changing every frame changes its width with it.
type CGSize ¶
type CGSize struct {
Width, Height float64
// contains filtered or unexported fields
}
func LoadStillImage ¶
LoadStillImage loads artwork upright. It blocks and returns a retained CGImage for the caller to release.
type CanvasHost ¶
type CanvasHost struct {
Ratio float64
Redraw func()
Owner any
BaseUp bool
// contains filtered or unexported fields
}
CanvasHost is the view a drawing plays in: the screen's pixels a point, what draws it again once an image it waits for loads, which Owner names so it waits once, and whether the context's base space points up (DrawTopDown).
type CanvasLayer ¶
type CanvasLayer struct {
// Drawing, Width and Height (in pixels) are what it was made for.
Drawing *driver.Drawing
Width, Height int
// contains filtered or unexported fields
}
CanvasLayer is what a drawing's static part (driver.CanvasSplit) paints, rasterized once into a CGLayer made for the contexts it is drawn into, as NSH's macOS Prefix: a frame then draws the layer and plays only the painting after it (PlayOver).
func NewCanvasLayer ¶
func NewCanvasLayer(ctx uintptr, d *driver.Drawing, ops []driver.DrawOp, split driver.CanvasSplit, w, h, scale float64, host CanvasHost) *CanvasLayer
NewCanvasLayer rasterizes what ops paint before split.At into a layer made for ctx, w × h points at scale pixels each. It reports nil when an image the part draws has not loaded yet, which the layer would miss.
func (*CanvasLayer) Draw ¶
func (l *CanvasLayer) Draw(ctx uintptr, w, h float64)
Draw draws the layer over ctx's top-down w × h points.
func (*CanvasLayer) Release ¶
func (l *CanvasLayer) Release()
Release lets the layer go; l may be nil.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery holds the live Bonjour operations of a surface. Its requests, callbacks and deallocation all run on the native main queue.
type Effect ¶
type Effect struct {
// contains filtered or unexported fields
}
Effect draws a shader over native children without changing their input. The platform supplies the host and its child container, while Effect owns the shader layer, its mask and the pictures it samples.
func (*Effect) CaptureStart ¶
func (fx *Effect) CaptureStart(target EffectTarget)
CaptureStart pictures what shows before the transition's batch applies.
func (*Effect) Close ¶
func (fx *Effect) Close()
Close restores the host's children and releases the shader's resources.
func (*Effect) Draw ¶
func (fx *Effect) Draw(target EffectTarget)
Draw attaches the effect to its host and captures the pictures it reads.
func (*Effect) Invalidate ¶
func (fx *Effect) Invalidate()
Invalidate marks the pictures for capture on the next draw.
func (*Effect) Navigating ¶
Navigating reports whether a navigation shader is drawing the transition.
type EffectHost ¶
type EffectHost[V comparable] struct { Root V Scale float64 Actions objc.ID Animator *driver.Animator ID func(V) driver.NodeID Native func(V) objc.ID Container func(V) objc.ID Current func(V) bool Ready func(V) }
EffectHost supplies the native views and animation graph of one surface.
type EffectTarget ¶
type EffectTarget struct {
View, Root objc.ID
Holder func() objc.ID
Scale float64
Lanes func([]float64)
}
EffectTarget is the native view an effect draws over for this frame. Holder makes its child container on demand.
type Effects ¶
type Effects[V comparable] struct { // contains filtered or unexported fields }
Effects owns a surface's effects, including captures made before a transition is installed. Its zero value is ready to use.
func (*Effects[V]) CaptureStart ¶
func (effects *Effects[V]) CaptureStart(v V, host EffectHost[V])
CaptureStart preserves the pixels before a transition's batch applies.
func (*Effects[V]) Draw ¶
func (effects *Effects[V]) Draw(host EffectHost[V])
Draw refreshes installed effects and forgets views replaced in the surface.
func (*Effects[V]) End ¶
func (effects *Effects[V]) End(v V)
End releases an effect and any capture it retained before installation.
func (*Effects[V]) Invalidate ¶
func (effects *Effects[V]) Invalidate()
Invalidate marks installed effects for capture on the next draw.
type GPULayer ¶
GPULayer is a gpu.View's Metal surface.
func NewGPULayer ¶
func NewGPULayer(cfg driver.GPUViewConfig, emit func(*driver.GPUEvent)) *GPULayer
NewGPULayer makes a GPU view's layer on the main thread, or returns nil where the machine has no Metal device. emit reports the view's events from any goroutine.
func (*GPULayer) Release ¶
func (l *GPULayer) Release()
Release detaches the layer, on the main thread; its render goroutine then lets every Metal resource go.
type GPUProbe ¶
type GPUProbe struct {
// contains filtered or unexported fields
}
GPUProbe reads the process' GPU use from the accumulatedGPUTime its accelerator clients report in the IO registry, the counter behind Activity Monitor's GPU column.
func NewGPUProbe ¶
func NewGPUProbe() *GPUProbe
NewGPUProbe returns a probe, or nil when the machine has no accelerator.
type ImageView ¶
type ImageView struct {
// Dispatch reports an event to the engine if the view listens for it.
Dispatch func(driver.Event)
// Changed runs on the main thread after rendered content changes,
// including an asynchronous image load, for snapshot renderers.
Changed func()
// AlphaChanged enables picture hit testing and invalidates a cached hit
// when the view shows a different image.
AlphaChanged func()
// contains filtered or unexported fields
}
ImageView shows an image view's source, and its placeholder until the source arrives, in a picture layer framed at the fitted rectangle inside a clipping layer it adds to the view's own, as NSH's does (the tint and its mask inside the picture). It loads them with imageload and decodes them with ImageIO on goroutines, at the size the view shows them. Its methods run on the main thread.
func NewDrawnImage ¶
func NewDrawnImage(changed func()) *ImageView
NewDrawnImage is an ImageView with no layer, for a backend that draws it itself (Draw): changed runs on the main thread each time what it shows changes.
func NewImageView ¶
NewImageView adds an image layer to host, a view's layer.
func (*ImageView) Close ¶
func (iv *ImageView) Close()
Close stops loading and lets the image go; the view is being deleted.
func (*ImageView) Configure ¶
func (iv *ImageView) Configure(c *driver.ImageConfig)
Configure sets the view's source and look. Start loads what changed.
func (*ImageView) Draw ¶
Draw draws a drawn image's picture into ctx, a context of the view's box with its y axis down: fitted, clipped to the view's corners, and filled with the tint through its alpha where the style tints it.
func (*ImageView) HitTest ¶
HitTest reports whether the picture at p takes the pointer and whether the sampled image is animated and may change at the next hit test.
func (*ImageView) Layout ¶
Layout fits the image to the view's new size, decoding the source again when the view outgrows the size it was decoded at.
type Keychain ¶ added in v0.2.0
type Keychain struct{}
Keychain keeps an app's secrets as generic passwords of the keychain through Security.framework, in the process, as the item's access control trusts the binary that wrote it: kSecClassGenericPassword with the item's kSecAttrService and kSecAttrAccount, labeled with the service, as MyGo's App.Secrets and keytar keep them, so an app keeps reading what they wrote.
macOS keeps them in the login keychain, which needs no entitlement; an AccessGroup takes them to the data protection keychain instead, which needs a signed app with the keychain-access-groups entitlement (unsigned builds get errSecMissingEntitlement), and only there does Accessible apply. iOS, tvOS and watchOS have only the data protection keychain.
func (Keychain) DeleteSecret ¶ added in v0.2.0
func (Keychain) DeleteSecret(item driver.SecretItem) (err error)
func (Keychain) ReadSecret ¶ added in v0.2.0
func (Keychain) WriteSecret ¶ added in v0.2.0
func (Keychain) WriteSecret(item driver.SecretItem, value string) (err error)
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout is text CoreText laid out on the engine goroutine, drawn on the main thread.
func (*Layout) Attachment ¶
Attachment implements core.AttachmentLayout.
func (*Layout) ContentFrame ¶
ContentFrame is the frame of the layer a text view of size w by h draws l into, its text in box: the view's bounds, grown to hold the decoration lines, backgrounds and shadow that reach past them, as a browser draws a text's ink outside its box. It is in whole points.
func (*Layout) Draw ¶
Draw draws l in box of a flipped context of a view viewHeight tall, whose base space points up when baseUp is set (DrawTopDown).
func (*Layout) DrawBackgrounds ¶
DrawBackgrounds fills the backgrounds of l's spans in box of a flipped context, behind the selection and the glyphs.
func (*Layout) IndexAt ¶
IndexAt returns the UTF-8 byte offset of the character at p, a point of the view Draw drew l in at box, or -1 when no character is there.
func (*Layout) OffsetAt ¶
OffsetAt returns the UTF-16 offset of the caret nearest p, a point of the view Draw drew l in at box: on the line nearest p, before the line's break.
func (*Layout) RangeRects ¶
RangeRects implements driver.TextHitTester.
func (*Layout) SelectionRects ¶
SelectionRects returns the boxes of the UTF-16 range from start to end in the view Draw draws l in at box: per line, a box per run of adjacent characters. A range that goes on past a line covers the rest of it.
type LayoutBatch ¶
type LayoutBatch struct {
Animation *driver.LayoutAnimation
Created map[driver.NodeID]bool
Deleted map[objc.ID]bool
}
LayoutBatch tracks views inserted or retained by one animated commit.
type LayoutGhost ¶
type LayoutGhost struct {
// contains filtered or unexported fields
}
LayoutGhost is a removed view kept alive until its exit ends.
func NewLayoutGhost ¶
func NewLayoutGhost(native objc.ID, transition *driver.LayoutTransition, start time.Duration) *LayoutGhost
NewLayoutGhost takes the caller's retain on native and records its opacity.
func StepLayoutMotions ¶
func StepLayoutMotions[V comparable](now time.Duration, motions map[V]*LayoutMotion, ghosts []*LayoutGhost, current func(V) bool, place func(V, driver.Bounds), restyle func(V)) []*LayoutGhost
StepLayoutMotions advances the mounted views and retires completed exits. The caller supplies view identity, placement and restyling for its toolkit.
func (*LayoutGhost) Release ¶
func (g *LayoutGhost) Release()
Release takes g's native view away and lets go of it, at the end of its exit or as its surface closes.
type LayoutHost ¶
type LayoutHost[V comparable] struct { Motions map[V]*LayoutMotion Ghosts *[]*LayoutGhost ID func(V) driver.NodeID Native func(V) objc.ID Framed func(V) bool Frame func(V) driver.Bounds Shift func(V) driver.Point Place func(V, driver.Bounds) Restyle func(V) Disable func(V) Now func() time.Duration Start func(*driver.LayoutTransition) time.Duration Tick func() }
LayoutHost supplies a backend's native views and placement to the shared layout transition lifecycle. Now is the frame clock; Start is when a new frame motion on a transition starts, which UIKit moves back to when the keyboard started moving.
func (LayoutHost[V]) Appear ¶
func (host LayoutHost[V]) Appear(v V, batch *LayoutBatch, parent driver.NodeID)
Appear starts only the top inserted view of an appearing subtree.
func (LayoutHost[V]) Match ¶
func (host LayoutHost[V]) Match(v, old V, batch *LayoutBatch)
Match moves a replacement from its predecessor's box in the new parent.
func (LayoutHost[V]) SetFrame ¶
func (host LayoutHost[V]) SetFrame(v V, item *driver.MountItem, batch *LayoutBatch)
SetFrame animates a changed frame from where it shows when the batch or the item asks for it, retargeting a running motion with its velocity.
func (LayoutHost[V]) Vanish ¶
func (host LayoutHost[V]) Vanish(v V, batch *LayoutBatch) bool
Vanish retains one exit per deleted subtree and lets UIKit disable its input.
type LayoutMotion ¶
type LayoutMotion struct {
Frame *driver.LayoutMotion
Appear *driver.LayoutTransition
AppearStart time.Duration
}
LayoutMotion is a view's part of a layout animation on the frame clock: its frame moving, its velocity kept as a spring retargets, or the view appearing.
type NSRange ¶
type NSRange struct {
Location, Length uint
// contains filtered or unexported fields
}
NSRange is Foundation's range of UTF-16 units.
type NativeViews ¶
NativeViews yields a surface's mounted views, each ID with its native view, for the geometry helpers below that macOS and iOS share.
type NetworkWatcher ¶
type NetworkWatcher struct{}
NetworkWatcher supplies the system's default Network.framework path.
func (NetworkWatcher) WatchNetwork ¶
func (NetworkWatcher) WatchNetwork(changed func(driver.Network)) (driver.Network, func())
WatchNetwork reads and follows the current default path.
type Picture ¶
type Picture struct {
// contains filtered or unexported fields
}
Picture is what a shader effect or transition reads of views: a layer tree drawn with renderInContext: into a bitmap it keeps, made again only when its size changes, and the Metal texture the bitmap goes into. renderInContext: draws no Metal layer, video, web page, backdrop blur or glass.
func (*Picture) Release ¶
func (p *Picture) Release()
Release lets the picture's bitmap and texture go.
type PictureInPicture ¶
type PictureInPicture struct {
// contains filtered or unexported fields
}
PictureInPicture owns AVKit's session and its source layer. Only the main thread mutates it. The sample playback delegate reads an atomic snapshot, so AVKit never waits for the engine while it is suspended.
func NewPictureInPicture ¶
func NewPictureInPicture(layer objc.ID, dispatch func(driver.Event)) *PictureInPicture
NewPictureInPicture creates a player-layer session. A nil layer creates a sample-buffer session whose independent NSGo tree supplies frames.
func (*PictureInPicture) Close ¶
func (p *PictureInPicture) Close(done func())
Close stops PiP and retains every source object until AVKit's stop callback. done releases the owning player's native objects afterward.
func (*PictureInPicture) Command ¶
func (p *PictureInPicture) Command(command uint32)
Command starts or stops the native session. Repeated commands while a transition or session is already active do not start another one.
func (*PictureInPicture) Configure ¶
func (p *PictureInPicture) Configure(c driver.PictureInPictureConfig)
Configure updates the sample delegate's state without calling Go from an AVKit queue. Automatically is opt-in for either source kind.
func (*PictureInPicture) ContinuesInBackground ¶
func (p *PictureInPicture) ContinuesInBackground() bool
ContinuesInBackground says whether the session plays on as the app enters the background: it is active or starting, or AVKit is about to start it automatically.
func (*PictureInPicture) Dirty ¶
func (p *PictureInPicture) Dirty()
Dirty coalesces tree changes until the next display frame.
func (*PictureInPicture) DrawFrame ¶
func (p *PictureInPicture) DrawFrame(tree objc.ID, scale float64) bool
DrawFrame draws a custom tree's layer only when AVKit can accept it. It returns true while a pending frame needs a display tick to retry.
func (*PictureInPicture) HoldAudio ¶
func (p *PictureInPicture) HoldAudio(session driver.AudioSession)
HoldAudio holds the shared audio session in the playback category PiP needs while the session lives, paused or not: mixing with other apps' audio for AudioSessionMixWithOthers, which a video asks for, and pausing it otherwise.
func (*PictureInPicture) Layer ¶
func (p *PictureInPicture) Layer() objc.ID
Layer returns the source layer a custom session must mount inline for AVKit to recognize it as a possible PiP source.
type ScrollEdge ¶
ScrollEdge is what macOS and iOS draw of a scroll edge effect over their blur, alike: the tint of the background the content scrolls over and a hard edge's hairline. Its layers are in the band's own space; the platform puts them over its blur.
func (*ScrollEdge) Paint ¶
func (p *ScrollEdge) Paint(e *driver.ScrollEdge, s driver.Side, w, h float64)
Paint lays the layers out for edge e at side s, in a band of w by h points, y growing down.
type Sensors ¶ added in v0.2.0
type Sensors struct {
// contains filtered or unexported fields
}
Sensors owns a surface's providers, on the main thread. Core Motion's handlers only copy samples into bounded packets; app code runs in core.
type ShaderLayer ¶
type ShaderLayer struct {
// Layer is the CAMetalLayer.
Layer objc.ID
// Ready is called when the program compiled after Set, to draw.
Ready func()
// contains filtered or unexported fields
}
ShaderLayer draws a shader view with Metal: a CAMetalLayer the view's layer holds below its children, drawn when the uniforms, the size or the animated lanes change, never on a timer of its own. Metal loads with the first shader, and each program compiles once for the process on a goroutine of its own, as Metal takes a tenth of a second for a library; the layer draws once it is ready.
The main thread only writes the uniforms (Draw); a render goroutine of the layer's own waits for a drawable, encodes and presents. Waiting for a drawable blocks until the display frees one, a whole refresh when frames come faster, so the main thread must never wait for it.
func NewShaderLayer ¶
func NewShaderLayer(scale float64) *ShaderLayer
NewShaderLayer returns a shader view's layer at scale pixels a point, or nil where the machine has no Metal device: the view stays empty.
func (*ShaderLayer) Draw ¶
func (l *ShaderLayer) Draw(animated func(lanes []float64))
Draw has the render goroutine draw the shader with its uniforms, animated writing the lanes animated nodes drive over them. It never waits.
func (*ShaderLayer) Drawable ¶
func (l *ShaderLayer) Drawable() bool
Drawable reports whether the layer has a program ready to draw.
func (*ShaderLayer) Release ¶
func (l *ShaderLayer) Release()
Release lets the layer go, with the view holding it, once its render goroutine finished the frame it draws.
func (*ShaderLayer) Resize ¶
func (l *ShaderLayer) Resize(w, h, scale float64)
Resize sizes the layer's drawable for w by h points at scale.
func (*ShaderLayer) Set ¶
func (l *ShaderLayer) Set(sh *driver.Shader)
Set gives the layer what it draws, compiling its program the first time a view shows it.
func (*ShaderLayer) SetPictures ¶
func (l *ShaderLayer) SetPictures(p [4]*Picture)
SetPictures gives a WGSL program the pictures it reads; a nil one, or one not taken yet, reads as transparent.
type TextEngine ¶
type TextEngine struct{}
TextEngine implements core.TextEngine with CoreText. Strikethrough and span backgrounds, which CoreText has no attributes for, are drawn from the lines' offsets; attachments' placeholders are sized by run delegates.
func (TextEngine) Prepare ¶
func (TextEngine) Prepare(t *driver.AttributedText) driver.PreparedText
Prepare implements core.TextEngine. It is safe off the main thread.
type Video ¶
type Video struct {
// Dispatch reports the video's events.
Dispatch func(driver.Event)
// Parent is the view controller an iOS player's controls join when
// the view is not in one yet.
Parent objc.ID
// contains filtered or unexported fields
}
Video is a video's AVPlayer, filling the view that holds it: in an AVPlayerLayer, or with the platform's controls in an AVPlayerView (macOS) or an AVPlayerViewController (iOS). AVFoundation and AVKit load on the first video, so apps without one do not pay for them. The layer is not opaque, so HEVC with alpha shows what is behind it; a local WebM file with alpha, which AVFoundation cannot open, reports EventError saying so.
func (*Video) ClearHitTestAlpha ¶
func (v *Video) ClearHitTestAlpha()
ClearHitTestAlpha releases the frame output when macOS stops sampling.
func (*Video) Close ¶
func (v *Video) Close()
Close stops the player. The view keeps the last frame while it still shows.
func (*Video) Configure ¶
func (v *Video) Configure(c *driver.VideoConfig)
Configure applies c, opening the source again when it changed.
func (*Video) HitTestAlpha ¶
HitTestAlpha reports whether a cached video pixel takes the pointer in a painted macOS window. Before the first mask, the whole view counts.
func (*Video) Layout ¶
func (v *Video) Layout()
Layout keeps an iOS player layer at the view's size.
func (*Video) PictureInPictureCommand ¶
PictureInPictureCommand starts or stops the video's PiP session.
func (*Video) SampleHitTestAlpha ¶
SampleHitTestAlpha reads the latest frame for macOS's painted-window timer. It returns true when a new mask may change the hit under a still pointer.
func (*Video) SetPictureInPictureOwner ¶
func (v *Video) SetPictureInPictureOwner(owner *PictureInPicture, wake func())
SetPictureInPictureOwner selects the custom PiP tree that renders this video, or nil when the video returns to the ordinary view hierarchy.
func (*Video) UpdatePictureInPictureFrame ¶
UpdatePictureInPictureFrame brings the detached video layer up to the player's current time. It returns whether another video tick is needed.
type Web ¶
type Web struct {
// Dispatch reports the web view's events.
Dispatch func(driver.Event)
// contains filtered or unexported fields
}
Web is a web view's WKWebView, filling the view that holds it. WebKit loads on the first web view, so apps without one do not pay for it. The WKWebView is made on the first Configure.
func (*Web) Command ¶
func (w *Web) Command(c driver.WebCommand, value string, data any)
Command does c, with value for messages and scripts.
func (*Web) Configure ¶
Configure applies c, loading the source again when it or the scripts changed.
Source Files
¶
- access.go
- animated_views.go
- appgroup.go
- apple.go
- applesignin.go
- appstore.go
- atlas.go
- audio.go
- audio_loop.go
- audio_timing.go
- audiooutput.go
- audiooutput_macos.go
- audiooutput_timeline.go
- audiosession_other.go
- authsession.go
- biometric.go
- border.go
- cache.go
- canvas.go
- canvas_vertices.go
- canvaslayer.go
- capture.go
- clip.go
- cloud.go
- crashreport.go
- decor.go
- dev_geometry.go
- discovery.go
- diskspace.go
- download.go
- edge.go
- effect.go
- effects.go
- encode.go
- files.go
- fonts.go
- gameservices.go
- gpu.go
- http.go
- image.go
- image_hit.go
- inline.go
- json.go
- keyevent_macos.go
- layer.go
- layout_host.go
- layout_motion.go
- localnetwork.go
- localnetwork_macos.go
- memory.go
- names.go
- network.go
- notifications.go
- offscreen.go
- perf.go
- picture.go
- pip.go
- pip_frames.go
- pip_playerhost.go
- pip_tv.go
- pip_video.go
- pixelbuffer.go
- power.go
- purchases.go
- render.go
- review.go
- scan.go
- secrets.go
- sensorext.go
- sensors.go
- shader.go
- speak.go
- speak_macos.go
- speech.go
- speech_macos.go
- strut.go
- super.go
- system.go
- text.go
- timezone.go
- tint.go
- video.go
- video_hit.go
- videocomposition.go
- videoplay.go
- videoresource.go
- view_batch.go
- web.go
- webcookie.go
- webwindow.go
- yield.go