I’m trying to make a GUI that updates variables when a new tab is selected.
I think i should be using the ‘currentTabChanged’ call back method from Tabbed Component Class although i’m having problems implementing this.
Header:
class GuiWorkAudioProcessorEditor : public AudioProcessorEditor,
private Slider::Listener,
private TabbedComponent
{
public:
GuiWorkAudioProcessorEditor (GuiWorkAudioProcessor&);
~GuiWorkAudioProcessorEditor();
//==============================================================================
void paint (Graphics&) override;
void resized() override;
static const char* gidiBg_png;
static const int gidiBg_pngSize;
private:
void sliderValueChanged(Slider * slider) override;
void currentTabChanged(int newCurrentTabIndex, const String& newCurrentTabName) override;
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
GuiWorkAudioProcessor& processor;
TabbedComponent tab;
Slider midiVolume,altSlider;
Image cachedImage_gidiBg_png_1;
Font font;
So by inheriting the TabbedComponent class i can then override the callback method … but this leads to error in my .cpp file…
The error if i hover over opening brace reads “no default constructor exist for class Juce::TabbedComponent” … These only occur when inheriting the Tabbed Component Class.
The errors only show when i inherit TabbedComponent… I reckon that’s the cause but unsure of how to fix it. The constructor for tab is taken care of with:
You need to make a new component class that inherits TabbedComponent, your AudioProcessorEditor should not inherit from TabbedComponent. Your AudioProcessorEditor class should then hold an instance of that customized TabbedComponent.
This is admittedly rather annoying, I don’t know why the JUCE developers have not added a TabbedComponent::Listener class or something to get notifications about the tab page changing…
Here’s my implementation that uses std::function so you can be saved from the hassle of passing additional pointers/references into the custom TabbedComponent. You would replace the TabChangedFunc with a lambda in your AudioProcessorEditor class code to do what you need to be done when the tab changes, for example : mytabs.TabChangedFunc = [this](int index){ tabchanged(index); };