From 7aff1e75ed07120d8ff1145d85ad1c561a0344b9 Mon Sep 17 00:00:00 2001 From: George Reales Date: Tue, 23 Jun 2020 09:54:09 +0200 Subject: [PATCH] v1.7 Preset name now displays in Load button. Active folder and preset is displayed with a tick on the Load drop down menu. Relocated - + preset navigation buttons. --- OPL.jucer | 2 +- Source/PluginEditor.h | 2 + Source/PluginGui.cpp | 91 +- Source/PluginGui.h | 7 +- Source/PluginGuiiOS.cpp | 4790 ++++++++++++++++++++++++++++++++++++ Source/PluginProcessor.cpp | 14 + Source/PluginProcessor.h | 3 + 7 files changed, 4874 insertions(+), 35 deletions(-) create mode 100644 Source/PluginGuiiOS.cpp diff --git a/OPL.jucer b/OPL.jucer index bcfeecd..12d7674 100644 --- a/OPL.jucer +++ b/OPL.jucer @@ -1,6 +1,6 @@ - comp; + + //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginEditor) }; diff --git a/Source/PluginGui.cpp b/Source/PluginGui.cpp index 40c01e7..13f8573 100644 --- a/Source/PluginGui.cpp +++ b/Source/PluginGui.cpp @@ -143,6 +143,10 @@ void PluginGui::updateFromParameters() tooltipWindow.setColour(tooltipWindow.backgroundColourId, Colour(0x0)); tooltipWindow.setColour(tooltipWindow.textColourId, Colour(COLOUR_MID)); + if (processor->lastLoadFile.length() > 0) { + File file(processor->lastLoadFile); + loadButton->setButtonText(file.getFileNameWithoutExtension()); + } } void PluginGui::setRecordButtonState(bool recording) { @@ -1157,9 +1161,9 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) exportButton->addListener (this); exportButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); exportButton->setColour (TextButton::buttonOnColourId, Colours::lime); -#if!JUCE_IOS - exportButton->setBounds (728, 512, 96, 24); -#endif + + exportButton->setBounds (728, 512, 48, 24); + loadButton.reset (new TextButton ("load button")); addAndMakeVisible (loadButton.get()); loadButton->setButtonText (TRANS("Load")); @@ -1168,7 +1172,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) loadButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); loadButton->setColour (TextButton::buttonOnColourId, Colours::lime); - loadButton->setBounds (728, 472, 48, 24); + loadButton->setBounds (728, 472, 96, 24); versionLabel.reset (new Label ("version label", String())); @@ -2032,7 +2036,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) previousButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); previousButton->setColour (TextButton::buttonOnColourId, Colours::lime); - previousButton->setBounds (776, 472, 24, 24); + previousButton->setBounds (776, 512, 24, 24); nextButton.reset (new TextButton ("next button")); addAndMakeVisible (nextButton.get()); @@ -2042,7 +2046,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) nextButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); nextButton->setColour (TextButton::buttonOnColourId, Colours::lime); - nextButton->setBounds (800, 472, 24, 24); + nextButton->setBounds (800, 512, 24, 24); drawable1 = Drawable::createFromImageData (gui_svg, gui_svgSize); @@ -2210,6 +2214,11 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) //[Constructor] You can add your own custom stuff here.. processor = ownerFilter; startTimer(1000/30); + // Update GUI Only + if (processor->lastLoadFile.length() > 0) { + File file(processor->lastLoadFile); + loadButton->setButtonText(file.getFileNameWithoutExtension()); + } //[/Constructor] } @@ -3001,7 +3010,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) void PluginGui::filesDropped (const StringArray& files, int x, int y) { if (isInterestedInFileDrag(files)) { - processor->loadInstrumentFromFile(files[0]); + this->loadandUpdateInstrument(files[0]); } } @@ -3013,20 +3022,20 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) } void PluginGui::loadPreNextFile(bool pre){ if (pre){ - selectedIdxFile -=1; + processor->selectedIdxFile -=1; } else{ - selectedIdxFile +=1; + processor->selectedIdxFile +=1; } if (allSbiFiles.size() > 0){ - if (selectedIdxFile > allSbiFiles.size() -1 ){ - selectedIdxFile = 0; + if (processor->selectedIdxFile > allSbiFiles.size() -1 ){ + processor->selectedIdxFile = 0; } - if (selectedIdxFile <0 ){ - selectedIdxFile = allSbiFiles.size() - 1; + if (processor->selectedIdxFile <0 ){ + processor->selectedIdxFile = allSbiFiles.size() - 1; } - if (allSbiFiles[selectedIdxFile].existsAsFile()){ - processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName()); + if (allSbiFiles[processor->selectedIdxFile].existsAsFile()){ + this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName()); } else { loadBrowserFile(); } @@ -3047,15 +3056,15 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) } } } - if (selectedIdxFile > allSbiFiles.size() - 1){ - selectedIdxFile = 0; + if (processor->selectedIdxFile > allSbiFiles.size() - 1){ + processor->selectedIdxFile = 0; } - if (selectedIdxFile <0 ){ - selectedIdxFile = allSbiFiles.size() - 1; + if (processor->selectedIdxFile <0 ){ + processor->selectedIdxFile = allSbiFiles.size() - 1; } if(hasFile){ - if (allSbiFiles[selectedIdxFile].existsAsFile()){ - processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName()); + if (allSbiFiles[processor->selectedIdxFile].existsAsFile()){ + this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName()); } else { loadBrowserFile(); } @@ -3080,7 +3089,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) if (browser.browseForFileToOpen()){ File selectedFile = browser.getResult(); instrumentLoadDirectory = selectedFile.getParentDirectory(); - processor->loadInstrumentFromFile(selectedFile.getFullPathName()); + this->loadandUpdateInstrument(selectedFile.getFullPathName()); } return 0; } @@ -3098,22 +3107,34 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) dir.findChildFiles (files, File::findFiles, false, "*.sbi"); files.sort(); if (files.size() > 0){ + bool selectedSub = false; PopupMenu subMenu; for (auto file : files){ allSbiFiles.add(file); hasFile = true; - subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension()); + if (processor->lastLoadFile == file.getFullPathName()){ + selectedSub = true; + subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension(), true, true); + } else { + subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension()); + } } - menuLoad.addSubMenu(dir.getFileName(), subMenu); + if(selectedSub){ + menuLoad.addSubMenu (std::move (dir.getFileName()), std::move (subMenu), true, nullptr, true, 0); + } + else{ + menuLoad.addSubMenu(dir.getFileName(), subMenu); + } + } } if(hasFile){ //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()); + processor->selectedIdxFile = id -1; + if (this->allSbiFiles[processor->selectedIdxFile].existsAsFile()){ + this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName()); } else { this->loadBrowserFile(); } @@ -3128,6 +3149,14 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) } return hasFile; } + + void PluginGui::loadandUpdateInstrument(String path) { + + processor->loadInstrumentFromFile(path); + + File file(path); + loadButton->setButtonText(file.getFileNameWithoutExtension()); + } //[/MiscUserCode] @@ -3584,11 +3613,11 @@ BEGIN_JUCER_METADATA txtcol="ff007f00" buttonText="Record to DRO (not working yet)" connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>