Changing Slider velocity mode Modifier key

Discussion and support for general JUCE issues

Changing Slider velocity mode Modifier key

Postby niccolo » Wed Apr 25, 2012 10:37 am

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:

Code: Select all
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) ?
niccolo
JUCE Weenie
 
Posts: 6
Joined: Thu Oct 13, 2011 10:55 am

Re: Changing Slider velocity mode Modifier key

Postby jules » Wed Apr 25, 2012 11:41 am

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.
User avatar
jules
Fearless Leader
 
Posts: 17372
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Re: Changing Slider velocity mode Modifier key

Postby Andrew J » Mon Apr 30, 2012 1:44 pm

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.
User avatar
Andrew J
JUCE UberWeenie
 
Posts: 218
Joined: Tue Feb 15, 2011 1:26 pm
Location: Hobart, Australia

Re: Changing Slider velocity mode Modifier key

Postby jules » Mon Apr 30, 2012 2:23 pm

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!
User avatar
jules
Fearless Leader
 
Posts: 17372
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Re: Changing Slider velocity mode Modifier key

Postby Andrew J » Mon Apr 30, 2012 2:40 pm

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!
User avatar
Andrew J
JUCE UberWeenie
 
Posts: 218
Joined: Tue Feb 15, 2011 1:26 pm
Location: Hobart, Australia

Re: Changing Slider velocity mode Modifier key

Postby TheVinn » Mon Apr 30, 2012 2:51 pm

Andrew J wrote: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!


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.
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2989
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California

Re: Changing Slider velocity mode Modifier key

Postby Andrew J » Mon Apr 30, 2012 2:53 pm

Ah well, barring any greater beneficence; search and replace here I come :wink:
User avatar
Andrew J
JUCE UberWeenie
 
Posts: 218
Joined: Tue Feb 15, 2011 1:26 pm
Location: Hobart, Australia

Re: Changing Slider velocity mode Modifier key

Postby jules » Mon Apr 30, 2012 3:00 pm

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.
User avatar
jules
Fearless Leader
 
Posts: 17372
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK


Return to General JUCE discussion

Who is online

Users browsing this forum: Google [Bot] and 2 guests