21BEGIN_IGRAPHICS_NAMESPACE
30 IVNumberBoxControl(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr,
const char* label =
"",
const IVStyle& style = DEFAULT_STYLE,
bool buttons =
false,
double defaultValue = 50.f,
double minValue = 1.f,
double maxValue = 100.f,
const char* fmtStr =
"%0.0f",
bool drawTriangle =
true)
34 .WithValueText(style.valueText.WithVAlign(EVAlign::Middle))
35 .WithLabelText(style.labelText.WithVAlign(EVAlign::Middle)))
40 , mRealValue(defaultValue)
41 , mDrawTriangle(drawTriangle)
43 assert(defaultValue >= minValue && defaultValue <= maxValue);
72 g.
FillTriangle(
GetColor(
mMouseIsOver ? kX1 : kSH), triangleRect.L, triangleRect.T, triangleRect.L + triangleRect.H(), triangleRect.MH(), triangleRect.L, triangleRect.B);
80 IRECT sections = mWidgetBounds;
99 IRECT sections = mWidgetBounds;
102 AddChildControl(mTextReadout =
new IVLabelControl(sections.
ReduceFromLeft(sections.
W() * (mButtons ? 0.75f : 1.f)),
"0", mStyle.WithDrawFrame(
true)));
104 mTextReadout->
SetStrFmt(32, mFmtStr.Get(), mRealValue);
115 if (mHideCursorOnDrag)
126 if (mHideCursorOnDrag)
132 mMouseIsDown =
false;
139 double gearing = IsFineControl(mod,
true) ? mSmallIncrement : mLargeIncrement;
140 mRealValue -= (double(dY) * gearing);
152 mRealValue = atof(str);
158 double gearing = IsFineControl(mod,
true) ? mSmallIncrement : mLargeIncrement;
159 double inc = (d > 0.f ? 1. : -1.) * gearing;
169 OnValueChanged(
true);
180 OnValueChanged(
true);
198 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const
204 return wheel ? mod.C : mod.R;
207 return (mod.C || mod.S);
211 void OnValueChanged(
bool preventAction =
false)
213 mRealValue =
Clip(mRealValue, mMinValue, mMaxValue);
215 mTextReadout->
SetStrFmt(32, mFmtStr.Get(), mRealValue);
223 double GetRealValue()
const {
return mRealValue; }
225 void SetDrawTriangle(
bool draw) { mDrawTriangle = draw;
SetDirty(
false); }
229 IActionFunction mIncrementFunc = [
this](
IControl* pCaller) { mRealValue += mLargeIncrement; OnValueChanged(); };
230 IActionFunction mDecrementFunc = [
this](
IControl* pCaller) { mRealValue -= mLargeIncrement; OnValueChanged(); };
235 double mLargeIncrement = 1.f;
236 double mSmallIncrement = 0.1f;
239 double mRealValue = 0.f;
240 bool mHideCursorOnDrag =
true;
241 bool mButtons =
false;
242 bool mDrawTriangle =
true;
243 bool mMouseIsDown =
false;
246END_IGRAPHICS_NAMESPACE
This file contains the base IControl implementation, along with some base classes for specific types ...
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
The lowest level base class of an IGraphics control.
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
virtual void SetValueFromDelegate(double value, int valIdx=0)
Set the control's value from the delegate This method is called from the class implementing the IEdit...
virtual void SetValueFromUserInput(double value, int valIdx=0)
Set the control's value after user input.
int GetParamIdx(int valIdx=0) const
Get the index of a parameter that the control is linked to Normaly controls are either linked to a si...
const IRECT & GetRECT() const
Get the rectangular draw area for this control, within the graphics context.
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
const IParam * GetParam(int valIdx=0) const
Get a const pointer to the IParam object (owned by the editor delegate class), associated with this c...
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the 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.
virtual void BeginInformHostOfParamChangeFromUI(int paramIdx)=0
Called by the UI at the beginning of a parameter change gesture, in order to notify the host (via a c...
virtual void EndInformHostOfParamChangeFromUI(int paramIdx)=0
Called by the user interface at the end of a parameter change gesture, in order to notify the host (v...
The lowest level base class of an IGraphics context.
void CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
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 FillTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0)
Fill a triangle with a color.
virtual void HideMouseCursor(bool hide=true, bool lock=true)=0
Call to hide/show the mouse cursor.
double GetDefault(bool normalized=false) const
Returns the parameter's default value.
double GetMin() const
Returns the parameter's minimum value.
double FromNormalized(double normalizedValue) const
Convert a normalized value to real value for this parameter.
double GetMax() const
Returns the parameter's maximum value.
virtual void SetStrFmt(int maxlen, const char *fmt,...)
Set the text to display, using a printf-like format string.
const char * GetStr() const
A vector label control that can display text with a shadow.
A "meta control" for a number box with an Inc/Dec button It adds several child buttons if buttons = t...
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
void SetValueFromDelegate(double value, int valIdx=0) override
Set the control's value from the delegate This method is called from the class implementing the IEdit...
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
void SetValueFromUserInput(double value, int valIdx=0) override
Set the control's value after user input.
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void SetStyle(const IVStyle &style) override
Set the Style of this IVControl.
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
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 SetStyle(const IVStyle &style)
Set the Style of this IVControl.
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.
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.
IRECT ReduceFromLeft(float amount)
Reduce in width from the left edge by 'amount' and return the removed region.
void Pad(float padding)
Pad this IRECT N.B.
IRECT FracRectVertical(float frac, bool fromTop=false) const
Returns a new IRECT with a height that is multiplied by frac.
bool Contains(const IRECT &rhs) const
Returns true if this IRECT completely contains rhs.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
A struct encapsulating a set of properties used to configure IVControls.