Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
37d0e6c22d
2 changed files with 23 additions and 10 deletions
  1. +22
    -9
      src/juce_appframework/gui/components/controls/juce_Slider.cpp
  2. +1
    -1
      src/juce_appframework/gui/components/controls/juce_Slider.h

+ 22
- 9
src/juce_appframework/gui/components/controls/juce_Slider.cpp View File

@@ -1011,6 +1011,8 @@ void Slider::mouseDown (const MouseEvent& e)
} }
} }
minMaxDiff = valueMax - valueMin;
mouseXWhenLastDragged = e.x; mouseXWhenLastDragged = e.x;
mouseYWhenLastDragged = e.y; mouseYWhenLastDragged = e.y;
lastAngle = rotaryStart + (rotaryEnd - rotaryStart) lastAngle = rotaryStart + (rotaryEnd - rotaryStart)
@@ -1086,13 +1088,14 @@ void Slider::restoreMouseIfHidden()
c->enableUnboundedMouseMovement (false); c->enableUnboundedMouseMovement (false);
int x = getWidth() / 2;
int y = getHeight() / 2;
const double pos = (sliderBeingDragged == 2) ? getMaxValue()
: ((sliderBeingDragged == 1) ? getMinValue()
: currentValue);
const int pixelPos = (int) getLinearSliderPos (pos);
if (isHorizontal())
x = (int) getLinearSliderPos (currentValue);
else if (isVertical())
y = (int) getLinearSliderPos (currentValue);
int x = isHorizontal() ? pixelPos : (getWidth() / 2);
int y = isVertical() ? pixelPos : (getHeight() / 2);
relativePositionToGlobal (x, y); relativePositionToGlobal (x, y);
Desktop::setMousePosition (x, y); Desktop::setMousePosition (x, y);
@@ -1185,7 +1188,7 @@ void Slider::mouseDrag (const MouseEvent& e)
return; return;
} }
if (isVelocityBased == e.mods.isAnyModifierKeyDown()
if (isVelocityBased == (e.mods.testFlags (ModifierKeys::ctrlModifier | ModifierKeys::commandModifier | ModifierKeys::altModifier))
|| ((maximum - minimum) / sliderRegionSize < interval)) || ((maximum - minimum) / sliderRegionSize < interval))
{ {
const int mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.x : e.y; const int mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.x : e.y;
@@ -1263,14 +1266,24 @@ void Slider::mouseDrag (const MouseEvent& e)
else if (sliderBeingDragged == 1) else if (sliderBeingDragged == 1)
{ {
setMinValue (snapValue (valueWhenLastDragged, true), setMinValue (snapValue (valueWhenLastDragged, true),
! sendChangeOnlyOnRelease, false);
! sendChangeOnlyOnRelease, false);
if (e.mods.isShiftDown())
setMaxValue (getMinValue() + minMaxDiff, false);
else
minMaxDiff = valueMax - valueMin;
} }
else else
{ {
jassert (sliderBeingDragged == 2); jassert (sliderBeingDragged == 2);
setMaxValue (snapValue (valueWhenLastDragged, true), setMaxValue (snapValue (valueWhenLastDragged, true),
! sendChangeOnlyOnRelease, false);
! sendChangeOnlyOnRelease, false);
if (e.mods.isShiftDown())
setMinValue (getMaxValue() - minMaxDiff, false);
else
minMaxDiff = valueMax - valueMin;
} }
mouseXWhenLastDragged = e.x; mouseXWhenLastDragged = e.x;


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_Slider.h View File

@@ -677,7 +677,7 @@ private:
double currentValue, valueMin, valueMax; double currentValue, valueMin, valueMax;
double minimum, maximum, interval, doubleClickReturnValue; double minimum, maximum, interval, doubleClickReturnValue;
double valueWhenLastDragged, valueOnMouseDown, skewFactor, lastAngle; double valueWhenLastDragged, valueOnMouseDown, skewFactor, lastAngle;
double velocityModeSensitivity, velocityModeOffset;
double velocityModeSensitivity, velocityModeOffset, minMaxDiff;
int velocityModeThreshold; int velocityModeThreshold;
float rotaryStart, rotaryEnd; float rotaryStart, rotaryEnd;
int numDecimalPlaces, mouseXWhenLastDragged, mouseYWhenLastDragged; int numDecimalPlaces, mouseXWhenLastDragged, mouseYWhenLastDragged;


Loading…
Cancel
Save