1.26.2.1
Gameface
cohtml::View Class Referenceabstract

The View represents a UI page with its DOM, styles and JavaScript context. Think of the View as a whole UI or UI element. The View for instance could be the whole HUD of a game. More...

Public Member Functions

virtual ~View ()
 
virtual void Destroy ()=0
 Destroys the View. Should be called before the destruction of the System and Library. More...
 
virtual void LoadURL (const char *url)=0
 Loads a page in the View. More...
 
virtual void Reload ()=0
 Reloads the current page in the view. More...
 
virtual void UnloadDocument ()=0
 Unloads the HTML document. This will remove the entire DOM tree, so nothing will rendered but the view object will still be usable and another document might be loaded using View::LoadURL. More...
 
virtual void ClearNavigationHistory ()=0
 Clears the navigation history accessed from JavaScript History object Use that method after View::LoadURL to reset the navigation history in case the view is reused to display unrelated page. More...
 
virtual unsigned Advance (TimePoint timeMilliseconds)=0
 Advances the internal timer of the View and runs all animations. If changes have happened in the page, this call will also trigger a new layout and render on the other threads. More...
 
virtual unsigned GetId () const =0
 Returns the unique ID of the View. More...
 
virtual TaskFamilyId GetTaskFamilyId () const =0
 Returns the Task Family Id that can be used to schedule Layout work in an auxiliary thread. More...
 
virtual void Resize (unsigned width, unsigned height)=0
 Resizes the View contents. More...
 
virtual void SetUserBackground (void *userTexture, const renoir::Texture2D &description)=0
 The background where the UI scene will be drawn. More...
 
virtual void SetUserBackgroundOffset (float x, float y)=0
 Set the user background offest. This has to be the location of the upper left corner of the UI texture relative to the upper left corner of the user backgorund texture. More...
 
virtual void SetResolutionForRendering (unsigned width, unsigned height)=0
 Sets a resolution for rendering. This allows setting one size for the HTML (via the Resize method) and authoring the UI for that resolution, while here you can tell the SDK that it should render the UI into a different-sized texture. The ViewRenderer's render target could be of a different size, although usually you'd want to have the resolution for rendering and ViewRenderer RT size to be the same. More...
 
virtual unsigned GetWidth () const =0
 Gets the View width. More...
 
virtual unsigned GetHeight () const =0
 Gets the View height. More...
 
virtual void OnListenerLost ()=0
 Informs the View that its listener has been lost. More...
 
virtual void EnableRendering (bool value)=0
 Enables or disables the recording of rendering commands for the view. Enabled by default. More...
 
virtual void ContinuousRepaint (bool enable)=0
 Debugging flag. This will cause the View to re-draw itself each frame. More...
 
virtual void ShowPaintRectangles (bool show)=0
 Debugging flag. This will cause the View show which parts of the texture are re-drawn each frame. More...
 
virtual void ShowElementAABBs (bool show)=0
 Debugging flag. This will cause the View to draw the bounding-boxes of all elements. More...
 
virtual void EmitRenderingMetadata (bool emit)=0
 Debugging flag. Enabling this will request the library to attach and emit metadata for every rendering command in the rendering backend. The metadata will contain the ID, CLASS and Node type of the Element that caused the drawing command. As multiple elements can be batched in the same command, the metadata will be a concatenated list of all Elements that have contributed to the batch. The user can emit the metadata in rendering & GPU debugging tools like PIX, RenderDoc, Razor etc. in order to gain better insight on the rendering operations & performance. More...
 
virtual bool SetAdditionalFontFallbacks (const char *fontFamilies)=0
 Sets fallback font families that will be used by all elements. Additional font families do not affect computed styles of an element. More...
 
virtual DebugDumpDebugDumpDOMTree (unsigned flags)=0
 Debugging helper. Collects a comprehensive DOM structure dump. More...
 
virtual DebugDumpDebugDumpStackingContextTree ()=0
 Debugging helper. Collects data about stacking context subtrees of the DOM tree. More...
 
virtual void TouchEvent (const cohtml::TouchEventData *events, unsigned count, bool *handled, void *userData)=0
 Sends a touch input event to the View. More...
 
virtual void GestureEvent (const cohtml::GestureEventData &event, bool *handled, void *userData)=0
 Sends a gesture input event to the View. More...
 
virtual void MouseEvent (const cohtml::MouseEventData &event, bool *handled, void *userData)=0
 Sends a mouse input event to the View. More...
 
virtual void KeyEvent (const cohtml::KeyEventData &event, bool *handled, void *userData)=0
 Sends a keyboard input event to the View. More...
 
virtual bool IMESetComposition (const char *composition, unsigned targetStart, unsigned targetEnd)=0
 Updates the internal state of the IME composition in the View. More...
 
virtual bool IMEConfirmComposition (const char *composition)=0
 Confirms the current IME composition. More...
 
virtual bool IMECancelComposition ()=0
 Cancels the current IME composition. More...
 
virtual float GetStartPanThreshold () const =0
 Returns the minumum length of pans to be performed. More...
 
virtual void SetStartPanThreshold (float value)=0
 Sets the minumum length of pans to be performed. More...
 
virtual void SetUserAgent (const char *userAgent)=0
 Sets the User Agent string. More...
 
virtual ImagesListGetUsedImagesList (ImagesListExtract::Options options) const =0
 Return a list of images currently in use by the View The list can be used to decide which images to pre-load or use for JS-based loading screens. The list is a current snapshot of the state of the View. Once built it will not change even if the View does. The user has to call the method again if she wants such changes applied. More...
 
virtual void BeginCaptureDebugFrame (void *userData, FrameCaptureCallback callback, CaptureMode mode=CM_PreserveAll)=0
 Will begin serializing every rendered frame to a memory blob which will be passed in the callback. The saved frames can be inspected for debug purposes. More...
 
virtual void EndCaptureDebugFrame ()=0
 Ends serializing rendered frames. More...
 
virtual void CaptureSingleDebugFrame (void *userData, FrameCaptureCallback callback, CaptureMode mode=CM_PreserveAll)=0
 Will serialize next rendered frame to a memory blob which will be passed in the callback. The saved frames can be inspected for debug purposes. More...
 
virtual void GetCacheCountStats (InternalCaches cache, unsigned &filled, unsigned &capacity)=0
 Get info about the number of objects statistic of a particular internal cache. More...
 
virtual void GetCacheBytesStats (InternalCaches cache, unsigned &filled, unsigned &capacity)=0
 Get info about the bytes statistic of a particular internal cache. More...
 
virtual void QueueSetCacheCountSize (InternalCaches cache, unsigned capacity)=0
 Queue task to set the maximum number of objects in internal cache. More...
 
virtual void QueueSetCacheBytesSize (InternalCaches cache, unsigned capacity)=0
 Queue task to set the maximum bytes allowed for internal cache. More...
 
virtual void QueueClearCaches (unsigned caches)=0
 Queue a task to clear an internal caches list. More...
 
virtual BoundEventHandle RegisterForEvent (const char *name, IEventHandler *handler)=0
 Expose C++ handler to be called when a specific event occurs. More...
 
virtual void UnregisterFromEvent (BoundEventHandle handle)=0
 Remove a registered C++ handler. More...
 
virtual BoundEventHandle BindCall (const char *name, IEventHandler *handler)=0
 Expose C++ handler to be called from UI. More...
 
virtual void UnbindCall (BoundEventHandle handle)=0
 Remove a bound C++ handler. More...
 
virtual void UnbindObject (const void *object)=0
 Remove all handlers bound to a specific object. More...
 
template<typename T >
void ExposeAsGlobal (const char *name, T *object)
 Expose object as global variable. More...
 
template<typename T >
void DestroyExposedObject (T *object)
 Remove exposed object from JavaScript. More...
 
virtual bool IsReadyForBindings () const =0
 Checks whether the cohtml.js bindings are initialized and ready to use. More...
 
virtual void ExecuteScript (const char *script)=0
 Execute arbitrary JavaScript code. This should be called only with a valid script context created. More...
 
virtual void AddInitialScript (const char *script)=0
 Schedules execution of JavaScript code on every page load. Can be called at any time. The scripts will be executed on the next page load in the same order they were added. More...
 
virtual void ResetInitialScripts ()=0
 Resets the list of initial scripts executed on every page load. More...
 
virtual void SetCustomSceneCompositor (renoir::ISubLayerCompositor *compositor, void *viewMetadata)=0
 Set a custom scene compositor whose callbacks will be invoked when the Renoir library processes the frontend graphics commands. More...
 
virtual void SetSceneCustomEffectRenderer (renoir::ICustomEffectRenderer *renderer, void *customEffectRendererMetadata)=0
 Set a custom effect renderer for the View. Callbacks of the interface will be invoked for elements that have the 'coh-custom-effect-name' property when the graphics library prepares the command buffer for execution. In the default rendering mode, this happens on the render thread and the same information will be handed when processing the BC_DrawCustomEffect command in the backend, which makes the use of this interface in this case redundant. If, however, you are processing the rendering commands on the game thread, callbacks will be invoked on the game thread as well. This allows clients to set parameters to custom materials in systems that require this to be done on the game thread. More...
 
virtual BinderGetBinder ()=0
 Returns a pointer to the internal binder. More...
 
