FXB/FXP drag and drop
This commit is contained in:
parent
56b3a34609
commit
839f492784
2 changed files with 62 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue