diff --git a/src/CardinalCommon.cpp b/src/CardinalCommon.cpp index 5358c77..8a84e33 100644 --- a/src/CardinalCommon.cpp +++ b/src/CardinalCommon.cpp @@ -52,6 +52,10 @@ # include #endif +#ifdef DISTRHO_OS_WASM +# include +#endif + const std::string CARDINAL_VERSION = "22.06"; namespace rack { @@ -268,6 +272,17 @@ void saveAsDialogUncompressed() #endif } +void openBrowser(const std::string& url) +{ +#ifdef DISTRHO_OS_WASM + EM_ASM({ + window.open(UTF8ToString($0), '_blank'); + }, url.c_str()); +#else + patchUtils::openBrowser(url); +#endif +} + } void async_dialog_filebrowser(const bool saving, diff --git a/src/CardinalCommon.hpp b/src/CardinalCommon.hpp index b45b1e8..16c74a9 100644 --- a/src/CardinalCommon.hpp +++ b/src/CardinalCommon.hpp @@ -66,6 +66,7 @@ void saveDialog(const std::string& path); void saveAsDialog(); void saveAsDialogUncompressed(); void appendSelectionContextMenu(rack::ui::Menu* menu); +void openBrowser(const std::string& url); bool connectToRemote(); bool isRemoteConnected(); diff --git a/src/override/MenuBar.cpp b/src/override/MenuBar.cpp index c19e857..416d859 100644 --- a/src/override/MenuBar.cpp +++ b/src/override/MenuBar.cpp @@ -572,11 +572,11 @@ struct HelpButton : MenuButton { menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->addChild(createMenuItem("Rack User manual", "F1", [=]() { - system::openBrowser("https://vcvrack.com/manual"); + patchUtils::openBrowser("https://vcvrack.com/manual"); })); menu->addChild(createMenuItem("Cardinal Project page", "", [=]() { - system::openBrowser("https://github.com/DISTRHO/Cardinal/"); + patchUtils::openBrowser("https://github.com/DISTRHO/Cardinal/"); })); menu->addChild(new ui::MenuSeparator); diff --git a/src/override/Model.cpp b/src/override/Model.cpp index 7ddafb0..a2541be 100644 --- a/src/override/Model.cpp +++ b/src/override/Model.cpp @@ -38,6 +38,8 @@ #include #include +#include "../CardinalCommon.hpp" + namespace rack { namespace plugin { @@ -120,7 +122,7 @@ std::string Model::getManualUrl() { void Model::appendContextMenu(ui::Menu* menu, bool inBrowser) { // plugin menu->addChild(createMenuItem("Plugin: " + plugin->name, "", [=]() { - system::openBrowser(plugin->pluginUrl); + patchUtils::openBrowser(plugin->pluginUrl); }, plugin->pluginUrl == "")); // version @@ -129,7 +131,7 @@ void Model::appendContextMenu(ui::Menu* menu, bool inBrowser) { // author if (plugin->author != "") { menu->addChild(createMenuItem("Author: " + plugin->author, "", [=]() { - system::openBrowser(plugin->authorUrl); + patchUtils::openBrowser(plugin->authorUrl); }, plugin->authorUrl.empty())); } @@ -137,7 +139,7 @@ void Model::appendContextMenu(ui::Menu* menu, bool inBrowser) { std::string license = plugin->license; if (string::startsWith(license, "https://") || string::startsWith(license, "http://")) { menu->addChild(createMenuItem("License: Open in browser", "", [=]() { - system::openBrowser(license); + patchUtils::openBrowser(license); })); } else if (license != "") { @@ -158,28 +160,28 @@ void Model::appendContextMenu(ui::Menu* menu, bool inBrowser) { std::string manualUrl = getManualUrl(); if (manualUrl != "") { menu->addChild(createMenuItem("User manual", RACK_MOD_CTRL_NAME "+F1", [=]() { - system::openBrowser(manualUrl); + patchUtils::openBrowser(manualUrl); })); } // donate if (plugin->donateUrl != "") { menu->addChild(createMenuItem("Donate", "", [=]() { - system::openBrowser(plugin->donateUrl); + patchUtils::openBrowser(plugin->donateUrl); })); } // source code if (plugin->sourceUrl != "") { menu->addChild(createMenuItem("Source code", "", [=]() { - system::openBrowser(plugin->sourceUrl); + patchUtils::openBrowser(plugin->sourceUrl); })); } // changelog if (plugin->changelogUrl != "") { menu->addChild(createMenuItem("Changelog", "", [=]() { - system::openBrowser(plugin->changelogUrl); + patchUtils::openBrowser(plugin->changelogUrl); })); } diff --git a/src/override/Scene.cpp b/src/override/Scene.cpp index b69bc80..9651f98 100644 --- a/src/override/Scene.cpp +++ b/src/override/Scene.cpp @@ -342,7 +342,7 @@ void Scene::onHoverKey(const HoverKeyEvent& e) { e.consume(this); } if (e.key == GLFW_KEY_F1 && (e.mods & RACK_MOD_MASK) == 0) { - system::openBrowser("https://vcvrack.com/manual/"); + patchUtils::openBrowser("https://vcvrack.com/manual/"); e.consume(this); } if (e.key == GLFW_KEY_F3 && (e.mods & RACK_MOD_MASK) == 0) {