Implement file browser showing in separate method

This commit is contained in:
xenakios 2019-01-22 00:09:28 +02:00
parent eef1f1a8e7
commit 1a42192509
2 changed files with 23 additions and 17 deletions

View File

@ -58,22 +58,7 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
m_import_button.setButtonText("Show browser");
m_import_button.onClick = [this]()
{
if (m_filechooser == nullptr)
{
String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder",
File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
File initialloc(initiallocfn);
m_filechooser = std::make_unique<FileBrowserComponent>(1 | 4,
initialloc, &m_filefilter, nullptr);
m_filechooser->addListener(this);
addChildComponent(m_filechooser.get());
}
m_filechooser->setBounds(0, 50, getWidth(), getHeight() - 60);
m_filechooser->setVisible(!m_filechooser->isVisible());
if (m_filechooser->isVisible())
m_import_button.setButtonText("Hide browser");
else
m_import_button.setButtonText("Show browser");
toggleFileBrowser();
};
addAndMakeVisible(&m_settings_button);
@ -609,6 +594,26 @@ void PaulstretchpluginAudioProcessorEditor::showAbout()
}
void PaulstretchpluginAudioProcessorEditor::toggleFileBrowser()
{
if (m_filechooser == nullptr)
{
String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder",
File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
File initialloc(initiallocfn);
m_filechooser = std::make_unique<FileBrowserComponent>(1 | 4,
initialloc, &m_filefilter, nullptr);
m_filechooser->addListener(this);
addChildComponent(m_filechooser.get());
}
m_filechooser->setBounds(0, 50, getWidth(), getHeight() - 60);
m_filechooser->setVisible(!m_filechooser->isVisible());
if (m_filechooser->isVisible())
m_import_button.setButtonText("Hide browser");
else
m_import_button.setButtonText("Show browser");
}
WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb, StretchAudioSource* sas)
: m_sas(sas)
{

View File

@ -479,6 +479,7 @@ private:
MyTabComponent m_wavefilter_tab;
Component* m_wave_container=nullptr;
void showAbout();
void toggleFileBrowser();
std::vector<int> m_capturelens{ 2,5,10,30,60,120 };
std::unique_ptr<FileBrowserComponent> m_filechooser;