The normal behaviour for the buttons on a mixer are to instantly switch modes when clicked… with the current Button behaviour we have setTriggeredOnMouseDown() to instantly trigger on the mouseDown() but the buttons still redraw and react to the mouseUp()
I have made these changes to the Button class for your consideration:
In juceButton.h add:
/** Sets whether the button should be instantly toggled when clicked.
Only works when setTriggeredOnMouseDown is true.
*/
void setInstantToggleMode(bool isInstantlyToggledOnClick) noexcept;
It’s a perfectly valid idea, but I just can’t add yet another subtle behavioural option to the already-bloated Button class!
I’d consider suggestions for simplifications/refactorings of the Button class’s functionality that would enable new behaviours like this, but not single-purpose additions like this, sorry!
The design and refactoring of user interface classes is a hard problem. To date, there has never been an elegant system designed that addresses all use-cases. JUCE does a fairly good job, especially with the Component base class interface. But it is showing signs of age.
Button classes are so simple, that discussions on a proper refactoring are academic at best. Button implementations are trivial to write, and if you want a custom JUCE button behavior it is a straightforward process to make a duplicate of the juce::Button and modify it to suit your needs. When it comes to user interface classes, you often need to compromise principles such as DRY.
The interesting part of juce::Button is in the handling of keyboard shortcuts and command messages. In my opinion, only this part needs to be refactored. Ideally it would be some sort of reusable class that can be leveraged to give keyboard shortcut / command support to any custom control not just buttons. As for the actual mouse down / tracking of the button, that is far too simple to justify making changes for.
Other JUCE interface classes are much more deserving of a refactoring. Slider should definitely be broken up into individual separate components: SliderEdit, SliderThumb come to mind. The actual Slider class could be replaced by a composite Component that creates child edit and thumb objects hooked together using a ComponentBroadcast facility.
ListBox and TableListBox could also use some spring cleaning, along with the menus.