Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
ultralight Namespace Reference

Namespaces

namespace  KeyCodes
 Namespace containing all the key-code definitions for KeyboardEvent.
 

Classes

class  App
 Main application singleton (use this if you want to let the library manage window creation). More...
 
class  AppListener
 Interface for all App-related events. More...
 
class  Bitmap
 Bitmap container with basic blitting and conversion routines. More...
 
class  BitmapSurface
 The default Surface implementation, backed by a Bitmap. More...
 
class  Buffer
 A fixed-size byte container for passing data around. More...
 
class  Clipboard
 User-defined clipboard interface. More...
 
struct  Command
 Command description. More...
 
struct  CommandList
 Command list,. More...
 
struct  Config
 Global config for Ultralight. More...
 
class  FileSystem
 User-defined file system interface. More...
 
class  FontFile
 Represents a font file, either on-disk path or in-memory file contents. More...
 
class  FontLoader
 User-defined font loader interface. More...
 
class  GamepadAxisEvent
 Event representing a change in gamepad axis state (eg, pressing a stick in a certain direction). More...
 
class  GamepadButtonEvent
 Event representing a change in gamepad button state (eg, pressing a button on a gamepad). More...
 
class  GamepadEvent
 Event representing a change in gamepad connection state. More...
 
class  GPUDriver
 User-defined GPU driver interface. More...
 
struct  GPUState
 GPU state description. More...
 
struct  IndexBuffer
 Vertex index buffer,. More...
 
struct  IntRect
 Integer Rectangle Helper. More...
 
class  JSArgs
 A vector of JSValues, used for passing around arguments in JSCallback. More...
 
class  JSArray
 JSArray wrapper that automatically manages lifetime and provides convenient access to indices and Array functions. More...
 
class  JSContext
 This class wraps a JSContextRef (a JavaScript execution context for use with JavaScriptCore) and locks the context on the current thread for the duration of its lifetime. More...
 
class  JSFunction
 JSFunction wrapper that automatically manages lifetime and provides convenient function invocation operators. More...
 
class  JSObject
 JSObject wrapper that automatically manages lifetime and provides convenient access to properties. More...
 
class  JSPropertyValue
 Wrapper for JSObject property value (JSValue subclass). More...
 
class  JSString
 JavaScript String wrapper that automatically manages JSStringRef lifetime and provides helpful conversions. More...
 
class  JSValue
 JavaScript variant value wrapper that automatically manages JSValueRef lifetime and provides helpful conversions. More...
 
struct  JSValueNullTag
 Tag type used with the JSValue constructor to create "Null" types. More...
 
struct  JSValueUndefinedTag
 Tag type used with the JSValue constructor to create "Undefined" types. More...
 
class  KeyEvent
 Generic keyboard event representing a change in keyboard state. More...
 
class  LoadListener
 User-defined interface to listen for load-related events for a View. More...
 
class  LockedPixels
 Forward declaration for the LockedPixels class. More...
 
class  Logger
 User-defined logging interface. More...
 
struct  Matrix
 Transformation Matrix helper. More...
 
struct  Matrix4x4
 4x4 Matrix Helper More...
 
class  Monitor
 Monitor class, represents a platform monitor. More...
 
class  MouseEvent
 Generic mouse event representing a change in mouse state. More...
 
class  Overlay
 Web-content overlay. More...
 
class  Platform
 Global platform singleton, manages user-defined platform handlers and global config. More...
 
struct  Rect
 Float Rectangle Helper. More...
 
class  RefCounted
 Interface for all ref-counted objects that will be managed using the RefPtr<> smart pointer. More...
 
class  RefPtr
 A nullable smart pointer. More...
 
struct  RenderBuffer
 RenderBuffer description,. More...
 
class  Renderer
 Core renderer singleton for the library, coordinates all library functions. More...
 
struct  RenderTarget
 Rendering details for a View, to be used with your own GPUDriver. More...
 
struct  RoundedRect
 Rounded Rectangle Helper. More...
 
class  ScrollEvent
 Generic scroll event representing a change in scroll state. More...
 
class  Session
 Storage for browsing data (cookies, local storage, etc.) optionally persisted to disk. More...
 
struct  Settings
 App-specific settings. More...
 
class  String
 UTF-8 String container with conversions for UTF-16 and UTF-32. More...
 
class  String16
 A UTF-16 string container. More...
 
class  String16Vector
 A UTF-16 string vector. More...
 
class  String32
 A UTF-32 string container. More...
 
class  String8
 A UTF-8 string container. More...
 
class  Surface
 Offscreen pixel buffer surface. More...
 
class  SurfaceFactory
 SurfaceFactory can be used to provide your own native Surface implementation. More...
 
struct  vec2
 2D Vector Helper More...
 
struct  vec3
 3D Vector Helper More...
 
struct  vec4
 4D Vector Helper More...
 
struct  Vertex_2f_4ub_2f
 Vertex layout for path vertices, useful for synthesizing or modifying vertex data. More...
 
struct  Vertex_2f_4ub_2f_2f_28f
 Vertex layout for quad vertices, useful for synthesizing or modifying vertex data. More...
 
struct  VertexBuffer
 Vertex buffer,. More...
 
class  View
 Web-page container rendered to an offscreen surface that you display yourself. More...
 
struct  ViewConfig
 View-specific configuration settings. More...
 
class  ViewListener
 User-defined interface to listen for View-specific events. More...
 
class  Window
 Window class, represents a platform window. More...
 
class  WindowListener
 Interface for all Window-related events. More...
 

Typedefs

typedef std::function< void(const JSObject &, const JSArgs &)> JSCallback
 JSCallback typedef used for binding C++ callbacks to JavaScript functions.
 
typedef std::function< JSValue(const JSObject &, const JSArgs &)> JSCallbackWithRetval
 JSCallbackWithRetval typedef used for binding C++ callbacks to JavaScript functions with an optional return value.
 
typedef void(* DestroyBufferCallback) (void *user_data, void *data)
 Function signature for a user-defined destruction callback to be optionally called when Buffer is destroyed.
 
typedef vec2 Point
 Point is typedef'd to a 2D vector.
 
typedef uint32_t IndexType
 Vertex index type.
 
typedef detail::selector< sizeof(wchar_t)>::Char16 Char16
 

Enumerations

enum  WindowFlags : uint8_t {
  kWindowFlags_Borderless = 1 << 0 , kWindowFlags_Titled = 1 << 1 , kWindowFlags_Resizable = 1 << 2 , kWindowFlags_Maximizable = 1 << 3 ,
  kWindowFlags_Hidden = 1 << 4
}
 Window creation flags. More...
 
enum class  BitmapFormat : uint8_t { A8_UNORM , BGRA8_UNORM_SRGB }
 The various Bitmap formats. More...
 
enum  MessageSource {
  kMessageSource_XML = 0 , kMessageSource_JS , kMessageSource_Network , kMessageSource_ConsoleAPI ,
  kMessageSource_Storage , kMessageSource_AppCache , kMessageSource_Rendering , kMessageSource_CSS ,
  kMessageSource_Security , kMessageSource_ContentBlocker , kMessageSource_Other
}
 MessageSource types,. More...
 
enum  MessageLevel {
  kMessageLevel_Log = 1 , kMessageLevel_Warning = 2 , kMessageLevel_Error = 3 , kMessageLevel_Debug = 4 ,
  kMessageLevel_Info = 5
}
 MessageLevel types,. More...
 
enum  Cursor {
  kCursor_Pointer = 0 , kCursor_Cross , kCursor_Hand , kCursor_IBeam ,
  kCursor_Wait , kCursor_Help , kCursor_EastResize , kCursor_NorthResize ,
  kCursor_NorthEastResize , kCursor_NorthWestResize , kCursor_SouthResize , kCursor_SouthEastResize ,
  kCursor_SouthWestResize , kCursor_WestResize , kCursor_NorthSouthResize , kCursor_EastWestResize ,
  kCursor_NorthEastSouthWestResize , kCursor_NorthWestSouthEastResize , kCursor_ColumnResize , kCursor_RowResize ,
  kCursor_MiddlePanning , kCursor_EastPanning , kCursor_NorthPanning , kCursor_NorthEastPanning ,
  kCursor_NorthWestPanning , kCursor_SouthPanning , kCursor_SouthEastPanning , kCursor_SouthWestPanning ,
  kCursor_WestPanning , kCursor_Move , kCursor_VerticalText , kCursor_Cell ,
  kCursor_ContextMenu , kCursor_Alias , kCursor_Progress , kCursor_NoDrop ,
  kCursor_Copy , kCursor_None , kCursor_NotAllowed , kCursor_ZoomIn ,
  kCursor_ZoomOut , kCursor_Grab , kCursor_Grabbing , kCursor_Custom
}
 Cursor types,. More...
 
enum class  FaceWinding : uint8_t { Clockwise , CounterClockwise }
 The winding order for front-facing triangles. More...
 
enum class  FontHinting : uint8_t { Smooth , Normal , Monochrome , None }
 
