iPlug2 - C++ Audio Plug-in Framework
|
A control that allows the embedding of HTML UI inside an IGraphics context using a platform-native webview and bi-directional communication with that content NOTE: this control attaches a sub view on top of the IGraphics view, so it will render all content on-top The platform native webviews run in a separate process and communicate via IPC. More...
#include <IWebViewControl.h>
Public Member Functions | |
IWebViewControl (const IRECT &bounds, bool opaque, OnReadyFunc readyFunc=nullptr, OnMessageFunc msgFunc=nullptr, bool enableDevTools=false, bool enableScroll=false) | |
Constructs am IWebViewControl. More... | |
void | OnAttached () override |
Called after the control has been attached, and its delegate and graphics member variable set. More... | |
void | Draw (IGraphics &g) override |
Draw the control to the graphics context. 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 | OnMessageFromWebView (const char *json) override |
When a script in the web view posts a message, it will arrive as a UTF8 json string here. More... | |
void | OnRescale () override |
Implement to do something when graphics is scaled globally (e.g. More... | |
void | OnResize () override |
Called when IControl is constructed or resized using SetRect(). More... | |
void | SetIgnoreMouse (bool ignore) override |
Specify whether the control should respond to mouse events. More... | |
void | Hide (bool hide) override |
Shows or hides the IControl. More... | |
![]() | |
IControl (const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr) | |
Constructor. More... | |
IControl (const IRECT &bounds, const std::initializer_list< int > ¶ms, IActionFunction actionFunc=nullptr) | |
Constructor (range of parameters) More... | |
IControl (const IRECT &bounds, IActionFunction actionFunc) | |
Constructor (no paramIdx) More... | |
IControl (const IControl &)=delete | |
void | operator= (const IControl &)=delete |
virtual | ~IControl () |
Destructor. More... | |
virtual void | OnMouseDown (float x, float y, const IMouseMod &mod) |
Implement this method to respond to a mouse down event on this control. More... | |
virtual void | OnMouseUp (float x, float y, const IMouseMod &mod) |
Implement this method to respond to a mouse up event on this control. More... | |
virtual void | OnMouseDrag (float x, float y, float dX, float dY, const IMouseMod &mod) |
Implement this method to respond to a mouse drag event on this control. More... | |
virtual void | OnMouseDblClick (float x, float y, const IMouseMod &mod) |
Implement this method to respond to a mouse double click event on this control. More... | |
virtual void | OnMouseWheel (float x, float y, const IMouseMod &mod, float d) |
Implement this method to respond to a mouse wheel event on this control. More... | |
virtual bool | OnKeyDown (float x, float y, const IKeyPress &key) |
Implement this method to respond to a key down event on this control. More... | |
virtual bool | OnKeyUp (float x, float y, const IKeyPress &key) |
Implement this method to respond to a key up event on this control. More... | |
virtual void | OnMouseOver (float x, float y, const IMouseMod &mod) |
Implement this method to respond to a mouseover event on this control. More... | |
virtual void | OnMouseOut () |
Implement this method to respond to a mouseout event on this control. More... | |
virtual void | OnTouchCancelled (float x, float y, const IMouseMod &mod) |
Implement this method to respond to a touch cancel event on this control. More... | |
virtual void | OnDrop (const char *str) |
Implement to do something when something was drag 'n dropped onto this control. More... | |
virtual void | OnDropMultiple (const std::vector< const char * > &paths) |
Implement to handle multiple items drag 'n dropped onto this control. More... | |
virtual void | OnRescale () |
Implement to do something when graphics is scaled globally (e.g. More... | |
virtual void | OnResize () |
Called when IControl is constructed or resized using SetRect(). More... | |
virtual void | OnInit () |
Called just prior to when the control is attached, after its delegate and graphics member variable set. More... | |
virtual void | OnAttached () |
Called after the control has been attached, and its delegate and graphics member variable set. More... | |
virtual void | OnMsgFromDelegate (int msgTag, int dataSize, const void *pData) |
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() More... | |
virtual void | OnMidi (const IMidiMsg &msg) |
Implement to receive MIDI messages sent to the control if mWantsMidi == true, see IEditorDelegate:SendMidiMsgFromDelegate() More... | |
virtual bool | OnGesture (const IGestureInfo &info) |
virtual void | CreateContextMenu (IPopupMenu &contextMenu) |
Called by default when the user right clicks a control. More... | |
virtual void | OnPopupMenuSelection (IPopupMenu *pSelectedMenu, int valIdx) |
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptUserInput. More... | |
virtual void | OnDeleteFromPopupMenu (IPopupMenu *pMenu, int itemIdx) |
Implement this method to handle popup menu deletion interactions (on IOS) after IGraphics::CreatePopupMenu/IControlPromptUserInput. More... | |
virtual void | OnTextEntryCompletion (const char *str, int valIdx) |
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput. More... | |
virtual void | OnContextSelection (int itemSelected) |
Implement this to respond to a menu selection from CreateContextMenu();. More... | |
virtual void | Draw (IGraphics &g)=0 |
Draw the control to the graphics context. More... | |
virtual void | DrawPTHighlight (IGraphics &g) |
Implement this to customise how a colored highlight is drawn on the control in ProTools (AAX format only), when a control is linked to a parameter that is automated. More... | |
void | PromptUserInput (int valIdx=0) |
Call this method in response to a mouse event to create an edit box so the user can enter a value, or pop up a pop-up menu, if the control is linked to a parameter (mParamIdx > kNoParameter) More... | |
void | PromptUserInput (const IRECT &bounds, int valIdx=0) |
Create a text entry box so the user can enter a value, or pop up a pop-up menu, if the control is linked to a parameter (mParamIdx > kNoParameter) specifying the bounds. More... | |
IControl * | SetActionFunction (IActionFunction actionFunc) |
Set an Action Function for this control. More... | |
IControl * | SetAnimationEndActionFunction (IActionFunction actionFunc) |
Set an Action Function to be called at the end of an animation. More... | |
IControl * | SetTooltip (const char *str) |
Set a tooltip for the control. More... | |
const char * | GetTooltip () const |
int | GetParamIdx (int valIdx=0) const |
Get the index of a parameter that the control is linked to Normaly controls are either linked to a single parameter or no parameter but some may be linked to multiple parameters. More... | |
virtual void | SetParamIdx (int paramIdx, int valIdx=0) |
Set the index of a parameter that the control is linked to If you are calling this "manually" to reuse a control for multiple parameters, you probably want to call IEditorDelegate::SendCurrentParamValuesFromDelegate() afterward, to update the control values. More... | |
int | LinkedToParam (int paramIdx) const |
Check if the control is linked to a particular parameter. More... | |
int | NVals () const |
virtual int | GetValIdxForPos (float x, float y) const |
Check to see which of the control's values relates to this x and y coordinate. More... | |
const IParam * | GetParam (int valIdx=0) const |
Get a const pointer to the IParam object (owned by the editor delegate class), associated with this control. More... | |
virtual void | SetValueFromDelegate (double value, int valIdx=0) |
Set the control's value from the delegate This method is called from the class implementing the IEditorDelegate interface in order to update a control's value members and set it to be marked dirty for redraw. More... | |
virtual void | SetValueFromUserInput (double value, int valIdx=0) |
Set the control's value after user input. More... | |
virtual void | SetValueToDefault (int valIdx=kNoValIdx) |
Set one or all of the control's values to the default value of the associated parameter. More... | |
virtual void | SetValue (double value, int valIdx=0) |
Set one of the control's values. More... | |
double | GetValue (int valIdx=0) const |
Get the control's value. More... | |
void | SetGroup (const char *groupName) |
Assign the control to a control group. More... | |
const char * | GetGroup () const |
Get the group that the control belongs to, if any. More... | |
const IText & | GetText () const |
Get the Text object for the control. More... | |
virtual void | SetText (const IText &txt) |
Set the Text object typically used to determine font/layout/size etc of the main text in a control. More... | |
void | SetBlend (const IBlend &blend) |
Set the Blend for this control. More... | |
IBlend | GetBlend () const |
Get the Blend for this control. More... | |
int | GetTextEntryLength () const |
Get the max number of characters that are allowed in text entry. More... | |
void | SetTextEntryLength (int len) |
Set the max number of characters that are allowed in text entry. More... | |
const IRECT & | GetRECT () const |
Get the rectangular draw area for this control, within the graphics context. More... | |
void | SetRECT (const IRECT &bounds) |
Set the rectangular draw area for this control, within the graphics context. More... | |
const IRECT & | GetTargetRECT () const |
Get the rectangular mouse tracking target area, within the graphics context for this control. More... | |
void | SetTargetRECT (const IRECT &bounds) |
Set the rectangular mouse tracking target area, within the graphics context for this control. More... | |
void | SetTargetAndDrawRECTs (const IRECT &bounds) |
Set BOTH the draw rect and the target area, within the graphics context for this control. More... | |
virtual void | SetPosition (float x, float y) |
Set the position of the control, preserving the width and height. More... | |
virtual void | SetSize (float w, float h) |
Set the size of the control, preserving the current position. More... | |
void | SetPTParameterHighlight (bool isHighlighted, int color) |
Used internally by the AAX wrapper view interface to set the control parmeter highlight. More... | |
bool | GetMouseDblAsSingleClick () const |
Get double click as single click By default, mouse double click has its own handler. More... | |
virtual void | Hide (bool hide) |
Shows or hides the IControl. More... | |
bool | IsHidden () const |
virtual void | SetDisabled (bool disable) |
Sets disabled mode for the control, the default implementation modifies the mBlend member. More... | |
bool | IsDisabled () const |
void | SetMouseOverWhenDisabled (bool allow) |
Specify whether the control should respond to mouse overs when disabled. More... | |
void | SetMouseEventsWhenDisabled (bool allow) |
Specify whether the control should respond to other mouse events when disabled. More... | |
bool | GetMouseOverWhenDisabled () const |
bool | GetMouseEventsWhenDisabled () const |
bool | GetIgnoreMouse () const |
virtual void | SetIgnoreMouse (bool ignore) |
Specify whether the control should respond to mouse events. More... | |
bool | GetPromptShowsParamLabel () const |
void | SetPromptShowsParamLabel (bool enable) |
Set if the control should show parameter labels/units e.g. More... | |
virtual bool | IsHit (float x, float y) const |
Hit test the control. More... | |
virtual void | SetDirty (bool triggerAction=true, int valIdx=kNoValIdx) |
Mark the control as dirty, i.e. More... | |
virtual void | SetClean () |
void | Animate () |
virtual bool | IsDirty () |
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(), to determine if the control is marked as dirty. More... | |
void | DisablePrompt (bool disable) |
Disable/enable default prompt for user input. More... | |
virtual void | OnGUIIdle () |
This is an idle timer tick call on the GUI thread, only active if USE_IDLE_CALLS is defined. More... | |
int | GetTag () const |
Get the control's tag. More... | |
void | SetWantsMidi (bool enable=true) |
Specify whether this control wants to know about MIDI messages sent to the UI. More... | |
bool | GetWantsMidi () const |
void | SetWantsMultiTouch (bool enable=true) |
Specify whether this control supports multiple touches. More... | |
bool | GetWantsMultiTouch () const |
IControl * | AttachGestureRecognizer (EGestureType type, IGestureFunc func) |
Add a IGestureFunc that should be triggered in response to a certain type of gesture. More... | |
virtual bool | GetWantsGestures () const |
EGestureType | GetLastGesture () const |
IGEditorDelegate * | GetDelegate () |
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes from this IGraphics instance. More... | |
void | SetDelegate (IGEditorDelegate &dlg) |
Used internally to set the mDelegate (and mGraphics) variables. More... | |
IContainerBase * | GetParent () const |
void | SetParent (IContainerBase *pParent) |
IGraphics * | GetUI () |
const IGraphics * | GetUI () const |
bool | GetMouseIsOver () const |
This can be used in IControl::Draw() to check if the mouse is over the control, without implementing mouse over methods. More... | |
virtual void | SnapToMouse (float x, float y, EDirection direction, const IRECT &bounds, int valIdx=-1, double minClip=0., double maxClip=1.) |
Set control value based on x, y position within a rectangle. More... | |
virtual void | OnEndAnimation () |
void | StartAnimation (int duration) |
void | SetAnimation (IAnimationFunction func) |
Set the animation function. More... | |
void | SetAnimation (IAnimationFunction func, int duration) |
Set the animation function and starts it. More... | |
IAnimationFunction | GetAnimationFunction () |
Get the control's animation function, if it exists. More... | |
IActionFunction | GetActionFunction () |
Get the control's action function, if it exists. More... | |
double | GetAnimationProgress () const |
Get the progress in a control's animation, in the range 0-1. More... | |
Milliseconds | GetAnimationDuration () const |
Get the duration of animations applied to the control. More... | |
template<class T > | |
T * | As () |
Helper function to dynamic cast an IControl to a subclass. More... | |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
using | completionHandlerFunc = std::function< void(const char *result)> |
![]() | |
template<typename T , typename... Args> | |
void | ForValIdx (int valIdx, T func, Args... args) |
A helper template function to call a method for an individual value, or for all values. More... | |
void | SetNVals (int nVals) |
![]() | |
IRECT | mRECT |
IRECT | mTargetRECT |
WDL_String | mGroup |
Controls can be grouped for hiding and showing panels. More... | |
IText | mText |
IBlend | mBlend |
int | mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN |
bool | mDirty = true |
bool | mHide = false |
bool | mDisabled = false |
bool | mDisablePrompt = true |
bool | mDblAsSingleClick = false |
bool | mMouseOverWhenDisabled = false |
bool | mMouseEventsWhenDisabled = false |
bool | mIgnoreMouse = false |
bool | mWantsMidi = false |
bool | mWantsMultiTouch = false |
bool | mPromptShowsParamLabel = false |
bool | mMouseIsOver = false |
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control. More... | |
WDL_String | mTooltip |
IColor | mPTHighlightColor = COLOR_RED |
bool | mPTisHighlighted = false |
A control that allows the embedding of HTML UI inside an IGraphics context using a platform-native webview and bi-directional communication with that content NOTE: this control attaches a sub view on top of the IGraphics view, so it will render all content on-top The platform native webviews run in a separate process and communicate via IPC.
On Windows the ICoreWebView2 is used, which requires Edge Chromium to be installed: https://docs.microsoft.com/en-us/microsoft-edge/webview2 On macOS and iOS WkWebView is used
Definition at line 36 of file IWebViewControl.h.
|
inline |
Constructs am IWebViewControl.
bounds | The control's bounds |
opaque | Should the web view background be opaque |
readyFunc | A function conforming to onReadyFunc, that will be called asyncronously when the webview has been initialized |
msgFunc | A function conforming to onMessageFunc, that will be called when messages are posted from the webview |
enableDevTools | Should the webview developer tools be available via context menu |
Definition at line 45 of file IWebViewControl.h.
|
inline |
Definition at line 57 of file IWebViewControl.h.
|
inlineoverridevirtual |
Draw the control to the graphics context.
g | The graphics context to which this control belongs. |
Implements IControl.
Definition at line 71 of file IWebViewControl.h.
|
inlineoverridevirtual |
Shows or hides the IControl.
hide | Set to true to hide the control |
Reimplemented from IControl.
Definition at line 111 of file IWebViewControl.h.
References IControl::GetUI(), IControl::Hide(), and IGraphics::HidePlatformView().
|
inlineoverridevirtual |
Called after the control has been attached, and its delegate and graphics member variable set.
Use this method for controls that might need to attach sub controls that should be above their parent in the stack
Reimplemented from IControl.
Definition at line 63 of file IWebViewControl.h.
References IGraphics::AttachPlatformView(), IWebView::EnableScroll(), IGraphics::GetDrawScale(), IControl::GetUI(), IGraphics::GetWindow(), IRECT::H(), and IRECT::W().
|
inlineoverridevirtual |
When a script in the web view posts a message, it will arrive as a UTF8 json string here.
Reimplemented from IWebView.
Definition at line 87 of file IWebViewControl.h.
|
inlineoverridevirtual |
Implement to do something when graphics is scaled globally (e.g.
moves to different DPI screen)
Reimplemented from IControl.
Definition at line 93 of file IWebViewControl.h.
|
inlineoverridevirtual |
Called when IControl is constructed or resized using SetRect().
NOTE: if you call SetDirty() in this method, you should call SetDirty(false) to avoid triggering parameter changes
Reimplemented from IControl.
Definition at line 98 of file IWebViewControl.h.
|
inlineoverridevirtual |
Called after navigation instructions have been exectued and e.g.
a page has loaded
Reimplemented from IWebView.
Definition at line 82 of file IWebViewControl.h.
References IWebView::EnableInteraction().
|
inlineoverridevirtual |
Called when the web view is ready to receive navigation instructions.
Reimplemented from IWebView.
Definition at line 76 of file IWebViewControl.h.
|
inlineoverridevirtual |
Specify whether the control should respond to mouse events.
ignore | true if it should ignore mouse events |
Reimplemented from IControl.
Definition at line 103 of file IWebViewControl.h.
References IWebView::EnableInteraction().