Documentation
¶
Overview ¶
Package nativeui is the interface of the desktop app's native windows: the types internal/desktop programs against, and the registration through which internal/webview provides them. Only the desktop app's binary (cmd/remohop-quick) links internal/webview; in any other binary (the static remohop command line tool) nothing is registered, Probe reports ErrUnavailable and the app falls back to a browser window.
Index ¶
- Variables
- func FitArea(w, h, minW, minH, areaW, areaH int) (int, int, int, int)
- func ParseColor(s string) (rgb [3]uint8, ok bool)
- func Register(probe func() (Info, error), run func(Config, func(App)) error)
- func Run(cfg Config, setup func(App)) error
- type App
- type Config
- type Info
- type MenuItem
- type Notifier
- type Options
- type Tray
- type Window
Constants ¶
This section is empty.
Variables ¶
ErrUnavailable means this system has no usable native web view: no WebView2 runtime on Windows, no WebKitGTK library on Linux, an unknown platform. Callers fall back to a browser window.
Functions ¶
func FitArea ¶
FitArea shrinks a window's size, and its minimum size, to fit a work area of areaW x areaH (the screen minus task bar, Dock or panels, in the same units). A window takes at most 92% of the area, so its edges stay clear of them; the minimum never exceeds the area. A zero area (unknown) leaves everything as it is. The overlay banner does not use it: it has its own fixed size.
func ParseColor ¶ added in v1.0.13
ParseColor reads "#rrggbb".
Types ¶
type App ¶
type App interface {
// NewWindow opens a window showing o.URL.
NewWindow(o Options) (Window, error)
// Dispatch runs fn on the UI thread. It may be called from any
// goroutine, and returns at once.
Dispatch(fn func())
// SetTray shows (or with nil removes) the tray icon. It fails where
// the system has no tray (a Linux desktop without AppIndicator
// support): callers must then not hide their last window.
SetTray(t *Tray) error
// Quit ends Run.
Quit()
}
App is the running native application.
type Config ¶
type Config struct {
// AppID names the program to the windowing system: the Linux
// application name that .desktop files match (WM_CLASS) and the
// AppIndicator ID.
AppID string
// DataDir is where the web engine keeps its profile (cache, local
// storage). WebView2 needs one it can write; the others ignore it.
DataDir string
// IconPNG is the tray icon on Linux and macOS (macOS draws it as a
// template image: only its alpha channel counts).
IconPNG []byte
// TemplatePNG, if set, is the macOS tray icon instead of IconPNG.
TemplatePNG []byte
// OnReopen runs when the user asks for the program again while it
// runs without a visible window (macOS: a click on its Dock icon).
OnReopen func()
// OnQuitRequest, if set, runs when the system asks the program to
// quit (macOS: Quit in the menu or the Dock) instead of quitting; the
// program calls App.Quit when it is ready.
OnQuitRequest func()
}
Config configures Run.
type Info ¶
type Info struct {
// Engine is "WebView2", "WKWebView" or "WebKitGTK".
Engine string
// Version is the engine's version where the system says.
Version string
}
Info describes the native web view of this system.
type Notifier ¶
type Notifier interface {
Notify(title, text string)
}
Notifier is an App that can also show a notification from its tray icon (a balloon or toast on Windows), for when its window may not be seen: hidden in the tray, or behind other windows because the system does not let a background program come to the front.
type Options ¶
type Options struct {
Title string
URL string
Width int // logical pixels; 0 means 960
Height int // 0 means 680
// MinWidth and MinHeight bound resizing (0: no bound).
MinWidth, MinHeight int
// OnClose runs when the user asks to close the window. Returning false
// keeps it open (the caller may hide it instead); true closes it.
// Nil closes it.
OnClose func() bool
// Hidden creates the window without showing it.
Hidden bool
// Overlay makes a small undecorated window that stays above the
// others and out of the task bar, in the bottom-right corner of the
// work area (where notifications appear, clear of the app's own
// window and tab bar): the "this computer is being controlled" banner.
Overlay bool
// Background and DarkBackground are the page's own background
// colours ("#rrggbb") in light and dark mode. The window shows the one
// that applies until the page has drawn, instead of the web engine's
// white. Empty: the engine's default.
Background, DarkBackground string
// Theme picks between them: "light", "dark", or "" for the system's
// setting.
Theme string
}
Options configure a window.
func (*Options) BackgroundFor ¶ added in v1.0.13
BackgroundFor returns the colour the window should show before its page has drawn, given whether the system is in dark mode, and whether that colour is the dark one (for a dark title bar). ok is false when no valid colour applies.