enum class  VertexBufferFormat : uint8_t { _2f_4ub_2f , _2f_4ub_2f_2f_28f }
 Vertex buffer formats (identifiers start with underscore due to C++ naming rules) More...
 
enum class  ShaderType : uint8_t { Fill , FillPath }
 Shader types, used by GPUState::shader_type. More...
 
enum class  CommandType : uint8_t { ClearRenderBuffer , DrawGeometry }
 Command types, used by Command::command_type. More...
 
enum class  LogLevel : uint8_t { Error , Warning , Info }
 Log levels, used with Logger::LogMessage. More...
 

Functions

void SetJSContext (JSContextRef ctx)
 Set the current JSContext.
 
JSContextRef GetJSContext ()
 Get the current JSContext.
 
JSObject JSGlobalObject ()
 Get the Global Object for the current JSContext.
 
JSValue JSEval (const JSString &str)
 Evaluate a string of JavaScript and return a result.
 
FontLoaderGetPlatformFontLoader ()
 Get the native font loader for the current platform.
 
FileSystemGetPlatformFileSystem (const String &baseDir)
 Get the native file system for the current platform, creating it if it doesn't exist using the base directory provided.
 
LoggerGetDefaultLogger (const String &logPath)
 Get the default logger (writes the log to a file on disk).
 
void GetKeyIdentifierFromVirtualKeyCode (int virtual_key_code, String &key_identifier_result)
 Utility function for generating a key identifier string from a virtual key-code.
 
void GetKeyFromVirtualKeyCode (int virtual_key_code, bool shift, String &key_result)
 Utility function for generating a key string from a virtual key-code.
 
bool operator== (const Matrix &a, const Matrix &b)
 
bool operator!= (const Matrix &a, const Matrix &b)
 
bool operator== (const Matrix4x4 &a, const Matrix4x4 &b)
 
bool operator!= (const Matrix4x4 &a, const Matrix4x4 &b)
 
SurfaceFactoryGetBitmapSurfaceFactory ()
 Get the default Bitmap Surface Factory singleton.
 
template<typename T >
RefPtr< T > AdoptRef (T &reference)
 Helper for wrapping new objects with the RefPtr smart pointer.
 
template<class T >
void swap (RefPtr< T > &a, RefPtr< T > &b)
 
template<typename T , typename U >
bool operator== (const RefPtr< T > &a, const RefPtr< U > &b)
 
template<typename T , typename U >
bool operator== (const RefPtr< T > &a, const U *b)
 
template<typename T , typename U >
bool operator== (const T *a, const RefPtr< U > &b)
 
template<typename T , typename U >
bool operator!= (const RefPtr< T > &a, const RefPtr< U > &b)
 
template<typename T , typename U >
bool operator!= (const RefPtr< T > &a, const U *b)
 
template<typename T , typename U >
bool operator!= (const T *a, const RefPtr< U > &b)
 

Typedef Documentation

◆ Char16

typedef detail::selector<sizeof(wchar_t)>::Char16 ultralight::Char16

◆ DestroyBufferCallback

typedef void(* ultralight::DestroyBufferCallback) (void *user_data, void *data)

Function signature for a user-defined destruction callback to be optionally called when Buffer is destroyed.

Parameters
user_dataPointer to user-defined user-data (this will be the same value as what was passed to Buffer::Create, if any)
dataPointer to raw Buffer data.

◆ IndexType

typedef uint32_t ultralight::IndexType

Vertex index type.

◆ JSCallback

typedef std::function<void(const JSObject&, const JSArgs&)> ultralight::JSCallback

JSCallback typedef used for binding C++ callbacks to JavaScript functions.

Takes two arguments (const JSObject& thisObj, const JSArgs& args) and returns nothing (void).

◆ JSCallbackWithRetval

typedef std::function<JSValue(const JSObject&, const JSArgs&)> ultralight::JSCallbackWithRetval

JSCallbackWithRetval typedef used for binding C++ callbacks to JavaScript functions with an optional return value.

Takes two arguments (const JSObject& thisObj, const JSArgs& args) and returns a JSValue back to JavaScript.

◆ Point

Point is typedef'd to a 2D vector.

Enumeration Type Documentation

◆ BitmapFormat

enum class ultralight::BitmapFormat : uint8_t
strong

The various Bitmap formats.

Enumerator
A8_UNORM 

Alpha channel only, 8-bits per pixel.

Encoding: 8-bits per channel, unsigned normalized.

Color-space: Linear (no gamma), alpha-coverage only.

BGRA8_UNORM_SRGB 

Blue Green Red Alpha channels, 32-bits per pixel.

Encoding: 8-bits per channel, unsigned normalized.

