Skip to content

Commit

Permalink
Include Steinberg PR responses (surge-synthesizer#573)
Browse files Browse the repository at this point in the history
We sent 3 pull requests to steinberg for vstgui and they correctly
responded that 2/3 were indicative of us not using their API correctly

As such I've removed those commits from vstgui/surge, applied the
changes to our code, and have confirmed that the two issues
(capture on mouse click and diacriticals and emojis in patch
and category names) work with the vstgui without the associated
incorrect patches.

The final patch for checmark submenus is still in vstgui.surge in
this commit

Closes surge-synthesizer#571
  • Loading branch information
baconpaul authored Feb 10, 2019
1 parent c4c3b8e commit f2e59c9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,26 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
for (auto &p : alldirs )
{
PatchCategory c;
#if WINDOWS
/*
** Windows filesystem names are properly wstrings which, if we want them to
** display properly in vstgui, need to be converted to UTF8 using the
** windows widechar API. Linux and Mac do not require this.
*/
std::wstring str = p.wstring().substr(patchpathSubstrLength);
std::string ret;
int len = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0, NULL, NULL);
if (len > 0)
{
ret.resize(len);
WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), &ret[0], len, NULL, NULL);
}

c.name = ret;
#else
c.name = p.generic_string().substr(patchpathSubstrLength);
c.numberOfPatchesInCatgory = 0;
#endif

for (auto& f : fs::directory_iterator(p))
{
Expand All @@ -351,8 +369,21 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
Patch e;
e.category = category;
e.path = f.path();
#if WINDOWS
std::wstring str = f.path().filename().wstring();
str = str.substr(0, str.size()-4);
std::string ret;
int len = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0, NULL, NULL);
if (len > 0)
{
ret.resize(len);
WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), &ret[0], len, NULL, NULL);
}
e.name = ret;
#else
e.name = f.path().filename().generic_string();
e.name = e.name.substr(0, e.name.size() - 4);
#endif
patch_list.push_back(e);

c.numberOfPatchesInCatgory ++;
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/CPatchBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ CMouseEventResult CPatchBrowser::onMouseDown(CPoint& where, const CButtonState&
contextMenu->popup();
getFrame()->removeView(contextMenu, true); // remove from frame and forget

return kMouseEventHandled;
return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}

bool CPatchBrowser::populatePatchMenuForCategory( int c, COptionMenu *contextMenu, bool single_category, int &main_e, bool rootCall )
Expand Down

0 comments on commit f2e59c9

Please sign in to comment.