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

An editor delegate base class that uses a platform native webview for the UI. More...

#include <IPlugWebViewEditorDelegate.h>

Inheritance diagram for WebViewEditorDelegate:
[legend]

Public Member Functions

 WebViewEditorDelegate (int nParams)
 
void * OpenWindow (void *pParent) override
 If you are not using IGraphics, you can implement this method to attach to the native parent view e.g. More...
 
void CloseWindow () override
 If you are not using IGraphics you can if you need to free resources etc when the window closes. More...
 
void SendControlValueFromDelegate (int ctrlTag, double normalizedValue) override
 SendControlValueFromDelegate (Abbreviation: SCVFD) WARNING: should not be called on the realtime audio thread. More...
 
void SendControlMsgFromDelegate (int ctrlTag, int msgTag, int dataSize, const void *pData) override
 SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio thread. More...
 
void SendParameterValueFromDelegate (int paramIdx, double value, bool normalized) override
 SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime audio thread. More...
 
void SendArbitraryMsgFromDelegate (int msgTag, int dataSize, const void *pData) override
 SendArbitraryMsgFromDelegate (Abbreviation: SAMFD) WARNING: should not be called on the realtime audio thread. More...
 
void SendMidiMsgFromDelegate (const IMidiMsg &msg) override
 SendMidiMsgFromDelegate (Abbreviation: SMMFD) WARNING: should not be called on the realtime audio thread. More...
 
bool OnKeyDown (const IKeyPress &key) override
 KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API, rather than the view. More...
 
bool OnKeyUp (const IKeyPress &key) override
 KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API rather than the view. More...
 
void SendJSONFromDelegate (const nlohmann::json &jsonMessage)
 
void OnMessageFromWebView (const char *jsonStr) override
 When a script in the web view posts a message, it will arrive as a UTF8 json string here. More...
 
void Resize (int width, int height)
 
void OnParentWindowResize (int width, int height) override
 Called by app wrappers when the OS window scaling buttons/resizers are used. More...
 
void OnWebViewReady () override
 Called when the web view is ready to receive navigation instructions. More...
 
void OnWebContentLoaded () override
 Called after navigation instructions have been exectued and e.g. More...
 
void SetMaxJSStringLength (int length)
 
void LoadIndexHtml (const char *pathOfPluginSrc, const char *bundleid)
 Load index.html (from plugin src dir in debug builds, and from bundle in release builds) on desktop Note: if your debug build is code-signed with the hardened runtime It won't be able to load the file outside it's sandbox, and this will fail. More...
 
- Public Member Functions inherited from IEditorDelegate
 IEditorDelegate (int nParams)
 
 IEditorDelegate (const IEditorDelegate &)=delete
 
IEditorDelegateoperator= (const IEditorDelegate &)=delete
 
IParamAddParam ()
 Adds an IParam to the parameters ptr list Note: This is only used in special circumstances, since most plug-in formats don't support dynamic parameters. More...
 
void RemoveParam (int idx)
 Remove an IParam at a particular index Note: This is only used in special circumstances, since most plug-in formats don't support dynamic parameters. More...
 
IParamGetParam (int paramIdx)
 Get a pointer to one of the delegate's IParam objects. More...
 
const IParamGetParam (int paramIdx) const
 Get a const pointer to one of the delegate's IParam objects (for const methods) More...
 
int NParams () const
 
virtual void * OpenWindow (void *pParent)
 If you are not using IGraphics, you can implement this method to attach to the native parent view e.g. More...
 
virtual void CloseWindow ()
 If you are not using IGraphics you can if you need to free resources etc when the window closes. More...
 
virtual void OnParentWindowResize (int width, int height)
 Called by app wrappers when the OS window scaling buttons/resizers are used. More...
 
virtual void OnUIOpen ()
 Override this method to do something before the UI is opened. More...
 
virtual void OnUIClose ()
 Override this method to do something before the UI is closed. More...
 
virtual void OnParamChange (int paramIdx, EParamSource source, int sampleOffset=-1)
 Override this method to do something to your DSP when a parameter changes. More...
 
virtual void OnParamChange (int paramIdx)
 Another version of the OnParamChange method without an EParamSource, for backwards compatibility / simplicity. More...
 
virtual void OnParamChangeUI (int paramIdx, EParamSource source=kUnknown)
 Override this method to do something when a parameter changes on the main/UI thread Like OnParamChange, OnParamChangeUI will be called when a parameter changes. More...
 
virtual void OnParamReset (EParamSource source)
 Called when parameters have changed to inform the plugin of the changes Override only if you need to handle notifications and updates in a specialist manner (e.g. More...
 
virtual void OnMidiMsgUI (const IMidiMsg &msg)
 Handle incoming MIDI messages sent to the user interface. More...
 
virtual void OnSysexMsgUI (const ISysEx &msg)
 Handle incoming SysEx messages sent to the user interface. More...
 
virtual bool OnMessage (int msgTag, int ctrlTag, int dataSize, const void *pData)
 This could be implemented in either DSP or EDITOR to receive a message from the other one. More...
 
virtual void OnRestoreState ()
 This is called by API classes after restoring state and by IPluginBase::RestorePreset(). More...
 
virtual bool OnKeyDown (const IKeyPress &key)
 KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API, rather than the view. More...
 
virtual bool OnKeyUp (const IKeyPress &key)
 KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API rather than the view. More...
 
void SendCurrentParamValuesFromDelegate ()
 Loops through all parameters, calling SendParameterValueFromDelegate() with the current value of the parameter This is important when modifying groups of parameters, restoring state and opening the UI, in order to update it with the latest values. More...
 
virtual void SendControlValueFromDelegate (int ctrlTag, double normalizedValue)
 SendControlValueFromDelegate (Abbreviation: SCVFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void SendControlMsgFromDelegate (int ctrlTag, int msgTag, int dataSize=0, const void *pData=nullptr)
 SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void SendArbitraryMsgFromDelegate (int msgTag, int dataSize=0, const void *pData=nullptr)
 SendArbitraryMsgFromDelegate (Abbreviation: SAMFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void SendMidiMsgFromDelegate (const IMidiMsg &msg)
 SendMidiMsgFromDelegate (Abbreviation: SMMFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void SendSysexMsgFromDelegate (const ISysEx &msg)
 SendSysexMsgFromDelegate (Abbreviation: SSMFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void SendParameterValueFromDelegate (int paramIdx, double value, bool normalized)
 SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime audio thread. More...
 
virtual void DirtyParametersFromUI ()
 When modifying a range of parameters in the editor, it can be necessary to broadcast that fact via the host, for instance in a distributed plug-in. More...
 
virtual void BeginInformHostOfParamChangeFromUI (int paramIdx)=0
 Called by the UI at the beginning of a parameter change gesture, in order to notify the host (via a call in the API class) that the parameter is going to be modified The host may be trying to automate the parameter as well, so it needs to relinquish control when the user is modifying something in the user interface. More...
 
virtual void SendParameterValueFromUI (int paramIdx, double normalizedValue)
 SPVFUI Called by the UI during a parameter change gesture, in order to notify the host of the new value (via a call in the API class) If you override this method you should call the base class implementation to make sure OnParamChangeUI gets triggered. More...
 
virtual void EndInformHostOfParamChangeFromUI (int paramIdx)=0
 Called by the user interface at the end of a parameter change gesture, in order to notify the host (via a call in the API class) that the parameter is no longer being modified The host may be trying to automate the parameter as well, so it needs to relinquish control when the user is modifying something in the user interface. More...
 
virtual bool EditorResizeFromUI (int viewWidth, int viewHeight, bool needsPlatformResize)
 If the editor changes UI dimensions, e.g. More...
 
virtual void SendMidiMsgFromUI (const IMidiMsg &msg)
 SendMidiMsgFromUI (Abbreviation: SMMFUI) This method should be used when sending a MIDI message from the UI. More...
 
virtual void SendSysexMsgFromUI (const ISysEx &msg)
 SendMidiMsgFromUI (Abbreviation: SSMFUI) If a plug-in can send Sysex data as a result of actions in the user interface, this method can be used. More...
 
virtual void SendArbitraryMsgFromUI (int msgTag, int ctrlTag=kNoTag, int dataSize=0, const void *pData=nullptr)
 SendArbitraryMsgFromUI (Abbreviation: SAMFUI) More...
 
virtual void DeferMidiMsg (const IMidiMsg &msg)
 This method is needed, for remote editors to avoid a feedback loop. More...
 
virtual void DeferSysexMsg (const ISysEx &msg)
 This method is needed, for remote editors to avoid a feedback loop. More...
 
void SetEditorSize (int width, int height)
 
void SetSizeConstraints (int widthLo, int widthHi, int heightLo, int heightHi)
 
int GetEditorWidth () const
 
int GetEditorHeight () const
 
int GetMinWidth () const
 
int GetMaxWidth () const
 
int GetMinHeight () const
 
int GetMaxHeight () const
 
virtual bool ConstrainEditorResize (int &w, int &h) const
 Constrain the incoming editor width and height values based on the minimum and maximum. More...
 
virtual bool SerializeEditorState (IByteChunk &chunk) const
 Serializes the editor state (such as scale) into a binary chunk. More...
 
virtual int UnserializeEditorState (const IByteChunk &chunk, int startPos)
 Unserializes editor state (such as scale). More...
 
virtual void SetScreenScale (float scale)
 Can be used by a host API to inform the editor of screen scale changes. More...
 
- Public Member Functions inherited from IWebView
 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...
 

Protected Attributes

int mMaxJSStringLength = kDefaultMaxJSStringLength
 
std::function< void()> mEditorInitFunc = nullptr
 
void * mView = nullptr
 

Additional Inherited Members

- Public Types inherited from IWebView
using completionHandlerFunc = std::function< void(const char *result)>
 

Detailed Description

An editor delegate base class that uses a platform native webview for the UI.

Definition at line 48 of file IPlugWebViewEditorDelegate.h.

Member Function Documentation

◆ CloseWindow()

void WebViewEditorDelegate::CloseWindow ( )
inlineoverridevirtual

If you are not using IGraphics you can if you need to free resources etc when the window closes.

Call base implementation.

Reimplemented from IEditorDelegate.

Definition at line 60 of file IPlugWebViewEditorDelegate.h.

◆ LoadIndexHtml()

void WebViewEditorDelegate::LoadIndexHtml ( const char *  pathOfPluginSrc,
const char *  bundleid 
)
inline

Load index.html (from plugin src dir in debug builds, and from bundle in release builds) on desktop Note: if your debug build is code-signed with the hardened runtime It won't be able to load the file outside it's sandbox, and this will fail.

On iOS, this will load index.html from the bundle

Parameters
pathOfPluginSrc- path to the plugin src directory
bundleid- the bundle id, used to load the correct index.html from the bundle

Definition at line 226 of file IPlugWebViewEditorDelegate.h.

References IWebView::LoadFile().

◆ OnKeyDown()

bool WebViewEditorDelegate::OnKeyDown ( const IKeyPress key)
overridevirtual

KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API, rather than the view.

Parameters
keyInformation about the key that was pressed
Returns
true if the key was handled by the plug-in

Reimplemented from IEditorDelegate.

Referenced by OnMessageFromWebView().

◆ OnKeyUp()

bool WebViewEditorDelegate::OnKeyUp ( const IKeyPress key)
overridevirtual

KeyDown handler, in order to get keystrokes from certain hosts/plugin formats that send key press messages through the plug-in API rather than the view.

Parameters
keyInformation about the key that was released
Returns
true if the key was handled by the plug-in

Reimplemented from IEditorDelegate.

Referenced by OnMessageFromWebView().

◆ OnMessageFromWebView()

void WebViewEditorDelegate::OnMessageFromWebView ( const char *  json)
inlineoverridevirtual

◆ OnParentWindowResize()

void WebViewEditorDelegate::OnParentWindowResize ( int  width,
int  height 
)
overridevirtual

Called by app wrappers when the OS window scaling buttons/resizers are used.

Reimplemented from IEditorDelegate.

◆ OnWebContentLoaded()

void WebViewEditorDelegate::OnWebContentLoaded ( )
inlineoverridevirtual

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

a page has loaded

Reimplemented from IWebView.

Definition at line 193 of file IPlugWebViewEditorDelegate.h.

References IParam::GetJSON(), IEditorDelegate::GetParam(), IEditorDelegate::NParams(), and IEditorDelegate::OnUIOpen().

◆ OnWebViewReady()

void WebViewEditorDelegate::OnWebViewReady ( )
inlineoverridevirtual

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

Reimplemented from IWebView.

Definition at line 185 of file IPlugWebViewEditorDelegate.h.

◆ OpenWindow()

void * WebViewEditorDelegate::OpenWindow ( void *  pParent)
overridevirtual

If you are not using IGraphics, you can implement this method to attach to the native parent view e.g.

NSView, UIView, HWND. Defer calling OnUIOpen() if necessary.

Reimplemented from IEditorDelegate.

◆ SendArbitraryMsgFromDelegate()

void WebViewEditorDelegate::SendArbitraryMsgFromDelegate ( int  msgTag,
int  dataSize,
const void *  pData 
)
inlineoverridevirtual

SendArbitraryMsgFromDelegate (Abbreviation: SAMFD) WARNING: should not be called on the realtime audio thread.

This method can be used to send opaque data from a class implementing IEditorDelegate to the IEditorDelegate connected to the user interface The message can be handled at the destination via IEditorDelegate::OnMessage()

Parameters
msgTagA unique tag to identify the message
dataSizeThe size in bytes of the data payload pointed to by pData. Note: if this is nonzero, pData must be valid.
pDataPtr to the opaque data payload for the message

Reimplemented from IEditorDelegate.

Definition at line 95 of file IPlugWebViewEditorDelegate.h.

References IWebView::EvaluateJavaScript().

◆ SendControlMsgFromDelegate()

void WebViewEditorDelegate::SendControlMsgFromDelegate ( int  ctrlTag,
int  msgTag,
int  dataSize,
const void *  pData 
)
inlineoverridevirtual

SendControlMsgFromDelegate (Abbreviation: SCMFD) WARNING: should not be called on the realtime audio thread.

This method can be used to send opaque data from a class implementing IEditorDelegate to a specific control in the user interface. The message can be handled in the destination control via IControl::OnMsgFromDelegate

Parameters
ctrlTagA unique tag to identify the control that is the destination of the message
msgTagA unique tag to identify the message
dataSizeThe size in bytes of the data payload pointed to by pData. Note: if this is nonzero, pData must be valid.
pDataPtr to the opaque data payload for the message

Reimplemented from IEditorDelegate.

Definition at line 72 of file IPlugWebViewEditorDelegate.h.

References IWebView::EvaluateJavaScript().

◆ SendControlValueFromDelegate()

void WebViewEditorDelegate::SendControlValueFromDelegate ( int  ctrlTag,
double  normalizedValue 
)
inlineoverridevirtual

SendControlValueFromDelegate (Abbreviation: SCVFD) WARNING: should not be called on the realtime audio thread.

In IGraphics plug-ins, this method is used to update controls in the user interface from a class implementing IEditorDelegate, when the control is not linked to a parameter. A typical use case would be a meter control. In OnIdle() your plug-in would call this method to update the IControl's value.

Parameters
ctrlTagA tag for the control
normalizedValueThe normalised value to set the control to. This will modify IControl::mValue;

Reimplemented from IEditorDelegate.

Definition at line 65 of file IPlugWebViewEditorDelegate.h.

References IWebView::EvaluateJavaScript().

◆ SendJSONFromDelegate()

void WebViewEditorDelegate::SendJSONFromDelegate ( const nlohmann::json &  jsonMessage)
inline

Definition at line 120 of file IPlugWebViewEditorDelegate.h.

◆ SendMidiMsgFromDelegate()

void WebViewEditorDelegate::SendMidiMsgFromDelegate ( const IMidiMsg msg)
inlineoverridevirtual

SendMidiMsgFromDelegate (Abbreviation: SMMFD) WARNING: should not be called on the realtime audio thread.

This method can be used to send regular MIDI data from the class implementing IEditorDelegate to the user interface The message can be handled at the destination via IEditorDelegate::OnMidiMsgUI()

Parameters
msgan IMidiMsg Containing the MIDI message to send to the user interface.

Reimplemented from IEditorDelegate.

Definition at line 108 of file IPlugWebViewEditorDelegate.h.

References IWebView::EvaluateJavaScript().

◆ SendParameterValueFromDelegate()

void WebViewEditorDelegate::SendParameterValueFromDelegate ( int  paramIdx,
double  value,
bool  normalized 
)
inlineoverridevirtual

SendParameterValueFromDelegate (Abbreviation: SPVFD) WARNING: should not be called on the realtime audio thread.

This method is called by the class implementing the delegate interface (not the plug-in API class) in order to update the user interface with the new parameter values, typically after automation. The similarly named IPlugAPIBase::SendParameterValueFromAPI() should take care of queueing and deferring, if there is no main thread notification from the API If you override this method you should call the base class implementation to make sure OnParamChangeUI gets triggered In IGraphics plug-ins, this will update any IControls that have their mParamIdx set > -1

Parameters
paramIdxThe index of the parameter to be updated
valueThe new value of the parameter
normalizedtrue if value is normalised

Reimplemented from IEditorDelegate.

Definition at line 82 of file IPlugWebViewEditorDelegate.h.

References IWebView::EvaluateJavaScript(), IEditorDelegate::GetParam(), and IParam::ToNormalized().

◆ SetMaxJSStringLength()

void WebViewEditorDelegate::SetMaxJSStringLength ( int  length)
inline

Definition at line 214 of file IPlugWebViewEditorDelegate.h.

Member Data Documentation

◆ mEditorInitFunc

std::function<void()> WebViewEditorDelegate::mEditorInitFunc = nullptr
protected

Definition at line 242 of file IPlugWebViewEditorDelegate.h.

◆ mMaxJSStringLength

int WebViewEditorDelegate::mMaxJSStringLength = kDefaultMaxJSStringLength
protected

Definition at line 241 of file IPlugWebViewEditorDelegate.h.

◆ mView

void* WebViewEditorDelegate::mView = nullptr
protected

Definition at line 243 of file IPlugWebViewEditorDelegate.h.


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