Triggering events

These overloads trigger an event in JavaScript with the supplied arguments

virtual void TriggerEvent (const char *name)=0
 Triggers a UI event. More...
 
template<typename T1 >
void TriggerEvent (const char *name, const T1 &argument1)
 Triggers a UI event. More...
 
template<typename T1 , typename T2 >
void TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2)
 Triggers a UI event. More...
 
template<typename T1 , typename T2 , typename T3 >
void TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3)
 Triggers a UI event. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4)
 Triggers a UI event. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4, const T5 &argument5)
 Triggers a UI event. More...
 

Data-binding

Methods related to data-binding

typedef void(* CoherentInternalBindGenericFunc) (cohtml::Binder *, void *)
 
template<typename T >
void CreateModel (const char *name, T *model)
 Creates a model for binding. More...
 
template<typename T >
void UpdateWholeModel (T *model)
 Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call. More...
 
virtual void SynchronizeModels ()=0
 Applies the changes accumulated by View::UpdateWholeModel and View::UpdateModelProperty to the corresponding JavaScript objects. More...
 
template<typename T >
void RegisterModel (const char *name, T *model, CoherentInternalBindGenericFunc func)
 Registers a model with a given name. More...
 
template<typename T >
void UnregisterModel (T *model)
 Unregisters a model. More...
 
virtual void DestroyExposedInstanceOfType (void *object, cohtml::TypeInfo *typeInfo)=0
 In order to identify different models internally we use a combination between a pointer to the object and a pointer to the type of the object. If you have an object where the type cannot be deduced statically during compile time, you need to provide it in a parameter to the function during runtime. More...
 
virtual void UpdateWholeModelOfType (void *model, cohtml::TypeInfo *typeInfo)=0
 Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call. More...
 
virtual void UnregisterModelOfType (void *model, cohtml::TypeInfo *typeInfo)=0
 Unregisters a model. More...
 
virtual void RegisterModelOfType (const char *name, void *model, cohtml::TypeInfo *typeInfo, CoherentInternalBindGenericFunc func)=0
 Registers a model with a given name. More...
 
virtual void * ReservedMethod (void *command, void *data)=0
 Reserved method for internal usage. Do not use. More...
 

Detailed Description

The View represents a UI page with its DOM, styles and JavaScript context. Think of the View as a whole UI or UI element. The View for instance could be the whole HUD of a game.

Member Typedef Documentation

◆ CoherentInternalBindGenericFunc

typedef void(* cohtml::View::CoherentInternalBindGenericFunc) (cohtml::Binder *, void *)

Constructor & Destructor Documentation

◆ ~View()

virtual cohtml::View::~View ( )
virtual

Member Function Documentation

◆ AddInitialScript()

virtual void cohtml::View::AddInitialScript ( const char *  script)
pure virtual

Schedules execution of JavaScript code on every page load. Can be called at any time. The scripts will be executed on the next page load in the same order they were added.

Parameters
scriptcode to be evaluated in the context of the main frame of the view

◆ Advance()

virtual unsigned cohtml::View::Advance ( TimePoint  timeMilliseconds)
pure virtual

Advances the internal timer of the View and runs all animations. If changes have happened in the page, this call will also trigger a new layout and render on the other threads.

Parameters
timeMillisecondsthe time in milliseconds since arbitrary point in time. The time must be monotonically increasing

◆ BeginCaptureDebugFrame()

virtual void cohtml::View::BeginCaptureDebugFrame ( void *  userData,
FrameCaptureCallback  callback,
CaptureMode  mode = CM_PreserveAll 
)
pure virtual

Will begin serializing every rendered frame to a memory blob which will be passed in the callback. The saved frames can be inspected for debug purposes.

Note
If you need to capture whole screen call ContinuousRepaint(true) to redraw the whole screen.
Warning
the option must be used only for debug and performance measurements. It slows down the application significantly.
Parameters
userDataopaque pointer which will be passed in the callback
callbackPointer to function which will be called with the serialized data. The callback will be called on the Main thread.
modeObfuscation behaviour to use when capturing frames
Note
Call Release() on the FrameCapture object to release the memory allocated for the data.
callback will be called on the Main thread

◆ BindCall()

virtual BoundEventHandle cohtml::View::BindCall ( const char *  name,
IEventHandler handler 
)
pure virtual

Expose C++ handler to be called from UI.

Parameters
namename for the handler in the UI
handlerhandler to be executed
Returns
bound handle so the handler can be unbound later
Note
BindCall takes ownership of the handler
Warning
Any object in the handler must be valid until cohtml::IViewListener::OnBindingsReleased is called or the handler is unbound with cohtml::View::UnbindCall

◆ CaptureSingleDebugFrame()

