Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
helpSVG));

pGraphics->AttachControl(new NAMAboutBoxControl(b, backgroundBitmap, style), kCtrlTagAboutBox)->Hide(true);

// Implements drag and drop capabilities for plugin
pGraphics->AttachControl(new NAMDragDropControl(mainArea, loadModelCompletionHandler));

pGraphics->ForAllControlsFunc([](IControl* pControl) {
pControl->SetMouseEventsWhenDisabled(true);
Expand Down
34 changes: 34 additions & 0 deletions NeuralAmpModeler/NeuralAmpModelerControls.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cmath> // std::round
#include <functional> // std::function
#include <sstream> // std::stringstream
#include "IControls.h"

Expand Down Expand Up @@ -558,3 +559,36 @@ class NAMAboutBoxControl : public IContainerBase
int mAnimationTime = 200;
bool mWillHide = false;
};

class NAMDragDropControl : public IControl
{
public:
NAMDragDropControl(const IRECT& bounds,
std::function<void(const WDL_String&, const WDL_String&)> loadModelCompletionHandler)
: IControl(bounds), loadModel(loadModelCompletionHandler)
{
mIgnoreMouse = true;
}

void Draw(IGraphics& g) override
{}

void OnDrop(const char* str) override
{
// Handle the dropped data
if (str)
{
std::cout << "Dropped data: " << str << std::endl;

WDL_String fileName, directory;
fileName.Set(str);
directory.Set(str);
directory.remove_filepart(true);

loadModel(fileName, directory);
}
}

private:
std::function<void(const WDL_String&, const WDL_String&)> loadModel;
};