Color-space: sRGB gamma with premultiplied linear alpha channel.

◆ CommandType

enum class ultralight::CommandType : uint8_t
strong

Command types, used by Command::command_type.

Enumerator
ClearRenderBuffer 
DrawGeometry 

◆ Cursor

Cursor types,.

See also
ViewListener::OnChangeCursor
Enumerator
kCursor_Pointer 
kCursor_Cross 
kCursor_Hand 
kCursor_IBeam 
kCursor_Wait 
kCursor_Help 
kCursor_EastResize 
kCursor_NorthResize 
kCursor_NorthEastResize 
kCursor_NorthWestResize 
kCursor_SouthResize 
kCursor_SouthEastResize 
kCursor_SouthWestResize 
kCursor_WestResize 
kCursor_NorthSouthResize 
kCursor_EastWestResize 
kCursor_NorthEastSouthWestResize 
kCursor_NorthWestSouthEastResize 
kCursor_ColumnResize 
kCursor_RowResize 
kCursor_MiddlePanning 
kCursor_EastPanning 
kCursor_NorthPanning 
kCursor_NorthEastPanning 
kCursor_NorthWestPanning 
kCursor_SouthPanning 
kCursor_SouthEastPanning 
kCursor_SouthWestPanning 
kCursor_WestPanning 
kCursor_Move 
kCursor_VerticalText 
kCursor_Cell 
kCursor_ContextMenu 
kCursor_Alias 
kCursor_Progress 
kCursor_NoDrop 
kCursor_Copy 
kCursor_None 
kCursor_NotAllowed 
kCursor_ZoomIn 
kCursor_ZoomOut 
kCursor_Grab 
kCursor_Grabbing 
kCursor_Custom 

◆ FaceWinding

enum class ultralight::FaceWinding : uint8_t
strong

The winding order for front-facing triangles.

(Only used when the GPU renderer is used)

Enumerator
Clockwise 

Clockwise Winding (Direct3D, etc.)

CounterClockwise 

Counter-Clockwise Winding (OpenGL, etc.)

◆ FontHinting

enum class ultralight::FontHinting : uint8_t
strong
Enumerator
Smooth 

Lighter hinting algorithm– glyphs are slightly fuzzier but better resemble their original shape.

This is achieved by snapping glyphs to the pixel grid only vertically which better preserves inter-glyph spacing.

Normal 

Default hinting algorithm– offers a good balance between sharpness and shape at smaller font sizes.

Monochrome 

Strongest hinting algorithm– outputs only black/white glyphs.

The result is usually unpleasant if the underlying TTF does not contain hints for this type of rendering.

None 

No hinting is performed– fonts may be blurry at smaller font sizes.

◆ LogLevel

enum class ultralight::LogLevel : uint8_t
strong

Log levels, used with Logger::LogMessage.

Enumerator
Error 
Warning 
Info 

◆ MessageLevel

MessageLevel types,.

See also
ViewListener::OnAddConsoleMessage
Enumerator
kMessageLevel_Log 
kMessageLevel_Warning 
kMessageLevel_Error 
kMessageLevel_Debug 
kMessageLevel_Info 

◆ MessageSource

MessageSource types,.

See also
ViewListener::OnAddConsoleMessage
Enumerator
kMessageSource_XML 
kMessageSource_JS 
kMessageSource_Network 
kMessageSource_ConsoleAPI 
kMessageSource_Storage 
kMessageSource_AppCache 
kMessageSource_Rendering 
kMessageSource_CSS 
kMessageSource_Security 
kMessageSource_ContentBlocker 
kMessageSource_Other 

◆ ShaderType

enum class ultralight::ShaderType : uint8_t
strong

Shader types, used by GPUState::shader_type.

Each of these correspond to a vertex/pixel shader pair. You can find stock shader code for these in the shaders folder of the AppCore repo.

Enumerator
Fill 
FillPath 

◆ VertexBufferFormat

enum class ultralight::VertexBufferFormat : uint8_t
strong

Vertex buffer formats (identifiers start with underscore due to C++ naming rules)

Enumerator
_2f_4ub_2f 
_2f_4ub_2f_2f_28f 

◆ WindowFlags

enum ultralight::WindowFlags : uint8_t

Window creation flags.

See also
Window::Create
Enumerator
kWindowFlags_Borderless 
kWindowFlags_Titled 
kWindowFlags_Resizable 
kWindowFlags_Maximizable 
kWindowFlags_Hidden 

Function Documentation

◆ AdoptRef()

template<typename T >
RefPtr< T > ultralight::AdoptRef ( T &  reference)

Helper for wrapping new objects with the RefPtr smart pointer.

All ref-counted object are created with an initial ref-count of '1'. The AdoptRef() helper returns a RefPtr<T> without calling AddRef(). This is used for creating new objects, like so:

RefPtr<Object> ref = AdoptRef(*new ObjectImpl());

◆ GetBitmapSurfaceFactory()

SurfaceFactory * ultralight::GetBitmapSurfaceFactory ( )

Get the default Bitmap Surface Factory singleton.

(Do not destroy this, this singleton is owned by the library).

◆ GetDefaultLogger()

Logger * ultralight::GetDefaultLogger ( const String logPath)

Get the default logger (writes the log to a file on disk).

Parameters
logPathA file path to write the log to.
Note
This singleton is owned by the library, do not destroy it.

◆ GetJSContext()

JSContextRef ultralight::GetJSContext ( )

Get the current JSContext.

◆ GetKeyFromVirtualKeyCode()

void ultralight::GetKeyFromVirtualKeyCode ( int  virtual_key_code,
bool  shift,
String key_result 
)

Utility function for generating a key string from a virtual key-code.

Parameters
virtual_key_codeThe virtual key-code to generate the key string from.
shiftWhether or not the shift key is currently pressed.
key_resultThe string to store the result in.
Note
This function assumes US keyboard layout.
See also
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values

◆ GetKeyIdentifierFromVirtualKeyCode()

void ultralight::GetKeyIdentifierFromVirtualKeyCode ( int  virtual_key_code,
String key_identifier_result 
)

Utility function for generating a key identifier string from a virtual key-code.

Parameters
virtual_key_codeThe virtual key-code to generate the key identifier from.
key_identifier_resultThe string to store the result in.

◆ GetPlatformFileSystem()

FileSystem * ultralight::GetPlatformFileSystem ( const String baseDir)

Get the native file system for the current platform, creating it if it doesn't exist using the base directory provided.

This is used to load data for file:/// URLs.

Parameters
baseDirAn base file path that will be used to resolve relative file paths. You can optionally specify "@resource_path" on macOS to use the app bundle's resource path.
Note
This singleton is owned by the library, do not destroy it.

◆ GetPlatformFontLoader()

FontLoader * ultralight::GetPlatformFontLoader ( )

Get the native font loader for the current platform.

Note
This singleton is owned by the library, do not destroy it.

◆ JSEval()

JSValue ultralight::JSEval ( const JSString str)

Evaluate a string of JavaScript and return a result.

◆ JSGlobalObject()

JSObject ultralight::JSGlobalObject ( )

Get the Global Object for the current JSContext.

In JavaScript, this would be equivalent to the "window" object.

◆ operator!=() [1/5]

bool ultralight::operator!= ( const Matrix a,
const Matrix b 
)

◆ operator!=() [2/5]

bool ultralight::operator!= ( const Matrix4x4 a,
const Matrix4x4 b 
)

◆ operator!=() [3/5]

template<typename T , typename U >
bool ultralight::operator!= ( const RefPtr< T > &  a,
const RefPtr< U > &  b 
)

◆ operator!=() [4/5]

template<typename T , typename U >
bool ultralight::operator!= ( const RefPtr< T > &  a,
const U *  b 
)

◆ operator!=() [5/5]

template<typename T , typename U >
bool ultralight::operator!= ( const T *  a,
const RefPtr< U > &  b 
)

◆ operator==() [1/5]

bool ultralight::operator== ( const Matrix a,
const Matrix b 
)

◆ operator==() [2/5]

bool ultralight::operator== ( const Matrix4x4 a,
const Matrix4x4 b 
)

◆ operator==() [3/5]

template<typename T , typename U >
bool ultralight::operator== ( const RefPtr< T > &  a,
const RefPtr< U > &  b 
)

◆ operator==() [4/5]

template<typename T , typename U >
bool ultralight::operator== ( const RefPtr< T > &  a,
const U *  b 
)

◆ operator==() [5/5]

template<typename T , typename U >
bool ultralight::operator== ( const T *  a,
const RefPtr< U > &  b 
)

◆ SetJSContext()

void ultralight::SetJSContext ( JSContextRef  ctx)

Set the current JSContext.

Most JavaScriptCore C API calls require an active JavaScript execution context (JSContextRef). You can get the JSContextRef for a page via View::LockJSContext(). This context changes with each page navigation.

Note: You MUST set a JSContext before using most of the C++ API below.

◆ swap()

template<class T >
void ultralight::swap ( RefPtr< T > &  a,
RefPtr< T > &  b 
)