21 BEGIN_IGRAPHICS_NAMESPACE
25 template <
int MAXNC = 1>
29 using OnNewValueFunc = std::function<void(int trackIdx, double val)>;
31 static constexpr
int kMsgTagSetHighlight = 0;
42 mDrawTrackFrame =
false;
56 mDrawTrackFrame =
false;
70 mDrawTrackFrame =
false;
84 void SnapToMouse(
float x,
float y, EDirection direction,
const IRECT& bounds,
int valIdx = -1 ,
double minClip = 0.,
double maxClip = 1.)
override 92 int step = GetStepIdxForPos(x, y);
94 if(direction == EDirection::Vertical)
98 y = mStepBounds.Get()[step].T;
100 if(mStepBounds.GetSize() == 1)
103 value = step * (1.f/float(mStepBounds.GetSize()-1));
107 value = 1.f - (y-bounds.
T) / bounds.
H();
110 for(
auto i = 0; i < nVals; i++)
112 if(mTrackBounds.Get()[i].ContainsEdge(x, mTrackBounds.Get()[i].MH()))
123 x = mStepBounds.Get()[step].L;
125 if(mStepBounds.GetSize() == 1)
128 value = 1.- (step * (1.f/float(mStepBounds.GetSize()-1)));
132 value = (x-bounds.
L) / bounds.
W();
134 for(
auto i = 0; i < nVals; i++)
136 if(mTrackBounds.Get()[i].ContainsEdge(mTrackBounds.Get()[i].MW(), y))
145 value = std::round(value / mGrain) * mGrain;
152 mSliderHit = sliderTest;
153 mMouseOverTrack = mSliderHit;
155 if (!GetStepped() && mPrevSliderHit != -1)
157 if (abs(mPrevSliderHit - mSliderHit) > 1 )
159 int lowBounds, highBounds;
161 if (mPrevSliderHit < mSliderHit)
163 lowBounds = mPrevSliderHit;
164 highBounds = mSliderHit;
168 lowBounds = mSliderHit;
169 highBounds = mPrevSliderHit;
172 for (
auto i = lowBounds; i < highBounds; i++)
174 double frac = (double)(i - lowBounds) / double(highBounds-lowBounds);
180 mPrevSliderHit = mSliderHit;
193 if(GetStepped() && !mZeroValueStepHasBounds && mPrevSliderHit != -1)
199 int step = GetStepIdxForPos(x, y);
203 float y = mStepBounds.Get()[step].T;
204 double valueAtStep = 1.f - (y-mWidgetBounds.
T) / mWidgetBounds.
H();
230 if (!
IsDisabled() && msgTag == kMsgTagSetHighlight && dataSize ==
sizeof(
int))
232 SetHighlightedTrack(*reinterpret_cast<const int*>(pData));
240 mOnNewValueFunc(trackIdx, val);
243 void SetOnNewValueFunc(OnNewValueFunc func)
245 mOnNewValueFunc = func;
248 int GetLastSliderHit()
const 254 OnNewValueFunc mOnNewValueFunc =
nullptr;
255 int mPrevSliderHit = -1;
257 double mGrain = 0.001;
262 template <
int MAXNC = 1>
274 END_IGRAPHICS_NAMESPACE
Used to manage a rectangular area, independent of draw class/platform.
virtual void OnNewValue(int trackIdx, double val)
override to do something when an individual slider is dragged
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void Draw(IGraphics &g) override
Draw the control to the graphics 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.
IVMultiSliderControl(const IRECT &bounds, const char *label, const IVStyle &style=DEFAULT_STYLE, int nSteps=0, EDirection dir=EDirection::Vertical)
Constructs a vector multi slider control that is not linked to parameters.
Used to manage mouse modifiers i.e.
T Lerp(T a, T b, T f)
Linear interpolate between values a and b.
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 OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() ...
This file contains the base IControl implementation, along with some base classes for specific types ...
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
The lowest level base class of an IGraphics context.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
void Constrain(float &x, float &y) const
Ensure the point (x,y) is inside this IRECT.
IVMultiSliderControl(const IRECT &bounds, const char *label, const IVStyle &style, const std::initializer_list< int > ¶ms, int nSteps, EDirection dir)
Constructs a vector multi slider control that is linked to a list of parameters that need not be sequ...
double GetValue(int valIdx=0) const
Get the control's value.
void SnapToMouse(float x, float y, EDirection direction, const IRECT &bounds, int valIdx=-1, double minClip=0., double maxClip=1.) override
Set control value based on x, y position within a rectangle.
float L
Left side of the rectangle (X)
int GetValIdxForPos(float x, float y) const override
Check to see which of the control's values relates to this x and y coordinate.
A vectorial multi-slider control.
A vectorial multi-toggle control, could be used for a trigger in a step sequencer or tarnce gate...
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
IVMultiSliderControl(const IRECT &bounds, const char *label, const IVStyle &style, int loParamIdx, int nSteps, EDirection dir)
Constructs a vector multi slider control that is linked to sequential parameters. ...
float T
Top of the rectangle (Y)
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
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.