23BEGIN_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);
50 mPlotBounds = mWidgetBounds.
GetPadded(mDirection == EDirection::Horizontal ? 0.f : -mStrokeThickness,
51 mDirection == EDirection::Horizontal ? -mStrokeThickness : 0.f,
52 mDirection == EDirection::Horizontal ? 0.f : -mStrokeThickness,
53 mDirection == EDirection::Horizontal ? -mStrokeThickness : 0.f);
70 float x = mPlotBounds.L;
71 float y = mPlotBounds.T;
72 float w = mPlotBounds.
W();
73 float h = mPlotBounds.
H();
75 const int sz =
static_cast<int>(mBuffer.size());
77 auto getPlotPos = [&](
int pos,
float axis,
float extrem) {
78 float v = mBuffer[(mReadPos+pos) % sz];
79 v = (v - mLoValue) / (mHiValue - mLoValue);
80 return axis + extrem - (v * extrem);
83 if(mDirection == EDirection::Horizontal)
87 for (
int i = 0; i < sz; i++)
89 float vx = x + ((float)i/(sz-1)) * w;
90 float vy = getPlotPos(i, y, h);
98 for (
int i = 0; i < sz; i++)
100 float vx = getPlotPos(i, x, w);
101 float vy = y + ((float)i/(sz-1)) * h;
106 strokeOptions.mJoinOption = ELineJoin::Bevel;
112 auto Update = [&](
float v) {
113 mBuffer[mReadPos] = v;
114 mReadPos = (mReadPos+1) % mBuffer.size();
124 pos = stream.
Get(&d, pos);
130 std::vector<float> mBuffer;
131 float mLoValue = 0.f;
132 float mHiValue = 1.f;
134 float mStrokeThickness = 2.f;
135 EDirection mDirection;
139END_IGRAPHICS_NAMESPACE
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.
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
The lowest level base class of an IGraphics control.
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
The lowest level base class of an IGraphics context.
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 PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options=IStrokeOptions(), const IBlend *pBlend=0)=0
Stroke the current current path.
virtual void PathMoveTo(float x, float y)=0
Move the current point in the current path.
virtual void PathLineTo(float x, float y)=0
Add a line to the current path from the current point to the specified location.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
A control to display a rolling graphics of historical values.
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
A base interface to be combined with IControl for vectorial controls "IVControls",...
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
Used to manage stroke behaviour for path based drawing back ends.
static IPattern CreateLinearGradient(float x1, float y1, float x2, float y2, const std::initializer_list< IColorStop > &stops={})
Create a linear gradient IPattern.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
ISenderData is used to represent a typed data packet, that may contain values for multiple channels.
A struct encapsulating a set of properties used to configure IVControls.