23 BEGIN_IGRAPHICS_NAMESPACE
30 static constexpr
int MAX_BUFFER_SIZE = 2048;
32 IVDisplayControl(
const IRECT& bounds,
const char* label =
"",
const IVStyle& style = DEFAULT_STYLE, EDirection dir = EDirection::Horizontal,
float lo = 0.,
float hi = 1.f,
float defaultVal = 0., uint32_t bufferSize = 100,
float strokeThickness = 2.f)
35 , mBuffer(bufferSize, defaultVal)
38 , mStrokeThickness(strokeThickness)
41 assert(bufferSize > 0 && bufferSize < MAX_BUFFER_SIZE);
48 mBuffer[mReadPos] = v;
49 mReadPos = (mReadPos+1) % mBuffer.size();
57 mPlotBounds = mWidgetBounds.
GetPadded(mDirection == EDirection::Horizontal ? 0.f : -mStrokeThickness,
58 mDirection == EDirection::Horizontal ? -mStrokeThickness : 0.f,
59 mDirection == EDirection::Horizontal ? 0.f : -mStrokeThickness,
60 mDirection == EDirection::Horizontal ? -mStrokeThickness : 0.f);
77 float x = mPlotBounds.
L;
78 float y = mPlotBounds.
T;
79 float w = mPlotBounds.
W();
80 float h = mPlotBounds.
H();
82 const int sz =
static_cast<int>(mBuffer.size());
84 auto getPlotPos = [&](
int pos,
float axis,
float extrem) {
85 float v = mBuffer[(mReadPos+pos) % sz];
86 v = (v - mLoValue) / (mHiValue - mLoValue);
87 return axis + extrem - (v * extrem);
90 if(mDirection == EDirection::Horizontal)
94 for (
int i = 0; i < sz; i++)
96 float vx = x + ((float)i/(sz-1)) * w;
97 float vy = getPlotPos(i, y, h);
105 for (
int i = 0; i < sz; i++)
107 float vx = getPlotPos(i, x, w);
108 float vy = y + ((float)i/(sz-1)) * h;
124 pos = stream.
Get(&d, pos);
131 std::vector<float> mBuffer;
132 float mLoValue = 0.f;
133 float mHiValue = 1.f;
135 float mStrokeThickness = 2.f;
136 EDirection mDirection;
140 END_IGRAPHICS_NAMESPACE
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
virtual void PathMoveTo(float x, float y)=0
Move the current point in the current path.
The lowest level base class of an IGraphics control.
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.
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
virtual void PathLineTo(float x, float y)=0
Add a line to the current path from the current point to the specified location.
virtual void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options=IStrokeOptions(), const IBlend *pBlend=0)=0
Stroke the current current path.
Used to manage stroke behaviour for path based drawing back ends.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
This file contains the base IControl implementation, along with some base classes for specific types ...
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...
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
The lowest level base class of an IGraphics context.
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() ...
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control...
float L
Left side of the rectangle (X)
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
static IPattern CreateLinearGradient(float x1, float y1, float x2, float y2, const std::initializer_list< IColorStop > &stops={})
Create a linear gradient IPattern.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
A base interface to be combined with IControl for vectorial controls "IVControls", in order for them to share a common style If you need more flexibility, you're on your own!
A control to display a rolling graphics of historical values.
float T
Top of the rectangle (Y)
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.