virtual void cohtml::View::CaptureSingleDebugFrame ( void *  userData,
FrameCaptureCallback  callback,
CaptureMode  mode = CM_PreserveAll 
)
pure virtual

Will serialize next rendered frame to a memory blob which will be passed in the callback. The saved frames can be inspected for debug purposes.

Note
If you need to capture whole screen call ContinuousRepaint(true) to redraw the whole screen.
Warning
the option must be used only for debug and performance measurements. It slows down the application significantly.
Parameters
userDataopaque pointer which will be passed in the callback
callbackPointer to function which will be called with the serialized data. The callback will be called on the Main thread.
modeObfuscation behaviour to use when capturing the frame
Note
Call Release() on the FrameCapture object to release the memory allocated for the data.
callback will be called on the Main thread

◆ ClearNavigationHistory()

virtual void cohtml::View::ClearNavigationHistory ( )
pure virtual

Clears the navigation history accessed from JavaScript History object Use that method after View::LoadURL to reset the navigation history in case the view is reused to display unrelated page.

◆ ContinuousRepaint()

virtual void cohtml::View::ContinuousRepaint ( bool  enable)
pure virtual

Debugging flag. This will cause the View to re-draw itself each frame.

Parameters
enablewhether to enable the continuous repaint mode
Note
this flag will have a significant impact on performance. Use for debugging purposes ONLY.

◆ CreateModel()

template<typename T >
void cohtml::View::CreateModel ( const char *  name,
T *  model 
)
inline

Creates a model for binding.

Parameters
namethe name for the model
modelpointer to the object used as model (must be even aligned)
Warning
The model pointer must remain valid until cohtml::IViewListener::OnBindingsReleased is called or unregistered with cohtml::View::UnregisterModel

◆ DebugDumpDOMTree()

virtual DebugDump* cohtml::View::DebugDumpDOMTree ( unsigned  flags)
pure virtual

Debugging helper. Collects a comprehensive DOM structure dump.

◆ DebugDumpStackingContextTree()

virtual DebugDump* cohtml::View::DebugDumpStackingContextTree ( )
pure virtual

Debugging helper. Collects data about stacking context subtrees of the DOM tree.

◆ Destroy()

virtual void cohtml::View::Destroy ( )
pure virtual

Destroys the View. Should be called before the destruction of the System and Library.

◆ DestroyExposedInstanceOfType()

virtual void cohtml::View::DestroyExposedInstanceOfType ( void *  object,
cohtml::TypeInfo *  typeInfo 
)
pure virtual

In order to identify different models internally we use a combination between a pointer to the object and a pointer to the type of the object. If you have an object where the type cannot be deduced statically during compile time, you need to provide it in a parameter to the function during runtime.

If you know the type of the object during compilation you can use template API CreateModel, UnregisterModel etc. If your object has a dynamic type (for example it may come from other VM) you must use their counterpart with the FromType postfix, listed below. The following code is an example on how you can get TypeInfo from the Binder:


binder->SetMode(Binder::BM_GetTypeInfo); binder->BeginType(); Add the properties and methods for your type, using RegisterType, AddProperty, etc. binder->EndType(model); auto typeInfo = binder->GetTypeInfo(); Remove exposed object from JavaScript

Parameters
objectthe C++ object to be removed from JavaScript
typeInfoused to identify exactly which object on this address you want to destroy.

◆ DestroyExposedObject()

template<typename T >
void cohtml::View::DestroyExposedObject ( T *  object)
inline

Remove exposed object from JavaScript.

Parameters
objectthe C++ object that to be removed from JavaScript

◆ EmitRenderingMetadata()

virtual void cohtml::View::EmitRenderingMetadata ( bool  emit)
pure virtual

Debugging flag. Enabling this will request the library to attach and emit metadata for every rendering command in the rendering backend. The metadata will contain the ID, CLASS and Node type of the Element that caused the drawing command. As multiple elements can be batched in the same command, the metadata will be a concatenated list of all Elements that have contributed to the batch. The user can emit the metadata in rendering & GPU debugging tools like PIX, RenderDoc, Razor etc. in order to gain better insight on the rendering operations & performance.

Parameters
emitwhether to emit or not the metadata - disabled by default
Note
The option should only be used during development as it has a percievable CPU cost associated.

◆ EnableRendering()

virtual void cohtml::View::EnableRendering ( bool  value)
pure virtual

Enables or disables the recording of rendering commands for the view. Enabled by default.

Parameters
valuewhether to enable the recording of rendering commands
Note
You must still call Paint for resource management on the GPU.

◆ EndCaptureDebugFrame()

virtual void cohtml::View::EndCaptureDebugFrame ( )
pure virtual

Ends serializing rendered frames.

