Changing Slider velocity mode Modifier key


#1

Hello,
I would like to activate the velocity mode of my rotary knobs with the Shift key, instead of the Ctrl/Command/Alt keys, that are used for other purposes in my plugin.
In the mouseDrag method of juce_Slider.cpp, there is this code:

if (isVelocityBased == (userKeyOverridesVelocity && e.mods.testFlags (ModifierKeys::ctrlModifier | ModifierKeys::commandModifier | ModifierKeys::altModifier)) || (maximum - minimum) / sliderRegionSize < interval) handleAbsoluteDrag (e); else handleVelocityDrag (e);

You can see that the ModifierKeys that enable the velocity mode are hard-coded. Is it possible to add a member for this (it could be set by an additional argument of setVelocityModeParameters() for example) ?


#2

Yeah, it’s not very flexible, sorry. But I’m afraid I can’t accept any requests to add any more minor methods to the slider class, which is already far too bloated… At some point I should clean it up and group its functionality better, but in the meantime I can’t pile any more junk in there.


#3

Could you make the private member variables protected so we could customise our own slider classes? I’d like to be able to change mouseDrag so I can use a velocity drag mode when ctrl clicking a rotary slider.


#4

Sorry, no chance! I often get asked to expose private implementation details and make them protected, but that’s a really bad idea in a library.

If people start writing subclasses that rely on the a class’s implementation details, then I can’t change anything in the base class without possibly breaking everyone’s code. That’s why things are kept private!


#5

I guess for everyone who takes that responsibility on themselves and keeps their complaints to themselves, there are enough that don’t eh?

So I guess it’s too much bloat if we ask for a velocity mode for Rotary sliders? I know you’ve pointed out before that velocity doesn’t make sense to you when in Rotary mode, but couldn’t you fall back to either horizontal or vertical drag mode? Of course we’d then want to be able to define which was our preference… more bloat!


#6

[quote=“Andrew J”]I guess for everyone who takes that responsibility on themselves and keeps their complaints to themselves, there are enough that don’t eh?

So I guess it’s too much bloat if we ask for a velocity mode for Rotary sliders? I know you’ve pointed out before that velocity doesn’t make sense to you when in Rotary mode, but couldn’t you fall back to either horizontal or vertical drag mode? Of course we’d then want to be able to define which was our preference… more bloat![/quote]

I have to be honest, out of all the controls, the Slider is the most benign one to just make a private copy of and modify it yourself.


#7

Ah well, barring any greater beneficence; search and replace here I come :wink:


#8

The “correct” way to do this would be to refactor it so that it uses some kind of virtual class to handle the different movement types, and then you could add your own instance of that for custom behaviours.

The slider is one of those classes that started out simple but has slowly bloated out over the years, and I’ve not yet got around to giving it the serious overhaul that it needs.