mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
added control over parameters used in velocity-sensitive mode
This commit is contained in:
parent
056a096c18
commit
29a4d1f99c
2 changed files with 49 additions and 9 deletions
|
|
@ -105,6 +105,9 @@ Slider::Slider (const String& name)
|
|||
maximum (10),
|
||||
interval (0),
|
||||
skewFactor (1.0),
|
||||
velocityModeSensitivity (1.0),
|
||||
velocityModeOffset (0.0),
|
||||
velocityModeThreshold (1),
|
||||
rotaryStart (float_Pi * 1.2f),
|
||||
rotaryEnd (float_Pi * 2.8f),
|
||||
numDecimalPlaces (7),
|
||||
|
|
@ -221,6 +224,19 @@ void Slider::setVelocityBasedMode (const bool velBased) throw()
|
|||
isVelocityBased = velBased;
|
||||
}
|
||||
|
||||
void Slider::setVelocityModeParameters (const double sensitivity,
|
||||
const int threshold,
|
||||
const double offset) throw()
|
||||
{
|
||||
jassert (threshold >= 0);
|
||||
jassert (sensitivity > 0);
|
||||
jassert (offset >= 0);
|
||||
|
||||
velocityModeSensitivity = sensitivity;
|
||||
velocityModeOffset = offset;
|
||||
velocityModeThreshold = threshold;
|
||||
}
|
||||
|
||||
void Slider::setSkewFactor (const double factor) throw()
|
||||
{
|
||||
skewFactor = factor;
|
||||
|
|
@ -1188,7 +1204,10 @@ void Slider::mouseDrag (const MouseEvent& e)
|
|||
|
||||
if (speed != 0)
|
||||
{
|
||||
speed = 0.2 * (1.0 + sin (double_Pi * (1.5 + jmax (0.0, speed - 1.0) / maxSpeed)));
|
||||
speed = 0.2 * velocityModeSensitivity
|
||||
* (1.0 + sin (double_Pi * (1.5 + jmin (0.5, velocityModeOffset
|
||||
+ jmax (0.0, (double) (speed - velocityModeThreshold))
|
||||
/ maxSpeed))));
|
||||
|
||||
if (mouseDiff < 0)
|
||||
speed = -speed;
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ public:
|
|||
*/
|
||||
SliderStyle getSliderStyle() const throw() { return style; }
|
||||
|
||||
//==============================================================================
|
||||
/** Changes the properties of a rotary slider.
|
||||
|
||||
@param startAngleRadians the angle (in radians, clockwise from the top) at which
|
||||
|
|
@ -137,6 +138,15 @@ public:
|
|||
const float endAngleRadians,
|
||||
const bool stopAtEnd);
|
||||
|
||||
/** Sets the distance the mouse has to move to drag the slider across
|
||||
the full extent of its range.
|
||||
|
||||
This only applies when in modes like RotaryHorizontalDrag, where it's using
|
||||
relative mouse movements to adjust the slider.
|
||||
*/
|
||||
void setMouseDragSensitivity (const int distanceForFullScaleDrag);
|
||||
|
||||
//==============================================================================
|
||||
/** Changes the way the the mouse is used when dragging the slider.
|
||||
|
||||
If true, this will turn on velocity-sensitive dragging, so that
|
||||
|
|
@ -147,6 +157,22 @@ public:
|
|||
*/
|
||||
void setVelocityBasedMode (const bool isVelocityBased) throw();
|
||||
|
||||
/** Changes aspects of the scaling used when in velocity-sensitive mode.
|
||||
|
||||
These apply when you've used setVelocityBasedMode() to turn on velocity mode,
|
||||
or if you're holding down ctrl.
|
||||
|
||||
@param sensitivity higher values than 1.0 increase the range of acceleration used
|
||||
@param threshold the minimum number of pixels that the mouse needs to move for it
|
||||
to be treated as a movement
|
||||
@param offset values greater than 0.0 increase the minimum speed that will be used when
|
||||
the threshold is reached
|
||||
*/
|
||||
void setVelocityModeParameters (const double sensitivity = 1.0,
|
||||
const int threshold = 1.0,
|
||||
const double offset = 0.0) throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Sets up a skew factor to alter the way values are distributed.
|
||||
|
||||
You may want to use a range of values on the slider where more accuracy
|
||||
|
|
@ -173,14 +199,7 @@ public:
|
|||
*/
|
||||
void setSkewFactorFromMidPoint (const double sliderValueToShowAtMidPoint) throw();
|
||||
|
||||
/** Sets the distance the mouse has to move to drag the slider across
|
||||
the full extent of its range.
|
||||
|
||||
This only applies when in modes like RotaryHorizontalDrag, where it's using
|
||||
relative mouse movements to adjust the slider.
|
||||
*/
|
||||
void setMouseDragSensitivity (const int distanceForFullScaleDrag);
|
||||
|
||||
//==============================================================================
|
||||
/** Used by setIncDecButtonsMode().
|
||||
*/
|
||||
enum IncDecButtonMode
|
||||
|
|
@ -637,6 +656,8 @@ private:
|
|||
double currentValue, valueMin, valueMax;
|
||||
double minimum, maximum, interval, doubleClickReturnValue;
|
||||
double valueWhenLastDragged, valueOnMouseDown, skewFactor, lastAngle;
|
||||
double velocityModeSensitivity, velocityModeOffset;
|
||||
int velocityModeThreshold;
|
||||
float rotaryStart, rotaryEnd;
|
||||
int numDecimalPlaces, mouseXWhenLastDragged, mouseYWhenLastDragged;
|
||||
int sliderRegionStart, sliderRegionSize;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue