iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
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
23using namespace iplug;
24using namespace igraphics;
25
29 , public IBitmapBase
30{
31public:
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 GetUI()->CreatePopupMenu(*this, mMenu, x, y);
50
51 SetDirty(false);
52 }
53
54 void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override
55 {
56 if(pSelectedMenu)
57 mKernelType = pSelectedMenu->GetChosenItemIdx();
58 }
59
60private:
61 int mKernelType = 0;
62 NVGframebuffer* mFBO = nullptr;
63 IPopupMenu mMenu {"MPS Type", 0, false, {"MPSImageGaussianBlur", "MPSImageSobel", "MPSImageThresholdToZero"}};
64};
65
66#else
69{
70public:
71 TestMPSControl(IRECT rect, const IBitmap& bmp, int paramIdx)
72 : IControl(rect)
73 {
74 SetTooltip("TestMPSControl");
75 }
76
77 void Draw(IGraphics& g) override
78 {
79 g.DrawText(mText, "UNSUPPORTED", mRECT);
80 }
81};
82#endif
This file contains the base IControl implementation, along with some base classes for specific types ...
A base interface to be combined with IControl for bitmap-based controls "IBControls",...
Definition: IControl.h:719
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
IGraphics * GetUI()
Definition: IControl.h:467
virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
Definition: IControl.cpp:283
virtual void OnMouseDown(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:252
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
Definition: IControl.h:216
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
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:670
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.
Definition: IGraphics.cpp:1960
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1368
A class for setting the contents of a pop up menu.
Control to test IGraphicsNanoVG with Metal Performance Shaders.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.