cohtml.Net.UISystem

A System owns multiple Views. These Views share resources among them. It is usually enough to have just one System per application run. All System APIs, unless explicitly stated otherwise, can be called on any thread, but should not be used on multiple threads simultaneously.

Inherits from SystemIDisposable

Public Functions

Name
virtual voidDispose()
virtual voidUpdateGamepadState(cohtml.Net.GamepadState state)
Updates the state of a single gamepad.
virtual uintGetId()
virtual voidSetId(uint id)
virtual SystemCacheStatsGetSystemCacheStats()
Returns an objects that holds the current statistics of the system-wide caches. Remember to Release when done.
virtual voidClearCachedUnusedImages()
Removes all unused images (raster and svg) from internal caches. Images must be unused (orphaned) for them to be cleared. If you want to force ALL images to be unloaded you need for first call View.UnloadDocument to remove any references the DOM might still hold to the images.
virtual SystemRendererCreateSystemRenderer(SystemRendererSettings settings)
Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread.
virtual SystemRendererCreateSystemRendererWithExternalRenderingLibrary(SystemRendererSettingsWithExternalRenderingLibrary settings)
Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread. Use this version when the Library is initialized with an external rendering library. cohtml.Library.InitializeWithRenderingLibrary
virtual voidAddFontsFromFolder_DEPRECATED(string path)
Loads all fonts from the specified folder. The fonts can later be used in the Views Prefer using the RegisterFont API for better control over the loaded fonts.
virtual voidRegisterFont(string url, FontDescription desc, FontSDF useSDF)
Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).
virtual voidRegisterFont(string url, FontDescription desc)
Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).
virtual voidRegisterFont(string url)
Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).
virtual boolUnregisterFont(string url)
Unregisters all registered fonts by the RegisterFont API for a specific font resource identified by the URL. Font resources are shared between the system and the views, so the font resource may not be freed if there are active at font-face rules using the same URL. Since the font resource is required for rendering, fonts will be freed after all pending frames are painted.
virtual voidAddUserFont(System.IntPtr imagesData, uint [] imagesDataSize, uint imagesCount, UserFontDescription description)
Load the user font using image files. The memory can be freed immediately after the call Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture
virtual voidAddUserFont(ResourceResponse.UserImageData userImages, uint imagesCount, UserFontDescription description)
Load the user font using image files. The memory can be freed immediately after the call Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture
virtual boolRemoveUserFont(UserFontDescription description)
Unregisters the bitmap font which has been registered by the user.
virtual voidSetDefaultFallbackFontName_DEPRECATED(string name)
Loads font with given name from folders specified by AddFontsFromFolder. This font will be used when the another font cannot be loaded or found as a default one. This font is a fallback if the font name used in a Style property is not found. If you want to change the default font that will be applied to all elements, you should change the value in LibraryParams.DefaultStyleFontFamily.
virtual voidAdvance(double timeMilliseconds)
Advances the internal timers and inspector when available.
virtual voidRegisterGamepad(uint id, string info, uint axesCount, uint buttonsCount, global.System.IntPtr reserved)
Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping.
virtual voidRegisterGamepad(uint id, string info, uint axesCount, uint buttonsCount)
Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping.
virtual voidUnregisterGamepad(uint id)
Unregisters a gamepad. All views will receive the gamepaddisconnected event.
virtual voidUpdateGamepadStateExtended(GamepadStateExtended state)
Updates the state of a single gamepad with motion tracking information.
virtual voidUserImagesChanged(uint [] images, uint count)
Trigger repaint of a user provided texture. Call this whenever the image is changed by logic external to the library. Make sure to have ImageHandle set for such images.
virtual voidPreloadAndCacheStylesheet(string url)
Schedules a preload task for a given stylesheet and caches it upon successful parsing.
virtual boolRemoveStylesheetCacheEntry(string url)
Clears data for a given stylesheet from the cache.
virtual voidClearStylesheetCache()
Clears all preloaded stylesheet data from the cache. If a stylesheet that is currently in use by a view is cleared, it won’t affect the view but a resource request will be fired the next time it is needed
virtual voidPreloadAndCacheHTML(string url)
Schedules a preload task for a given HTML, parses it, and caches it.
virtual boolRemoveHTMLCacheEntry(string url)
Clears data for a given HTML from the cache.
virtual voidClearHTMLCache()
Clears all preloaded HTML data from the cache. Removing HTML from cache that is currently in use by a view won’t free HTML data immediately, data will be freed after the View finishes DOM building, even if the HTML is not loaded yet.
voidUpdateGamepadState(uint id, float [] axisValues, float [] buttonValues)
Update the gamepad button and axis values.
virtual ViewCreateView(ViewSettings settings, uint systemId)
Creates a new View with the specified options.
virtual voidDestroy()
Destroys the native Cohtml System

Protected Attributes

Name
boolswigCMemOwn

Public Functions Documentation

function Dispose

virtual void Dispose()

function UpdateGamepadState

