Coherent UI  2.5.3
A modern user interface library for games
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Coherent::UI::ViewListener Class Referenceabstract

Interface that allows clients to listen to View events. More...

#include <Coherent/UI/ViewListener.h>

+ Inheritance diagram for Coherent::UI::ViewListener:

Public Member Functions

virtual void Release ()
 Called when the listener is no longer needed by the UI context.
 
virtual void OnViewCreated (View *view)=0
 Called when the requested View has been created and is ready to use. More...
 
virtual void OnDraw (CoherentHandle handle, bool usesSharedMemory, int width, int height)
 Called when a new surface has been drawn and is ready to use by the client. More...
 
virtual void OnFinishLoad (int frameId, const wchar_t *validatedPath, bool isMainFrame, int statusCode, HTTPHeader *headers, unsigned headersCount)
 Called when a frame has been successfully loaded. More...
 
virtual void OnFailLoad (int frameId, const wchar_t *validatedPath, bool isMainFrame, const char *error)
 Called when a frame has been failed loading. More...
 
virtual void OnURLRequest (URLRequest *request)
 Called before an URL request is made. The default implementation allows all requests. NOTE: this method will be called only when View::InterceptURLRequests(true) has been called. More...
 
virtual void OnReadyForBindings (int frameId, const wchar_t *path, bool isMainFrame)
 Called when a frame is ready for bindings. More...
 
virtual void OnBindingsReleased (int frameId, const wchar_t *path, bool isMainFrame)
 Called when the bindings for frame are released. More...
 
virtual void OnStartLoading ()
 Called when a new path has started loading.
 
virtual void OnStopLoading ()
 Called when all load operations have completed.
 
virtual void OnNavigateTo (const wchar_t *path)
 Called when the view starts navigation to a new path. More...
 
virtual void OnError (const ViewError &error)
 Called when an error occurs for this specific View. More...
 
virtual void OnScriptMessage (MessageLevel level, const wchar_t *message, const wchar_t *sourceId, int line)
 Called when a message is sent from a script running in this specific View. More...
 
virtual void OnCursorChanged (CursorTypes cursor)
 Called when the cursor has changed internally in the View. Can be used to allow the user to change the shown cursor if needed - for instance when hovering a text field etc. More...
 
virtual void OnCallback (const char *eventName, const EventArguments &arguments)
 Called by the UI when there is no registered handler for this event. More...
 
virtual void OnJavaScriptMessage (const wchar_t *message, const wchar_t *defaultPrompt, const wchar_t *frameUrl, int messageType)
 Called when the view triggered a javascript message box, i.e. an alert, confirmation dialog or a prompt dialog. More...
 
virtual void OnGetAuthCredentials (bool isProxy, const wchar_t *host, unsigned int port, const wchar_t *realm, const wchar_t *scheme)
 Called when a view requires authentication credentials. More...
 
virtual void CreateSurface (bool sharedMemory, unsigned width, unsigned height, SurfaceResponse *response)=0
 Called when the View requires a new surface to draw on. Allows the user to create the resources. Shared textures are preferred and allow for much higher performance. Shared textures must be crated as render targets. More...
 
virtual void DestroySurface (CoherentHandle surface, bool usesSharedMemory)=0
 Called when a surface is unneeded anymore and should be destroyed This function can be called from a thread different than the main UI context thread in order to support client applications with multi-threaded rendering. More...
 
virtual void OnCertificateError (const wchar_t *url, CertificateStatus status, Certificate *certificate, CertificateErrorResponse *response)
 Called when there is an error with the certificate of a particular URL. More...
 
virtual void OnRequestMediaStream (MediaStreamRequest *request)
 Called when the view requests access to a media stream. Media streams are the audio capture (microphone) and video capture (camera) devices on the system. More...
 
virtual void OnTextInputTypeChanged (TextInputControlType type, bool canComposeInline)
 Called when the current text input control changes (i.e. the user click an edit-box). Use this methof to decide when to allow for IME input. More...
 
virtual void OnCaretRectChanged (unsigned x, unsigned y, unsigned width, unsigned height)
 Called when the caret changes during IME composition. You can use this method to correctly position a custom IME control & candidate list. More...
 
virtual void OnIMEShouldCancelComposition ()
 Called when the user must cancel the IME composition due to an event in the View itself (i.e. the user has focused a non-editable element while a composition was on-going)
 
virtual bool OnCanCreateChildWindow (const wchar_t *openerUrl, const wchar_t *targetUrl, ChildViewInfo &childViewInfo)
 Called when the view wants to open a new window. More...
 
virtual void OnFileSelectRequest (FileSelectRequest *request)
 Called when the view requests file selection. It could be either single file, directory or multiple files. More...
 
virtual void OnAudioStreamCreated (int streamId, int channels, int bitDepth, int frequency)
 Called when a new WebAudio stream is created. This is usually when the page is loading (for <audio> HTML tags). More...
 
virtual void OnAudioStreamPlay (int streamId)
 Called when a WebAudio stream is played. More...
 
virtual void OnAudioStreamPause (int streamId)
 Called when a WebAudio stream is stopped. More...
 
virtual void OnAudioStreamClose (int streamId)
 Called when a WebAudio stream is closed. This is usually called when the page is unloading. More...
 

Additional Inherited Members

- Public Types inherited from Coherent::UI::ViewListenerBase
enum  MessageLevel
 Levels of script messages.
 

Detailed Description

Interface that allows clients to listen to View events.

Member Function Documentation

virtual void Coherent::UI::ViewListener::CreateSurface ( bool  sharedMemory,
unsigned  width,
unsigned  height,
SurfaceResponse response 
)
pure virtual

Called when the View requires a new surface to draw on. Allows the user to create the resources. Shared textures are preferred and allow for much higher performance. Shared textures must be crated as render targets.

Warning
The format for DirectX9 must be D3DFMT_A8R8G8B8
The format for DirectX10 and DirectX11 must be B8G8R8A8_UNORM
Parameters
sharedMemorytrue if the surface should be created in shared memory (4 * width * height bytes); false if a shared texture must be created.
widththe width of the surface in pixels
heightthe height of the surface in pixels
response- object to hold the response when the surface is created or fails it's creation - must be signaled

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::DestroySurface ( CoherentHandle  surface,
bool  usesSharedMemory 
)
pure virtual

Called when a surface is unneeded anymore and should be destroyed This function can be called from a thread different than the main UI context thread in order to support client applications with multi-threaded rendering.

Parameters
surfacehandle to the surface
usesSharedMemorydetermines whether the surface parameter is a handle to shared memory or shared texture

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnAudioStreamClose ( int  streamId)
inlinevirtual

Called when a WebAudio stream is closed. This is usually called when the page is unloading.

Parameters
streamIdthe ID of the stream that is closed

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnAudioStreamCreated ( int  streamId,
int  channels,
int  bitDepth,
int  frequency 
)
inlinevirtual

Called when a new WebAudio stream is created. This is usually when the page is loading (for <audio> HTML tags).

Parameters
streamIdthe generated ID for the new stream
channelsthe number of channels in the stream
bitDepthbits per sample in the stream
frequencythe audio stream frequency, in Hz

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnAudioStreamPause ( int  streamId)
inlinevirtual

Called when a WebAudio stream is stopped.

Parameters
streamIdthe ID of the stream that is stopped
Note
This is not called when the stream stops playing data but rather when there was nothing audible played for a certaing amount of time. The same stream is re-used if you play a track fully, wait a little and then play it again. If the waiting time exceeds a certain threshold, then this callback is invoked.
See Also
Coherent::UI::ViewListenerBase::OnAudioStreamPlay

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnAudioStreamPlay ( int  streamId)
inlinevirtual

Called when a WebAudio stream is played.

Parameters
streamIdthe ID of the stream that is played
Note
This callback is invoked when a stream starts playing.
See Also
Coherent::UI::ViewListenerBase::OnAudioStreamPause

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnBindingsReleased ( int  frameId,
const wchar_t *  path,
bool  isMainFrame 
)
inlinevirtual

Called when the bindings for frame are released.

Parameters
frameIdthe id of the frame
paththe path in the frame
isMainFrametrue if this is the main frame of the view

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnCallback ( const char *  eventName,
const EventArguments &  arguments 
)
inlinevirtual

Called by the UI when there is no registered handler for this event.

Parameters
eventNamename of the event
argumentsarguments of the event invocation

Implements Coherent::UI::ViewListenerBase.

virtual bool Coherent::UI::ViewListener::OnCanCreateChildWindow ( const wchar_t *  openerUrl,
const wchar_t *  targetUrl,
ChildViewInfo childViewInfo 
)
inlinevirtual

Called when the view wants to open a new window.

Parameters
openerUrlthe URL that wants to open the new window
targetUrlthe target URL of the new window
childViewInfostructure that the user should fill in if she's about to allow new view creation
See Also
Coherent::UI::ViewListenerBase::ChildViewInfo
Returns
true if you allow the creation of a new window, false otherwise (if false, the childViewInfo parameter is ignored)

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnCaretRectChanged ( unsigned  x,
unsigned  y,
unsigned  width,
unsigned  height 
)
inlinevirtual

Called when the caret changes during IME composition. You can use this method to correctly position a custom IME control & candidate list.

Parameters
thex position of the selection caret
they position of the selection caret
thewidth of the selection caret
theheight of the selection caret

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnCertificateError ( const wchar_t *  url,
CertificateStatus  status,
Certificate *  certificate,
CertificateErrorResponse *  response 
)
inlinevirtual

Called when there is an error with the certificate of a particular URL.

Warning
the certificate and response pointers are valid only for the duration of this call
Parameters
urlthe url of the request
statusthe error status of the certificate
certificatethe certificate details. This pointer will be valid only for this call
responseobject to signal whether to continue loading the URL. This pointer will be valid only for this call

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnCursorChanged ( CursorTypes  cursor)
inlinevirtual

Called when the cursor has changed internally in the View. Can be used to allow the user to change the shown cursor if needed - for instance when hovering a text field etc.

Parameters
cursorthe new cursor

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnDraw ( CoherentHandle  handle,
bool  usesSharedMemory,
int  width,
int  height 
)
inlinevirtual

Called when a new surface has been drawn and is ready to use by the client.

Parameters
handlea handle to one of the buffers created by CreateSurface. May be a shared memory buffer or a shared texture depending on the way the View was created. The handle is valid only during this call
usesSharedMemorydetermines whether the handle parameter is a handle to shared memory or shared texture
widththe width of the surface
heightthe height of the surface

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnError ( const ViewError error)
inlinevirtual

Called when an error occurs for this specific View.

Parameters
errorerror description

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnFailLoad ( int  frameId,
const wchar_t *  validatedPath,
bool  isMainFrame,
const char *  error 
)
inlinevirtual

Called when a frame has been failed loading.

Parameters
frameIdthe id of the frame
validatedPaththe path in the frame
isMainFrametrue if this is the main frame of the View
errorerror message for the failure

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnFileSelectRequest ( FileSelectRequest request)
inlinevirtual

Called when the view requests file selection. It could be either single file, directory or multiple files.

Parameters
requestcontains the file selection params for the request

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnFinishLoad ( int  frameId,
const wchar_t *  validatedPath,
bool  isMainFrame,
int  statusCode,
HTTPHeader headers,
unsigned  headersCount 
)
inlinevirtual

Called when a frame has been successfully loaded.

Parameters
frameIdthe id of the loaded frame
validatedPaththe path loaded in the frame
isMainFrametrue if this is the main frame of the View
statusCodethe status code of the response
headersan array of header fields
headersCountthe count of items in the headers array

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnGetAuthCredentials ( bool  isProxy,
const wchar_t *  host,
unsigned int  port,
const wchar_t *  realm,
const wchar_t *  scheme 
)
inlinevirtual

Called when a view requires authentication credentials.

Parameters
isProxywhether the request came from a server or a proxy
hostthe host which triggered the request
portthe port at which the request was triggered
realmrealm of the authentication challenge. Encoded in UTF-8
schemethe authentication scheme used, e.g. "basic" or "digest". Encoded in ASCII

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnJavaScriptMessage ( const wchar_t *  message,
const wchar_t *  defaultPrompt,
const wchar_t *  frameUrl,
int  messageType 
)
inlinevirtual

Called when the view triggered a javascript message box, i.e. an alert, confirmation dialog or a prompt dialog.

Parameters
messagethe JavaScript message
defaultPromptthe default value of the prompt text box, in case the message type is prompt
frameUrlthe URL which created the message
messageTypethe type of the message (alert/confirm/prompt)

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnNavigateTo ( const wchar_t *  path)
inlinevirtual

Called when the view starts navigation to a new path.

Parameters
pathURL that the view is navigating to

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnReadyForBindings ( int  frameId,
const wchar_t *  path,
bool  isMainFrame 
)
inlinevirtual

Called when a frame is ready for bindings.

Parameters
frameIdthe id of the frame
paththe path in the frame
isMainFrametrue if this is the main frame of the view

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnRequestMediaStream ( MediaStreamRequest request)
inlinevirtual

Called when the view requests access to a media stream. Media streams are the audio capture (microphone) and video capture (camera) devices on the system.

Parameters
requestcontains the available media streams for the request

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnScriptMessage ( MessageLevel  level,
const wchar_t *  message,
const wchar_t *  sourceId,
int  line 
)
inlinevirtual

Called when a message is sent from a script running in this specific View.

Parameters
levelmessage level
messagethe text of the message
sourceIdid of the script (usually file name)
linethe number of the line in which the message was sent

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnTextInputTypeChanged ( TextInputControlType  type,
bool  canComposeInline 
)
inlinevirtual

Called when the current text input control changes (i.e. the user click an edit-box). Use this methof to decide when to allow for IME input.

Note
the method will be called ONLY if IME is activated on this View.
See Also
View::IMEActivate
Parameters
typethe type of the currently focused text input control by the user
canComposeInlineif the IME composition could be performed in-line in the control

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnURLRequest ( URLRequest request)
inlinevirtual

Called before an URL request is made. The default implementation allows all requests. NOTE: this method will be called only when View::InterceptURLRequests(true) has been called.

Parameters
requestthe URLRequest object that can be used to modify the request. This pointer will be valid only for this call

Implements Coherent::UI::ViewListenerBase.

virtual void Coherent::UI::ViewListener::OnViewCreated ( View view)
pure virtual

Called when the requested View has been created and is ready to use.

Parameters
viewthe instance of the view containing all manipulation methods

Implements Coherent::UI::ViewListenerBase.