platform

package
v0.0.0-...-f02ac08 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package platform provides low-level bindings for windows, event loops, graphics, typography, and other operating-system services.

Platform objects are thread-affine and use a single-threaded model. The caller is responsible for creating and using them on the same OS thread. Unless an API explicitly says otherwise, methods are not safe for concurrent use. EventLoop.Post and EventLoop.Quit are the only cross-thread operations.

Index

Constants

View Source
const (
	ColorSchemeLight = common.ColorSchemeLight
	ColorSchemeDark  = common.ColorSchemeDark

	InputMethodCommit  = common.InputMethodCommit
	InputMethodPreedit = common.InputMethodPreedit

	CursorDefault   = common.CursorDefault
	CursorText      = common.CursorText
	CursorPointing  = common.CursorPointing
	CursorCrosshair = common.CursorCrosshair
	CursorForbidden = common.CursorForbidden
	CursorNone      = common.CursorNone
)

Variables

View Source
var ErrUnsupported = errors.New("unsupported platform")

Functions

func DefaultName

func DefaultName() string

Types

type Clipboard

type Clipboard = common.Clipboard

type ColorScheme

type ColorScheme = common.ColorScheme

type Cursor

type Cursor = common.Cursor

type CursorShape

type CursorShape = common.CursorShape

type Event

type Event = events.Event

type EventHandler

type EventHandler = events.EventHandler

type EventLoop

type EventLoop = common.EventLoop

type Image

type Image = common.Image

type InputMethod

type InputMethod = common.InputMethod

type InputMethodHandler

type InputMethodHandler = common.InputMethodHandler

type InputMethodKind

type InputMethodKind = common.InputMethodKind

type InputMethodResult

type InputMethodResult = common.InputMethodResult

type Platform

type Platform interface {
	Destroy()
	Name() string
	NewImage(width, height uint) (Image, error)
	// NewWindow creates a top-level window. width/height is a logical (DIP)
	// preferred size; the platform may override it (WM/compositor), and the
	// authoritative size always arrives via SizeEvent.
	NewWindow(width, height float32, handler EventHandler) (Window, error)
	// NewPopup creates a borderless popup owned by owner. width/height is its
	// authoritative logical (DIP) size; use SetSize to change it later.
	NewPopup(owner Window, width, height float32, handler EventHandler) (Popup, error)
	NewEventLoop() (EventLoop, error)
	NewTypography() (typography.Context, error)
	// NewPainter creates a painter for any paint target — a Window or a Popup.
	NewPainter(surface Surface, typo typography.Context) (graphics.Painter, error)
	NewSettings() (Settings, error)
	NewClipboard() (Clipboard, error)
	// NewInputMethod creates the text-composition (IME) capability for window.
	// handler receives committed/preedit text. Returns ErrUnsupported when the
	// platform or window does not support input methods.
	NewInputMethod(window Window, handler InputMethodHandler) (InputMethod, error)
	// NewCursor creates the mouse-cursor capability for window, used to change
	// the window's current cursor shape. Returns ErrUnsupported when the platform
	// or window does not support cursor control.
	NewCursor(window Window) (Cursor, error)
}

Platform owns low-level operating-system resources. It and every object created from it must be used on the same OS thread, except for EventLoop.Post and EventLoop.Quit.

func NewPlatform

func NewPlatform(name string) (Platform, error)
type Popup = common.Popup

type Settings

type Settings = common.Settings

type Surface

type Surface = common.Surface

type Window

type Window = common.Window

Jump to

Keyboard shortcuts

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