From ad86b46f95ff14352e1a42714c0ca5bce9091a0d Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 31 Jan 2018 20:58:16 +0200 Subject: [PATCH] Added a separate performance meter component --- Source/PluginEditor.cpp | 13 +++++-------- Source/PluginEditor.h | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index f16a519..dfad35a 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -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) { diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index fb56adb..8518971 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -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> m_parcomps; //SpectralVisualizer m_specvis; - + PerfMeterComponent m_perfmeter; TextButton m_import_button; TextButton m_settings_button; Label m_info_label;