DaveH
April 7, 2019, 9:38am
1
Useful for parameter adjustment knobs found in hardware synths/effects.
If people use
setRotaryParameters(degreesToRadians(0.0f), degreesToRadians(359.0f), false);
// or ~360.0f?
Using the existing stopAtEnd parameter…
All in juce_Slider.cpp
~Line 779 in handleAbsoluteDrag
if (rotaryParams.stopAtEnd)
return owner.proportionOfLengthToValue(jlimit(0.0, 1.0, newPos)) - value;
else
return owner.proportionOfLengthToValue(newPos - floor(newPos)) - value;
And
~Line 820 in handleVelocityDrag
auto newPos = currentPos + speed;
//valueWhenLastDragged = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + speed));
if (rotaryParams.stopAtEnd)
{
valueWhenLastDragged = owner.proportionOfLengthToValue(jlimit(0.0, 1.0, newPos));
}
else
{
valueWhenLastDragged = owner.proportionOfLengthToValue(newPos - floor(newPos));
}
And
~Line 1070 in getMouseWheelDelta
if (rotaryParams.stopAtEnd)
return owner.proportionOfLengthToValue(jlimit(0.0, 1.0, newPos)) - value;
else
return owner.proportionOfLengthToValue(newPos - floor(newPos)) - value;
Thanks for the consideration.
Dave H.
t0m
April 8, 2019, 2:39pm
2
How does this interact with the changes proposed here?
DaveH
April 8, 2019, 3:51pm
3
It does exactly that. You can’t override a function to do this though, these changes need to be in Juce itself.
t0m
April 8, 2019, 4:08pm
4
Sorry, I wasn’t clear. The commit linked to in the issue
doesn’t contain the same set of changes at the ones in this topic on the forum. Which set of changes are you proposing that JUCE uses?
DaveH
April 8, 2019, 4:32pm
5
I just tried that commit using 5.4.3 and it only worked with the mouse wheel and it made it move really slowly. The additions I used work with the mouse and holding CTRL for slower increments.
t0m
April 9, 2019, 2:12pm
6
Sorry, I got myself confused with the two sets of changes and thought that they were linked…
It looks like you are proposing a breaking change, as this would alter how the wrap-around behaviour currently works. Is that correct?
DaveH
April 9, 2019, 2:20pm
7
No, it makes it actually work for linearly controlling.
Currently it only works for dials that point towards the mouse pointer.
The ‘jlimit’ is the existing function call in each case in my code. The if statement includes the wrap around 0-1. It’s not a complex solution.
‘newPos - floor(newPos)’ is just a neat way to wrap around 0-1. The whole change could of course be ternary in each case.