TwoValueSlider drag behavior


#1

I am making some range sliders. They will look something like this:

With the way the thumbs stick out, especially on the horizontal version, the dragging behavior is often fairly broken. To make this kind of layout work, we would need a way to specify explicitly what regions within the slider cause the min and max values to start dragging.

The easiest fix would be to make virtual Slider::mouseDrag() (and mouseWheelMove() while we’re at it). This may rightfully be considered ugly, though.

Another option is a virtual function called something like getSubSliderFromMousePos(). It would be called from Slider::mouseDown and Slider::mouseWheelMove. This is probably nicest because it’s only called once on drags, and makes clear what’s being factored out. I’m happy to write this but am new to contributing here, so please let me know what you think.


#2

Sounds like an excellent idea! If you want to chuck some code at me, that’s always appreciated as a starting point!


#3

OK.

http://2uptech.com/juce/juce_Slider.cpp
http://2uptech.com/juce/juce_Slider.h

This change adds a virtual function findSliderToDrag() that does what it says.
Other than that the code should function just the same as before.


#4

Ok, thanks. I’ll take a look at that asap…


#5

lest we forget…