mirror of
https://codeberg.org/armin/monoslicer.git
synced 2026-10-11 21:11:53 +02:00
Support text drag-and-drop of files and validate extensions via format manager
This commit is contained in:
parent
c10df9642c
commit
7630bb93fc
5 changed files with 89 additions and 10 deletions
|
|
@ -555,8 +555,7 @@ void MonoslicerEditor::comboBoxChanged(juce::ComboBox* comboBoxThatHasChanged)
|
|||
bool MonoslicerEditor::isInterestedInFileDrag(const juce::StringArray& files)
|
||||
{
|
||||
for (const auto& f : files)
|
||||
if (f.endsWithIgnoreCase(".wav") || f.endsWithIgnoreCase(".aiff") ||
|
||||
f.endsWithIgnoreCase(".flac") || f.endsWithIgnoreCase(".ogg"))
|
||||
if (processorRef.canLoadFileExtension(f))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -590,12 +589,52 @@ void MonoslicerEditor::filesDropped(const juce::StringArray& files, int, int)
|
|||
for (const auto& f : files)
|
||||
{
|
||||
juce::File file(f);
|
||||
if (file.existsAsFile())
|
||||
if (file.existsAsFile() && processorRef.canLoadFileExtension(f))
|
||||
{
|
||||
processorRef.loadAudioFile(file);
|
||||
waveformDisplay.setSampleBuffer(&processorRef.getSampleBuffer(), processorRef.getSampleRateLoaded());
|
||||
|
||||
handleDroppedSample(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MonoslicerEditor::isInterestedInTextDrag(const juce::String& text)
|
||||
{
|
||||
juce::File file(text);
|
||||
if (text.startsWithIgnoreCase("file://"))
|
||||
file = juce::URL(text).getLocalFile();
|
||||
|
||||
return file.existsAsFile() && processorRef.canLoadFileExtension(file.getFullPathName());
|
||||
}
|
||||
|
||||
void MonoslicerEditor::textDragEnter(const juce::String& text, int, int)
|
||||
{
|
||||
if (isInterestedInTextDrag(text))
|
||||
{
|
||||
dropOverlay.setVisible(true);
|
||||
dropOverlay.toFront(false);
|
||||
dropOverlay.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void MonoslicerEditor::textDragExit(const juce::String&)
|
||||
{
|
||||
dropOverlay.setVisible(false);
|
||||
}
|
||||
|
||||
void MonoslicerEditor::textDropped(const juce::String& text, int, int)
|
||||
{
|
||||
dropOverlay.setVisible(false);
|
||||
|
||||
juce::File file(text);
|
||||
if (text.startsWithIgnoreCase("file://"))
|
||||
file = juce::URL(text).getLocalFile();
|
||||
|
||||
if (processorRef.canLoadFileExtension(file.getFullPathName()))
|
||||
handleDroppedSample(file);
|
||||
}
|
||||
|
||||
void MonoslicerEditor::handleDroppedSample(const juce::File& file)
|
||||
{
|
||||
processorRef.loadAudioFile(file);
|
||||
waveformDisplay.setSampleBuffer(&processorRef.getSampleBuffer(), processorRef.getSampleRateLoaded());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue