21 #include "IPlugStructs.h" 24 BEGIN_IGRAPHICS_NAMESPACE
28 template <
int MAXNC = 1>
32 IVMeterControl(
const IRECT& bounds,
const char* label,
const IVStyle& style = DEFAULT_STYLE, EDirection dir = EDirection::Vertical, std::initializer_list<const char*> trackNames = {},
int totalNSegs = 0,
float lowRangeDB = -72.f,
float highRangeDB = 12.f)
34 , mLowRangeDB(lowRangeDB)
35 , mHighRangeDB(highRangeDB)
57 pos = stream.
Get(&d, pos);
59 double lowPointAbs = std::fabs(mLowRangeDB);
60 double rangeDB = std::fabs(mHighRangeDB - mLowRangeDB);
61 for (
auto c = d.chanOffset; c < (d.chanOffset + d.nChans); c++)
63 double ampValue =
AmpToDB(static_cast<double>(d.vals[c]));
64 double linearPos = (ampValue + lowPointAbs)/rangeDB;
76 const static IColor LED1 = {255, 36, 157, 16};
77 const static IColor LED2 = {255, 153, 191, 28};
78 const static IColor LED3 = {255, 215, 222, 37};
79 const static IColor LED4 = {255, 247, 153, 33};
80 const static IColor LED5 = COLOR_RED;
84 template <
int MAXNC = 1>
96 LEDRange(
float lowRangeDB,
float highRangeDB,
int nSegs,
IColor color)
97 : lowRangeDB(lowRangeDB)
98 , highRangeDB(highRangeDB)
105 IVLEDMeterControl(
const IRECT& bounds,
int totalNSegs = 13,
const std::vector<LEDRange>& ranges = {{0., 6., 1, LED5},{-18., 0., 3, LED4}, {-36., -18., 3, LED3}, {-54., -36., 3, LED2}, {-72., -54., 3, LED1}},
const char* label =
"",
const IVStyle& style = DEFAULT_STYLE, EDirection dir = EDirection::Vertical, std::initializer_list<const char*> trackNames = {})
115 for (
auto ledRange : ranges)
117 if(ledRange.lowRangeDB < minRange)
118 minRange = ledRange.lowRangeDB;
120 if(ledRange.highRangeDB > maxRange)
121 maxRange = ledRange.highRangeDB;
123 nSegs += ledRange.nSegs;
126 assert(totalNSegs == nSegs);
139 void DrawTrackBackground(
IGraphics &g,
const IRECT &r,
int chIdx)
override 144 const float valPos = (dir == EDirection::Vertical) ? r.
B - (val * r.
H()) : r.
R - ((1.f-val) * r.
W());
148 for (
auto ledRange : mLEDRanges)
150 for (
auto i = 0; i < ledRange.nSegs; i++)
153 if(dir == EDirection::Vertical)
155 segRect = r.
GetGridCell(segIdx + i, totalNSegs, 1, dir, 1);
157 if(segRect.
MH() > valPos)
162 segRect = r.
GetGridCell(totalNSegs - 1 - (segIdx + i), 1, totalNSegs, dir, 1);
164 if(segRect.
MW() < valPos)
168 segIdx += ledRange.nSegs;
178 std::vector<LEDRange> mLEDRanges;
181 END_IGRAPHICS_NAMESPACE
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
Used to manage a rectangular area, independent of draw class/platform.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
void DrawTrackHandle(IGraphics &g, const IRECT &r, int chIdx, bool aboveBaseValue) override
Draw the main body of the track.
Used to manage color data, independent of draw class/platform.
Vectorial multi-channel capable meter control.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
This file contains the base IControl implementation, along with some base classes for specific types ...
float R
Right side of the rectangle (X + W)
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Manages a non-owned block of memory, for receiving arbitrary message byte streams.
ISenderData is used to represent a typed data packet, that may contain values for multiple channels...
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
Vectorial multi-channel capable meter control with segmented LEDs.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
LED Range comprises info for a range of LED segments.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
The lowest level base class of an IGraphics context.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() ...
IRECT GetGridCell(int row, int col, int nRows, int nColumns) const
Get a subrect (by row, column) of this IRECT which is a cell in a grid of size (nRows * nColumns) ...
double GetValue(int valIdx=0) const
Get the control's value.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
static double AmpToDB(double amp)
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
A struct encapsulating a set of properties used to configure IVControls.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
float B
Bottom of the rectangle (Y + H)