Skip to content

Commit

Permalink
Merge pull request surge-synthesizer#336 from baconpaul/drag-n-drop-199
Browse files Browse the repository at this point in the history
Implement .wt drag-n-drop. Closes surge-synthesizer#199
  • Loading branch information
baconpaul authored Jan 19, 2019
2 parents d50d02d + a877a4b commit aa6703c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
41 changes: 33 additions & 8 deletions src/common/gui/COscillatorDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#include "Oscillator.h"
#include <time.h>
#include "unitconversion.h"
#include "UserInteractions.h"
#if MAC
#include "filesystem.h"
#else
#include "filesystem"
#endif

namespace fs = std::experimental::filesystem;

const float disp_pitch = 90.15f - 48.f;
const int wtbheight = 12;
Expand Down Expand Up @@ -210,17 +218,34 @@ void COscillatorDisplay::draw(CDrawContext* dc)

bool COscillatorDisplay::onDrop(IDataPackage* drag, const CPoint& where)
{
/*long size,type;
char *filename = (char*)drag->first(size,type);
//while(filename)
if(filename)
uint32_t ct = drag->getCount();
if (ct == 1)
{
if(type == CDragContainer::kFile)
IDataPackage::Type t = drag->getDataType( 0 );
if (t == IDataPackage::kFilePath)
{
const void* fn;
drag->getData(0, fn, t);
const char* fName = static_cast<const char*>(fn);
fs::path fPath(fName);
if (_stricmp(fPath.extension().generic_string().c_str(),".wt")!=0)
{
Surge::UserInteractions::promptError(std::string( "Surge only supports drag-and-drop of .wt wavetables onto the oscillator. " )
+ "You dropped a file with extension " + fPath.extension().generic_string(),
"Please drag a valid file type");
}
else
{
strncpy(oscdata->wt.queue_filename, filename, 255);
strncpy(oscdata->wt.queue_filename, fName, 255);
}
// filename = (char*)drag->next(size,type);
}*/
}
else
{
Surge::UserInteractions::promptError("Surge only supports drag-and-drop of files onto the oscillator",
"Please Drag a File");
}
}

return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,6 @@ void SurgeGUIEditor::openOrRecreateEditor()
queue_refresh = false;
frame->setDirty();
frame->invalid();
// frame->setDropActive(true); // TODO VSTGUI4
}

void SurgeGUIEditor::close_editor()
Expand Down

0 comments on commit aa6703c

Please sign in to comment.