22BEGIN_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);
171END_IGRAPHICS_NAMESPACE
This file contains the base IControl implementation, along with some base classes for specific types ...
The lowest level base class of an IGraphics control.
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.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
bool IsDirty() override
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(),...
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 PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
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.
virtual const char * GetDrawingAPIStr()=0
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
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.
A base interface to be combined with IControl for vectorial controls "IVControls",...
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
Used to manage mouse modifiers i.e.
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.
IText is used to manage font and text/text entry style for a piece of text on the UI,...