@@ -352,7 +352,7 @@ MainComponent::MainComponent (Validator& v)
352352 {
353353 strictnessDialog = std::make_unique<StrictnessInfoDialog> (
354354 getStrictnessLevel (),
355- [this , updateStrictnessButtonText] (int newLevel)
355+ [updateStrictnessButtonText] (int newLevel)
356356 {
357357 setStrictnessLevel (newLevel);
358358 updateStrictnessButtonText ();
@@ -384,26 +384,45 @@ void MainComponent::paint (juce::Graphics& g)
384384
385385void MainComponent::paintOverChildren (juce::Graphics& g)
386386{
387- if (! dragHighlight )
387+ if (dragAction == DropAction::none )
388388 return ;
389389
390390 constexpr float cornerRadius = 10 .0f ;
391- constexpr float borderThickness = 3 .0f ;
392391 constexpr float inset = 6 .0f ;
393- const auto accent = juce::Colour (0xff4a9eff );
392+ constexpr float gap = 8 .0f ;
393+ const auto accent = juce::Colour (0xff4a9eff ).withAlpha (0 .9f );
394394
395- auto r = getLocalBounds ().withTrimmedTop (menuBar.getBottom ())
396- .toFloat ()
397- .reduced (inset);
395+ auto area = getDragOverlayBounds ().toFloat ().reduced (inset);
398396
399- g.setColour (accent.withAlpha (0 .12f ));
400- g.fillRoundedRectangle (r, cornerRadius);
397+ auto leftHalf = area.removeFromLeft ((area.getWidth () - gap) * 0 .5f );
398+ area.removeFromLeft (gap);
399+ auto rightHalf = area;
401400
402- g.setColour (accent);
403- g.drawRoundedRectangle (r, cornerRadius, borderThickness);
401+ auto drawZone = [&] (juce::Rectangle<float > zone, const juce::String& title,
402+ const juce::String& subtitle, bool active)
403+ {
404+ auto bgCol = accent.withMultipliedSaturation (active ? 1 .0f : 0 .2f );
405+ g.setColour (bgCol);
406+ g.fillRoundedRectangle (zone, cornerRadius);
407+
408+ g.setColour (accent);
409+ g.drawRoundedRectangle (zone, cornerRadius, active ? 3 .0f : 1 .5f );
410+
411+ auto textArea = zone.reduced (12 .0f );
412+ auto titleArea = textArea.removeFromTop (textArea.getHeight () * 0 .5f );
413+
414+ g.setColour (bgCol.contrasting ().withAlpha (active ? 1 .0f : 0 .6f ));
415+ g.setFont (juce::Font (juce::FontOptions (24 .0f , juce::Font::bold)));
416+ g.drawText (title, titleArea, juce::Justification::centredBottom);
404417
405- g.setFont (juce::Font (juce::FontOptions (22 .0f , juce::Font::bold)));
406- g.drawText (" Drop plug-in to validate" , r, juce::Justification::centred);
418+ g.setFont (juce::Font (juce::FontOptions (14 .0f )));
419+ g.drawText (subtitle, textArea, juce::Justification::centredTop);
420+ };
421+
422+ drawZone (leftHalf, " Validate" , " Run validation now" ,
423+ dragAction == DropAction::validate);
424+ drawZone (rightHalf, " Add to List" , " Scan into the plug-in list" ,
425+ dragAction == DropAction::addToList);
407426}
408427
409428void MainComponent::resized ()
@@ -468,31 +487,55 @@ bool MainComponent::isInterestedInFileDrag (const juce::StringArray& files)
468487 return false ;
469488}
470489
471- void MainComponent::fileDragEnter ( const juce::StringArray& files, int , int )
490+ juce::Rectangle< int > MainComponent::getDragOverlayBounds () const
472491{
473- const bool shouldHighlight = isInterestedInFileDrag (files);
492+ return getLocalBounds ().withTrimmedTop (menuBar.getBottom ());
493+ }
474494
475- if (dragHighlight != shouldHighlight)
495+ MainComponent::DropAction MainComponent::dropActionForX (int x) const
496+ {
497+ return x < getDragOverlayBounds ().getCentreX () ? DropAction::validate
498+ : DropAction::addToList;
499+ }
500+
501+ void MainComponent::updateDragAction (const juce::StringArray& files, int x)
502+ {
503+ const auto newAction = isInterestedInFileDrag (files) ? dropActionForX (x)
504+ : DropAction::none;
505+
506+ if (dragAction != newAction)
476507 {
477- dragHighlight = shouldHighlight ;
508+ dragAction = newAction ;
478509 repaint ();
479510 }
480511}
481512
513+ void MainComponent::fileDragEnter (const juce::StringArray& files, int x, int )
514+ {
515+ updateDragAction (files, x);
516+ }
517+
518+ void MainComponent::fileDragMove (const juce::StringArray& files, int x, int )
519+ {
520+ updateDragAction (files, x);
521+ }
522+
482523void MainComponent::fileDragExit (const juce::StringArray&)
483524{
484- if (dragHighlight )
525+ if (dragAction != DropAction::none )
485526 {
486- dragHighlight = false ;
527+ dragAction = DropAction::none ;
487528 repaint ();
488529 }
489530}
490531
491- void MainComponent::filesDropped (const juce::StringArray& files, int , int )
532+ void MainComponent::filesDropped (const juce::StringArray& files, int x , int )
492533{
493- if (dragHighlight)
534+ const auto action = dropActionForX (x);
535+
536+ if (dragAction != DropAction::none)
494537 {
495- dragHighlight = false ;
538+ dragAction = DropAction::none ;
496539 repaint ();
497540 }
498541
@@ -507,12 +550,17 @@ void MainComponent::filesDropped (const juce::StringArray& files, int, int)
507550
508551 getAppPreferences ().setValue (" lastPluginLocation" , pluginFiles[pluginFiles.size () - 1 ]);
509552
510- juce::OwnedArray<juce::PluginDescription> typesFound;
511- knownPluginList.scanAndAddDragAndDroppedFiles (formatManager, pluginFiles, typesFound);
512- savePluginList ();
513-
514- validator.setValidateInProcess (getValidateInProcess ());
515- validator.validate (pluginFiles, getTestOptions ());
553+ if (action == DropAction::addToList)
554+ {
555+ juce::OwnedArray<juce::PluginDescription> typesFound;
556+ knownPluginList.scanAndAddDragAndDroppedFiles (formatManager, pluginFiles, typesFound);
557+ savePluginList ();
558+ }
559+ else
560+ {
561+ validator.setValidateInProcess (getValidateInProcess ());
562+ validator.validate (pluginFiles, getTestOptions ());
563+ }
516564}
517565
518566// ==============================================================================
0 commit comments