More details for mini version, make menubar variant specific
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
b71acc9f22
commit
91cac905cc
17 changed files with 331 additions and 79 deletions
1
src/Cardinal/MenuBar.cpp
Symbolic link
1
src/Cardinal/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
1
src/CardinalFX/MenuBar.cpp
Symbolic link
1
src/CardinalFX/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
1
src/CardinalMini/MenuBar.cpp
Symbolic link
1
src/CardinalMini/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
1
src/CardinalNative/MenuBar.cpp
Symbolic link
1
src/CardinalNative/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
|
@ -76,13 +76,21 @@ bool connectToRemote()
|
|||
|
||||
RemoteDetails* remoteDetails = ui->remoteDetails;
|
||||
|
||||
#ifdef HAVE_LIBLO
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
if (remoteDetails == nullptr)
|
||||
{
|
||||
ui->remoteDetails = remoteDetails = new RemoteDetails;
|
||||
remoteDetails->handle = ui;
|
||||
remoteDetails->connected = true;
|
||||
remoteDetails->autoDeploy = true;
|
||||
}
|
||||
#elif defined(HAVE_LIBLO)
|
||||
if (remoteDetails == nullptr)
|
||||
{
|
||||
const lo_server oscServer = lo_server_new_with_proto(nullptr, LO_UDP, nullptr);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(oscServer != nullptr, false);
|
||||
|
||||
remoteDetails = new RemoteDetails;
|
||||
ui->remoteDetails = remoteDetails = new RemoteDetails;
|
||||
remoteDetails->handle = oscServer;
|
||||
remoteDetails->connected = false;
|
||||
remoteDetails->autoDeploy = false;
|
||||
|
@ -106,13 +114,14 @@ void disconnectFromRemote(RemoteDetails* const remote)
|
|||
{
|
||||
#ifdef HAVE_LIBLO
|
||||
lo_server_free(static_cast<lo_server>(remote->handle));
|
||||
delete remote;
|
||||
#endif
|
||||
delete remote;
|
||||
}
|
||||
}
|
||||
|
||||
void idleRemote(RemoteDetails* const remote)
|
||||
{
|
||||
DISTRHO_SAFE_ASSERT_RETURN(remote != nullptr,);
|
||||
#ifdef HAVE_LIBLO
|
||||
while (lo_server_recv_noblock(static_cast<lo_server>(remote->handle), 0) != 0) {}
|
||||
#endif
|
||||
|
@ -120,15 +129,26 @@ void idleRemote(RemoteDetails* const remote)
|
|||
|
||||
void deployToRemote(RemoteDetails* const remote)
|
||||
{
|
||||
#ifdef HAVE_LIBLO
|
||||
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,);
|
||||
|
||||
context->engine->prepareSave();
|
||||
context->patch->saveAutosave();
|
||||
context->patch->cleanAutosave();
|
||||
std::vector<uint8_t> data(rack::system::archiveDirectory(context->patch->autosavePath, 1));
|
||||
|
||||
DISTRHO_SAFE_ASSERT_RETURN(data.size() >= 4,);
|
||||
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
if (char* const patch = String::asBase64(data.data(), data.size()).getAndReleaseBuffer())
|
||||
{
|
||||
static_cast<CardinalBaseUI*>(remote->handle)->setState("patch", patch);
|
||||
std::free(patch);
|
||||
}
|
||||
#elif defined(HAVE_LIBLO)
|
||||
const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,);
|
||||
|
||||
APP->engine->prepareSave();
|
||||
APP->patch->saveAutosave();
|
||||
APP->patch->cleanAutosave();
|
||||
std::vector<uint8_t> data(rack::system::archiveDirectory(APP->patch->autosavePath, 1));
|
||||
|
||||
if (const lo_blob blob = lo_blob_new(data.size(), data.data()))
|
||||
{
|
||||
lo_send(addr, "/load", "b", blob);
|
||||
|
@ -139,7 +159,7 @@ void deployToRemote(RemoteDetails* const remote)
|
|||
#endif
|
||||
}
|
||||
|
||||
void sendScreenshotToRemote(RemoteDetails* const remote, const char* const screenshot)
|
||||
void sendScreenshotToRemote(RemoteDetails*, const char* const screenshot)
|
||||
{
|
||||
#ifdef HAVE_LIBLO
|
||||
const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT);
|
||||
|
|
1
src/CardinalRemote/MenuBar.cpp
Symbolic link
1
src/CardinalRemote/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
1
src/CardinalSynth/MenuBar.cpp
Symbolic link
1
src/CardinalSynth/MenuBar.cpp
Symbolic link
|
@ -0,0 +1 @@
|
|||
../override/MenuBar.cpp
|
|
@ -62,9 +62,6 @@
|
|||
#endif
|
||||
|
||||
namespace rack {
|
||||
namespace app {
|
||||
widget::Widget* createMenuBar(bool isStandalone);
|
||||
}
|
||||
namespace engine {
|
||||
void Engine_setAboutToClose(Engine*);
|
||||
}
|
||||
|
@ -87,7 +84,7 @@ bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; }
|
|||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifdef DISTRHO_OS_WASM
|
||||
#if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
|
||||
struct WasmWelcomeDialog : rack::widget::OpaqueWidget
|
||||
{
|
||||
static const constexpr float margin = 10;
|
||||
|
@ -346,7 +343,10 @@ public:
|
|||
{
|
||||
rack::contextSet(context);
|
||||
|
||||
#if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
DISTRHO_SAFE_ASSERT_RETURN(remoteUtils::connectToRemote(),);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(remoteDetails != nullptr,);
|
||||
|
||||
// create unique temporary path for this instance
|
||||
try {
|
||||
char uidBuf[24];
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
const float sampleRate = getSampleRate();
|
||||
rack::settings::sampleRate = sampleRate;
|
||||
|
||||
context->bufferSize = 128;
|
||||
context->bufferSize = 1;
|
||||
context->sampleRate = sampleRate;
|
||||
|
||||
context->engine = new rack::engine::Engine;
|
||||
|
@ -403,15 +403,6 @@ public:
|
|||
|
||||
rack::window::WindowSetPluginUI(context->window, this);
|
||||
|
||||
if (rack::widget::Widget* const menuBar = context->scene->menuBar)
|
||||
{
|
||||
context->scene->removeChild(menuBar);
|
||||
delete menuBar;
|
||||
}
|
||||
|
||||
context->scene->menuBar = rack::app::createMenuBar(getApp().isStandalone());
|
||||
context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll);
|
||||
|
||||
// hide "Browse VCV Library" button
|
||||
rack::widget::Widget* const browser = context->scene->browser->children.back();
|
||||
rack::widget::Widget* const headerLayout = browser->children.front();
|
||||
|
@ -444,7 +435,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DISTRHO_OS_WASM
|
||||
#if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI
|
||||
if (rack::patchStorageSlug != nullptr)
|
||||
{
|
||||
psDialog = new WasmRemotePatchLoadingDialog(true);
|
||||
|
@ -477,26 +468,18 @@ public:
|
|||
|
||||
context->nativeWindowId = 0;
|
||||
|
||||
if (rack::widget::Widget* const menuBar = context->scene->menuBar)
|
||||
{
|
||||
context->scene->removeChild(menuBar);
|
||||
delete menuBar;
|
||||
}
|
||||
|
||||
context->scene->menuBar = rack::app::createMenuBar();
|
||||
context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll);
|
||||
|
||||
rack::window::WindowSetPluginUI(context->window, nullptr);
|
||||
|
||||
#if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
context->tlw = nullptr;
|
||||
context->ui = nullptr;
|
||||
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
{
|
||||
const ScopedContext sc(this);
|
||||
context->patch->clear();
|
||||
|
||||
// do a little dance to prevent context scene deletion from saving to temp dir
|
||||
#ifndef HEADLESS
|
||||
const ScopedValueSetter<bool> svs(rack::settings::headless, true);
|
||||
#endif
|
||||
Engine_setAboutToClose(context->engine);
|
||||
delete context;
|
||||
}
|
||||
|
@ -620,6 +603,10 @@ public:
|
|||
filebrowserhandle = nullptr;
|
||||
}
|
||||
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
context->engine->stepBlock(1);
|
||||
#endif
|
||||
|
||||
if (windowParameters.rateLimit != 0 && ++rateLimitStep % (windowParameters.rateLimit * 2))
|
||||
return;
|
||||
|
||||
|
@ -804,7 +791,7 @@ protected:
|
|||
|
||||
void stateChanged(const char* const key, const char* const value) override
|
||||
{
|
||||
#if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
#if CARDINAL_VARIANT_MINI
|
||||
if (std::strcmp(key, "patch") == 0)
|
||||
{
|
||||
if (fAutosavePath.empty())
|
||||
|
@ -952,9 +939,9 @@ protected:
|
|||
#endif
|
||||
|
||||
rack::math::Vec scrollDelta = rack::math::Vec(ev.delta.getX(), ev.delta.getY());
|
||||
#ifndef DISTRHO_OS_MAC
|
||||
#ifndef DISTRHO_OS_MAC
|
||||
scrollDelta = scrollDelta.mult(50.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const int mods = glfwMods(ev.mod);
|
||||
const ScopedContext sc(this, mods);
|
||||
|
|
|
@ -165,7 +165,6 @@ RACK_FILES += override/context.cpp
|
|||
RACK_FILES += override/minblep.cpp
|
||||
RACK_FILES += override/plugin.cpp
|
||||
RACK_FILES += override/Engine.cpp
|
||||
RACK_FILES += override/MenuBar.cpp
|
||||
RACK_FILES += override/Model.cpp
|
||||
RACK_FILES += override/ModuleWidget.cpp
|
||||
RACK_FILES += override/OpenGlWidget.cpp
|
||||
|
|
|
@ -108,6 +108,7 @@ FILES_DSP += RemoteWindow.cpp
|
|||
else
|
||||
FILES_UI = CardinalUI.cpp
|
||||
FILES_UI += glfw.cpp
|
||||
FILES_UI += MenuBar.cpp
|
||||
FILES_UI += Window.cpp
|
||||
endif
|
||||
|
||||
|
@ -255,6 +256,7 @@ FILES_UI += CardinalCommon-UI.cpp
|
|||
FILES_UI += CardinalRemote.cpp
|
||||
FILES_UI += common.cpp
|
||||
FILES_UI += glfw.cpp
|
||||
FILES_UI += MenuBar.cpp
|
||||
FILES_UI += Window.cpp
|
||||
EXTRA_UI_DEPENDENCIES = $(subst -headless,,$(EXTRA_DSP_DEPENDENCIES))
|
||||
EXTRA_UI_LIBS += $(subst -headless,,$(EXTRA_DSP_LIBS))
|
||||
|
|
|
@ -182,13 +182,10 @@ public:
|
|||
|
||||
~CardinalBaseUI() override
|
||||
{
|
||||
disconnectFromRemote(remoteDetails);
|
||||
remoteUtils::disconnectFromRemote(remoteDetails);
|
||||
|
||||
if (filebrowserhandle != nullptr)
|
||||
fileBrowserClose(filebrowserhandle);
|
||||
|
||||
context->tlw = nullptr;
|
||||
context->ui = nullptr;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -209,10 +209,15 @@ static void Engine_stepFrame(Engine* that) {
|
|||
float smoothValue = internal->smoothValue;
|
||||
Param* smoothParam = &smoothModule->params[smoothParamId];
|
||||
float value = smoothParam->value;
|
||||
// Use decay rate of roughly 1 graphics frame
|
||||
const float smoothLambda = 60.f;
|
||||
float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime;
|
||||
if (value == newValue) {
|
||||
float newValue;
|
||||
if (internal->blockFrames != 1) {
|
||||
// Use decay rate of roughly 1 graphics frame
|
||||
const float smoothLambda = 60.f;
|
||||
newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime;
|
||||
} else {
|
||||
newValue = value;
|
||||
}
|
||||
if (d_isEqual(value, newValue)) {
|
||||
// Snap to actual smooth value if the value doesn't change enough (due to the granularity of floats)
|
||||
smoothParam->setValue(smoothValue);
|
||||
internal->smoothModule = NULL;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include "../CardinalCommon.hpp"
|
||||
#include "../CardinalRemote.hpp"
|
||||
#include "DistrhoPlugin.hpp"
|
||||
#include "DistrhoStandaloneUtils.hpp"
|
||||
|
||||
#ifdef HAVE_LIBLO
|
||||
|
@ -98,14 +99,14 @@ struct MenuButton : ui::Button {
|
|||
|
||||
struct FileButton : MenuButton {
|
||||
const bool isStandalone;
|
||||
#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD))
|
||||
#if ! CARDINAL_VARIANT_MINI
|
||||
std::vector<std::string> demoPatches;
|
||||
#endif
|
||||
|
||||
FileButton(const bool standalone)
|
||||
: MenuButton(), isStandalone(standalone)
|
||||
{
|
||||
#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD))
|
||||
#if ! CARDINAL_VARIANT_MINI
|
||||
const std::string patchesDir = asset::patchesPath() + DISTRHO_OS_SEP_STR "examples";
|
||||
|
||||
if (system::isDirectory(patchesDir))
|
||||
|
@ -167,7 +168,7 @@ struct FileButton : MenuButton {
|
|||
patchUtils::revertDialog();
|
||||
}, APP->patch->path.empty()));
|
||||
|
||||
#ifdef HAVE_LIBLO
|
||||
// #if defined(HAVE_LIBLO) && ! CARDINAL_VARIANT_MINI
|
||||
menu->addChild(new ui::MenuSeparator);
|
||||
|
||||
remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote();
|
||||
|
@ -186,7 +187,7 @@ struct FileButton : MenuButton {
|
|||
remoteUtils::connectToRemote();
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
#ifndef DISTRHO_OS_WASM
|
||||
menu->addChild(new ui::MenuSeparator);
|
||||
|
@ -201,7 +202,7 @@ struct FileButton : MenuButton {
|
|||
}));
|
||||
#endif
|
||||
|
||||
#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD))
|
||||
#if ! CARDINAL_VARIANT_MINI
|
||||
if (!demoPatches.empty())
|
||||
{
|
||||
menu->addChild(new ui::MenuSeparator);
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace rack {
|
|||
namespace app {
|
||||
|
||||
|
||||
widget::Widget* createMenuBar(bool isStandalone);
|
||||
|
||||
|
||||
struct ResizeHandle : widget::OpaqueWidget {
|
||||
math::Vec size;
|
||||
|
||||
|
@ -131,7 +134,7 @@ Scene::Scene() {
|
|||
|
||||
rack = rackScroll->rackWidget;
|
||||
|
||||
menuBar = createMenuBar();
|
||||
menuBar = createMenuBar(isStandalone());
|
||||
addChild(menuBar);
|
||||
|
||||
browser = browserCreate();
|
||||
|
@ -209,7 +212,7 @@ void Scene::step() {
|
|||
if (remoteDetails->autoDeploy) {
|
||||
const int actionIndex = APP->history->actionIndex;
|
||||
const double time = system::getTime();
|
||||
if (internal->historyActionIndex != actionIndex && time - internal->lastSceneChangeTime >= 5.0) {
|
||||
if (internal->historyActionIndex != actionIndex && time - internal->lastSceneChangeTime >= 1.0) {
|
||||
internal->historyActionIndex = actionIndex;
|
||||
internal->lastSceneChangeTime = time;
|
||||
remoteUtils::deployToRemote(remoteDetails);
|
||||
|
@ -315,7 +318,8 @@ void Scene::onHoverKey(const HoverKeyEvent& e) {
|
|||
e.consume(this);
|
||||
}
|
||||
if (e.key == GLFW_KEY_F7 && (e.mods & RACK_MOD_MASK) == 0) {
|
||||
remoteUtils::deployToRemote(remoteUtils::getRemote());
|
||||
if (remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote())
|
||||
remoteUtils::deployToRemote(remoteDetails);
|
||||
window::generateScreenshot();
|
||||
e.consume(this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue