From 3a66cbe99e0d57e4718e3c03751ee400e8824458 Mon Sep 17 00:00:00 2001 From: George Reales Date: Sat, 30 May 2020 18:59:56 +0200 Subject: [PATCH] Async menu --- Source/PluginEditor.cpp | 1 - Source/PluginEditor.h | 2 -- Source/PluginGui.cpp | 31 ++++++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 9445acd..ed6dd19 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -31,7 +31,6 @@ PluginEditor::PluginEditor (AdlibBlasterAudioProcessor* ownerFilter) : AudioProcessorEditor (ownerFilter) { //[Constructor_pre] You can add your own custom stuff here.. - PropertiesFile::Options options; options.applicationName = ProjectInfo::projectName; options.osxLibrarySubFolder = "Application Support"; diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index a4aae7f..51b458c 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -62,8 +62,6 @@ private: //============================================================================== std::unique_ptr comp; - - //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginEditor) }; diff --git a/Source/PluginGui.cpp b/Source/PluginGui.cpp index cef1f48..21c5cdf 100644 --- a/Source/PluginGui.cpp +++ b/Source/PluginGui.cpp @@ -163,6 +163,7 @@ void PluginGui::setRecordButtonState(bool recording) { PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) { //[Constructor_pre] You can add your own custom stuff here.. + //[/Constructor_pre] groupComponent2.reset (new GroupComponent ("new group", @@ -3043,6 +3044,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) } bool PluginGui::loadBrowserFile(){ + FileChooser browser("Select SBI instrument file", instrumentLoadDirectory, #ifdef JUCE_IOS @@ -3082,20 +3084,23 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) } } if(hasFile){ - int id = menuLoad.show(); - if (id > 0) { - selectedIdxFile = id -1; - if (allSbiFiles[selectedIdxFile].existsAsFile()){ - processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName()); - } else { - loadBrowserFile(); + //int id = menuLoad.show(); + menuLoad.showMenuAsync (PopupMenu::Options().withParentComponent (this->getTopLevelComponent()), [this](int id){ + if (id > 0) { + this->selectedIdxFile = id -1; + if (this->allSbiFiles[selectedIdxFile].existsAsFile()){ + this->processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName()); + } else { + this->loadBrowserFile(); + } + } - - } - // No select, return true to ignore the popup menu - else{ - return true; - } + // No select, return true to ignore the popup menu + else{ + return; + } + }); + } return hasFile; }