Documentation
¶
Index ¶
- Constants
- Variables
- func NewWebViewBackend(context *Context) (scene.WebViewBackend, error)
- func OpenFile(options FileDialogOptions) (string, error)
- func OpenFileDialog(options FileDialogOptions) ([]string, error)
- func OpenFiles(options FileDialogOptions) ([]string, error)
- func OpenFolder(options FileDialogOptions) (string, error)
- func RegisterFileDialogBackend(backend FileDialogBackend)
- func RegisterWebViewBackend(factory WebViewBackendFactory)
- func RegisterWebViewBackendIfUnset(factory WebViewBackendFactory) bool
- func RegisterX11WebViewBackendIfUnset(factory WebViewBackendFactory) bool
- type Context
- func (c *Context) ActivateRender()
- func (c *Context) Canvas2D(width, height int) *graphics.Canvas2D
- func (c *Context) ClipboardText() (string, bool)
- func (c *Context) Destroy()
- func (c *Context) DevicePixelRatio() float64
- func (c *Context) FrameRequested() bool
- func (c *Context) GetLogicalXY(x, y float64) (float64, float64)
- func (c *Context) GetViewport() (int, int)
- func (c *Context) LoopGame(f func() (bool, error)) error
- func (c *Context) Minimize()
- func (s *Context) MouseCaptured() bool
- func (c *Context) NativeHandle() uintptr
- func (c *Context) NativeX11Window() uintptr
- func (s *Context) OnCloseRequested(handler func() bool)
- func (c *Context) OnFilesDropped(f func(x, y float64, files []string))
- func (c *Context) OnKeydown(f func(input.KeyCode))
- func (c *Context) OnKeyup(f func(input.KeyCode))
- func (c *Context) OnMouseDown(f func(x, y float64, button input.MouseButton))
- func (c *Context) OnMouseMove(f func(x, y float64))
- func (c *Context) OnMouseUp(f func(x, y float64, button input.MouseButton))
- func (c *Context) OnMouseWheel(f func(xoff float64, yoff float64))
- func (s *Context) OnTextCommand(handler func(input.TextCommand))
- func (s *Context) OnTextComposition(handler func(input.TextComposition))
- func (s *Context) OnTextInput(handler func(string))
- func (s *Context) OnTextSelection(handler func(input.TextSelection))
- func (c *Context) OnTouchEnd(f func(x, y float64))
- func (c *Context) OnTouchMove(f func(x, y float64))
- func (c *Context) OnTouchStart(f func(x, y float64))
- func (c *Context) OpenFile(options FileDialogOptions) (string, error)
- func (c *Context) OpenFileDialog(options FileDialogOptions) ([]string, error)
- func (c *Context) OpenFiles(options FileDialogOptions) ([]string, error)
- func (c *Context) OpenFolder(options FileDialogOptions) (string, error)
- func (s *Context) RequestClose()
- func (c *Context) RequestFrame()
- func (c *Context) SetAlwaysOnTop(enabled bool)
- func (c *Context) SetBorderVisible(visible bool)
- func (c *Context) SetClipboardText(text string) bool
- func (c *Context) SetDecorations(mode DecorationMode)
- func (c *Context) SetIcon(data []byte) error
- func (support *Context) SetIconDecoder(decoder IconDecoder)
- func (c *Context) SetIdleDeadline(deadline func() (time.Time, bool))
- func (c *Context) SetInputRegion(rects []InputRegionRect)
- func (s *Context) SetMouseCaptured(captured bool) bool
- func (c *Context) SetResizable(enabled bool)
- func (c *Context) SetRoundedCorners(enabled bool)
- func (c *Context) SetShadowVisible(visible bool)
- func (c *Context) SetTargetFPS(fps int)
- func (c *Context) SetTaskbarVisible(visible bool)
- func (s *Context) SetTextInputConfig(config input.TextInputConfig)
- func (c *Context) SetTitle(title string)
- func (c *Context) SetTitleBarHeight(float64)
- func (c *Context) SetViewport(width, height int)
- func (c *Context) SetViewportMode(mode ViewportMode)
- func (c *Context) SetVsyncEnabled(enable bool)
- func (c *Context) StartWindowDrag()
- func (c *Context) TakeFrameRequest() bool
- func (s *Context) TakeMouseDelta() (float64, float64)
- func (s *Context) TextInputConfig() input.TextInputConfig
- func (c *Context) ToggleFullscreen()
- func (c *Context) ToggleMaximize()
- func (c *Context) UsesClientWindowBorder() bool
- func (c *Context) Wake()
- type DecorationMode
- type FileDialogBackend
- type FileDialogFilter
- type FileDialogMode
- type FileDialogOptions
- type IconDecoder
- type InputRegionRect
- type Options
- type ViewportMode
- type WebViewBackendFactory
Constants ¶
const DefaultCornerRadius = 10
const DefaultTargetFPS = 30
Variables ¶
var ( // synchronous native file dialog integration (for example, a browser or // mobile build). ErrFileDialogUnavailable = errors.New("window: native file dialog is unavailable") // ErrFileDialogInvalidOptions indicates an invalid mode or filter. ErrFileDialogInvalidOptions = errors.New("window: invalid file dialog options") )
ErrWebViewUnavailable is returned when no platform browser implementation is installed for the current target.
Functions ¶
func NewWebViewBackend ¶
func NewWebViewBackend(context *Context) (scene.WebViewBackend, error)
NewWebViewBackend selects a host-provided backend. The built-in adapters live in the optional window/webview package so applications that do not enable WebView do not link platform browser dependencies.
func OpenFile ¶
func OpenFile(options FileDialogOptions) (string, error)
OpenFile opens a native dialog for one file. An empty path means cancellation.
func OpenFileDialog ¶
func OpenFileDialog(options FileDialogOptions) ([]string, error)
OpenFileDialog opens a modal native file dialog without an explicit owner. An empty result means the user cancelled the dialog.
func OpenFiles ¶
func OpenFiles(options FileDialogOptions) ([]string, error)
OpenFiles opens a native dialog that allows multiple files. An empty result means cancellation.
func OpenFolder ¶
func OpenFolder(options FileDialogOptions) (string, error)
OpenFolder opens a native dialog for one folder. An empty path means cancellation.
func RegisterFileDialogBackend ¶
func RegisterFileDialogBackend(backend FileDialogBackend)
RegisterFileDialogBackend installs the optional native file dialog backend. Applications should call this once during startup, before opening a dialog.
func RegisterWebViewBackend ¶
func RegisterWebViewBackend(factory WebViewBackendFactory)
RegisterWebViewBackend installs a host-provided platform backend factory. Passing nil clears the current registration.
func RegisterWebViewBackendIfUnset ¶
func RegisterWebViewBackendIfUnset(factory WebViewBackendFactory) bool
RegisterWebViewBackendIfUnset installs factory only when no backend factory has been registered. Optional built-in adapters use this form so an application-provided factory keeps precedence.
func RegisterX11WebViewBackendIfUnset ¶
func RegisterX11WebViewBackendIfUnset(factory WebViewBackendFactory) bool
RegisterX11WebViewBackendIfUnset installs an embedded Linux backend that requires an X11 parent window. Linux window creation will prefer X11 or XWayland when this registration succeeds.
Types ¶
type Context ¶
func (*Context) ActivateRender ¶
func (c *Context) ActivateRender()
ActivateRender selects this window's immediate rendering context. Windows share a rendering thread; resource residency and lifetime stay per device.
func (*Context) ClipboardText ¶
func (*Context) DevicePixelRatio ¶
DevicePixelRatio returns the current platform pixel density.
func (*Context) FrameRequested ¶
func (c *Context) FrameRequested() bool
func (*Context) GetViewport ¶
func (*Context) MouseCaptured ¶
func (s *Context) MouseCaptured() bool
MouseCaptured reports whether the platform currently owns the mouse lock.
func (*Context) NativeHandle ¶
NativeHandle returns the native surface identifier when the host needs to embed a platform control. On Wayland this is the wl_surface pointer.
func (*Context) NativeX11Window ¶
NativeX11Window returns the X11 parent window used for embedded native controls. It returns zero when the context uses another display backend.
func (*Context) OnCloseRequested ¶
func (s *Context) OnCloseRequested(handler func() bool)
func (*Context) OnFilesDropped ¶
OnFilesDropped registers a callback for files dropped onto the window. Coordinates are in logical viewport units. The files slice is only valid for the duration of the callback and must be copied when retained.
func (*Context) OnMouseDown ¶
func (c *Context) OnMouseDown(f func(x, y float64, button input.MouseButton))
func (*Context) OnMouseMove ¶
func (*Context) OnMouseUp ¶
func (c *Context) OnMouseUp(f func(x, y float64, button input.MouseButton))
func (*Context) OnMouseWheel ¶
func (*Context) OnTextCommand ¶
func (s *Context) OnTextCommand(handler func(input.TextCommand))
func (*Context) OnTextComposition ¶
func (s *Context) OnTextComposition(handler func(input.TextComposition))
func (*Context) OnTextInput ¶
func (s *Context) OnTextInput(handler func(string))
func (*Context) OnTextSelection ¶
func (s *Context) OnTextSelection(handler func(input.TextSelection))
func (*Context) OnTouchEnd ¶
func (*Context) OnTouchMove ¶
func (*Context) OnTouchStart ¶
func (*Context) OpenFileDialog ¶
func (c *Context) OpenFileDialog(options FileDialogOptions) ([]string, error)
OpenFileDialog opens a modal native file dialog owned by the engine window. An empty result means the user cancelled the dialog.
func (*Context) OpenFiles ¶
func (c *Context) OpenFiles(options FileDialogOptions) ([]string, error)
func (*Context) OpenFolder ¶
func (c *Context) OpenFolder(options FileDialogOptions) (string, error)
func (*Context) RequestClose ¶
func (s *Context) RequestClose()
func (*Context) RequestFrame ¶
func (c *Context) RequestFrame()
func (*Context) SetAlwaysOnTop ¶
func (*Context) SetBorderVisible ¶
func (*Context) SetClipboardText ¶
func (*Context) SetDecorations ¶
func (c *Context) SetDecorations(mode DecorationMode)
func (*Context) SetIconDecoder ¶
func (support *Context) SetIconDecoder(decoder IconDecoder)
SetIconDecoder configures the decoder used by SetIcon.
func (*Context) SetIdleDeadline ¶
SetIdleDeadline installs the loop-thread scheduler's next idle deadline. A zero deadline with idle=true means wait until a platform event or Wake.
func (*Context) SetInputRegion ¶
func (c *Context) SetInputRegion(rects []InputRegionRect)
func (*Context) SetMouseCaptured ¶
SetMouseCaptured hides and locks the mouse for unlimited relative movement. It returns whether the platform accepted the request. Activation may be asynchronous; MouseCaptured reports the actual state. Call on the window thread.
func (*Context) SetResizable ¶
func (*Context) SetRoundedCorners ¶
func (*Context) SetShadowVisible ¶
func (*Context) SetTargetFPS ¶
func (*Context) SetTaskbarVisible ¶
func (*Context) SetTextInputConfig ¶
func (s *Context) SetTextInputConfig(config input.TextInputConfig)
func (*Context) SetTitleBarHeight ¶
func (*Context) SetViewport ¶
func (*Context) SetViewportMode ¶
func (c *Context) SetViewportMode(mode ViewportMode)
func (*Context) SetVsyncEnabled ¶
func (*Context) StartWindowDrag ¶
func (c *Context) StartWindowDrag()
func (*Context) TakeFrameRequest ¶
func (c *Context) TakeFrameRequest() bool
func (*Context) TakeMouseDelta ¶
TakeMouseDelta consumes motion accumulated since the last call, in native window coordinates. Absolute cursor movement and capture transitions are excluded.
func (*Context) TextInputConfig ¶
func (s *Context) TextInputConfig() input.TextInputConfig
func (*Context) ToggleFullscreen ¶
func (c *Context) ToggleFullscreen()
func (*Context) ToggleMaximize ¶
func (c *Context) ToggleMaximize()
func (*Context) UsesClientWindowBorder ¶
UsesClientWindowBorder reports whether custom decorations should render the border in the surface content for consistent X11 and Wayland appearance.
type DecorationMode ¶
type DecorationMode string
const ( DecorationSystem DecorationMode = "system" DecorationNone DecorationMode = "none" )
func (DecorationMode) Valid ¶
func (m DecorationMode) Valid() bool
type FileDialogBackend ¶
type FileDialogBackend func(*Context, FileDialogOptions) ([]string, error)
FileDialogBackend is the platform implementation selected by the host project. Keeping it outside this package lets projects that do not use file dialogs avoid linking desktop portal dependencies.
type FileDialogFilter ¶
FileDialogFilter describes one group in the native dialog's file type menu. Extensions may be written with or without a leading dot (for example, both "png" and ".png" are accepted).
type FileDialogMode ¶
type FileDialogMode uint8
FileDialogMode controls which kind of entries a native file dialog accepts.
const ( // FileDialogFiles selects one file. FileDialogFiles FileDialogMode = iota // FileDialogFolder selects one folder. FileDialogFolder // FileDialogMultipleFiles selects one or more files. FileDialogMultipleFiles )
type FileDialogOptions ¶
type FileDialogOptions struct {
Title string
DefaultPath string
Filters []FileDialogFilter
// Mode defaults to FileDialogFiles.
Mode FileDialogMode
}
FileDialogOptions configures OpenFileDialog.
type IconDecoder ¶
IconDecoder decodes a window icon selected by an application resource feature. Concrete image formats live outside the window core package.
type InputRegionRect ¶
InputRegionRect describes an interactive rectangle in logical viewport coordinates.
type Options ¶
type Options struct {
DRMDevice string
Decorations DecorationMode
RenderScale float64
MaxDevicePixelRatio float64
TitleBarHeight float64
// CornerRadius controls renderer-owned window corners in logical pixels.
// Windows uses alpha composition for radii larger than its native 8 DIP.
CornerRadius int
DRMConnectorID uint32
Antialias bool
Transparent bool
Border bool
Shadow bool
Resizable bool
}
func DefaultOptions ¶
func DefaultOptions() Options
type ViewportMode ¶
type ViewportMode string
const ( ViewportModeContain ViewportMode = "contain" ViewportModeCover ViewportMode = "cover" ViewportModeStretch ViewportMode = "stretch" ViewportModeFixedWidth ViewportMode = "fixed-width" ViewportModeFixedHeight ViewportMode = "fixed-height" ViewportModeExpand ViewportMode = "expand" ViewportModeAdaptive ViewportMode = "adaptive" ViewportModeInteger ViewportMode = "integer-scale" )
type WebViewBackendFactory ¶
type WebViewBackendFactory func(*Context) (scene.WebViewBackend, error)
WebViewBackendFactory allows a host application to provide a native browser backend without changing the ECS protocol. Registration should happen before creating the window context.
Source Files
¶
- callback.go
- clipboard_linux.go
- close.go
- device_pixel_ratio_linux.go
- file_dialog.go
- file_dialog_linux.go
- file_drop.go
- frame_pacer.go
- icon_decoder.go
- icon_image.go
- input_callbacks_desktop.go
- input_region.go
- linux_native.go
- loop_control.go
- mouse_capture.go
- options.go
- render_context.go
- render_opengl_native.go
- textinput.go
- viewport.go
- viewport_context.go
- wake_pipe_linux.go
- webview_factory.go
Directories
¶
| Path | Synopsis |
|---|---|
|
codec
|
|
|
png
Package png provides the opt-in PNG window icon decoder.
|
Package png provides the opt-in PNG window icon decoder. |
|
svg
Package svg provides SVG window icon decoding at a statically selected size.
|
Package svg provides SVG window icon decoding at a statically selected size. |