surface

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 1 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

Overview

Package surface connects the content of a window that MyGo draws itself (package ui) to the window (package mygo), without either importing the other's internals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Surface platform.Surface
	// Window is the *mygo.Window.
	Window any
	// Clipboard is the system clipboard.
	Clipboard platform.Clipboard
	// StartDrag moves the window with the pointer, for drag regions;
	// TitleBarDoubleClicked does what a double click on a title bar does.
	StartDrag             func()
	TitleBarDoubleClicked func()
	// IsDark reports the system's dark appearance, and Preferences the
	// settings of the desktop that controls follow, which ThemeChanged
	// tells changes of as well.
	IsDark      func() bool
	Preferences func() platform.Preferences
	// UIFont returns the family of the desktop's interface font where the
	// system's text stack does not know it (Linux), else "".
	UIFont func() string
	// FontRendering returns how the desktop's settings say to rasterize
	// text where the system's text stack does not know them (Linux).
	FontRendering func() platform.FontRendering
	// TitleBar returns the room the window controls take in a window with
	// a hidden title bar, zero in other windows.
	TitleBar func() platform.TitleBar
	// OpenURL opens a link in the default browser, and gives done, unless
	// nil, what came of it on the main thread.
	OpenURL func(url string, done func(error))
	// DevTools tells that the window's developer tools are on
	// (PageOptions.DevTools): the content then opens its inspector.
	DevTools bool
	// Invalidate asks for a frame; it is safe from any goroutine.
	Invalidate func()
	// Changed asks for a frame built anew after the app changed the state
	// the content shows (Window.Update, Window.Invalidate); the content
	// sets it, else the window asks the surface for a frame.
	Changed func()
	// Post runs fn on the main thread soon, unless the window has closed;
	// it is safe from any goroutine.
	Post func(fn func())
	// PopupMenu shows m as a context menu at (x, y) in the surface, in
	// DIPs, once the event being handled returns. chosen receives the ID of
	// the item chosen, if one is.
	PopupMenu func(m *platform.Menu, x, y float64, chosen func(id int))

	// Event receives the surface's events, and Focus and Blur of the
	// window. It reports whether the content takes dragged files, as
	// WindowHandler.SurfaceEvent does.
	Event func(ev platform.SurfaceEvent) bool
	// ThemeChanged is called when the system appearance changes, and
	// TitleBarChanged when TitleBar does.
	ThemeChanged    func()
	TitleBarChanged func()
	// Capture renders the content as it is now into premultiplied RGBA.
	Capture func() (width, height int, rgba []byte)
	// ToggleDevTools opens or closes the content's inspector, for the
	// Toggle Developer Tools menu item, when DevTools is set.
	ToggleDevTools func()
	// Detach is called once the window is closed.
	Detach func()
}

Conn is a window's side of the connection. Package mygo fills it before calling Content.AttachContent; the content sets the hooks it handles. Everything runs on the main thread, except Invalidate and Post.

type Content

type Content interface {
	AttachContent(conn *Conn)
}

Content is implemented by package ui.

Jump to

Keyboard shortcuts

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