Browse Source

Implement openBrowser for wasm

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.07
falkTX 1 month ago
parent
commit
74b41e1713
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 28 additions and 10 deletions
  1. +15
    -0
      src/CardinalCommon.cpp
  2. +1
    -0
      src/CardinalCommon.hpp
  3. +2
    -2
      src/override/MenuBar.cpp
  4. +9
    -7
      src/override/Model.cpp
  5. +1
    -1
      src/override/Scene.cpp

+ 15
- 0
src/CardinalCommon.cpp View File

@@ -52,6 +52,10 @@
# include <unistd.h>
#endif

#ifdef DISTRHO_OS_WASM
# include <emscripten/emscripten.h>
#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,


+ 1
- 0
src/CardinalCommon.hpp View File

@@ -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();


+ 2
- 2
src/override/MenuBar.cpp View File

@@ -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);


+ 9
- 7
src/override/Model.cpp View File

@@ -38,6 +38,8 @@
#include <ui/MenuSeparator.hpp>
#include <helpers.hpp>

#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);
}));
}



+ 1
- 1
src/override/Scene.cpp View File

@@ -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) {


Loading…
Cancel
Save