iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
IWebView Class Reference

IWebView is a base interface for hosting a platform web view inside an IPlug plug-in's UI. More...

#include <IPlugWebView.h>

Inheritance diagram for IWebView:
[legend]

Public Types

using completionHandlerFunc = std::function< void(const char *result)>
 

Public Member Functions

 IWebView (bool opaque=true, bool enableDevTools=false, const char *customUrlScheme="")
 Constructs an IWebView. More...
 
void * OpenWebView (void *pParent, float x, float y, float w, float h, float scale=1.0f)
 
void CloseWebView ()
 
void HideWebView (bool hide)
 
void LoadHTML (const char *html)
 Load an HTML string into the webview.
 
void LoadURL (const char *url)
 Instruct the webview to load an external URL.
 
void LoadFile (const char *fileName, const char *bundleID="")
 Load a file on disk into the web view. More...
 
void ReloadPageContent ()
 Trigger a reload of the webview's content.
 
void EvaluateJavaScript (const char *scriptStr, completionHandlerFunc func=nullptr)
 Runs some JavaScript in the webview. More...
 
void EnableScroll (bool enable)
 Enable scrolling on the webview. More...
 
void EnableInteraction (bool enable)
 Sets whether the webview is interactive.
 
void SetWebViewBounds (float x, float y, float w, float h, float scale=1.)
 Set the bounds of the webview in the parent window. More...
 
void GetWebRoot (WDL_String &path) const
 Fills the path where web content is being served from, when LoadFile() is used.
 
const char * GetCustomUrlScheme () const
 Returns the custom URL scheme, if set. More...
 
bool GetEnableDevTools () const
 Are developer tools enabled on this webview. More...
 
bool IsOpaque () const
 True if the webview was configured opaque. More...
 
void SetCustomUrlScheme (const char *customUrlScheme)
 Used to set the URL scheme after the IWebView has been contstructed;. More...
 
void SetEnableDevTools (bool enable)
 Used to toggle devtools after the IWebView has been contstructed. More...
 
virtual void OnWebViewReady ()
 Called when the web view is ready to receive navigation instructions. More...
 
virtual void OnWebContentLoaded ()
 Called after navigation instructions have been exectued and e.g. More...
 
virtual void OnMessageFromWebView (const char *json)
 When a script in the web view posts a message, it will arrive as a UTF8 json string here. More...
 
virtual bool OnCanNavigateToURL (const char *url)
 Override to filter URLs. More...
 
virtual bool OnCanDownloadMIMEType (const char *mimeType)
 Override to filter MIME types that should be downloaded. More...
 
virtual void OnGetLocalDownloadPathForFile (const char *fileName, WDL_String &localPath)
 Override to download the file to a specific location other than e.g. More...
 
virtual void OnDownloadedFile (const char *path)
 Override to handle file download success. More...
 
virtual void OnFailedToDownloadFile (const char *path)
 Override to handle file download failure. More...
 
virtual void OnReceivedData (size_t numBytesReceived, size_t totalNumBytes)
 Override to handle file download progress. More...
 

Detailed Description

IWebView is a base interface for hosting a platform web view inside an IPlug plug-in's UI.

Definition at line 43 of file IPlugWebView.h.

Member Typedef Documentation

◆ completionHandlerFunc

using IWebView::completionHandlerFunc = std::function<void(const char* result)>

Definition at line 46 of file IPlugWebView.h.

Constructor & Destructor Documentation

◆ IWebView()

IWebView::IWebView ( bool  opaque = true,
bool  enableDevTools = false,
const char *  customUrlScheme = "" 
)

Constructs an IWebView.

Parameters
opaque.Is the WebView opaque or does it have a transparent background
enableDevTools.Should the WebView's developer tools panel be enabled
customUrlSchemeIf set, the string used as a custom url scheme. It should not include a colon. This means that the webview content is served as if it was on a web server (required for some web frameworks

Member Function Documentation

◆ EnableScroll()

void IWebView::EnableScroll ( bool  enable)

Enable scrolling on the webview.

NOTE: currently only implemented for iOS

Referenced by IWebViewControl::OnAttached().

◆ EvaluateJavaScript()

void IWebView::EvaluateJavaScript ( const char *  scriptStr,
completionHandlerFunc  func = nullptr 
)

Runs some JavaScript in the webview.

Parameters
scriptStrUTF8 encoded JavaScript code to run
funcA function conforming to completionHandlerFunc that should be called on successful execution of the script

Referenced by WebViewEditorDelegate::SendArbitraryMsgFromDelegate(), WebViewEditorDelegate::SendControlMsgFromDelegate(), WebViewEditorDelegate::SendControlValueFromDelegate(), WebViewEditorDelegate::SendMidiMsgFromDelegate(), and WebViewEditorDelegate::SendParameterValueFromDelegate().

◆ GetCustomUrlScheme()

const char * IWebView::GetCustomUrlScheme ( ) const
inline

Returns the custom URL scheme, if set.

Definition at line 93 of file IPlugWebView.h.

◆ GetEnableDevTools()

bool IWebView::GetEnableDevTools ( ) const
inline

Are developer tools enabled on this webview.

Definition at line 96 of file IPlugWebView.h.

◆ IsOpaque()

bool IWebView::IsOpaque ( ) const
inline

True if the webview was configured opaque.

Definition at line 99 of file IPlugWebView.h.

◆ LoadFile()

void IWebView::LoadFile ( const char *  fileName,
const char *  bundleID = "" 
)

Load a file on disk into the web view.

Parameters
fileNameOn windows this should be an absolute path to the file you want to load. On macOS/iOS it can just be the file name if the file is packaged into a subfolder "web" of the bundle resources
bundleIDThe NSBundleID of the macOS/iOS bundle, not required on Windows

Referenced by WebViewEditorDelegate::LoadIndexHtml().

◆ OnCanDownloadMIMEType()

virtual bool IWebView::OnCanDownloadMIMEType ( const char *  mimeType)
inlinevirtual

Override to filter MIME types that should be downloaded.

Definition at line 122 of file IPlugWebView.h.

◆ OnCanNavigateToURL()

virtual bool IWebView::OnCanNavigateToURL ( const char *  url)
inlinevirtual

Override to filter URLs.

Definition at line 119 of file IPlugWebView.h.

◆ OnDownloadedFile()

virtual void IWebView::OnDownloadedFile ( const char *  path)
inlinevirtual

Override to handle file download success.

Definition at line 128 of file IPlugWebView.h.

◆ OnFailedToDownloadFile()

virtual void IWebView::OnFailedToDownloadFile ( const char *  path)
inlinevirtual

Override to handle file download failure.

Definition at line 131 of file IPlugWebView.h.

◆ OnGetLocalDownloadPathForFile()

virtual void IWebView::OnGetLocalDownloadPathForFile ( const char *  fileName,
WDL_String &  localPath 
)
virtual

Override to download the file to a specific location other than e.g.

NSTemporaryDirectory

◆ OnMessageFromWebView()

virtual void IWebView::OnMessageFromWebView ( const char *  json)
inlinevirtual

When a script in the web view posts a message, it will arrive as a UTF8 json string here.

Reimplemented in IWebViewControl, and WebViewEditorDelegate.

Definition at line 116 of file IPlugWebView.h.

◆ OnReceivedData()

virtual void IWebView::OnReceivedData ( size_t  numBytesReceived,
size_t  totalNumBytes 
)
inlinevirtual

Override to handle file download progress.

Definition at line 134 of file IPlugWebView.h.

◆ OnWebContentLoaded()

virtual void IWebView::OnWebContentLoaded ( )
inlinevirtual

Called after navigation instructions have been exectued and e.g.

a page has loaded

Reimplemented in IWebViewControl, and WebViewEditorDelegate.

Definition at line 113 of file IPlugWebView.h.

◆ OnWebViewReady()

virtual void IWebView::OnWebViewReady ( )
inlinevirtual

Called when the web view is ready to receive navigation instructions.

Reimplemented in IWebViewControl, and WebViewEditorDelegate.

Definition at line 110 of file IPlugWebView.h.

◆ SetCustomUrlScheme()

void IWebView::SetCustomUrlScheme ( const char *  customUrlScheme)
inline

Used to set the URL scheme after the IWebView has been contstructed;.

Definition at line 102 of file IPlugWebView.h.

◆ SetEnableDevTools()

void IWebView::SetEnableDevTools ( bool  enable)
inline

Used to toggle devtools after the IWebView has been contstructed.

Will only have an effect after close/reopen

Definition at line 105 of file IPlugWebView.h.

◆ SetWebViewBounds()

void IWebView::SetWebViewBounds ( float  x,
float  y,
float  w,
float  h,
float  scale = 1. 
)

Set the bounds of the webview in the parent window.

xywh are specifed in relation to a 1:1 non retina screen


The documentation for this class was generated from the following file: