A helper class for handling drag-and-drop of audio files into a JUCE component.
More...
#include <audio_file_drop_source.h>
|
class | Listener |
| A listener interface for classes interested in receiving audio file load events. More...
|
|
|
| AudioFileDropSource () |
| Constructs an AudioFileDropSource and registers basic audio formats.
|
|
bool | isInterestedInFileDrag (const StringArray &files) override |
| Checks if the drag operation includes exactly one file and if it matches supported audio formats.
|
|
void | filesDropped (const StringArray &files, int x, int y) override |
| Called when files are dropped onto the component.
|
|
virtual void | audioFileLoaded (const File &file)=0 |
| Called internally when a recognized audio file is dropped. Must be implemented by subclasses.
|
|
void | addListener (Listener *listener) |
| Adds a listener to receive audio file load notifications.
|
|
String | getExtensions () |
| Gets a wildcard pattern representing all supported audio formats.
|
|
AudioFormatManager & | formatManager () |
| Provides access to the underlying AudioFormatManager.
|
|
|
AudioFormatManager | format_manager_ |
| Manages and recognizes different audio file formats.
|
|
A helper class for handling drag-and-drop of audio files into a JUCE component.
AudioFileDropSource integrates with JUCE's FileDragAndDropTarget to respond when a user drags and drops an audio file over a component. It:
- Registers basic audio formats with an AudioFormatManager.
- Checks if a dropped file is a supported audio format.
- Notifies registered listeners when an audio file has been dropped and loaded.
Subclasses must implement audioFileLoaded(const File& file) to define custom loading behavior, and can add listeners that also receive audio file load notifications.
◆ AudioFileDropSource()
AudioFileDropSource::AudioFileDropSource |
( |
| ) |
|
|
inline |
◆ addListener()
void AudioFileDropSource::addListener |
( |
Listener * | listener | ) |
|
|
inline |
Adds a listener to receive audio file load notifications.
- Parameters
-
listener | The listener to add. |
◆ audioFileLoaded()
virtual void AudioFileDropSource::audioFileLoaded |
( |
const File & | file | ) |
|
|
pure virtual |
◆ filesDropped()
void AudioFileDropSource::filesDropped |
( |
const StringArray & | files, |
|
|
int | x, |
|
|
int | y ) |
|
inlineoverride |
Called when files are dropped onto the component.
If at least one file is dropped, it calls audioFileLoaded with the first file and notifies all listeners.
- Parameters
-
files | The array of dropped files. |
x | The x-coordinate of the drop (unused). |
y | The y-coordinate of the drop (unused). |
◆ formatManager()
AudioFormatManager & AudioFileDropSource::formatManager |
( |
| ) |
|
|
inline |
Provides access to the underlying AudioFormatManager.
- Returns
- A reference to the AudioFormatManager.
◆ getExtensions()
String AudioFileDropSource::getExtensions |
( |
| ) |
|
|
inline |
Gets a wildcard pattern representing all supported audio formats.
- Returns
- A string containing wildcard patterns for all recognized audio formats (e.g. "*.wav;*.aif").
◆ isInterestedInFileDrag()
bool AudioFileDropSource::isInterestedInFileDrag |
( |
const StringArray & | files | ) |
|
|
inlineoverride |
Checks if the drag operation includes exactly one file and if it matches supported audio formats.
- Parameters
-
files | The list of files being dragged. |
- Returns
- True if there's a single file and it matches a known audio format, false otherwise.
◆ format_manager_
AudioFormatManager AudioFileDropSource::format_manager_ |
|
protected |
Manages and recognizes different audio file formats.
The documentation for this class was generated from the following file: