22 BEGIN_IGRAPHICS_NAMESPACE
31 static constexpr
int MAXBUF = 100;
51 mNameLabelText =
IText(14,
GetColor(kFR), DEFAULT_FONT, EAlign::Near, EVAlign::Bottom);
58 if(mStyle == kNumStyles)
67 void Update(
float frameTime)
69 mReadPos = (mReadPos+1) % MAXBUF;
70 mBuffer[mReadPos] = frameTime;
76 for (
int i = 0; i < MAXBUF; i++)
79 avg = avg / (float)MAXBUF;
97 for (
int i = 0; i < MAXBUF; i++) {
98 float v = 1.0f / (0.00001f + mBuffer[(mReadPos+i) % MAXBUF]);
100 if (v > 80.0f) v = 80.0f;
101 vx = x + ((float)i/(MAXBUF-1)) * w;
102 vy = y + h - ((v / 80.0f) * h);
106 else if (mStyle == kPercentage)
108 for (
int i = 0; i < MAXBUF; i++) {
109 float v = mBuffer[(mReadPos+i) % MAXBUF] * 1.0f;
111 if (v > 100.0f) v = 100.0f;
112 vx = x + ((float)i/(MAXBUF-1)) * w;
113 vy = y + h - ((v / 100.0f) * h);
119 for (
int i = 0; i < MAXBUF; i++) {
120 float v = mBuffer[(mReadPos+i) % MAXBUF] * 1000.0f;
122 if (v > 20.0f) v = 20.0f;
123 vx = x + ((float)i/(MAXBUF-1)) * w;
124 vy = y + h - ((v / 20.0f) * h);
134 if (mNameLabel.GetLength())
135 g.
DrawText(mNameLabelText, mNameLabel.Get(), padded);
141 str.SetFormatted(32,
"%.2f FPS", 1.0f / avg);
142 g.
DrawText(mTopLabelText, str.Get(), padded);
144 str.SetFormatted(32,
"%.2f ms", avg * 1000.0f);
145 g.
DrawText(mBottomLabelText, str.Get(), padded);
147 else if (mStyle == kPercentage)
149 str.SetFormatted(32,
"%.1f %%", avg * 1.0f);
150 g.
DrawText(mTopLabelText, str.Get(), padded);
154 str.SetFormatted(32,
"%.2f ms", avg * 1000.0f);
155 g.
DrawText(mTopLabelText, str.Get(), padded);
160 WDL_String mNameLabel;
161 float mBuffer[MAXBUF] = {};
164 float mPadding = 1.f;
165 IText& mNameLabelText = mText;
166 IText mAPILabelText =
IText(14,
GetColor(kFR), DEFAULT_FONT, EAlign::Near, EVAlign::Top);
167 IText mTopLabelText =
IText(18,
GetColor(kFR), DEFAULT_FONT, EAlign::Far, EVAlign::Top);
168 IText mBottomLabelText =
IText(15,
GetColor(kFR), DEFAULT_FONT, EAlign::Far, EVAlign::Bottom);
171 END_IGRAPHICS_NAMESPACE
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.
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
Used to manage mouse modifiers i.e.
virtual void PathLineTo(float x, float y)=0
Add a line to the current path from the current point to the specified location.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
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.
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
This file contains the base IControl implementation, along with some base classes for specific types ...
float R
Right side of the rectangle (X + W)
bool IsDirty() override
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(), to determine if the control is marked as dirty.
IText is used to manage font and text/text entry style for a piece of text on the UI...
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.
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
Performance display meter, based on code from NanoVG This is a special control that lives outside the...
void Draw(IGraphics &g) override
Draw the control to the graphics context.
The lowest level base class of an IGraphics context.
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
float L
Left side of the rectangle (X)
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!
float T
Top of the rectangle (Y)
virtual const char * GetDrawingAPIStr()=0
float B
Bottom of the rectangle (Y + H)