windows

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 52 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for windows/amd64

Overview

Package windows is NSGo's Win32 backend: one window that draws a retained tree of views with Direct2D into a flip-model swap chain on a Direct3D 11 device, text the engine laid out with DirectWrite, presses hit tested by the engine, inputs as editors of the backend's own drawn with the views (input.go), web views as WebView2 composition controllers in the window's DirectComposition tree, videos played by Media Foundation's media engine, images decoded by Go, native components' child windows following their views (component.go), files dropped through OLE (drop.go), alerts as task dialogs and updates through WinSparkle (updates.go). A window with a material behind its content draws through DirectComposition too, over the system backdrop DWM draws (material.go). It uses only the syscall package, so it builds without cgo.

Transforms are Direct2D world transforms, translucent views draw in layers, and shapes and text are antialiased by Direct2D. Style transitions, animated values, layout animations and animated images tick on one frame clock, a timer that runs only while something animates (animate.go). Image blur and modal animations are not drawn, and there is no accessibility yet, which needs UI Automation providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(app engine.App, opts Options)

Run opens a window showing app and runs the message loop. Call it from main; it does not return until the window closes.

Types

type Options

type Options struct {
	Title         string
	Width, Height driver.Points
	// Hidden keeps the backend's root window off the screen as the app's
	// own surface (nsgo.Run(App)), which opens the windows the app shows
	// and shows only as an alert's window.
	Hidden bool
	// Frame is where the window opens (nsgo.WindowFrame).
	Frame driver.WindowFrame
	// ID names the app's directories and storage (engine.AppDirs).
	ID string
	// InstanceKey scopes the single-instance lock; empty keeps one lock per ID.
	InstanceKey string
	// Components are the native components Native elements name.
	Components driver.NativeComponents
	// Material is the material behind the window's content, where the app
	// draws nothing opaque (nsgo.WindowMaterial). It needs Windows 11
	// 22H2 or later, where DWM draws system backdrops; earlier Windows
	// keeps the window opaque.
	Material driver.WindowMaterial
	// Constraints limit the window (nsgo.WindowConstraints).
	Constraints driver.WindowConstraints
	// Transparent opens the window without a background or frame, NoShadow without DWM's shadow, which only a transparent window lacks, and SkipTaskbar off the taskbar (look.go).
	Transparent, NoShadow, SkipTaskbar 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
	// Perf shows the performance monitor over the app (perf.go).
	Perf bool
	// Updates is how the app updates, with WinSparkle (updates.go).
	Updates updates.Config
	// RegisterToast is the shortcut the installer has the app stamp with the toast activator, and UnregisterToast has the uninstaller's run remove the activator's registration, from the launch flags; either run does that alone and returns (toast_activation.go).
	RegisterToast   string
	UnregisterToast bool
	// DockTask is the label of the item the Jump List task that started the app chose, from the launch flags.
	DockTask string
	// LaunchedAtLogin says the login item started this process.
	LaunchedAtLogin bool
	// Host is what an embedding host gives the view (NewView), and Parent
	// the HWND of the window it is a child window of.
	Host   engine.HostOptions
	Parent uintptr
	// contains filtered or unexported fields
}

Options configure the window.

type View

type View struct {
	// contains filtered or unexported fields
}

View is an app in a child window of an embedding host's window, which the host's own message loop runs (NewView).

func NewView

func NewView(app engine.App, opts Options) (*View, error)

NewView makes a child window of opts.Parent showing app, for a host that runs the message loop itself on this thread, with COM initialized (OleInitialize, for the clipboard and drops). The host places it (MoveWindow); its engine starts once it first has a size, so settings made before that are in the app's first frame. Several views may show at once.

func (*View) Close

func (v *View) Close()

Close stops the app, destroys its native components and the child window.

func (*View) Handle

func (v *View) Handle() uintptr

Handle returns the child window's HWND, which the host places.

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 the fields NSGo draws take too.

func (*View) SetTokens

func (v *View) SetTokens(t engine.Tokens)

SetTokens sets the values the host themes the app with.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL