From f2e59c9c03efe8ee0a752eb7982458844694b9b2 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 10 Feb 2019 15:34:07 -0500 Subject: [PATCH] Include Steinberg PR responses (#573) 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 #571 --- src/common/SurgeStorage.cpp | 31 +++++++++++++++++++++++++++++++ src/common/gui/CPatchBrowser.cpp | 2 +- vstgui.surge | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/common/SurgeStorage.cpp b/src/common/SurgeStorage.cpp index 4d5457bf1a2..0659a91a16d 100644 --- a/src/common/SurgeStorage.cpp +++ b/src/common/SurgeStorage.cpp @@ -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)) { @@ -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 ++; diff --git a/src/common/gui/CPatchBrowser.cpp b/src/common/gui/CPatchBrowser.cpp index 38c12fb24c9..05989bfb0ea 100644 --- a/src/common/gui/CPatchBrowser.cpp +++ b/src/common/gui/CPatchBrowser.cpp @@ -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 ) diff --git a/vstgui.surge b/vstgui.surge index 78203d44cf3..1dced2b2d82 160000 --- a/vstgui.surge +++ b/vstgui.surge @@ -1 +1 @@ -Subproject commit 78203d44cf38858eed7d4dff8fe1c8cd34e2ac30 +Subproject commit 1dced2b2d82d78173dcaddfff998c0d21f199871