diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 89c275a..c31a7af 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -878,6 +878,64 @@ void ObxdAudioProcessorEditor::paint(Graphics& g) } + +bool ObxdAudioProcessorEditor::isInterestedInFileDrag(const StringArray& files) +{ + StringArray extensions; + extensions.add(".fxp"); + extensions.add(".fxb"); + + if (files.size() == 1) { + File file = File(files[0]); + String ext = file.getFileExtension().toLowerCase(); + return file.existsAsFile() && extensions.contains(ext); + } else { + for (int q = 0; q < files.size(); q++) { + File file = File(files[q]); + String ext = file.getFileExtension().toLowerCase(); + + if (ext == ".fxb" || ext == ".fxp") { + return true; + } + } + } + return false; +} + +void ObxdAudioProcessorEditor::filesDropped(const StringArray& files, int x, int y) +{ + if (files.size() == 1) { + File file = File(files[0]); + String ext = file.getFileExtension().toLowerCase(); + + if (ext == ".fxp") { + processor.loadPreset(file); + createMenu(); + } else if (ext == ".fxb") { + auto name = file.getFileName().replace("%20", " "); + auto result = processor.getBanksFolder().getChildFile(name); + + if (file.copyFileTo(result)){ + processor.loadFromFXBFile(result); + processor.scanAndUpdateBanks(); + createMenu(); + } + } + } else { + int i = processor.getCurrentProgram(); + + for (int q = 0; q < files.size(); q++) { + File file = File(files[q]); + String ext = file.getFileExtension().toLowerCase(); + if (ext == ".fxp") { + processor.setCurrentProgram(i++); + processor.loadPreset(file); + } + } + processor.sendChangeMessage(); + createMenu(); + } +} /* bool ObxdAudioProcessorEditor::keyPressed(const KeyPress & press) { if (press.getKeyCode() == '+' || press.getKeyCode() == KeyPress::numberPadAdd) diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index fa1b9c5..a493a25 100755 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -55,12 +55,15 @@ class ObxdAudioProcessorEditor : public AudioProcessorEditor // , public ComboBox::Listener , public ApplicationCommandTarget , public Timer + , public FileDragAndDropTarget { public: ObxdAudioProcessorEditor(ObxdAudioProcessor& ownerFilter); ~ObxdAudioProcessorEditor(); - + + bool isInterestedInFileDrag(const StringArray& files) override; + void filesDropped(const StringArray& files, int x, int y) override; void mouseUp (const MouseEvent& e) override; void paint (Graphics& g) override;