Hi folks,
I’m subclassing the GenericAudioProcessorEditor to create a simple template for development, but I’ve added some labels to the editor - which I’d like to sit at the top of the window. All of the labels update correctly and work great (they’re based on a video by @eyalamir), it’s just the layout which I’m having this issue with.
I can’t seem to access the base class for the editor to move it down 50 or so pixels to allow the labels to fit.
PluginEditor.h
#ifndef PLUGINEDITOR_H_INCLUDED
#define PLUGINEDITOR_H_INCLUDED
#include <JuceHeader.h>
#include "PluginProcessor.h"
struct AtomicLabel:
juce::Component,
juce::Timer
{
AtomicLabel(std::atomic<double>& valueToUse): value(valueToUse)
{
startTimerHz(60);
addAndMakeVisible(label);
}
void resized() override
{
label.setBounds(getLocalBounds());
}
void timerCallback() override {
label.setText(juce::String(value.load()), juce::dontSendNotification);
}
juce::Label label;
std::atomic<double>& value;
};
class MyAudioProcessorEditor : public juce::GenericAudioProcessorEditor
{
public:
MyAudioProcessorEditor (MyAudioProcessor&);
~MyAudioProcessorEditor() override;
void paint (Graphics&) override;
void resized() override;
private:
MyAudioProcessor& processor;
// host info
AtomicLabel tempoLabel;
AtomicLabel PPQLabel;
AtomicLabel timeInSamplesLabel;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyAudioProcessorEditor)
};
#endif // PLUGINEDITOR_H_INCLUDED
PluginEditor.cpp
#include "PluginProcessor.h"
#include "PluginEditor.h"
MyAudioProcessorEditor::MyAudioProcessorEditor (MyAudioProcessor& p)
: GenericAudioProcessorEditor (&p), processor (p),
tempoLabel(p.hostTempo),
PPQLabel(p.hostPPQ),
timeInSamplesLabel(p.hostTimeSamples)
{
// host info
// Note: this is drawn over the top of the GenericEditor
addAndMakeVisible(tempoLabel);
addAndMakeVisible(PPQLabel);
addAndMakeVisible(timeInSamplesLabel);
setSize(400,400);
}
MyAudioProcessorEditor::~MyAudioProcessorEditor()
{
}
void MyAudioProcessorEditor::paint (Graphics& g)
{
// Note: this paint method is never called
g.fillAll (getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
g.setColour (Colours::white);
g.setFont (15.0f);
g.drawFittedText ("Hello World", 0, 0, getWidth(), 30, juce::Justification::centred, 1);
}
void MyAudioProcessorEditor::resized()
{
// this doesn't work.
this->GenericAudioProcessorEditor::setTopLeftPosition(0,50);
// host info
tempoLabel.setBounds(105,10,50,50);
PPQLabel.setBounds(160, 10, 65, 50);
timeInSamplesLabel.setBounds(235, 10, 65, 50);
}
I would just like the ParametersPanel to move downward here under the three labels, i’m hoping it’s just an inheritance thing I’m missing?