virtual void UpdateGamepadState(
    cohtml.Net.GamepadState state
)

Updates the state of a single gamepad.

Parameters:

  • state The new state of the gamepad

function GetId

virtual uint GetId()

function SetId

virtual void SetId(
    uint id
)

function GetSystemCacheStats

virtual SystemCacheStats GetSystemCacheStats()

Returns an objects that holds the current statistics of the system-wide caches. Remember to Release when done.

function ClearCachedUnusedImages

virtual void ClearCachedUnusedImages()

Removes all unused images (raster and svg) from internal caches. Images must be unused (orphaned) for them to be cleared. If you want to force ALL images to be unloaded you need for first call View.UnloadDocument to remove any references the DOM might still hold to the images.

function CreateSystemRenderer

virtual SystemRenderer CreateSystemRenderer(
    SystemRendererSettings settings
)

Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread.

function CreateSystemRendererWithExternalRenderingLibrary

virtual SystemRenderer CreateSystemRendererWithExternalRenderingLibrary(
    SystemRendererSettingsWithExternalRenderingLibrary settings
)

Creates a new SystemRenderer. The SystemRenderer will hold rendering resources shared by all view renderers. Can be used on any thread. Use this version when the Library is initialized with an external rendering library. cohtml.Library.InitializeWithRenderingLibrary

function AddFontsFromFolder_DEPRECATED

virtual void AddFontsFromFolder_DEPRECATED(
    string path
)

Loads all fonts from the specified folder. The fonts can later be used in the Views Prefer using the RegisterFont API for better control over the loaded fonts.

Parameters:

  • path the name of the folder

Warning: This API is deprecated. Use font-face rules or RegisterFont API to load/preload fonts

Note: Requires a valid IFileSystemReader for enumerating the folder.

function RegisterFont

virtual void RegisterFont(
    string url,
    FontDescription desc,
    FontSDF useSDF
)

Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).

Parameters:

  • url URL for the font to be loaded. Must be a valid URL. Spaces aren’t allowed.
  • desc The description of the font to be loaded
  • useSDF Controls the method used when rendering fonts, same as the coh-font-sdf font-face property SDF reduces memory consumption but finer font details are lost. If you experience a loss of detail in font rendering, try turning SDF off.

function RegisterFont

virtual void RegisterFont(
    string url,
    FontDescription desc
)

Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).

Parameters:

  • url URL for the font to be loaded. Must be a valid URL. Spaces aren’t allowed.
  • desc The description of the font to be loaded

function RegisterFont

virtual void RegisterFont(
    string url
)

Registers a font that can be later used in the Views. This API is similar to a font-face rule and allows you to prepare font stream readers in advance, so that text can render without delays. Unlike the font-face rule, this API also allows you to load the font with its original description (using ‘Auto’ for weight or/and style with or without specifying specific family name for it). This API will load all available fonts from font collections (ttc, otc) when a specific font description isn’t provided (use ‘Auto’ without family name). If any description is specified for a font collection, only the first font will be loaded under that description (same behavior as a font-face rule with font collection).

Parameters:

  • url URL for the font to be loaded. Must be a valid URL. Spaces aren’t allowed.

function UnregisterFont

virtual bool UnregisterFont(
    string url
)

Unregisters all registered fonts by the RegisterFont API for a specific font resource identified by the URL. Font resources are shared between the system and the views, so the font resource may not be freed if there are active at font-face rules using the same URL. Since the font resource is required for rendering, fonts will be freed after all pending frames are painted.

Parameters:

  • url URL identifying the font resource. Must be a valid URL. Spaces aren’t allowed.

Return: true, if the font was unregistered successfully and false otherwise.

function AddUserFont

virtual void AddUserFont(
    System.IntPtr imagesData,
    uint [] imagesDataSize,
    uint imagesCount,
    UserFontDescription description
)

Load the user font using image files. The memory can be freed immediately after the call Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture

Parameters:

  • imagesData pointer to image files data.
  • imagesDataSize pointer to size of the image files.
  • imagesCount number of images
  • description Description of the bitmap font.

function AddUserFont

virtual void AddUserFont(
    ResourceResponse.UserImageData userImages,
    uint imagesCount,
    UserFontDescription description
)

Load the user font using image files. The memory can be freed immediately after the call Images must have the appropriate number of channels Bitmap: 1-channel(A) texture MSDF: 3-channel(RGB) texture

Parameters:

  • imagesCount number of images
  • description Description of the bitmap font.

function RemoveUserFont

virtual bool RemoveUserFont(
    UserFontDescription description
)

Unregisters the bitmap font which has been registered by the user.

Parameters:

  • description Description of the bitmap font.

Return: true, if the font was unregistered successfully and false otherwise.

function SetDefaultFallbackFontName_DEPRECATED

virtual void SetDefaultFallbackFontName_DEPRECATED(
    string name
)

Loads font with given name from folders specified by AddFontsFromFolder. This font will be used when the another font cannot be loaded or found as a default one. This font is a fallback if the font name used in a Style property is not found. If you want to change the default font that will be applied to all elements, you should change the value in LibraryParams.DefaultStyleFontFamily.

