Browse Source

Allowed linear-drag rotary sliders to rollover

tags/2021-05-28
Tom Poole 6 years ago
parent
commit
92c30e780d
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      modules/juce_gui_basics/widgets/juce_Slider.cpp

+ 11
- 4
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -775,7 +775,9 @@ public:
newPos = 1.0 - newPos;
}
valueWhenLastDragged = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, newPos));
newPos = (isRotary() && ! rotaryParams.stopAtEnd) ? newPos - std::floor (newPos)
: jlimit (0.0, 1.0, newPos);
valueWhenLastDragged = owner.proportionOfLengthToValue (newPos);
}
void handleVelocityDrag (const MouseEvent& e)
@@ -806,8 +808,10 @@ public:
|| (style == IncDecButtons && ! incDecDragDirectionIsHorizontal()))
speed = -speed;
auto currentPos = owner.valueToProportionOfLength (valueWhenLastDragged);
valueWhenLastDragged = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + speed));
auto newPos = owner.valueToProportionOfLength (valueWhenLastDragged) + speed;
newPos = (isRotary() && ! rotaryParams.stopAtEnd) ? newPos - std::floor (newPos)
: jlimit (0.0, 1.0, newPos);
valueWhenLastDragged = owner.proportionOfLengthToValue (newPos);
e.source.enableUnboundedMouseMovement (true, false);
}
@@ -1051,7 +1055,10 @@ public:
auto proportionDelta = wheelAmount * 0.15;
auto currentPos = owner.valueToProportionOfLength (value);
return owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)) - value;
auto newPos = currentPos + proportionDelta;
newPos = (isRotary() && ! rotaryParams.stopAtEnd) ? newPos - std::floor (newPos)
: jlimit (0.0, 1.0, newPos);
return owner.proportionOfLengthToValue (newPos) - value;
}
bool mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)


Loading…
Cancel
Save