Documentation ¶
Index ¶
- type App
- type Bitmap
- func (bit *Bitmap) BytesPerPixel() uint
- func (bit *Bitmap) CreateCopy() *Bitmap
- func (bit *Bitmap) Destroy()
- func (bit *Bitmap) Erase()
- func (bit *Bitmap) Format() BitmapFormat
- func (bit *Bitmap) Height() uint
- func (bit *Bitmap) IsEmpty() bool
- func (bit *Bitmap) RowBytes() uint
- func (bit *Bitmap) Width() uint
- func (bit *Bitmap) WritePNG(path string) bool
- type BitmapFormat
- type Config
- func (conf *Config) AnimationTimerDelay(delay float64)
- func (conf *Config) Destroy()
- func (conf *Config) DeviceScaleHint(value float64)
- func (conf *Config) EnableBGRA(enabled bool)
- func (conf *Config) EnableImages(enabled bool)
- func (conf *Config) EnableJavaScript(enabled bool)
- func (conf *Config) FontFamilyFixed(fontName string)
- func (conf *Config) FontFamilySansSerif(fontName string)
- func (conf *Config) FontFamilySerif(fontName string)
- func (conf *Config) FontFamilyStandard(fontName string)
- func (conf *Config) ForceRepaint(enabled bool)
- func (conf *Config) MemoryCacheSize(size uint)
- func (conf *Config) PageCacheSize(size uint)
- func (conf *Config) UserAgent(agent string)
- func (conf *Config) UserStylesheet(css string)
- type Cursor
- type JSBindFunc
- type JSContext
- type JSValue
- type KeyEvent
- type KeyEventType
- type MessageLevel
- type MessageSource
- type Monitor
- type MouseButton
- type MouseEvent
- type MouseEventType
- type Overlay
- func (ol *Overlay) Destroy()
- func (ol *Overlay) Focus()
- func (ol *Overlay) GetHeight() uint
- func (ol *Overlay) GetView() *View
- func (ol *Overlay) GetWidth() uint
- func (ol *Overlay) GetX() int
- func (ol *Overlay) GetY() int
- func (ol *Overlay) HasFocus() bool
- func (ol *Overlay) Hide()
- func (ol *Overlay) IsHidden() bool
- func (ol *Overlay) MoveTo(x, y int)
- func (ol *Overlay) Resize(width, height uint)
- func (ol *Overlay) Show()
- func (ol *Overlay) Unfocus()
- type Renderer
- type ScrollEvent
- type ScrollEventType
- type Settings
- type View
- func (view *View) BindJSCallback(name string, function JSBindFunc)
- func (view *View) CanGoBack() bool
- func (view *View) CanGoForward() bool
- func (view *View) Destroy()
- func (view *View) EvaluateScript(script string) string
- func (view *View) FireKeyEvent(event *KeyEvent)
- func (view *View) FireMouseEvent(event *MouseEvent)
- func (view *View) FireScrollEvent(event *ScrollEvent)
- func (view *View) GetBitmap() *Bitmap
- func (view *View) GetJSContext() JSContext
- func (view *View) GetNeedsPaint() bool
- func (view *View) GetTitle() string
- func (view *View) GetURL() string
- func (view *View) GoBack()
- func (view *View) GoForward()
- func (view *View) GoToHistoryOffset(offset int)
- func (view *View) IsBitmapDirty() bool
- func (view *View) IsLoading() bool
- func (view *View) JSBindBool(val bool) *JSValue
- func (view *View) JSBindJSON(val string) *JSValue
- func (view *View) JSBindNum(val float64) *JSValue
- func (view *View) JSBindString(val string) *JSValue
- func (view *View) LoadHTML(html string)
- func (view *View) LoadURL(url string)
- func (view *View) NeedsPaint(needsPaint bool)
- func (view *View) Reload()
- func (view *View) Resize(width, height uint)
- func (view *View) SetAddConsoleMessageCallback(...)
- func (view *View) SetBeginLoadingCallback(callFunc func())
- func (view *View) SetChangeCursorCallback(callFunc func(cursor Cursor))
- func (view *View) SetChangeTitleCallback(callFunc func(title string))
- func (view *View) SetChangeTooltipCallback(callFunc func(tooltip string))
- func (view *View) SetChangeURLCallback(callFunc func(url string))
- func (view *View) SetDOMReadyCallback(callFunc func())
- func (view *View) SetFinishLoadingCallback(callFunc func())
- func (view *View) SetUpdateHistoryCallback(callFunc func())
- func (view *View) Stop()
- type Window
- func (win *Window) Close()
- func (win *Window) Destroy()
- func (win *Window) DeviceToPixel(value int) int
- func (win *Window) GetHeight() uint
- func (win *Window) GetScale() float64
- func (win *Window) GetWidth() uint
- func (win *Window) IsFullscreen() bool
- func (win *Window) PixelsToDevice(value int) int
- func (win *Window) SetCloseCallback(callFunc func())
- func (win *Window) SetCursor(cursor Cursor)
- func (win *Window) SetResizeCallback(callFunc func(width uint, height uint))
- func (win *Window) SetTitle(title string)
- type WindowFlag
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App wraps the underlying App struct
func (*App) GetMainMonitor ¶
GetMainMonitor returns the main Monitor instance
func (*App) GetRenderer ¶
GetRenderer returns the underlying Renderer instance
func (*App) Run ¶
func (a *App) Run()
Run executes the main loop. Ensure App.SetWindow() has been called prior to calling
func (*App) SetUpdateCallback ¶
func (a *App) SetUpdateCallback(callFunc func())
SetUpdateCallback executes the specified function whenever the App updates
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap wraps the underlying struct
func CreateBitmap ¶
func CreateBitmap(width, height uint, format BitmapFormat) *Bitmap
CreateBitmap will produce a bitmap with the specified parameters
func CreateEmptyBitmap ¶
func CreateEmptyBitmap() *Bitmap
CreateEmptyBitmap will create an empty bitmap
func (*Bitmap) BytesPerPixel ¶
BytesPerPixel returns the bytes per pixel of the bitmap
func (*Bitmap) CreateCopy ¶
CreateCopy creates a copy of the bitmap
func (*Bitmap) Format ¶
func (bit *Bitmap) Format() BitmapFormat
Format returns the format of the bitmap
type BitmapFormat ¶
type BitmapFormat int
BitmapFormat enumerates the possible formats for a bitmap
const ( A8 BitmapFormat = iota RGBA8 )
The bitmap formats
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config wraps the C config stuct
func (*Config) AnimationTimerDelay ¶
AnimationTimerDelay sets the amount of time to wait before repainting when a CSS animation is active (Default = 1/60)
func (*Config) DeviceScaleHint ¶
DeviceScaleHint sets the amount that the application DPI has been scaled, which is used for scaling device coordinates to pixels and oversampling raster shapes (Default = 1.0)
func (*Config) EnableBGRA ¶
EnableBGRA sets wheter to use BGRA byte order (instead of RGBA) for offscreen rendering of View bitmaps (Default = false)
func (*Config) EnableImages ¶
EnableImages sets whether images should be enabled (Default = true)
func (*Config) EnableJavaScript ¶
EnableJavaScript sets whether JavaScript should be enabled (Default = true)
func (*Config) FontFamilyFixed ¶
FontFamilyFixed sets the default font-family to use for fixed fonts, e.g. <pre> and <code> (Default = "Courier New")
func (*Config) FontFamilySansSerif ¶
FontFamilySansSerif sets the default font-family to use for sans-serif fonts (Default = "Arial")
func (*Config) FontFamilySerif ¶
FontFamilySerif sets the default font-family to use for serif fonts (Default = "Times New Roman")
func (*Config) FontFamilyStandard ¶
FontFamilyStandard sets the default font-family to use (Default = "Times New Roman")
func (*Config) ForceRepaint ¶
ForceRepaint sets whether the views should be continuously repainted or not. Mainly used for diagnosis
func (*Config) MemoryCacheSize ¶
MemoryCacheSize sets the size of the cache for assets in bytes (Default = 64MB)
func (*Config) PageCacheSize ¶
PageCacheSize sets the number of pages to keep cached (Default = 0)
func (*Config) UserStylesheet ¶
UserStylesheet sets the user stylesheet (CSS) (Default = Empty)
type Cursor ¶
type Cursor int
Cursor enumerates the different types of cursor to show
const ( Pointer Cursor = iota Cross Hand IBeam Wait Help EastResize NorthResize NorthEastResize NorthWestResize SouthResize SouthEastResize SouthWestResize WestResize NorthSouthResize EastWestResize NorthEastSouthWestResize NorthWestSouthEastResize ColumnResize RowResize MiddlePanning EastPanning NorthPanning NorthEastPanning NorthWestPanning SouthPanning SouthEastPanning SouthWestPanning WestPanning Move VerticalText Cell ContextMenu Alias Progress NoDrop Copy CursorNone NotAllowed ZoomIn ZoomOut Grab Grabbing Custom )
The cursor types
type JSBindFunc ¶
JSBindFunc defines the structure of JavaScript callback functions, where 'params' is an array of the parameters passed to the JavaScript function
type JSContext ¶
type JSContext struct {
// contains filtered or unexported fields
}
JSContext wraps the underlying struct
type JSValue ¶
type JSValue struct {
// contains filtered or unexported fields
}
JSValue wraps the underlying struct
type KeyEvent ¶
type KeyEvent struct {
// contains filtered or unexported fields
}
KeyEvent wraps the underlying struct
func CreateKeyEvent ¶
func CreateKeyEvent(eventType KeyEventType, modifiers uint, virtKeyCode, nativeKeyCode int, text, rawText string, isKeypad, isAutoRepeat, isSystemKey bool) *KeyEvent
CreateKeyEvent creates a new key event
type KeyEventType ¶
type KeyEventType int
KeyEventType enumerates the possible key events
const ( KeyDown KeyEventType = iota KeyUp RawKeyDown Char )
KeyEventTypes
type MessageLevel ¶
type MessageLevel int
MessageLevel enumerates the severity levels of a message
const ( Log MessageLevel = iota + 1 Warning Error Debug Info )
The severity levels
type MessageSource ¶
type MessageSource int
MessageSource enumerates the possible sources for a message
const ( XML MessageSource = iota JS Network ConsoleAPI Storage AppCache Rendering CSS Security ContentBlocker Other )
The message sources
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor wraps the underlying struct
type MouseButton ¶
type MouseButton int
MouseButton enumerates the possible mouse buttons
const ( MouseButtonNone MouseButton = iota Left Middle Right )
MouseButtons
type MouseEvent ¶
type MouseEvent struct {
// contains filtered or unexported fields
}
MouseEvent wraps the underlying struct
func CreateMouseEvent ¶
func CreateMouseEvent(eventType MouseEventType, x, y int, button MouseButton) *MouseEvent
CreateMouseEvent creates a new mouse event
type MouseEventType ¶
type MouseEventType int
MouseEventType enumerates the possible mouse events
const ( MouseMoved MouseEventType = iota MouseDown MouseUp )
MouseEventTypes
type Overlay ¶
type Overlay struct {
// contains filtered or unexported fields
}
Overlay wraps the underlying struct
func CreateOverlay ¶
CreateOverlay creates a new Overlay instance with the specified width and height (in device coordinates) at the offset (x,y) from the top-left corner of the Window instance
func (*Overlay) Focus ¶
func (ol *Overlay) Focus()
Focus grants the Overlay exclusive keyboard focus
func (*Overlay) GetX ¶
GetX returns the horizontal offset of the Overlay relative to it's Window (in device coordinates)
func (*Overlay) GetY ¶
GetY returns the vertical offset of the Overlay relative to it's Window (in device coordinates)
func (*Overlay) MoveTo ¶
MoveTo moves the Overlay to the specified (x,y) position (in device coordinates)
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer wraps the underlying struct
func CreateRenderer ¶
CreateRenderer creates a Renderer instance (create only one per application lifetime)
type ScrollEvent ¶
type ScrollEvent struct {
// contains filtered or unexported fields
}
ScrollEvent wraps the underlying struct
func CreateScrollEvent ¶
func CreateScrollEvent(eventType ScrollEventType, deltaX, deltaY int) *ScrollEvent
CreateScrollEvent creates a new scroll event
type ScrollEventType ¶
type ScrollEventType int
ScrollEventType enumerates the possible ways of scrolling
const ( ScrollByPixel ScrollEventType = iota ScrollByPage )
ScrollEventTypes
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings wraps the underlying struct
func CreateSettings ¶
func CreateSettings() *Settings
CreateSettings creates settings with default values
func (*Settings) SetFileSystemPath ¶
SetFileSystemPath sets the root file path for all data used by the app
func (*Settings) SetLoadShadersFromFileSystem ¶
SetLoadShadersFromFileSystem decides whether or not to load and compile shaders from the file system or load pre-compiled shaders from memory
type View ¶
type View struct {
// contains filtered or unexported fields
}
View wraps the underlying struct
func CreateView ¶
CreateView creates a View instance with the specified size (in device coordinates)
func (*View) BindJSCallback ¶
func (view *View) BindJSCallback(name string, function JSBindFunc)
BindJSCallback executes the specified function when a JavaScript call to the 'name' function is made
Example ¶
// Create the app instance config := ultralight.CreateConfig() renderer := ultralight.CreateRenderer(config) view := ultralight.CreateView(renderer, 300, 300, false) // Prints each name passed to the 'hello' JavaScript function to the console view.BindJSCallback("hello", func(v *ultralight.View, parameters []string) *ultralight.JSValue { for i := range parameters { if parameters[i] == "" { fmt.Println("Hello mystery person!") continue } fmt.Printf("Hello %s!\n", parameters[i]) } return nil }) isReady := false // Execute the JavaScript function when the page has finished loading view.SetDOMReadyCallback(func() { view.EvaluateScript("hello('John', 'Anita', '', 'Derek')") isReady = true }) // Give the View something to load to trigger the above function view.LoadHTML("<html></html>") // Update the View until the DOM is ready for !isReady { renderer.Update() } // Will output: // Hello John! // Hello Anita! // Hello mystery person! // Hello Derek!
Output:
func (*View) CanGoForward ¶
CanGoForward checks if forward history navigation is available
func (*View) EvaluateScript ¶
EvaluateScript evaluates a raw string of JavaScript, and returns the result
func (*View) FireKeyEvent ¶
FireKeyEvent will fire the supplied keyboard event
func (*View) FireMouseEvent ¶
func (view *View) FireMouseEvent(event *MouseEvent)
FireMouseEvent will fire the supplied mouse event
func (*View) FireScrollEvent ¶
func (view *View) FireScrollEvent(event *ScrollEvent)
FireScrollEvent will fire the supplied scroll event
func (*View) GetJSContext ¶
GetJSContext gets the JSContext of the current page
func (*View) GetNeedsPaint ¶
GetNeedsPaint returns whether the View should be painted during the next call to Renderer.Render()
func (*View) GoBack ¶
func (view *View) GoBack()
GoBack navigates backwards through the View history
func (*View) GoForward ¶
func (view *View) GoForward()
GoForward navigates forwards through the View history
func (*View) GoToHistoryOffset ¶
GoToHistoryOffset navigates to the specified offset in the View history
func (*View) IsBitmapDirty ¶
IsBitmapDirty checks if the bitmap has changed since the last call to GetBitmap()
func (*View) JSBindBool ¶
JSBindBool will wrap a boolean value to be retuned by a bound Go function
func (*View) JSBindJSON ¶
JSBindJSON will wrap a JSON string value to be retuned by a bound Go function
func (*View) JSBindString ¶
JSBindString will wrap a string value to be retuned by a bound Go function
func (*View) NeedsPaint ¶
NeedsPaint sets whether the View should be repainted during the next call to Renderer.Render()
func (*View) Resize ¶
Resize changes the View dimensions to the specified width and height (in device coordinates)
func (*View) SetAddConsoleMessageCallback ¶
func (view *View) SetAddConsoleMessageCallback(callFunc func( source MessageSource, level MessageLevel, message string, lineNumber uint, colNumber uint, sourceID string))
SetAddConsoleMessageCallback executes the specified function when a message is added to the console
func (*View) SetBeginLoadingCallback ¶
func (view *View) SetBeginLoadingCallback(callFunc func())
SetBeginLoadingCallback executes the specified function when the page begins loading a new URL
func (*View) SetChangeCursorCallback ¶
SetChangeCursorCallback executes the specified function when the mouse cursor changes
func (*View) SetChangeTitleCallback ¶
SetChangeTitleCallback executes the specified function when the page title changes
func (*View) SetChangeTooltipCallback ¶
SetChangeTooltipCallback executes the specified function when the tooltip changes (usually due to a mouse hover)
func (*View) SetChangeURLCallback ¶
SetChangeURLCallback executes the specified function when the page URL changes
func (*View) SetDOMReadyCallback ¶
func (view *View) SetDOMReadyCallback(callFunc func())
SetDOMReadyCallback executes the specified function when all JavaScript has been parsed and the document is ready
func (*View) SetFinishLoadingCallback ¶
func (view *View) SetFinishLoadingCallback(callFunc func())
SetFinishLoadingCallback executes the specified function when the page finished loading a URL
func (*View) SetUpdateHistoryCallback ¶
func (view *View) SetUpdateHistoryCallback(callFunc func())
SetUpdateHistoryCallback executes the specified function when the history (back/forward state) is modified
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window wraps the underlying struct
func CreateWindow ¶
func CreateWindow(m *Monitor, width, height uint, isTransparent bool, windowType WindowFlag) *Window
CreateWindow creates a new Window with the specified size (in device coordinates)
func (*Window) DeviceToPixel ¶
DeviceToPixel converts device coordinates to pixels using the current DPI scale
func (*Window) GetHeight ¶
GetHeight returns the height of the Window instance (in device coordinates)
func (*Window) IsFullscreen ¶
IsFullscreen returns whether the Window is fullscreen
func (*Window) PixelsToDevice ¶
PixelsToDevice converts pixels to device coordinates using the current DPI scale
func (*Window) SetCloseCallback ¶
func (win *Window) SetCloseCallback(callFunc func())
SetCloseCallback executes the specified function when the Window closes
func (*Window) SetResizeCallback ¶
SetResizeCallback executes the specified function when the Window is resized
type WindowFlag ¶
type WindowFlag int
WindowFlag enumerates the window features in a bitwise-OR ('|') friendly manner
const ( WindowBorderless WindowFlag = 1 << 0 WindowTitled WindowFlag = 1 << 1 WindowResizable WindowFlag = 1 << 2 WindowMaximizable WindowFlag = 1 << 3 )
Feature flags for the Window instance