◆ ExecuteScript()

virtual void cohtml::View::ExecuteScript ( const char *  script)
pure virtual

Execute arbitrary JavaScript code. This should be called only with a valid script context created.

Parameters
scriptcode to be evaluated in the context of the main frame of the view

◆ ExposeAsGlobal()

template<typename T >
void cohtml::View::ExposeAsGlobal ( const char *  name,
T *  object 
)
inline

Expose object as global variable.

Parameters
namename of the global variable
objectthe instance for the global variable
Warning
The object pointer must remain valid until cohtml::IViewListener::OnBindingsReleased is called or destroyed with cohtml::View::DestroyExposedObject

◆ GestureEvent()

virtual void cohtml::View::GestureEvent ( const cohtml::GestureEventData event,
bool *  handled,
void *  userData 
)
pure virtual

Sends a gesture input event to the View.

Parameters
eventa gesture event
handleda deprecated parameter, you should pass nullptr.
userDataan opaque pointer passed to the ViewListener::OnNodeGestureEvent method. Can be nullptr.

◆ GetBinder()

virtual Binder* cohtml::View::GetBinder ( )
pure virtual

Returns a pointer to the internal binder.

◆ GetCacheBytesStats()

virtual void cohtml::View::GetCacheBytesStats ( InternalCaches  cache,
unsigned &  filled,
unsigned &  capacity 
)
pure virtual

Get info about the bytes statistic of a particular internal cache.

Warning
only the ICACHE_Textures and the ICACHE_ScratchLayerTextures have the bytes statistic
Note
the filled bytes in cache can be higher than the capacity, because some caches are pruned at the end of the frame.
Parameters
cachespecifies for which cache to return the info about the bytes statistic
filledbytes in the cache
capacitymaximum bytes that the cache can contain

◆ GetCacheCountStats()

virtual void cohtml::View::GetCacheCountStats ( InternalCaches  cache,
unsigned &  filled,
unsigned &  capacity 
)
pure virtual

Get info about the number of objects statistic of a particular internal cache.

Warning
the ICACHE_ScratchLayerTextures doesn't currently have the count statistic
Note
the filled count in cache can be higher than the capacity, because some caches are pruned at the end of the frame.
Parameters
cachespecifies for which cache to return the info about the count statistic
fillednumber of existing objects in the cache
capacitymaximum number of objects that can coexist in the cache

◆ GetHeight()

virtual unsigned cohtml::View::GetHeight ( ) const
pure virtual

Gets the View height.

◆ GetId()

virtual unsigned cohtml::View::GetId ( ) const
pure virtual

Returns the unique ID of the View.

◆ GetStartPanThreshold()

virtual float cohtml::View::GetStartPanThreshold ( ) const
pure virtual

Returns the minumum length of pans to be performed.

◆ GetTaskFamilyId()

virtual TaskFamilyId cohtml::View::GetTaskFamilyId ( ) const
pure virtual

Returns the Task Family Id that can be used to schedule Layout work in an auxiliary thread.

◆ GetUsedImagesList()

virtual ImagesList* cohtml::View::GetUsedImagesList ( ImagesListExtract::Options  options) const
pure virtual

Return a list of images currently in use by the View The list can be used to decide which images to pre-load or use for JS-based loading screens. The list is a current snapshot of the state of the View. Once built it will not change even if the View does. The user has to call the method again if she wants such changes applied.

Returns
An object that represents an iterator over the list
Note
Call the Release method on the returned ImagesList to reclaim its memory.

◆ GetWidth()

virtual unsigned cohtml::View::GetWidth ( ) const
pure virtual

Gets the View width.

◆ IMECancelComposition()

virtual bool cohtml::View::IMECancelComposition ( )
pure virtual

Cancels the current IME composition.