Parameters:

  • name name of the font to load as default fallback

Warning: This function is deprecated and about to be removed. Cohtml now uses an embedded fallback font.

Note: This should be called after AddFontsFromFolder

function Advance

virtual void Advance(
    double timeMilliseconds
)

Advances the internal timers and inspector when available.

function RegisterGamepad

virtual void RegisterGamepad(
    uint id,
    string info,
    uint axesCount,
    uint buttonsCount,
    global.System.IntPtr reserved
)

Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping.

Parameters:

  • id the unique identifier for the gamepad
  • info general information for the gamepad such as producer and model
  • axesCount the number of analog axes the gamepad has
  • buttonsCount the number of buttons the gamepad has
  • reserved reserved parameter. Set to nullptr

function RegisterGamepad

virtual void RegisterGamepad(
    uint id,
    string info,
    uint axesCount,
    uint buttonsCount
)

Registers a new gamepad. All views will receive the gamepadconnected event. You can provide any number of axes and buttons though the standard mapping according to the HTML spec has 4 axes and 17 buttons which can be found here https://w3c.github.io/gamepad/#remapping.

Parameters:

  • id the unique identifier for the gamepad
  • info general information for the gamepad such as producer and model
  • axesCount the number of analog axes the gamepad has
  • buttonsCount the number of buttons the gamepad has

function UnregisterGamepad

virtual void UnregisterGamepad(
    uint id
)

Unregisters a gamepad. All views will receive the gamepaddisconnected event.

Parameters:

  • id the id of the gamepad to unregister

function UpdateGamepadStateExtended

virtual void UpdateGamepadStateExtended(
    GamepadStateExtended state
)

Updates the state of a single gamepad with motion tracking information.

Parameters:

  • state new state of the gamepad

Note: If you do not require motion tracking, use System.UpdateGamepadState

function UserImagesChanged

virtual void UserImagesChanged(
    uint [] images,
    uint count
)

Trigger repaint of a user provided texture. Call this whenever the image is changed by logic external to the library. Make sure to have ImageHandle set for such images.

Parameters:

  • images array of image handles - id-s of the user provided images that are changed
  • count the number of changed images

function PreloadAndCacheStylesheet

virtual void PreloadAndCacheStylesheet(
    string url
)

Schedules a preload task for a given stylesheet and caches it upon successful parsing.

Parameters:

  • url A URL for the stylesheet to be preloaded and cached. Must be a valid URL. Spaces aren’t allowed.

Note: The stylesheet cache is shared among all views

function RemoveStylesheetCacheEntry

virtual bool RemoveStylesheetCacheEntry(
    string url
)

Clears data for a given stylesheet from the cache.

Parameters:

  • url The URL for the stylesheet to be cleared from cache. Must be the same URL used for its preloading.

Return: true, if the cache entry corresponding to the given URL was found and cleared successfully

Note: but a resource request will be fired the next time it is needed

function ClearStylesheetCache

virtual void ClearStylesheetCache()

Clears all preloaded stylesheet data from the cache. If a stylesheet that is currently in use by a view is cleared, it won’t affect the view but a resource request will be fired the next time it is needed

function PreloadAndCacheHTML

virtual void PreloadAndCacheHTML(
    string url
)

Schedules a preload task for a given HTML, parses it, and caches it.

Parameters:

  • url A URL for the HTML to be preloaded and cached. Must be a valid absolute URL. Spaces aren’t allowed.

Note: The HTML cache is shared among all views

function RemoveHTMLCacheEntry

virtual bool RemoveHTMLCacheEntry(
    string url
)

Clears data for a given HTML from the cache.

Parameters:

  • url The URL for the HTML to be cleared from the cache. Must be the same URL used for its preloading.

Return: true, if the cache entry corresponding to the given URL was found and cleared successfully

Note: data will be freed after the View finishes DOM building, even if the HTML is not loaded yet.

function ClearHTMLCache

virtual void ClearHTMLCache()

Clears all preloaded HTML data from the cache. Removing HTML from cache that is currently in use by a view won’t free HTML data immediately, data will be freed after the View finishes DOM building, even if the HTML is not loaded yet.

function UpdateGamepadState

void UpdateGamepadState(
    uint id,
    float [] axisValues,
    float [] buttonValues
)

Update the gamepad button and axis values.

Parameters:

  • id Id of the gamepad.
  • axisValues The axis collection to apply.
  • buttonValues The button collection to apply.

Note: All gamepad-related methods are system-wise. All views will get the new state.

function CreateView

virtual View CreateView(
    ViewSettings settings,
    uint systemId
)

Creates a new View with the specified options.

Parameters:

  • settings Settings used when initializing a View.
  • systemId The system id containing the view.

function Destroy

virtual void Destroy()

Destroys the native Cohtml System

Protected Attributes Documentation

variable swigCMemOwn

bool swigCMemOwn;