34#if defined(IGRAPHICS_NANOVG) + defined(IGRAPHICS_CANVAS) + defined(IGRAPHICS_SKIA) != 1
35#error Either NO_IGRAPHICS or one and only one choice of graphics library must be defined!
40#include "IPlugAAX_view_interface.h"
47#include "IGraphicsConstants.h"
48#include "IGraphicsStructs.h"
57#include <unordered_map>
73BEGIN_IGRAPHICS_NAMESPACE
84:
public IPlugAAXView_Interface
88#pragma mark - Drawing API implementation
118 virtual void DrawRotatedSVG(
const ISVG& svg,
float destCentreX,
float destCentreY,
float width,
float height,
double angle,
const IBlend* pBlend = 0);
157 virtual void DrawLine(
const IColor& color,
float x1,
float y1,
float x2,
float y2,
const IBlend* pBlend = 0,
float thickness = 1.f);
167 virtual void DrawDottedLine(
const IColor& color,
float x1,
float y1,
float x2,
float y2,
const IBlend* pBlend = 0,
float thickness = 1.f,
float dashLen = 2.f);
179 virtual void DrawTriangle(
const IColor& color,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
const IBlend* pBlend = 0,
float thickness = 1.f);
205 virtual void DrawRoundRect(
const IColor& color,
const IRECT& bounds,
float cRTL,
float cRTR,
float cRBR,
float cRBL,
const IBlend* pBlend = 0,
float thickness = 1.f);
216 virtual void DrawArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend = 0,
float thickness = 1.f);
225 virtual void DrawCircle(
const IColor& color,
float cx,
float cy,
float r,
const IBlend* pBlend = 0,
float thickness = 1.f);
243 virtual void DrawEllipse(
const IColor& color,
float x,
float y,
float r1,
float r2,
float angle = 0.0,
const IBlend* pBlend = 0,
float thickness = 1.f);
270 virtual void FillTriangle(
const IColor& color,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
const IBlend* pBlend = 0);
317 virtual void FillEllipse(
const IColor& color,
float x,
float y,
float r1,
float r2,
float angle = 0.0,
const IBlend* pBlend = 0);
327 virtual void FillArc(
const IColor& color,
float cx,
float cy,
float r,
float a1,
float a2,
const IBlend* pBlend = 0);
350 void DrawText(
const IText& text,
const char* str,
float x,
float y,
const IBlend* pBlend = 0);
406#pragma mark - Base implementation - drawing helpers
426 void DrawBitmapedText(
const IBitmap& bitmap,
const IRECT& bounds,
IText& text,
IBlend* pBlend,
const char* str,
bool vCenter =
true,
bool multiline =
false,
int charWidth = 6,
int charHeight = 12,
int charOffset = 0);
480 void DrawRadialLine(
const IColor& color,
float cx,
float cy,
float angle,
float rMin,
float rMax,
const IBlend* pBlend = 0,
float thickness = 1.f);
489 virtual void DrawGrid(
const IColor& color,
const IRECT& bounds,
float gridSizeH,
float gridSizeV,
const IBlend* pBlend = 0,
float thickness = 1.f);
500 virtual void DrawData(
const IColor& color,
const IRECT& bounds,
float* normYPoints,
int nPoints,
float* normXPoints =
nullptr,
const IBlend* pBlend = 0,
float thickness = 1.f,
const IColor* pFillColor =
nullptr);
506 virtual bool LoadFont(
const char* fontID,
const char* fileNameOrResID);
513 virtual bool LoadFont(
const char* fontID,
void* pData,
int dataSize);
520 bool LoadFont(
const char* fontID,
const char* fontName, ETextStyle style);
522#pragma mark - Layer management
588#pragma mark - Drawing API path support
601 void PathLine(
float x1,
float y1,
float x2,
float y2)
613 void PathRadialLine(
float cx,
float cy,
float angle,
float rMin,
float rMax);
622 void PathTriangle(
float x1,
float y1,
float x2,
float y2,
float x3,
float y3);
647 virtual void PathArc(
float cx,
float cy,
float r,
float a1,
float a2, EWinding winding = EWinding::CW) = 0;
665 void PathEllipse(
float x,
float y,
float r1,
float r2,
float angle = 0.0);
694 virtual void PathCubicBezierTo(
float c1x,
float c1y,
float c2x,
float c2y,
float x2,
float y2) = 0;
757 virtual void PathTransformSetMatrix(
const IMatrix& matrix) = 0;
759 void DoTextRotation(
const IText& text,
const IRECT& bounds,
const IRECT& rect)
764 IRECT rotated = rect;
773 IPattern GetSVGPattern(
const NSVGpaint& paint,
float opacity);
775 void DoDrawSVG(
const ISVG& svg,
const IBlend* pBlend =
nullptr,
const IColor* pStrokeColor =
nullptr,
const IColor* pFillColor =
nullptr);
779 void PrepareRegion(
const IRECT& bounds)
783 SetClipRegion(bounds);
789 virtual void CompleteRegion(
const IRECT& bounds) {}
791 virtual void SetClipRegion(
const IRECT& r) = 0;
794#pragma mark - Platform implementation
830 ECursor oldCursorType = mCursorType;
831 mCursorType = cursorType;
832 return oldCursorType;
883 virtual EMsgBoxResult
ShowMessageBox(
const char* str,
const char* title, EMsgBoxType type, IMsgBoxCompletionHandlerFunc completionHandler =
nullptr) = 0;
891 virtual void PromptForFile(WDL_String& fileName, WDL_String& path, EFileAction action = EFileAction::Open,
const char* ext =
"", IFileDialogCompletionHandlerFunc completionHandler =
nullptr) = 0;
896 virtual void PromptForDirectory(WDL_String& dir, IFileDialogCompletionHandlerFunc completionHandler =
nullptr) = 0;
911 virtual bool OpenURL(
const char* url,
const char* msgWindowTitle = 0,
const char* confirmMsg = 0,
const char* errMsgOnFailure = 0) = 0;
946 virtual PlatformFontPtr
LoadPlatformFont(
const char* fontID,
const char* fileNameOrResID) = 0;
953 virtual PlatformFontPtr
LoadPlatformFont(
const char* fontID,
void* pData,
int dataSize) = 0;
960 virtual PlatformFontPtr
LoadPlatformFont(
const char* fontID,
const char* fontName, ETextStyle style) = 0;
975 virtual void ActivateGLContext() {};
978 virtual void DeactivateGLContext() {};
995#pragma mark - Base implementation
1075 void Resize(
int w,
int h,
float scale,
bool needsPlatformResize =
true);
1082 void SetLayoutOnResize(
bool layoutOnResize);
1094 int WindowWidth()
const {
return static_cast<int>(
static_cast<float>(mWidth) * mDrawScale); }
1098 int WindowHeight()
const {
return static_cast<int>(
static_cast<float>(mHeight) * mDrawScale); }
1102 int FPS()
const {
return mFPS; }
1156 mEnableMultiTouch = enable;
1160 mEnableMultiTouch =
false;
1230 virtual void PlatformResize(
bool parentHasResized) {}
1233 virtual void DrawResize() {}
1238 void Draw(
const IRECT& bounds,
float scale);
1244 void DrawControl(
IControl* pControl,
const IRECT& bounds,
float scale);
1255 void StartDragResize() { mResizingInProcess =
true; }
1258 void EndDragResize();
1260#pragma mark - Control management
1269 template<
typename T,
typename... Args>
1280 template<
typename T,
typename... Args>
1291 void ForControlWithParam(
const std::initializer_list<int>& params, IControlFunction func);
1312 void AttachCornerResizer(EUIResizerMode sizeMode = EUIResizerMode::Scale,
bool layoutOnResize =
false,
const IColor& color = COLOR_TRANSLUCENT,
const IColor& mouseOverColor = COLOR_BLACK,
const IColor& dragColor = COLOR_BLACK,
float size = 20.f);
1340 void ShowBubbleControl(
IControl* pCaller,
float x,
float y,
const char* str, EDirection dir = EDirection::Horizontal,
IRECT minimumContentBounds =
IRECT());
1385 for (
auto itr = mCtrlTags.begin(); itr != mCtrlTags.end(); ++itr)
1387 if (itr->second == pControl)
1406 return std::find_if(std::begin(mCapturedMap), std::end(mCapturedMap), [pControl](
auto&& press) {
return press.second == pControl; }) != mCapturedMap.end();
1412 for (
auto i = mCapturedMap.begin(), j = mCapturedMap.end(); i != j; ++i)
1413 if (i->second == pControl)
1414 touchesOnThisControl.push_back(i->first);
1498 int GetMouseControlIdx(
float x,
float y,
bool mouseOver =
false);
1507 IControl* GetMouseControl(
float x,
float y,
bool capture,
bool mouseOver =
false, ITouchID touchID = 0);
1509#pragma mark - Event handling
1512 void OnMouseDown(
const std::vector<IMouseInfo>& points);
1515 void OnMouseUp(
const std::vector<IMouseInfo>& points);
1518 void OnMouseDrag(
const std::vector<IMouseInfo>& points);
1563 void OnDrop(
const char* str,
float x,
float y);
1568 void OnDropMultiple(
const std::vector<const char*>& paths,
float x,
float y);
1604#pragma mark - Plug-in API Specific
1639#pragma mark - Resource/File Loading
1653 virtual IBitmap LoadBitmap(
const char* fileNameOrResID,
int nStates = 1,
bool framesAreHorizontal =
false,
int targetScale = 0);
1663 virtual IBitmap LoadBitmap(
const char *name,
const void* pData,
int dataSize,
int nStates = 1,
bool framesAreHorizontal =
false,
int targetScale = 0);
1668 virtual ISVG LoadSVG(
const char* fileNameOrResID,
const char* units =
"px",
float dpi = 72.f);
1677 virtual ISVG LoadSVG(
const char* name,
const void* pData,
int dataSize,
const char* units =
"px",
float dpi = 72.f);
1683 virtual WDL_TypedBuf<uint8_t>
LoadResource(
const char* fileNameOrResID,
const char* fileType);
1728 virtual bool LoadAPIFont(
const char* fontID,
const PlatformFontPtr& font) = 0;
1746 EResourceLocation
SearchImageResource(
const char* fileName,
const char* type, WDL_String& result,
int targetScale,
int& sourceScale);
1786 IMatrix GetTransformMatrix()
const {
return mTransform; }
1790 void ClearMouseOver()
1792 mMouseOver =
nullptr;
1796 WDL_PtrList<IControl> mControls;
1797 std::unordered_map<int, IControl*> mCtrlTags;
1800 std::unique_ptr<ICornerResizerControl> mCornerResizer;
1801 WDL_PtrList<IBubbleControl> mBubbleControls;
1802 std::unique_ptr<IPopupMenuControl> mPopupControl;
1803 std::unique_ptr<IFPSDisplayControl> mPerfDisplay;
1804 std::unique_ptr<ITextEntryControl> mTextEntryControl;
1805 std::unique_ptr<IControl> mLiveEdit;
1809 WDL_String mSharedResourcesSubPath;
1811 ECursor mCursorType = ECursor::ARROW;
1815 float mScreenScale = 1.f;
1816 float mDrawScale = 1.f;
1820 std::vector<EGestureType> mRegisteredGestures;
1822 std::unordered_map<int, IGestureFunc> mGestureRegionFuncs;
1823 std::unordered_map<ITouchID, IControl*> mCapturedMap;
1827 void* mPlatformContext =
nullptr;
1828 bool mIsContextMenu =
false;
1829 int mTextEntryValIdx = kNoValIdx;
1830 int mPopupMenuValIdx = kNoValIdx;
1831 int mMouseOverIdx = -1;
1832 float mMouseDownX = -1.f;
1833 float mMouseDownY = -1.f;
1836 int mLastClickedParam = kNoParameter;
1837 bool mEnableMouseOver =
false;
1838 bool mStrict =
false;
1839 bool mEnableTooltips =
false;
1840 bool mShowControlBounds =
false;
1841 bool mShowAreaDrawn =
false;
1842 bool mResizingInProcess =
false;
1843 bool mLayoutOnResize =
false;
1844 bool mEnableMultiTouch =
false;
1845 EUIResizerMode mGUISizeMode = EUIResizerMode::Scale;
1846 double mPrevTimestamp = 0.;
1847 IKeyHandlerFunc mKeyHandlerFunc =
nullptr;
1848 IDisplayTickFunc mDisplayTickFunc =
nullptr;
1849 IUIAppearanceChangedFunc mAppearanceChangedFunc =
nullptr;
1853 bool mCursorHidden =
false;
1854 bool mCursorLock =
false;
1855 bool mTabletInput =
false;
1856 float mCursorX = -1.f;
1857 float mCursorY = -1.f;
1858 float mXTranslation = 0.f;
1859 float mYTranslation = 0.f;
1865 std::stack<ILayer*> mLayers;
1869 std::stack<IMatrix> mTransformStates;
1872END_IGRAPHICS_NAMESPACE
IPlug Constant definitions, Types, magic numbers.
IPlug logging a.k.a tracing functionality.
Common paths useful for plug-ins.
A base class interface for a bitmap abstraction around the different drawing back end bitmap represen...
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
A special control to draw contextual info as a slider etc is moved If used in the main IControl stack...
The lowest level base class of an IGraphics control.
A control for resizing the plug-in window by clicking and dragging in the bottom right-hand corner Th...
Performance display meter, based on code from NanoVG This is a special control that lives outside the...
An editor delegate base class that uses IGraphics for the UI.
The lowest level base class of an IGraphics context.
bool ControlIsCaptured() const
Check to see if any control is captured.
void EnableTooltips(bool enable)
void CreatePopupMenu(IControl &control, IPopupMenu &menu, float x, float y, int valIdx=0)
Shows a pop up/contextual menu at point.
virtual float DoMeasureText(const IText &text, const char *str, IRECT &bounds) const =0
virtual bool SetFilePathInClipboard(const char *path)
Set a file path in the clipboard.
virtual void ClientToScreen(float &x, float &y)
Convert an x, y position in the view to screen coordinates.
void Resize(int w, int h, float scale, bool needsPlatformResize=true)
virtual void DrawRotatedSVG(const ISVG &svg, float destCentreX, float destCentreY, float width, float height, double angle, const IBlend *pBlend=0)
Draw an SVG image to the graphics context with rotation.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
virtual bool PlatformSupportsMultiTouch() const
virtual void FillEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill an ellipse within a rectangular region of the graphics context.
ILayer * PopLayer()
Pop a layer off the stack.
virtual void DrawConvexPolygon(const IColor &color, float *x, float *y, int nPoints, const IBlend *pBlend=0, float thickness=1.f)
Draw a convex polygon to the graphics context.
virtual bool OpenURL(const char *url, const char *msgWindowTitle=0, const char *confirmMsg=0, const char *errMsgOnFailure=0)=0
Open a URL in the platform’s default browser.
virtual void DrawEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw an ellipse within a rectangular region of the graphics context.
virtual PlatformFontPtr LoadPlatformFont(const char *fontID, const char *fontName, ETextStyle style)=0
Load a system font in a platform format.
virtual void DrawFittedBitmap(const IBitmap &bitmap, const IRECT &bounds, const IBlend *pBlend=0)
Draw a bitmap (raster) image to the graphics context, scaling the image to fit the bounds.
void DrawBitmapedText(const IBitmap &bitmap, const IRECT &bounds, IText &text, IBlend *pBlend, const char *str, bool vCenter=true, bool multiline=false, int charWidth=6, int charHeight=12, int charOffset=0)
Draws mono spaced bitmap text.
void AttachPopupMenuControl(const IText &text=DEFAULT_TEXT, const IRECT &bounds=IRECT())
Attach a control for pop-up menus, to override platform style menus.
virtual void DrawPoint(const IColor &color, float x, float y, const IBlend *pBlend=0)
Fill a rectangle corresponding to a pixel on a 1:1 screen with a color.
void RemoveControl(int idx)
Remove a control at a particular index, (frees memory).
void DeleteFromPopupMenu(IPopupMenu *pMenu, int itemIdx)
Called by IOS platform (or other supported platforms) in order to update a control with a deletion in...
virtual const char * GetBundleID() const
Get the bundle ID on macOS and iOS, returns emtpy string on other OSs.
void PathConvexPolygon(float *x, float *y, int nPoints)
Add a convex polygon to the current path.
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
void SetTabletInput(bool tablet)
Set by the platform class if the mouse input is coming from a tablet/stylus.
virtual float GetPlatformWindowScale() const
Returns a scaling factor for resizing parent windows via the host/plugin API.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
float GetTotalScale() const
Gets the combined draw and screen/display scaling factor.
int GetParamIdxForPTAutomation(float x, float y)
[AAX only] This can be called by the ProTools API class (e.g.
virtual IColor GetPoint(int x, int y)=0
Get the color at an X, Y location in the graphics context.
void CreatePopupMenu(IControl &control, IPopupMenu &menu, const IRECT &bounds, int valIdx=0)
Shows a pop up/contextual menu in relation to a rectangular region of the graphics context.
void CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
virtual void PathClear()=0
Clear the stack of path drawing commands.
virtual bool InitiateExternalFileDragDrop(const char *path, const IRECT &iconBounds)
Initiate an drag-n-drop operation of an existing file, to be dropped outside of the current window.
virtual void MoveMouseCursor(float x, float y)=0
Force move the mouse cursor to a specific position.
virtual void * GetDrawContext()=0
Gets a void pointer to underlying drawing context, for the IGraphics backend See draw class implement...
virtual PlatformFontPtr LoadPlatformFont(const char *fontID, void *pData, int dataSize)=0
Load a font from data in memory.
void PathRoundRect(const IRECT &bounds, float ctl, float ctr, float cbl, float cbr)
Add a rounded rectangle to the current path, with independent corner roundness.
void SetPTParameterHighlight(int paramIdx, bool isHighlighted, int color)
[AAX only] See AAX_CEffectGUI::SetControlHighlightInfo()
virtual void PathClose()=0
Close the path that is being specified.
void PathTransformTranslate(float x, float y)
Apply a translation transform to the current path.
void ClearInTextEntryControl()
Called when the text entry is dismissed, to reset mInTextEntry.
void DrawRadialLine(const IColor &color, float cx, float cy, float angle, float rMin, float rMax, const IBlend *pBlend=0, float thickness=1.f)
Draw a radial line to the graphics context, useful for pointers on dials.
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
virtual void RetainBitmap(const IBitmap &bitmap, const char *cacheName)
Adds an IBitmap to the cache/static storage.
virtual void * GetWindow()=0
Get a pointer to the platform view e.g.
void ForMatchingControls(T method, int paramIdx, Args... args)
For all standard controls in the main control stack that are linked to a specific parameter,...
virtual void AttachPlatformView(const IRECT &r, void *pView)
Add an OS view as a sub-view, on top of the IGraphics view.
virtual void CreatePlatformTextEntry(int paramIdx, const IText &text, const IRECT &bounds, int length, const char *str)=0
Creates a platform native text entry field.
void ResumeLayer(ILayerPtr &layer)
If a layer already exists, continue drawing to it.
ITextEntryControl * GetTextEntryControl()
void PathTransformMatrix(const IMatrix &matrix)
Apply an arbitary affine transform matrix to the current path.
void DrawRotatedLayer(const ILayerPtr &layer, double angle)
Draw a layer to the main IGraphics context, with rotation.
virtual const char * GetAppGroupID() const
Get the app group ID on macOS and iOS, returns emtpy string on other OSs.
int FPS() const
Gets the drawing frame rate.
void PathTransformScale(float x, float y)
Apply a scale transform to the current path, with independant x, y scales.
virtual ECursor SetMouseCursor(ECursor cursorType=ECursor::ARROW)
Sets the mouse cursor to one of ECursor (implementations should return the result of the base impleme...
void PathLine(float x1, float y1, float x2, float y2)
Add a line to the current path.
virtual void DrawDottedRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f, float dashLen=2.f)
Draw a dotted rectangle to the graphics context.
IControl * GetControlWithTag(int ctrlTag) const
Get the control with a particular tag.
virtual void PathSetWinding(bool clockwise)
NanoVG only.
virtual bool SetTextInClipboard(const char *str)=0
Set text in the clipboard.
virtual void HidePlatformView(void *pView, bool hide)
Hide a previously attached platform view from the IGraphics view.
void OnMouseDrag(const std::vector< IMouseInfo > &points)
Called when the platform class sends drag events.
virtual void ReleaseBitmap(const IBitmap &bitmap)
Releases an IBitmap from the cache/static storage.
void ShowControlBounds(bool enable)
virtual void DrawRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0, float thickness=1.f)
Draw a rounded rectangle to the graphics context.
void SetUIAppearanceChangedFunc(IUIAppearanceChangedFunc func)
Sets a function that is called when the OS appearance (light/dark mode) is changed.
void OnMouseOut()
Called when the mouse leaves the graphics context.
void UpdatePeers(IControl *pCaller, int callerValIdx)
This method is called after interacting with a control, so that any other controls linked to the same...
void RemovePopupMenuControl()
Remove the IGraphics popup menu, use platform popup menu if available.
virtual float GetBackingPixelScale() const
virtual void DrawRotatedBitmap(const IBitmap &bitmap, float destCentreX, float destCentreY, double angle, const IBlend *pBlend=0)
Draw a bitmap (raster) image to the graphics context with rotation.
bool OnKeyDown(float x, float y, const IKeyPress &key)
virtual int AlphaChannel() const =0
void AttachGestureRecognizerToRegion(const IRECT &bounds, EGestureType type, IGestureFunc func)
Attach a gesture recognizer to a rectangular region of the GUI, i.e.
bool MultiTouchEnabled() const
virtual const char * GetDrawingAPIStr()=0
int Width() const
Gets the width of the graphics context.
virtual void SetWinModuleHandle(void *pHinstance)
Used on Windows to set the HINSTANCE module handle, which allows graphics APIs to load resources from...
virtual void EndFrame()
Called by some drawing API classes to finally blit the draw bitmap onto the screen or perform other c...
void DisableControl(int paramIdx, bool diable)
Disable or enable controls linked to a specific parameter.
virtual bool GetTextFromClipboard(WDL_String &str)=0
Get text from the clipboard.
void SetControlBounds(IControl *pControl, const IRECT &r)
Set a controls target and draw rect to r, redrawing the interface correctly.
void PathTriangle(float x1, float y1, float x2, float y2, float x3, float y3)
Add a triangle to the current path.
void DoMeasureTextRotation(const IText &text, const IRECT &bounds, IRECT &rect) const
void AttachTextEntryControl()
Attach a control for text entry, to override platform text entry.
void AttachCornerResizer(EUIResizerMode sizeMode=EUIResizerMode::Scale, bool layoutOnResize=false, const IColor &color=COLOR_TRANSLUCENT, const IColor &mouseOverColor=COLOR_BLACK, const IColor &dragColor=COLOR_BLACK, float size=20.f)
Attach the default control to scale or increase the UI size by dragging the plug-in bottom right-hand...
virtual void AttachGestureRecognizer(EGestureType type)
Registers a gesture recognizer with the graphics context.
virtual APIBitmap * CreateAPIBitmap(int width, int height, float scale, double drawScale, bool cacheable=false)=0
Creates a new API bitmap, either in memory or as a GPU texture.
void OnMouseUp(const std::vector< IMouseInfo > &points)
Called when the platform class sends mouse up events.
void PathTransformReset(bool clearStates=false)
Reset the affine transform of the current path, to the default state.
void OnAppearanceChanged(EUIAppearance appearance)
Called by the platform class if the view changes to dark/light mode.
virtual void * OpenWindow(void *pParentWnd)=0
Open a new platform view for this graphics context.
virtual void PromptForDirectory(WDL_String &dir, IFileDialogCompletionHandlerFunc completionHandler=nullptr)=0
Create a platform file prompt dialog to choose a directory path for opening/saving a directory.
void CalculateTextRotation(const IText &text, const IRECT &bounds, IRECT &rect, double &tx, double &ty) const
bool IsInPlatformTextEntry()
void SetTranslation(float x, float y)
Called by some platform IGraphics classes in order to translate the graphics context,...
int GetIdxOfTaggedControl(int ctrlTag) const
Gets the index of a tagged control.
virtual bool AssetsLoaded()
Specialized in IGraphicsCanvas drawing backend.
virtual void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options=IStrokeOptions(), const IBlend *pBlend=0)=0
Stroke the current current path.
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
int WindowWidth() const
Gets the width of the graphics context including draw scaling.
void Draw(IRECTList &rects)
Called by the platform class indicating a number of rectangles in the UI that need to redraw.
EResourceLocation SearchImageResource(const char *fileName, const char *type, WDL_String &result, int targetScale, int &sourceScale)
Search for a bitmap image resource matching the target scale.
IControl * GetControlWithParamIdx(int paramIdx)
Get the first control with a parameter index that matches paramIdx.
virtual void OnViewDestroyed()
Called after a platform view is destroyed, so that drawing classes can e.g.
virtual void ApplyShadowMask(ILayerPtr &layer, RawBitmapData &mask, const IShadow &shadow)=0
Implemented by a graphics backend to apply a calculated shadow mask to a layer, according to the shad...
void EnableLiveEdit(bool enable)
Live edit mode allows you to relocate controls at runtime in debug builds.
void PathTransformRestore()
Restore the affine transform of the current path, to the previously saved state.
void SetControlValueAfterPopupMenu(IPopupMenu *pMenu)
Called by PopupMenuControl in order to update a control with a new value after returning from the non...
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
void PushLayer(ILayer *pLayer)
Push a layer on to the stack.
void ReleaseMouseCapture()
Used to tell the graphics context to stop tracking mouse interaction with a control.
IRECT GetPixelSnapped(IRECT &r) const
Gets the nearest backing pixel aligned rect to the input IRECT.
int GetLastClickedParamForPTAutomation()
[AAX only]
void ForControlWithParam(int paramIdx, IControlFunction func)
For all standard controls in the main control stack that are linked to a specific parameter,...
bool ShowAreaDrawnEnabled() const
void AttachBubbleControl(const IText &text=DEFAULT_TEXT)
Attach the default control to show text as a control changes.
IBubbleControl * GetBubbleControl(int i=0)
EUIResizerMode GetResizerMode() const
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
int GetRoundedScreenScale() const
Gets the screen/display scaling factor, rounded up.
virtual void DrawFastDropShadow(const IRECT &innerBounds, const IRECT &outerBounds, float xyDrop=5.f, float roundness=0.f, float blur=10.f, IBlend *pBlend=nullptr)
NanoVG only.
virtual bool PromptForColor(IColor &color, const char *str="", IColorPickerHandlerFunc func=nullptr)=0
Create a platform color chooser dialog.
APIBitmap * SearchBitmapInCache(const char *fileName, int targetScale, int &sourceScale)
Search the static storage cache for a bitmap image resource matching the target scale.
void * GetPlatformContext()
Get the platform level draw context - an HDC or CGContextRef.
virtual bool RevealPathInExplorerOrFinder(WDL_String &path, bool select=false)
virtual void DrawLine(const IColor &color, float x1, float y1, float x2, float y2, const IBlend *pBlend=0, float thickness=1.f)
Draw a line to the graphics context.
virtual void DrawArc(const IColor &color, float cx, float cy, float r, float a1, float a2, const IBlend *pBlend=0, float thickness=1.f)
Draw an arc to the graphics context.
void OnTouchCancelled(const std::vector< IMouseInfo > &points)
Called when the platform class sends touch cancel events.
bool OnMouseOver(float x, float y, const IMouseMod &mod)
virtual void UpdateTooltips()=0
Call this if you modify control tool tips at runtime.
void OnDragResize(float x, float y)
Called by ICornerResizerControl as the corner is dragged to resize.
virtual PlatformFontPtr LoadPlatformFont(const char *fontID, const char *fileNameOrResID)=0
Load a font from disk or resource in a platform format.
void ForAllControlsFunc(IControlFunction func)
For all controls, including the "special controls" call a method.
int NBubbleControls() const
void HideControl(int paramIdx, bool hide)
Hide controls linked to a specific parameter.
virtual bool LoadFont(const char *fontID, const char *fileNameOrResID)
Load a font to be used by the graphics context.
void SetDisplayTickFunc(IDisplayTickFunc func)
Sets a function that is called at the frame rate, prior to checking for dirty controls.
virtual bool BitmapExtSupported(const char *ext)=0
Checks a file extension and reports whether this drawing API supports loading that extension.
void RemoveAllControls()
Removes all regular IControls from the control list, as well as special controls (frees memory).
virtual void DrawCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0, float thickness=1.f)
Draw a circle to the graphics context.
bool LiveEditEnabled() const
void OnMouseDown(const std::vector< IMouseInfo > &points)
Called when the platform class sends mouse down events.
void GetMouseDownPoint(float &x, float &y) const
Get the x, y position of the last mouse down message.
int Height() const
Gets the height of the graphics context.
void PathClipRegion(const IRECT r=IRECT())
Clip the current path to a particular region.
void PathCircle(float cx, float cy, float r)
Add a circle to the current path.
void PathRadialLine(float cx, float cy, float angle, float rMin, float rMax)
Add a radial line to the current path.
void PathTransformRotate(float angle)
Apply a rotation transform to the current path.
bool GetResizingInProcess() const
bool OnKeyUp(float x, float y, const IKeyPress &key)
bool IsDirty(IRECTList &rects)
Called repeatedly at frame rate by the platform class to check what the graphics context says is dirt...
virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)
Fill a rounded rectangle with a color.
virtual void GetLayerBitmapData(const ILayerPtr &layer, RawBitmapData &data)=0
Get the contents of a layer as Raw RGBA bitmap data NOTE: you should only call this within IControl::...
bool RespondsToGesture(float x, float y)
Called by platform class to see if the point at x, y is linked to a gesture recognizer.
virtual void PromptForFile(WDL_String &fileName, WDL_String &path, EFileAction action=EFileAction::Open, const char *ext="", IFileDialogCompletionHandlerFunc completionHandler=nullptr)=0
Create a platform file prompt dialog to choose a path for opening/saving a single file.
void ForAllControls(T method, Args... args)
For all controls, including the "special controls" call a method.
void ClearGestureRegions()
Remove all gesture recognizers linked to regions.
void SetControlValueAfterTextEdit(const char *str)
Called by the platform class after returning from a text entry in order to update a control with a ne...
bool ControlIsCaptured(IControl *pControl) const
Check to see if the control is already captured.
virtual void GetMouseLocation(float &x, float &y) const =0
Get the x, y position of the mouse cursor.
virtual void * GetWinModuleHandle()
virtual void UpdateLayer()
Implemented by a graphics backend to prepare for drawing to the layer at the top of the stack.
virtual void DrawData(const IColor &color, const IRECT &bounds, float *normYPoints, int nPoints, float *normXPoints=nullptr, const IBlend *pBlend=0, float thickness=1.f, const IColor *pFillColor=nullptr)
Draw a line between a collection of normalized points.
void SetQwertyMidiKeyHandlerFunc(std::function< void(const IMidiMsg &msg)> func=nullptr)
A helper to set the IGraphics KeyHandlerFunc in order to make an instrument playable via QWERTY keys.
void AttachSVGBackground(const char *fileName)
Attach an ISVGControl as the lowest IControl in the control stack to be the background for the graphi...
virtual void FillTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0)
Fill a triangle with a color.
void ApplyLayerDropShadow(ILayerPtr &layer, const IShadow &shadow)
Applies a drop shadow directly onto a layer.
virtual void DrawGrid(const IColor &color, const IRECT &bounds, float gridSizeH, float gridSizeV, const IBlend *pBlend=0, float thickness=1.f)
Draw a grid to the graphics context.
void SetSharedResourcesSubPath(const char *sharedResourcesSubPath)
Sets the name of the shared resources subpath.
void SetAllControlsDirty()
Calls SetDirty() on every control.
virtual IBitmap ScaleBitmap(const IBitmap &inBitmap, const char *cacheName, int targetScale)
Returns a new IBitmap, an integer scaled version of the input, and adds it to the cache.
IControl * GetControlInTextEntry()
IBitmap GetScaledBitmap(IBitmap &inBitmap)
Get a version of the input bitmap from the cache that corresponds to the current screen scale For exa...
void AttachPanelBackground(const IPattern &color)
Attach an IPanelControl as the lowest IControl in the control stack to fill the background with a sol...
virtual void FillConvexPolygon(const IColor &color, float *x, float *y, int nPoints, const IBlend *pBlend=0)
Fill a convex polygon with a color.
bool OnMouseWheel(float x, float y, const IMouseMod &mod, float delta)
void SetAllControlsClean()
Calls SetClean() on every control.
virtual void OnViewInitialized(void *pContext)
Called after platform view initialization, so that drawing classes can e.g.
void StyleAllVectorControls(const IVStyle &style)
Helper method to style all of the controls which inherit IVectorBase.
virtual IPopupMenu * CreatePlatformPopupMenu(IPopupMenu &menu, const IRECT bounds, bool &isAsync)=0
Calls the platform backend to create the platform popup menu.
void RemoveControlWithTag(int ctrlTag)
Remove controls from the control list with a particular tag.
virtual void RemovePlatformView(void *pView)
Remove a previously attached platform view from the IGraphics view.
void GetTouches(IControl *pControl, std::vector< ITouchID > &touchesOnThisControl) const
Populate a vector with the touchIDs active on pControl.
void DrawVerticalLine(const IColor &color, const IRECT &bounds, float x, const IBlend *pBlend=0, float thickness=1.f)
Draw a vertical line, within a rectangular region of the graphics context.
virtual void PathMoveTo(float x, float y)=0
Move the current point in the current path.
virtual void PathArc(float cx, float cy, float r, float a1, float a2, EWinding winding=EWinding::CW)=0
Add an arc to the current path.
void PopupHostContextMenuForParam(int controlIdx, int paramIdx, float x, float y)
[VST3 primarily] In VST3 plug-ins this enable support for the IContextMenu interface,...
virtual bool FlippedBitmap() const =0
void PromptUserInput(IControl &control, const IRECT &bounds, int valIdx=0)
Prompt for user input either using a text entry or pop up menu.
virtual const char * GetPlatformAPIStr()
void SetControlSize(IControl *pControl, float w, float h)
Resize a control, redrawing the interface correctly.
float GetScreenScale() const
Gets the screen/display scaling factor, e.g.
virtual bool LoadAPIFont(const char *fontID, const PlatformFontPtr &font)=0
Drawing API method to load a font from a PlatformFontPtr, called internally.
bool ShowControlBoundsEnabled() const
void OnDropMultiple(const std::vector< const char * > &paths, float x, float y)
void AssignParamNameToolTips()
Call this method in order to create tool tips for every IControl that show the associated parameter's...
bool EnableMultiTouch(bool enable)
Enable/disable multi touch, if platform supports it.
virtual ISVG LoadSVG(const char *fileNameOrResID, const char *units="px", float dpi=72.f)
Load an SVG from disk or from windows resource.
virtual APIBitmap * LoadAPIBitmap(const char *fileNameOrResID, int scale, EResourceLocation location, const char *ext)=0
Drawing API method to load a bitmap, called internally.
virtual EMsgBoxResult ShowMessageBox(const char *str, const char *title, EMsgBoxType type, IMsgBoxCompletionHandlerFunc completionHandler=nullptr)=0
Pop up a modal platform message box dialog.
virtual void HideMouseCursor(bool hide=true, bool lock=true)=0
Call to hide/show the mouse cursor.
void SetScaleConstraints(float lo, float hi)
Sets the minimum and maximum (draw) scaling values.
virtual void PathQuadraticBezierTo(float cx, float cy, float x2, float y2)=0
Add a quadratic bezier to the current path from the current point to the specified location.
void DrawHorizontalLine(const IColor &color, const IRECT &bounds, float y, const IBlend *pBlend=0, float thickness=1.f)
Draw a horizontal line, within a rectangular region of the graphics context.
void ForControlInGroup(const char *group, IControlFunction func)
For all standard controls in the main control stack that are linked to a group, execute a function.
virtual void DoDrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=nullptr)=0
virtual EUIAppearance GetUIAppearance() const
Get the UI Appearance (Light/Dark mode)
void PathTransformSave()
Save the current affine transform of the current path.
virtual void FillArc(const IColor &color, float cx, float cy, float r, float a1, float a2, const IBlend *pBlend=0)
Fill an arc segment with a color.
IPopupMenu & GetPromptMenu()
void SetKeyHandlerFunc(IKeyHandlerFunc func)
Set a function that is called when key presses are not intercepted by any controls.
virtual void DrawDottedLine(const IColor &color, float x1, float y1, float x2, float y2, const IBlend *pBlend=0, float thickness=1.f, float dashLen=2.f)
Draw a dotted line to the graphics context.
virtual bool WindowIsOpen()
void RemoveTextEntryControl()
Remove the IGraphics text entry, use platform text entry if available.
void ShowFPSDisplay(bool enable)
Shows a control to display the frame rate of drawing.
virtual void PathLineTo(float x, float y)=0
Add a line to the current path from the current point to the specified location.
void DrawLineAcross(const IColor &color, const IRECT &bounds, EDirection dir, float pos, const IBlend *pBlend=0, float thickness=1.f)
Draw a horzional or vertical line, within a rectangular region of the graphics context.
int GetControlIdx(IControl *pControl) const
Get the index of a particular IControl in the control stack.
const char * GetSharedResourcesSubPath() const
Gets the name of the shared resources subpath.
IPopupMenuControl * GetPopupMenuControl()
void PathTransformSkew(float xAngle, float yAngle)
Apply a skew transform to the current path.
float GetDrawScale() const
Gets the graphics context scaling factor.
void DrawFittedLayer(const ILayerPtr &layer, const IRECT &bounds, const IBlend *pBlend)
Draw a layer to the main IGraphics context, fitting it to a rectangle that is different to the layer'...
virtual void DrawMultiLineText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some multi-line text to the graphics context in a specific rectangle (NanoVG only)
void RemoveControls(int fromIdx)
Remove controls from the control list above a particular index, (frees memory).
void AttachBackground(const char *fileName)
Attach an IBitmapControl as the lowest IControl in the control stack to be the background for the gra...
void SetStrictDrawing(bool strict)
Enables strict drawing mode.
bool MouseOverEnabled() const
virtual void ForceEndUserEdit()=0
Call to force end text entry (will cancel any half input text.
void OnGUIIdle()
This is an idle timer tick call on the GUI thread, only active if USE_IDLE_CALLS is defined.
IGEditorDelegate * GetDelegate()
Gets a pointer to the delegate class that handles communication to and from this graphics context.
void ShowAreaDrawn(bool enable)
IControl * GetControl(int idx)
Get the control at a certain index in the control stack.
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
int GetControlTag(const IControl *pControl) const
Get the tag given to a control.
void OnGestureRecognized(const IGestureInfo &info)
Called by platform class when a gesture is recognized.
virtual void CachePlatformFont(const char *fontID, const PlatformFontPtr &font)=0
Called to indicate that the platform should cache data about the platform font if needed.
bool OnMouseDblClick(float x, float y, const IMouseMod &mod)
bool TooltipsEnabled() const
virtual void DrawSVG(const ISVG &svg, const IRECT &bounds, const IBlend *pBlend=0, const IColor *pStrokeColor=nullptr, const IColor *pFillColor=nullptr)
Draw an SVG image to the graphics context.
void ForStandardControlsFunc(IControlFunction func)
For all standard controls in the main control stack perform a function.
virtual void DrawTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0, float thickness=1.f)
Draw a triangle to the graphics context.
virtual void CloseWindow()=0
Close the platform view for this graphics context.
virtual void PathCubicBezierTo(float c1x, float c1y, float c2x, float c2y, float x2, float y2)=0
Add a cubic bezier to the current path from the current point to the specified location.
int WindowHeight() const
Gets the height of the graphics context including draw scaling.
void PathEllipse(const IRECT &bounds)
Add an ellipse to the current path, specifying the rectangular region.
virtual IBitmap LoadBitmap(const char *fileNameOrResID, int nStates=1, bool framesAreHorizontal=false, int targetScale=0)
Load a bitmap image from disk or from windows resource.
void SetPlatformContext(void *pContext)
Set the platform draw context Used in order to set the platform level draw context - CGContextRef con...
virtual void BeginFrame()
Called at the beginning of drawing.
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
void OnSetCursor()
Called when the mouse enters the graphics context, to update the cursor to mCursorType.
void SetControlPosition(IControl *pControl, float x, float y)
Reposition a control, redrawing the interface correctly.
void SetScreenScale(float scale)
Called by the platform IGraphics class when moving to a new screen to set DPI.
void EnableMouseOver(bool enable)
virtual APIBitmap * LoadAPIBitmap(const char *name, const void *pData, int dataSize, int scale)=0
Drawing API method to load a bitmap from binary data, called internally.
ILayerPtr EndLayer()
End an IGraphics layer.
virtual WDL_TypedBuf< uint8_t > LoadResource(const char *fileNameOrResID, const char *fileType)
Load a resource from the file system, the bundle, or a Windows resource, and returns its data.
void OnDrop(const char *str, float x, float y)
IRECT GetBounds() const
Returns an IRECT that represents the entire UI bounds This is useful for programatically arranging UI...
IControl * AttachControl(IControl *pControl, int ctrlTag=kNoTag, const char *group="")
Attach an IControl to the graphics context and add it to the top of the control stack.
virtual void DrawBitmap(const IBitmap &bitmap, const IRECT &bounds, int srcX, int srcY, const IBlend *pBlend=0)=0
Draw a bitmap (raster) image to the graphics context.
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
A control to enable live modification of control layout in an IGraphics context in debug builds This ...
An abstraction that is used to store a temporary raster image/framebuffer.
Used to manage a list of rectangular areas and optimize them for drawing to the screen.
A Text entry widget drawn by IGraphics.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to describe a particular gesture.
Used to manage stroke behaviour for path based drawing back ends.
Used to manage composite/blend operations, independent of draw class/platform.
Used to manage color data, independent of draw class/platform.
Used to manage fill behaviour.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Used to store transformation matrices.
Encapsulates a MIDI message and provides helper functions.
Used to manage mouse modifiers i.e.
Used to store pattern information for gradients.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetPixelSnapped() const
User-facing SVG abstraction that you use to manage SVG data ISVG doesn't actually own the image data.
Used to specify properties of a drop-shadow to a layer.
IText is used to manage font and text/text entry style for a piece of text on the UI,...
A struct encapsulating a set of properties used to configure IVControls.