Returns
the outcome of the operation (will fail if there isn't a focused input field)

◆ IMEConfirmComposition()

virtual bool cohtml::View::IMEConfirmComposition ( const char *  composition)
pure virtual

Confirms the current IME composition.

Parameters
compositionthe string to confirm
Returns
the outcome of the operation (will fail if there isn't a focused input field)

◆ IMESetComposition()

virtual bool cohtml::View::IMESetComposition ( const char *  composition,
unsigned  targetStart,
unsigned  targetEnd 
)
pure virtual

Updates the internal state of the IME composition in the View.

Parameters
compositionthe composition string so far
targetStartthe index at the start of the selection
targetEndthe index at the end of the selection
Returns
the outcome of the operation (will fail if there isn't a focused input field)

◆ IsReadyForBindings()

virtual bool cohtml::View::IsReadyForBindings ( ) const
pure virtual

Checks whether the cohtml.js bindings are initialized and ready to use.

Returns
true, if the view is ready to accept JavaScript bindings, false otherwise.

◆ KeyEvent()

virtual void cohtml::View::KeyEvent ( const cohtml::KeyEventData event,
bool *  handled,
void *  userData 
)
pure virtual

Sends a keyboard input event to the View.

Parameters
eventa keyboard event
handleda deprecated parameter, you should pass nullptr.
userDataan opaque pointer passed to the ViewListener::OnNodeMouseEvent method. Can be nullptr.

◆ LoadURL()

virtual void cohtml::View::LoadURL ( const char *  url)
pure virtual

Loads a page in the View.

Parameters
urlA URL for the page to be loaded. Must be a valid URL. Spaces aren't allowed.
Note
Calling View::LoadURL pushes states in the navigation history. If thats undesired, call View::ClearNavigationHistory next.

◆ MouseEvent()

virtual void cohtml::View::MouseEvent ( const cohtml::MouseEventData event,
bool *  handled,
void *  userData 
)
pure virtual

Sends a mouse input event to the View.

Parameters
eventa mouse event
handleda deprecated parameter, you should pass nullptr.
userDataan opaque pointer passed to the ViewListener::OnNodeMouseEvent method. Can be nullptr.

◆ OnListenerLost()

virtual void cohtml::View::OnListenerLost ( )
pure virtual

Informs the View that its listener has been lost.

◆ QueueClearCaches()

virtual void cohtml::View::QueueClearCaches ( unsigned  caches)
pure virtual

Queue a task to clear an internal caches list.

Note
This takes effect at the next Advance/Paint cycle
Parameters
cachesa bit field listing all caches to clear

◆ QueueSetCacheBytesSize()

virtual void cohtml::View::QueueSetCacheBytesSize ( InternalCaches  cache,
unsigned  capacity 
)
pure virtual

Queue task to set the maximum bytes allowed for internal cache.

Note
This takes effect at the next Advance/Paint cycle
Warning
only the ICACHE_Textures and the ICACHE_ScratchLayerTextures have the bytes statistic
Parameters
cachespecifies for which cache to set the count size
capacitymaximum bytes allowed in the cache

◆ QueueSetCacheCountSize()

virtual void cohtml::View::QueueSetCacheCountSize ( InternalCaches  cache,
unsigned  capacity 
)
pure virtual

Queue task to set the maximum number of objects in internal cache.

Note
This takes effect at the next Advance/Paint cycle
Warning
the ICACHE_ScratchLayerTextures doesn't have this statistic
Parameters
cachespecifies for which cache to set the bytes size
capacitymaximum number of objects allowed in the cache

◆ RegisterForEvent()

virtual BoundEventHandle cohtml::View::RegisterForEvent ( const char *  name,
IEventHandler handler 
)
pure virtual

Expose C++ handler to be called when a specific event occurs.

Parameters
namename of the event
handlerhandler to be executed
Returns
bound handle so the handler can be unregistered
Note
RegisterForEvent takes ownership of the handler
Warning
Any object in the handler must be valid until cohtml::IViewListener::OnBindingsReleased is called or the handler is unregistered with cohtml::View::UnregisterFromEvent

◆ RegisterModel()

template<typename T >
void cohtml::View::RegisterModel ( const char *  name,
T *  model,
CoherentInternalBindGenericFunc  func 
)
inline

Registers a model with a given name.

Parameters
namethe name of the model
modelthe model pointer (must be even aligned)
funcoverload of CoherentBindInternal for the custom type
Warning
For internal use only. Use View::CreateModel to create a model, which wraps the usage of this internal method.

◆ RegisterModelOfType()

virtual void cohtml::View::RegisterModelOfType ( const char *  name,
void *  model,
cohtml::TypeInfo *  typeInfo,
CoherentInternalBindGenericFunc  func 
)
pure virtual

Registers a model with a given name.

Parameters
namethe name of the model
modelthe model pointer (must be even aligned)
typeInfoused to identify exactly which object on this address you want to register.
funcfunction that will be used to bind instances of this type

◆ Reload()

virtual void cohtml::View::Reload ( )
pure virtual

Reloads the current page in the view.

◆ ReservedMethod()

virtual void* cohtml::View::ReservedMethod ( void *  command,
void *  data 
)
pure virtual

Reserved method for internal usage. Do not use.

◆ ResetInitialScripts()

virtual void cohtml::View::ResetInitialScripts ( )
pure virtual

Resets the list of initial scripts executed on every page load.

◆ Resize()

virtual void cohtml::View::Resize ( unsigned  width,
unsigned  height 
)
pure virtual

Resizes the View contents.

Note
You must also update the texture for the ViewRenderer with the SetRenderTarget method
Parameters
widththe new width of the View
heightthe new height of the View

◆ SetAdditionalFontFallbacks()

virtual bool cohtml::View::SetAdditionalFontFallbacks ( const char *  fontFamilies)
pure virtual

Sets fallback font families that will be used by all elements. Additional font families do not affect computed styles of an element.

Parameters
fontFamiliesfont families to be applied (use CSS font-family property format: "Arial, Roboto")
Returns
if font families were parsed or cleared successfully. The value was not changed if return value is false
Note
pass nullptr or empty string to clear additional fallbacks.

◆ SetCustomSceneCompositor()

virtual void cohtml::View::SetCustomSceneCompositor ( renoir::ISubLayerCompositor *  compositor,
void *  viewMetadata 
)
pure virtual

Set a custom scene compositor whose callbacks will be invoked when the Renoir library processes the frontend graphics commands.

Parameters
compositorThe compositor instance that the View will use to invoke callbacks
viewMetadataCustom metadata passed to the renoir::ISubLayerCompositor::OnDrawSubLayer callback into the renoir::ISubLayerCompositor::DrawData::CustomSceneMetadata field
Warning
The compositor instance passed must outlive the View.
Note
The DOM tree can be divided into "sublayers" for rendering purposes. Each sublayer is drawn to an off-screen texture and then composed back to the original render target. Setting a custom compositor allows the user to do the composition themselves, and even use the data from the renoir::ISubLayerCompositor callbacks to draw the sublayer practically anywhere, on any render target (not necessarily the originally intended one).
See the documentation for custom composition for more details.

◆ SetResolutionForRendering()

virtual void cohtml::View::SetResolutionForRendering ( unsigned  width,
unsigned  height 
)
pure virtual

Sets a resolution for rendering. This allows setting one size for the HTML (via the Resize method) and authoring the UI for that resolution, while here you can tell the SDK that it should render the UI into a different-sized texture. The ViewRenderer's render target could be of a different size, although usually you'd want to have the resolution for rendering and ViewRenderer RT size to be the same.

Note
This API is useful for implementing a LOD system
Parameters
widththe width component of the resolution to render to
heightthe height component of the resolution to render to

◆ SetSceneCustomEffectRenderer()

virtual void cohtml::View::SetSceneCustomEffectRenderer ( renoir::ICustomEffectRenderer *  renderer,
void *  customEffectRendererMetadata 
)
pure virtual

Set a custom effect renderer for the View. Callbacks of the interface will be invoked for elements that have the 'coh-custom-effect-name' property when the graphics library prepares the command buffer for execution. In the default rendering mode, this happens on the render thread and the same information will be handed when processing the BC_DrawCustomEffect command in the backend, which makes the use of this interface in this case redundant. If, however, you are processing the rendering commands on the game thread, callbacks will be invoked on the game thread as well. This allows clients to set parameters to custom materials in systems that require this to be done on the game thread.

Parameters
rendererThe custom effect renderer instance that will receive callbacks.
customEffectRendererMetadataCustom metadata passed as-is in the renoir::DrawCustomEffectCmd::UserData field within the structure passed to the backend

◆ SetStartPanThreshold()

virtual void cohtml::View::SetStartPanThreshold ( float  value)
pure virtual

Sets the minumum length of pans to be performed.

Parameters
valuethe minumum length in pixels

◆ SetUserAgent()

virtual void cohtml::View::SetUserAgent ( const char *  userAgent)
pure virtual

Sets the User Agent string.

Parameters
userAgentthe user agent string

◆ SetUserBackground()

virtual void cohtml::View::SetUserBackground ( void *  userTexture,
const renoir::Texture2D &  description 
)
pure virtual

The background where the UI scene will be drawn.

Parameters
userTexturePointer to a user-defined representation of the texture. Will be passed as-is to the graphics backend.
descriptionDescription of the provided texture. The most relevant fields are Width, Height, ContentRectX, ContentRectY,
Note
With the ContentRectX abd ContentRectY fields you can pass offset of the user background relative to the UI texture for this view. That is, where execatly will the top left corner of the UI texture end up in the user background ContentRectWidth, and ContentRectHeight

◆ SetUserBackgroundOffset()

virtual void cohtml::View::SetUserBackgroundOffset ( float  x,
float  y 
)
pure virtual

Set the user background offest. This has to be the location of the upper left corner of the UI texture relative to the upper left corner of the user backgorund texture.

Parameters
xThe x coordinate of the upper left corner where the UI texture will be drawn
yThe y coordinate of the upper left corner where the UI texture will be drawn

◆ ShowElementAABBs()

virtual void cohtml::View::ShowElementAABBs ( bool  show)
pure virtual

Debugging flag. This will cause the View to draw the bounding-boxes of all elements.

Parameters
showwhether to show the bounding-boxes of elements

◆ ShowPaintRectangles()

virtual void cohtml::View::ShowPaintRectangles ( bool  show)
pure virtual

Debugging flag. This will cause the View show which parts of the texture are re-drawn each frame.

Parameters
showwhether to show the paint rectangles

◆ SynchronizeModels()

virtual void cohtml::View::SynchronizeModels ( )
pure virtual

Applies the changes accumulated by View::UpdateWholeModel and View::UpdateModelProperty to the corresponding JavaScript objects.

◆ TouchEvent()

virtual void cohtml::View::TouchEvent ( const cohtml::TouchEventData events,
unsigned  count,
bool *  handled,
void *  userData 
)
pure virtual

Sends a touch input event to the View.

Parameters
eventsan array of 'count' events
countthe count of events passed
handleda deprecated parameter, you should pass nullptr.
userDataan opaque pointer passed to the ViewListener::OnNodeTouched method. Can be nullptr.

◆ TriggerEvent() [1/6]

virtual void cohtml::View::TriggerEvent ( const char *  name)
pure virtual

Triggers a UI event.

◆ TriggerEvent() [2/6]

template<typename T1 >
void cohtml::View::TriggerEvent ( const char *  name,
const T1 &  argument1 
)
inline

Triggers a UI event.

◆ TriggerEvent() [3/6]

template<typename T1 , typename T2 >
void cohtml::View::TriggerEvent ( const char *  name,
const T1 &  argument1,
const T2 &  argument2 
)
inline

Triggers a UI event.

◆ TriggerEvent() [4/6]

template<typename T1 , typename T2 , typename T3 >
void cohtml::View::TriggerEvent ( const char *  name,
const T1 &  argument1,
const T2 &  argument2,
const T3 &  argument3 
)
inline

Triggers a UI event.

◆ TriggerEvent() [5/6]

template<typename T1 , typename T2 , typename T3 , typename T4 >
void cohtml::View::TriggerEvent ( const char *  name,
const T1 &  argument1,
const T2 &  argument2,
const T3 &  argument3,
const T4 &  argument4 
)
inline

Triggers a UI event.

◆ TriggerEvent() [6/6]

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void cohtml::View::TriggerEvent ( const char *  name,
const T1 &  argument1,
const T2 &  argument2,
const T3 &  argument3,
const T4 &  argument4,
const T5 &  argument5 
)
inline

Triggers a UI event.

◆ UnbindCall()

virtual void cohtml::View::UnbindCall ( BoundEventHandle  handle)
pure virtual

Remove a bound C++ handler.

Parameters
handlethe handle of the handler to be unbound
Warning
Unbinding a handler inside the handler callback is not supported and will result in undefined behavior

◆ UnbindObject()

virtual void cohtml::View::UnbindObject ( const void *  object)
pure virtual

Remove all handlers bound to a specific object.

Parameters
objectthe object whose handlers will be removed
Warning
Unbinding the object inside the handler callback is not supported and will result in undefined behavior

◆ UnloadDocument()

virtual void cohtml::View::UnloadDocument ( )
pure virtual

Unloads the HTML document. This will remove the entire DOM tree, so nothing will rendered but the view object will still be usable and another document might be loaded using View::LoadURL.

◆ UnregisterFromEvent()

virtual void cohtml::View::UnregisterFromEvent ( BoundEventHandle  handle)
pure virtual

Remove a registered C++ handler.

Parameters
handlethe handle of the event handler to be unregistered
Warning
Unregistering a handler inside the handler callback is not supported and will result in undefined behavior

◆ UnregisterModel()

template<typename T >
void cohtml::View::UnregisterModel ( T *  model)
inline

Unregisters a model.

Parameters
modelthe model to be unregistered.
Note
The global variable for the model in JavaScript will be deleted as well

◆ UnregisterModelOfType()

virtual void cohtml::View::UnregisterModelOfType ( void *  model,
cohtml::TypeInfo *  typeInfo 
)
pure virtual

Unregisters a model.

Parameters
modelthe model to be unregistered.
typeInfoused to identify exactly which object on this address you want to unregister.
Note
The global variable for the model in JavaScript will be deleted as well

◆ UpdateWholeModel()

template<typename T >
void cohtml::View::UpdateWholeModel ( T *  model)
inline

Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call.

Parameters
modelthe model to be marked as dirty

◆ UpdateWholeModelOfType()

virtual void cohtml::View::UpdateWholeModelOfType ( void *  model,
cohtml::TypeInfo *  typeInfo 
)
pure virtual

Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call.

Parameters
modelthe model to be marked as dirty
typeInfoused to identify exactly which object on this address you want to update.