Slider velocity mode not working (sometimes)


#1

I want to use velocity mode for touch based devices, but depending on slider size and it's range sometimes velocity mode does not work

 

For example, this code will cause velocity mode to NOT work:

slider.setSliderStyle (Slider::LinearVertical);
slider.setVelocityBasedMode (true);
slider.setRange (0, 127, 1);

While this piece of code will make velocity mode work:

slider.setSliderStyle (Slider::RotaryVerticalDrag);
slider.setVelocityBasedMode (true);
slider.setRange (0, 127, 1);

In both cases the slider is the same size

slider.setBounds (32,32,128,256);

 

Why is that ?


#2

No idea..  but if you step into the mouseDrag code you'll probably be able to see what the test is that makes this decision.


#3

Seeing the same behavior here. It looks like this part of the conditional in the juce slider code is always true for me:

(maximum - minimum) / sliderRegionSize < interval

— which is causing it to jump to absolute drag mode no matter what. Is that the expected behavior?


#4

There's nothing wrong with that expression. If your ranges/size cause it to do something you don't want, then you'll need to change your ranges or size to something more suitable.


#5

Can you explain why that requirement is imposed for velocity drag? Unless I'm misunderstanding something, I believe our range, min/max, interval are all reasonable.

A related question: is toggling the velocity/absolute drag mode during a drag gesture unsupported? We're used to being able to switch between three drag modes (fine, standard, coarse; selected by mouse modifiers) on the fly in our existing plugins, but doing so in juce causes the slider/mouse to jump erratically.


#6

Sorry, I see what you mean. The point of that test is to avoid using relative mode if absolute mode would already provide all the accuracy that's needed to set any legal value for the slider. That's probably a good choice for the user, because it makes it easier, but I guess that if you want a consistent experience it's not ideal..

And yes, it'd certainly be very difficult to toggle the mode while it's dragging, as there's a bunch of state that gets created when the drag starts, which would cause some complication if the mode randomly changes.


#7

Thanks, that makes sense. Is there a way to manually trigger a drag stop/start when we know the mouse modifier has changed? Or alternatively, can you recommend any approaches for dupilcating our existing mouse handling? We actually don't really want a velocity mode for the fine control, but rather, a mode in which a slider movement requires something like ~5x mouse movement.   


#8

It might just be worth writing your own version if you need something that specific - it wouldn't be hard to just override the mouse callbacks and implement some other kind of mapping.