iPlug2 - C++ Audio Plug-in Framework
TestMPSControl.h
1 /*
2  ==============================================================================
3 
4  This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5 
6  See LICENSE.txt for more info.
7 
8  ==============================================================================
9  */
10 
11 #pragma once
12 
13 #include "IControl.h"
14 #if defined IGRAPHICS_NANOVG && defined IGRAPHICS_METAL
15 
21 #include "IGraphicsNanoVG.h"
22 
23 using namespace iplug;
24 using namespace igraphics;
25 
28 class TestMPSControl : public IKnobControlBase
29  , public IBitmapBase
30 {
31 public:
32  TestMPSControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx)
33  : IKnobControlBase(bounds, paramIdx)
34  , IBitmapBase(bitmap)
35  {
36  SetTooltip("TestMPSControl");
37  }
38 
40  {
41  if (mFBO)
42  nvgDeleteFramebuffer(mFBO);
43  }
44 
45  void Draw(IGraphics& g) override;
46 
47  void OnMouseDown(float x, float y, const IMouseMod& mod) override
48  {
49  if(mod.R)
50  GetUI()->CreatePopupMenu(*this, mMenu, x, y);
51 
52  SetDirty(false);
53  }
54 
55  void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override
56  {
57  if(pSelectedMenu)
58  mKernelType = pSelectedMenu->GetChosenItemIdx();
59  }
60 
61 private:
62  int mKernelType = 0;
63  NVGframebuffer* mFBO = nullptr;
64  IPopupMenu mMenu {"MPS Type", 0, false, {"MPSImageGaussianBlur", "MPSImageSobel", "MPSImageThresholdToZero"}};
65 };
66 
67 #else
68 
69 class TestMPSControl : public IControl
70 {
71 public:
72  TestMPSControl(IRECT rect, const IBitmap& bmp, int paramIdx)
73  : IControl(rect)
74  {
75  SetTooltip("TestMPSControl");
76  }
77 
78  void Draw(IGraphics& g) override
79  {
80  g.DrawText(mText, "UNSUPPORTED", mRECT);
81  }
82 };
83 #endif
The lowest level base class of an IGraphics control.
Definition: IControl.h:42
Used to manage a rectangular area, independent of draw class/platform.
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
Used to manage mouse modifiers i.e.
A base interface to be combined with IControl for bitmap-based controls "IBControls", managing an IBitmap.
Definition: IControl.h:586
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.
Definition: IGraphics.cpp:631
This file contains the base IControl implementation, along with some base classes for specific types ...
A class for setting the contents of a pop up menu.
Control to test IGraphicsNanoVG with Metal Performance Shaders.
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1191
void Draw(IGraphics &g) override
Draw the control to the graphics context.