It would be great if this class was a derivable class in juce_AudioProcessorValueTreeState.h so we could provide our own implementation of derived classes to attach to our custom widgets that can’t really be represented as sliders, buttons, or comboBoxes.
At present, I’m using my 2D widget to modify a pair of hidden Sliders that are attached accordingly. I’d prefer to avoid doing this, but that’s what must be done to make this work.
Let’s all share our implementations so we can see how everyone solves the problem. I’m sure they’ll all be similar but uniquely different I’ll go first:
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
struct GroupButton : public Button
{
GroupButton(const String& name, int index) : Button(name), groupIndex(index) { }
const int groupIndex;
};
struct GroupButtonParamListener : public AudioProcessorParameter::Listener, public AsyncUpdater, public Timer
{
/*
a group of buttons that are connected to a AudioParameterChoice
*/
GroupButtonParamListener(Array<GroupButton*>&& bs,
AudioParameterChoice& choices);
~GroupButtonParamListener();
void timerCallback() override;
void handleAsyncUpdate() override;
void parameterValueChanged(int i, float v) override;
void parameterGestureChanged(int, bool) override { }
juce::Atomic<int> parameterIndex;
Array<GroupButton*> buttons;
AudioParameterChoice& param;
std::function<void(int,float)> parameterChanged;
};
Not the most reusable nor the highest quality solution, but here’s how I was able to do a XY(Z)pad component for a plugin that uses AudioProcessorValueTreeState :
I don’t think anyone here would really care how nice the interface is, as long as it becomes derivable. I requested this almost a year ago. There are only a couple of other feature requests that have as many votes…
I don’t think that’s true; we get a lot of feedback from the JUCE community letting us know they value our thoughtful approach to API design. We’re not going to suddenly lower our standards.