Ferature request: Slider step size

hi,

For now the scroll step size is function of the the slider height:

const double proportionDelta = (wheelIncrementX != 0 ? -wheelIncrementX : wheelIncrementY) * 0.15f;
const double currentPos = valueToProportionOfLength (currentValue);
const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta));
double delta = (newValue != currentValue) ? jmax (fabs (newValue - currentValue), interval) : 0;

So when the range size is big compared to the slider height its easy to have values jumping from 29 to 45 in just one mouse scroll step.
Moreover the wheelIncrementY value is different on mac and windows, so for the same widget I can have a step size of 1 on mac and of 16 on windows.

Could you add a step size option or a constrainDelta() method so that we can have greater control over this?

more over that would be great if we could have a finer more with ctrl+scroll

Ok, that’s a good request, though the best approach isn’t immediately obvious. One of my to-do-list items is to look at mac vs win scroll wheel behaviour, to make things work better with non-stepped scrolling, so I’ll probably address this when I do that.

I was about to request the same feature, some Slider::setScrollWheelInterval function or something like that.

Typically, when a slider drives a MIDI = integer value, it makes sense to want the wheel to perform a +/-1 increment, and by default (at least under windows) it’s much more than this (more about +/-15 on a 128 pixel slider)

So, we’re now two guys eagerly waiting for this feature…

This is a really old post - I think Slider::setSingleStepSize() is what you want?

I don’t see a Slider::setSingleStepSize() in the online Juce documentation. Is it already implemented?

What I’m requesting is to be able to adjust the step size when you use the mouse wheel, typically when you have a slider that is NOT in velocity mode and that has more possible values than pixels: you adjust it roughly by dragging the mouse then fine tune the value with the wheel if necessary. I know fine tuning can be performed by pressing CTRL + mouse drag (=> velocity mode), but doing it with the wheel is more convenient as it requires only one hand…

I asked something similar here
http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=5514&hilit=about+slider

Julian, what about making Slider::mouseWheelMove overridable?

Yes, it has been for some time. There’s a lot of stuff that’s in the code but not yet in the online docs.

I don’t understand why you’re asking that - what makes you think it’s not overridable??

I just noticed it’s protected!
Cool!

Yes, it has been for some time. There’s a lot of stuff that’s in the code but not yet in the online docs.[/quote]

Hummm… I downloaded the latest sources with GIT, and did a text search in .cpp/.h files on the whole Juce directory, and the only setSingleStepSize function I found was ScrollBar::setSingleStepSize (plus a ViewPort::setSingleStepSizes). No such function in the Slider class, and unless I’m mistaken I don’t see any inheritance relationship between ScrollBar and Slider that could make setSingleStepSize function available on a Slider. Besides, the ScrollBar::setSingleStepSize function has nothing to do with the mouse wheel (same goes for ViewPort::setSingleStepSizes)

Reminder: what I’m after is using the standard Slider class and being able to set the increment value of the mouse wheel…

Sorry, I was looking at the wrong class! doh!

Thing is, you can’t really talk about “step size” when using the wheel, because although some old mice have stepped wheels, a lot of modern ones are continuous, and you get a stream of updates from them rather than a few “clicks”. Not sure how best to tune this so that it works well in all cases… Suggestions welcome!

I ended with creating my custom class, which doesn’t inherit from the Slider class, but only from the Component class.
My purpouse was to create an IncDec slider, that could increment/decrement its values by one when the mousewheel was moved.
So basically I have now a component with a label and 2 buttons.
I made it inheriting mouseWheelMove from the Component class, forcing the component to change its values only by one when the wheel is moved.
In order to catch the values I created also a custom listener class.

Well, make sure you test it with things like a two-finger scroll on a Mac trackpad, because that’ll send a whole load of incremental moves rather than a few big ones.

I know.
And I checked with my MBP. Works fine!

Doesn't it already do that?

I suppose I could expose the scale factor, but mouse-wheels will use a range of speeds and some will be smooth-scrolling, so I'm not sure whether it makes much sense to think of them as nudging the value in unit-sized clicks.

To do it properly I guess that I should inherit from the Slider class and override the mouseWheelMove(...) method to make any positive change increment the value and any negative change to decrement the value right?

No, that'll make it unusable with wheels that scroll smoothly! They send huge numbers of messages, so the value would just spin wildly.

Actually, that code needed a bit of a re-think - try it again now...