@@ -33,7 +33,8 @@ static const Font FONT_LABEL ("Small Text", 10, Font::plain);
3333FileReaderEditor::FileReaderEditor (GenericProcessor* parentNode, bool useDefaultParameterEditors = true )
3434 : GenericEditor (parentNode, useDefaultParameterEditors)
3535 , fileReader (static_cast <FileReader*> (parentNode))
36- , recTotalTime (0 )
36+ , recTotalTime (0 )
37+ , m_isFileDragAndDropActive (false )
3738{
3839 lastFilePath = File::getCurrentWorkingDirectory ();
3940
@@ -91,6 +92,17 @@ void FileReaderEditor::setFile (String file)
9192}
9293
9394
95+ void FileReaderEditor::paintOverChildren (Graphics& g)
96+ {
97+ // Draw a frame around component if files are drag&dropping now
98+ if (m_isFileDragAndDropActive)
99+ {
100+ g.setColour (Colours::aqua);
101+ g.drawRect (getLocalBounds (), 2 .f );
102+ }
103+ }
104+
105+
94106void FileReaderEditor::buttonEvent (Button* button)
95107{
96108 if (! acquisitionIsActive)
@@ -251,6 +263,45 @@ void FileReaderEditor::loadCustomParameters (XmlElement* xml)
251263}
252264
253265
266+ bool FileReaderEditor::isInterestedInFileDrag (const StringArray& files)
267+ {
268+ if (! acquisitionIsActive)
269+ {
270+ const bool isExtensionSupported = fileReader->isFileSupported (files[0 ]);
271+ m_isFileDragAndDropActive = true ;
272+
273+ return isExtensionSupported;
274+ }
275+
276+ return false ;
277+ }
278+
279+
280+ void FileReaderEditor::fileDragExit (const StringArray& files)
281+ {
282+ m_isFileDragAndDropActive = false ;
283+
284+ repaint ();
285+ }
286+
287+
288+ void FileReaderEditor::fileDragEnter (const StringArray& files, int x, int y)
289+ {
290+ m_isFileDragAndDropActive = true ;
291+
292+ repaint ();
293+ }
294+
295+
296+ void FileReaderEditor::filesDropped (const StringArray& files, int x, int y)
297+ {
298+ setFile (files[0 ]);
299+
300+ m_isFileDragAndDropActive = false ;
301+ repaint ();
302+ }
303+
304+
254305// DualTimeComponent
255306// ================================================================================
256307DualTimeComponent::DualTimeComponent (FileReaderEditor* e, bool editable)
@@ -298,15 +349,14 @@ DualTimeComponent::~DualTimeComponent()
298349
299350void DualTimeComponent::paint (Graphics& g)
300351{
301- g.setFont (FONT_LABEL);
302- g.setColour (Colours::darkgrey);
303-
304352 String sep;
305353 if (isEditable)
306354 sep = " -" ;
307355 else
308356 sep = " /" ;
309357
358+ g.setFont (FONT_LABEL);
359+ g.setColour (Colours::darkgrey);
310360 g.drawText (sep, 78 , 0 , 5 , 20 , Justification::centred, false );
311361}
312362
0 commit comments