Added a separate performance meter component

This commit is contained in:
xenakios 2018-01-31 20:58:16 +02:00
parent 6f89b544ab
commit ad86b46f95
2 changed files with 23 additions and 9 deletions

View File

@ -28,9 +28,11 @@ extern String g_plugintitle;
PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p)
: AudioProcessorEditor(&p),
m_wavecomponent(p.m_afm,p.m_thumb.get()),
processor(p)
processor(p), m_perfmeter(&p)
{
addAndMakeVisible(&m_perfmeter);
addAndMakeVisible(&m_import_button);
m_import_button.setButtonText("Import file...");
m_import_button.onClick = [this]() { chooseFile(); };
@ -84,12 +86,6 @@ PaulstretchpluginAudioProcessorEditor::~PaulstretchpluginAudioProcessorEditor()
void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g)
{
g.fillAll(Colours::darkgrey);
double amt = processor.getPreBufferingPercent();
g.setColour(Colours::green);
int w = amt * 100.0;
g.fillRect(m_settings_button.getRight() + 1, 1, w, 24);
g.setColour(Colours::white);
g.drawRect(m_settings_button.getRight() + 1, 1, 100, 24);
}
void PaulstretchpluginAudioProcessorEditor::resized()
@ -98,6 +94,7 @@ void PaulstretchpluginAudioProcessorEditor::resized()
m_import_button.changeWidthToFitText();
m_settings_button.setBounds(m_import_button.getRight() + 1, 1, 60, 24);
m_settings_button.changeWidthToFitText();
m_perfmeter.setBounds(m_settings_button.getRight() + 1, 1, 200, 12);
m_info_label.setBounds(m_settings_button.getRight() + 1, m_settings_button.getY(),
getWidth()-m_settings_button.getRight()-1, 24);
int w = getWidth();
@ -205,8 +202,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
infotext += " (offline rendering)";
if (processor.m_playposinfo.isPlaying)
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
m_info_label.setText(infotext, dontSendNotification);
m_perfmeter.repaint();
}
if (id == 2)
{

View File

@ -72,6 +72,23 @@ private:
bool m_dragging = false;
};
class PerfMeterComponent : public Component
{
public:
PerfMeterComponent(PaulstretchpluginAudioProcessor* p) : m_proc(p) {}
void paint(Graphics& g) override
{
g.fillAll(Colours::grey);
double amt = m_proc->getPreBufferingPercent();
g.setColour(Colours::green);
int w = amt * getWidth();
g.fillRect(0, 0, w, getHeight());
g.setColour(Colours::white);
g.drawRect(0, 0, getWidth(), getHeight());
}
PaulstretchpluginAudioProcessor* m_proc = nullptr;
};
class MyThumbCache : public AudioThumbnailCache
{
public:
@ -192,7 +209,7 @@ private:
PaulstretchpluginAudioProcessor& processor;
std::vector<std::shared_ptr<ParameterComponent>> m_parcomps;
//SpectralVisualizer m_specvis;
PerfMeterComponent m_perfmeter;
TextButton m_import_button;
TextButton m_settings_button;
Label m_info_label;