From f9cce79f4983d6e1a12000754572bb5d1b3bc2de Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 27 Dec 2017 16:56:37 +0200 Subject: [PATCH] Added support for dropping audio files into the plugin GUI --- Source/PluginEditor.cpp | 22 ++++++++++++++++++++++ Source/PluginEditor.h | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 0e7012c..f30f33b 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -249,6 +249,28 @@ void PaulstretchpluginAudioProcessorEditor::addAudioBlock(AudioBuffer& bu m_wavecomponent.addAudioBlock(buf, samplerate, pos); } +bool PaulstretchpluginAudioProcessorEditor::isInterestedInFileDrag(const StringArray & files) +{ + if (files.size() == 0) + return false; + File f(files[0]); + String extension = f.getFileExtension().toLowerCase(); + if (processor.m_afm->getWildcardForAllFormats().containsIgnoreCase(extension)) + return true; + return false; + +} + +void PaulstretchpluginAudioProcessorEditor::filesDropped(const StringArray & files, int x, int y) +{ + if (files.size() > 0) + { + File f(files[0]); + processor.setAudioFile(f); + toFront(true); + } +} + void PaulstretchpluginAudioProcessorEditor::chooseFile() { String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder", diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 75c10c6..32f758b 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -239,7 +239,7 @@ public: }; class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor, - public MultiTimer + public MultiTimer, public FileDragAndDropTarget, public DragAndDropContainer { public: PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor&); @@ -251,6 +251,9 @@ public: void setAudioBuffer(AudioBuffer* buf, int samplerate, int len); void beginAddingAudioBlocks(int channels, int samplerate, int totalllen); void addAudioBlock(AudioBuffer& buf, int samplerate, int pos); + bool isInterestedInFileDrag(const StringArray &files) override; + void filesDropped(const StringArray &files, int x, int y) override; + WaveformComponent m_wavecomponent; private: PaulstretchpluginAudioProcessor& processor;