Class that encapsulates a UI View (an HTML5 page and JS context) Provides all manipulation and query functions for the view. More...
#include <Coherent/Coherent/UIGT/View.h>
Public Member Functions | |
virtual void | Destroy ()=0 |
Destroys this view. More... | |
virtual unsigned | GetId () const =0 |
Returns a unique id of the View. More... | |
virtual const char * | GetTitle () const =0 |
Gets the "<title>" of the View. More... | |
virtual const char * | GetInputGroupUnderCoordinates (float normX, float normY) const =0 |
Gets the value of the data-input-group attribute of the element under the given mouse coordinates. If the element does not have the attribute, it will return the value of the attribute of the first ancestor that has it. Useful when you need to customize mouse queries and need extra data besides whether the mouse is on the view. More... | |
virtual unsigned | GetWidth ()=0 |
Gets the width of the View. More... | |
virtual unsigned | GetHeight ()=0 |
Gets the height of the View. More... | |
virtual void | Resize (int width, int height)=0 |
Resizes the View contents. More... | |
virtual void | KeyEvent (const Coherent::UIGT::KeyEventData &event)=0 |
Sends a key event to the UI renderer. More... | |
virtual void | MouseEvent (const Coherent::UIGT::MouseEventData &event)=0 |
Sends a mouse event to the UI renderer. More... | |
virtual void | SetFocus ()=0 |
Sets this view on focus. This must be called in order for the text caret to appear. | |
virtual void | KillFocus ()=0 |
Removes the focus from this view. | |
virtual bool | IsTransparent () const =0 |
Tells if this view is transparent or not. More... | |
virtual unsigned | Layout ()=0 |
Layouts the content of the page. You should call this method each frame after calling Advance on the UI system. More... | |
virtual void | ExecuteJSTimers ()=0 |
Executes all JS timers (setTimeout/requestAnimationFrame) for the View. More... | |
virtual void | UpdateStylesAndLayout ()=0 |
Updates the styles of the View and performs an eventual re-layout of it. More... | |
virtual unsigned | RecordRenderingCommands ()=0 |
Records rendering commands that will later be replayed in the "Paint(frameId)" method. More... | |
virtual bool | HasLastLayoutCompleted ()=0 |
Checks whether the last issued Layout operation has completed. More... | |
virtual void | ShowPaintRects (bool show)=0 |
Will render the rects in the page that get re-drawn each frame. More... | |
virtual void | ShowLayerBorders (bool show)=0 |
Will render the borders of the layers in the page. More... | |
virtual const char * | GetLastLoadedURL () const =0 |
Returns the last loaded URL by the View. More... | |
virtual bool | IsDocumentReady () const =0 |
Tells if the Document object is ready in JS. More... | |
virtual void | StopLoading ()=0 |
Interrupts the loading process of the View. More... | |
virtual void | LoadURL (const char *url, ViewLoadPolicy policy=VLP_UseCacheOrLoad)=0 |
Loads a new page in the View. More... | |
virtual void | Reload ()=0 |
Reloads the current HTML5 page. | |
virtual void | RedrawAll ()=0 |
Causes the whole frame to be re-submitted for painting. | |
virtual bool | CanGoBack () const =0 |
Tells if the View can go back in history. More... | |
virtual bool | GoBack ()=0 |
Goes back in the View history. More... | |
virtual bool | CanGoForward () const =0 |
Tells if the View can go forward in history. More... | |
virtual bool | GoForward ()=0 |
Goes forward in the View history. More... | |
virtual bool | CookiesEnabled () const =0 |
Tells if cookies are enabled for this View. More... | |
virtual bool | IsMouseOnView ()=0 |
Checks if the mouse is currently on the logical view (a part of the view that has elements on it) or not (click-through). Uses the coordinates last set in IssueMouseOnUIQuery. More... | |
virtual void | SetMediaType (MediaType type)=0 |
Change the media type of the view. More... | |
virtual bool | IMESetComposition (const char *composition, unsigned cursorPos, 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 void | SetClickThroughAlphaThreshold (float threshold)=0 |
The alpha value of the pixels is used to determine if the mouse is on an element or on the background (click-through). All pixels below or equal to the alpha threshold (default = 0) are marked as not-belonging to the View and IsMouseOnView for them return false. More... | |
virtual float | GetClickThroughAlphaThreshold () const =0 |
Get the currently set alpha threshold for click-through queries. More... | |
virtual float | GetAnimationFrameDefer () const =0 |
Returns the minimum delay between animation frames in seconds. More... | |
virtual void | SetAnimationFrameDefer (float valueSec)=0 |
Sets the minimum delay between animation frames in seconds. More... | |
virtual bool | GetOffscreenCanvasRendering () const =0 |
Returns offscreen canvas command execution mode. More... | |
virtual void | SetOffscreenCanvasRendering (bool force)=0 |
Sets the offscreen canvas command execution mode. More... | |
virtual void | EnableOnScreenPerformanceInfo (bool enable, unsigned x=0u, unsigned y=0u)=0 |
Will display performance information on-screen. Enabling this option will also force compositing mode on the View. More... | |
virtual void | BeginCaptureDebugFrame (void *userData, FrameCaptureCallback callback)=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. | |
virtual void | CaptureSingleDebugFrame (void *userData, FrameCaptureCallback callback)=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. This will force redraw of the whole UI for the frame. More... | |
virtual void | AuditPerformance (bool shouldDisplayOnScreen=false, const char *frameSelector=nullptr)=0 |
Executes an auditing script that detects sub-optimal parts of your UI and reports them on screen and via ViewListener::OnPerformanceAudit. By default the main frame will be audited but you can specify a CSS selector to any iframe in the page. More... | |
virtual void | InspectorTimelineBeginEvent (const char *name)=0 |
Marks the beginning of an event in the Inspector timeline. Events must be 'ended' with InspectorTimelineEndEvent to get a measure of their duration. More... | |
virtual void | InspectorTimelineEndEvent (const char *name)=0 |
Marks the end of an event in the Inspector timeline. 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 void | SetScriptError (ScriptCallErrorType error, const char *message)=0 |
Sets an error for the currently executing handler. 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, Binder::BindingMode mode=Binder::BindingMode::BM_ScopedUnsafe) |
Expose object as global variable. More... | |
template<typename T > | |
void | RemoveExposedInstance (T *object) |
Remove exposed object from JavaScript. More... | |
virtual void | RemoveExposedArray (void *array)=0 |
Remove exposed array from JavaScript. More... | |
virtual bool | IsReadyForBindings () const =0 |
Checks whether the coherent.js bindings are initialized and ready to use. More... | |
virtual void | ExecuteScript (const char *script, const char *frameSelector=nullptr)=0 |
Execute arbitrary JavaScript code in a given frame in the page. By default the code will be executed inside the main frame but you can specify a CSS selector to any iframe in the page. More... | |
template<typename T > | |
ModelHandle | CreateModel (const char *name, T *model, Binder::BindingMode mode=Binder::BindingMode::BM_ScopedUnsafe) |
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... | |
template<typename T > | |
void | UpdateModelProperty (T *model, Property *prop) |
Marks a model's property as dirty. The property will be synchronized using the View::SynchronizeModels call. More... | |
template<typename T > | |
void | UpdateModelArrayPropertyIndex (T *model, Property *prop, size_t index) |
Marks a model's item at a specified index for a given property as dirty. The property will be synchronized using the View::SynchronizeModels call. More... | |
virtual void | SetZoom (ZoomType type, float value)=0 |
Sets the zoom value of the view. More... | |
virtual float | GetZoom (ZoomType type)=0 |
Returns the current zoom level for the given zoom type. More... | |
virtual void | RegisterModel (const char *name, void *model)=0 |
Registers a model with a given name. More... | |
template<typename T > | |
ComponentHandle | InstantiateComponent (const char *name, const char *selector, T *model=nullptr) |
Instantiates data binding component. More... | |
virtual void | RemoveInstantiateComponent (ComponentHandle instance)=0 |
Removes an instance of a data binding component. More... | |
template<typename T > | |
void | UnregisterModel (T *model) |
Unregisters a model. More... | |
virtual void | SynchronizeModels ()=0 |
Applies the changes accumulated by View::UpdateWholeModel and View::UpdateModelProperty to the corresponding JavaScript objects. | |
template<typename T > | |
const char * | GetModelTypename (T *model) |
Gets tye typename for a given model. More... | |
template<typename T > | |
TypeInfo * | CoherentGetTypeInfo (T *model) |
Triggering events | |
These overloads trigger an event in JavaScript with the supplied arguments | |
virtual void | TriggerEvent (const char *name)=0 |
Triggers a UI event. | |
template<typename T1 > | |
void | TriggerEvent (const char *name, const T1 &argument1) |
Triggers a UI event. | |
template<typename T1 , typename T2 > | |
void | TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2) |
Triggers a UI event. | |
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. | |
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. | |
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. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
void | TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4, const T5 &argument5, const T6 &argument6) |
Triggers a UI event. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > | |
void | TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4, const T5 &argument5, const T6 &argument6, const T7 &argument7) |
Triggers a UI event. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > | |
void | TriggerEvent (const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4, const T5 &argument5, const T6 &argument6, const T7 &argument7, const T8 &argument8) |
Triggers a UI event. | |
Class that encapsulates a UI View (an HTML5 page and JS context) Provides all manipulation and query functions for the view.
|
pure virtual |
Executes an auditing script that detects sub-optimal parts of your UI and reports them on screen and via ViewListener::OnPerformanceAudit. By default the main frame will be audited but you can specify a CSS selector to any iframe in the page.
shouldDisplayOnScreen | whether to display the resulting report as an overlay on the page |
frameSelector | CSS selector to the target iframe. Leave nullptr if for the main frame. |
|
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.
userData | opaque pointer which will be passed in the callback |
callback | Pointer to function which will be called with the serialized data. The callback will be called on the Main thread. |
|
pure virtual |
Expose C++ handler to be called from UI.
name | name for the handler in the UI |
handler | handler to be executed |
|
pure virtual |
Tells if the View can go back in history.
|
pure virtual |
Tells if the View can go forward in history.
|
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. This will force redraw of the whole UI for the frame.
userData | opaque pointer which will be passed in the callback |
callback | Pointer to function which will be called with the serialized data. The callback will be called on the Main thread. |
|
inline |
model | the model which would be checked for existing TypeInfo |
|
pure virtual |
Tells if cookies are enabled for this View.
|
inline |
Creates a model for binding.
name | the name for the model |
model | pointer to the object used as model |
|
pure virtual |
Destroys this view.
|
pure virtual |
Will display performance information on-screen. Enabling this option will also force compositing mode on the View.
enable | Whether to enable or disable the perf info. |
x | Screen x (in pixels) position of the performance info. |
y | Screen y (in pixels) position of the performance info. |
|
pure virtual |
Executes all JS timers (setTimeout/requestAnimationFrame) for the View.
always
call in turn ExecuteJSTimers(), UpdateStylesAndLayout() and RecordRenderingCommands(). The functions are split for easier profiling. You can also call just "Layout" that internally calls all of them.
|
pure virtual |
Execute arbitrary JavaScript code in a given frame in the page. By default the code will be executed inside the main frame but you can specify a CSS selector to any iframe in the page.
script | code to be evaluated in the context of the main frame of the view |
frameSelector | CSS selector to the target iframe. Leave nullptr if for the main frame. |
|
inline |
Expose object as global variable.
name | name of the global variable |
object | the instance of the global variable |
|
pure virtual |
Returns the minimum delay between animation frames in seconds.
|
pure virtual |
Get info about the bytes statistic of a particular internal cache.
cache | specifies for which cache to return the info about the bytes statistic |
filled | bytes in the cache |
capacity | maximum bytes that the cache can contain |
|
pure virtual |
Get info about the number of objects statistic of a particular internal cache.
cache | specifies for which cache to return the info about the count statistic |
filled | number of existing objects in the cache |
capacity | maximum number of objects that can coexist in the cache |
|
pure virtual |
Get the currently set alpha threshold for click-through queries.
|
pure virtual |
|
pure virtual |
|
pure virtual |
Gets the value of the data-input-group attribute of the element under the given mouse coordinates. If the element does not have the attribute, it will return the value of the attribute of the first ancestor that has it. Useful when you need to customize mouse queries and need extra data besides whether the mouse is on the view.
normX | the x coordinate of the point in the normalized space of the view [0..1] |
normY | the y coordinate of the point in the normalized space of the view [0..1] |
|
pure virtual |
Returns the last loaded URL by the View.
|
inline |
Gets tye typename for a given model.
model | the model pointer |
|
pure virtual |
Returns offscreen canvas command execution mode.
|
pure virtual |
Gets the "<title>" of the View.
|
pure virtual |
|
pure virtual |
Returns the current zoom level for the given zoom type.
type | the type of zoom for which the values is returned. |
|
pure virtual |
Goes back in the View history.
|
pure virtual |
Goes forward in the View history.
|
pure virtual |
Checks whether the last issued Layout operation has completed.
|
pure virtual |
Cancels the current IME composition.
|
pure virtual |
Confirms the current IME composition.
composition | the string to confirm |
|
pure virtual |
Updates the internal state of the IME composition in the View.
composition | the composition string so far |
cursorPos | the cursor position in the composition |
targetStart | the index at the start of the selection |
targetEnd | the index at the end of the selection |
|
pure virtual |
Marks the beginning of an event in the Inspector timeline. Events must be 'ended' with InspectorTimelineEndEvent to get a measure of their duration.
name | the 'name' of the event that will be displayed in the Timeline |
|
pure virtual |
Marks the end of an event in the Inspector timeline.
name | the 'name' of the event that will be displayed in the Timeline |
|
inline |
Instantiates data binding component.
name | The name of the component. |
selector | The element selector is a pattern used to select HTML elements based on their id, classes, types, attributes, values of attributes, etc. |
model | pointer to the object used as model |
|
pure virtual |
Tells if the Document object is ready in JS.
|
pure virtual |
Checks if the mouse is currently on the logical view (a part of the view that has elements on it) or not (click-through). Uses the coordinates last set in IssueMouseOnUIQuery.
|
pure virtual |
Checks whether the coherent.js bindings are initialized and ready to use.
|
pure virtual |
Tells if this view is transparent or not.
|
pure virtual |
Sends a key event to the UI renderer.
event | the key event |
|
pure virtual |
Layouts the content of the page. You should call this method each frame after calling Advance on the UI system.
|
pure virtual |
Loads a new page in the View.
url | the url of the new page to load |
policy | defines if the View should use cached resources or reload everything from disk/server. The parameter is important during development with the 'coui' protocol. A resource might be modified but still available in the in-memory cache. In that case the View might use the cached version ignoring the cache. It's advisable to ignore the cache if loading a View that is being actively developed. In shipped builds always use the cache as it substantially improves load-speed and resources in shipped titles should be immutable. |
|
pure virtual |
Sends a mouse event to the UI renderer.
event | the mouse event |
|
pure virtual |
Queue a task to clear an internal caches list.
caches | a bit field listing all caches to clear |
|
pure virtual |
Queue task to set the maximum bytes allowed for internal cache.
cache | specifies for which cache to set the count size |
capacity | maximum bytes allowed in the cache |
|
pure virtual |
Queue task to set the maximum number of objects in internal cache.
cache | specifies for which cache to set the bytes size |
capacity | maximum number of objects allowed in the cache |
|
pure virtual |
Records rendering commands that will later be replayed in the "Paint(frameId)" method.
always
call in turn ExecuteJSTimers(), UpdateStylesAndLayout() and RecordRenderingCommands(). The functions are split for easier profiling. You can also call just "Layout" that internally calls all of them.
|
pure virtual |
Expose C++ handler to be called when a specific event occurs.
name | name of the event |
handler | handler to be executed |
|
pure virtual |
Registers a model with a given name.
name | the name of the model |
model | the model pointer |
|
pure virtual |
Remove exposed array from JavaScript.
array | exposed array to be removed |
|
inline |
Remove exposed object from JavaScript.
object | exposed object to be removed |
|
pure virtual |
Removes an instance of a data binding component.
instance | The instance handle given from InstantiateComponent. |
|
pure virtual |
Resizes the View contents.
|
pure virtual |
Sets the minimum delay between animation frames in seconds.
valueSec | the minimum delay |
|
pure virtual |
The alpha value of the pixels is used to determine if the mouse is on an element or on the background (click-through). All pixels below or equal to the alpha threshold (default = 0) are marked as not-belonging to the View and IsMouseOnView for them return false.
threshold | sets the new alpha threshold |
|
pure virtual |
Change the media type of the view.
type | the type of media we want to change to |
|
pure virtual |
Sets the offscreen canvas command execution mode.
force | whether to force execute canvas commands every frame or to defer the execution until the canvas is visible |
|
pure virtual |
Sets an error for the currently executing handler.
error | the type of the error |
message | the error message |
|
pure virtual |
Sets the zoom value of the view.
type | the type of zoom for which the values is set. |
value | value the value by which to zoom |
|
pure virtual |
Will render the borders of the layers in the page.
show | whether to show the layers' borders or not |
|
pure virtual |
Will render the rects in the page that get re-drawn each frame.
show | whether to show the paint rectangles or not |
|
pure virtual |
Interrupts the loading process of the View.
|
pure virtual |
Remove a bound C++ handler.
handle | the handle of the handler to be unbound |
|
pure virtual |
Remove all handlers bound to a specific object.
object | the object whose handlers will be removed |
|
pure virtual |
Remove a registered C++ handler.
handle | the handle of the event handler to be unregistered |
|
inline |
Unregisters a model.
model | the model to be unregistered. |
|
inline |
Marks a model's item at a specified index for a given property as dirty. The property will be synchronized using the View::SynchronizeModels call.
model | the model instance whose property will be marked as dirty |
prop | the array property containing the item to be dirtified |
index | the index of the item within the array property that will be marked as dirty |
|
inline |
Marks a model's property as dirty. The property will be synchronized using the View::SynchronizeModels call.
model | the model instance whose property will be marked as dirty |
prop | the property to be marked as dirty |
|
pure virtual |
Updates the styles of the View and performs an eventual re-layout of it.
always
call in turn ExecuteJSTimers(), UpdateStylesAndLayout() and RecordRenderingCommands(). The functions are split for easier profiling. You can also call just "Layout" that internally calls all of them.
|
inline |
Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call.
model | the model to be marked as dirty |