Signed-off-by: falkTX <falktx@falktx.com>tags/22.12
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * DISTRHO Cardinal Plugin | |||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -1,35 +0,0 @@ | |||
| /* | |||
| * DISTRHO Cardinal Plugin | |||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 3 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the LICENSE file. | |||
| */ | |||
| #pragma once | |||
| #include_next <rack.hpp> | |||
| #ifdef BUILDING_PLUGIN_MODULES | |||
| namespace rack { | |||
| namespace app { | |||
| struct CardinalModuleWidget : ModuleWidget { | |||
| CardinalModuleWidget() : ModuleWidget() {} | |||
| DEPRECATED CardinalModuleWidget(engine::Module* module) : ModuleWidget() { | |||
| setModule(module); | |||
| } | |||
| void onButton(const ButtonEvent& e) override; | |||
| }; | |||
| } | |||
| } | |||
| # define ModuleWidget CardinalModuleWidget | |||
| #endif | |||
| @@ -1,5 +1,4 @@ | |||
| #include "../Bidoo/src/plugin.hpp" | |||
| #undef ModuleWidget | |||
| void InstantiateExpanderItem::onAction(const event::Action &e) { | |||
| engine::Module* module = model->createModule(); | |||
| @@ -36,5 +35,5 @@ void BidooWidget::prepareThemes(const std::string& filename) { | |||
| } | |||
| void BidooWidget::step() { | |||
| CardinalModuleWidget::step(); | |||
| ModuleWidget::step(); | |||
| } | |||
| @@ -1 +1 @@ | |||
| Subproject commit e373378491d2cf3b8257137d154aef1d389c5204 | |||
| Subproject commit 82c3c5e11176c364b61d501059d9182e86464eca | |||
| @@ -1 +1 @@ | |||
| Subproject commit 056cc2ec9186a4175d9214eee91e4ff5cc2e5fb1 | |||
| Subproject commit 494fefaf38cb48928a165fd20d1535a0690bf613 | |||
| @@ -40,94 +40,11 @@ | |||
| #include <settings.hpp> | |||
| #include <system.hpp> | |||
| #undef ModuleWidget | |||
| namespace rack { | |||
| namespace app { | |||
| struct CardinalModuleWidget : ModuleWidget { | |||
| CardinalModuleWidget() : ModuleWidget() {} | |||
| DEPRECATED CardinalModuleWidget(engine::Module* module) : ModuleWidget() { | |||
| setModule(module); | |||
| } | |||
| void onButton(const ButtonEvent& e) override; | |||
| }; | |||
| struct ModuleWidget::Internal { | |||
| math::Vec dragOffset; | |||
| math::Vec dragRackPos; | |||
| bool dragEnabled; | |||
| widget::Widget* panel; | |||
| }; | |||
| static void CardinalModuleWidget__loadDialog(ModuleWidget* const w) | |||
| { | |||
| std::string presetDir = w->model->getUserPresetDirectory(); | |||
| system::createDirectories(presetDir); | |||
| WeakPtr<ModuleWidget> weakThis = w; | |||
| async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) { | |||
| // Delete directories if empty | |||
| DEFER({ | |||
| try { | |||
| system::remove(presetDir); | |||
| system::remove(system::getDirectory(presetDir)); | |||
| } | |||
| catch (Exception& e) { | |||
| // Ignore exceptions if directory cannot be removed. | |||
| } | |||
| }); | |||
| if (!weakThis) | |||
| return; | |||
| if (!pathC) | |||
| return; | |||
| try { | |||
| weakThis->loadAction(pathC); | |||
| } | |||
| catch (Exception& e) { | |||
| async_dialog_message(e.what()); | |||
| } | |||
| std::free(pathC); | |||
| }); | |||
| } | |||
| void CardinalModuleWidget__saveDialog(ModuleWidget* const w) | |||
| { | |||
| const std::string presetDir = w->model->getUserPresetDirectory(); | |||
| system::createDirectories(presetDir); | |||
| WeakPtr<ModuleWidget> weakThis = w; | |||
| async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) { | |||
| // Delete directories if empty | |||
| DEFER({ | |||
| try { | |||
| system::remove(presetDir); | |||
| system::remove(system::getDirectory(presetDir)); | |||
| } | |||
| catch (Exception& e) { | |||
| // Ignore exceptions if directory cannot be removed. | |||
| } | |||
| }); | |||
| if (!weakThis) | |||
| return; | |||
| if (!pathC) | |||
| return; | |||
| std::string path = pathC; | |||
| std::free(pathC); | |||
| // Automatically append .vcvm extension | |||
| if (system::getExtension(path) != ".vcvm") | |||
| path += ".vcvm"; | |||
| weakThis->save(path); | |||
| }); | |||
| } | |||
| // Create ModulePresetPathItems for each patch in a directory. | |||
| static void appendPresetItems(ui::Menu* menu, WeakPtr<ModuleWidget> moduleWidget, std::string presetDir) { | |||
| bool foundPresets = false; | |||
| @@ -165,117 +82,6 @@ static void appendPresetItems(ui::Menu* menu, WeakPtr<ModuleWidget> moduleWidget | |||
| } | |||
| }; | |||
| static void CardinalModuleWidget__createContextMenu(ModuleWidget* const w, | |||
| plugin::Model* const model, | |||
| engine::Module* const module) { | |||
| DISTRHO_SAFE_ASSERT_RETURN(model != nullptr,); | |||
| ui::Menu* menu = createMenu(); | |||
| WeakPtr<ModuleWidget> weakThis = w; | |||
| // Brand and module name | |||
| menu->addChild(createMenuLabel(model->name)); | |||
| menu->addChild(createMenuLabel(model->plugin->brand)); | |||
| // Info | |||
| menu->addChild(createSubmenuItem("Info", "", [model](ui::Menu* menu) { | |||
| model->appendContextMenu(menu); | |||
| })); | |||
| // Preset | |||
| menu->addChild(createSubmenuItem("Preset", "", [weakThis](ui::Menu* menu) { | |||
| menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->copyClipboard(); | |||
| })); | |||
| menu->addChild(createMenuItem("Paste", RACK_MOD_CTRL_NAME "+V", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->pasteClipboardAction(); | |||
| })); | |||
| menu->addChild(createMenuItem("Open", "", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| CardinalModuleWidget__loadDialog(weakThis); | |||
| })); | |||
| /* TODO requires setting up user dir | |||
| menu->addChild(createMenuItem("Save as", "", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| CardinalModuleWidget__saveDialog(weakThis); | |||
| })); | |||
| // Scan `<user dir>/presets/<plugin slug>/<module slug>` for presets. | |||
| menu->addChild(new ui::MenuSeparator); | |||
| menu->addChild(createMenuLabel("User presets")); | |||
| appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory()); | |||
| */ | |||
| // Scan `<plugin dir>/presets/<module slug>` for presets. | |||
| appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory()); | |||
| })); | |||
| // Initialize | |||
| menu->addChild(createMenuItem("Initialize", RACK_MOD_CTRL_NAME "+I", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->resetAction(); | |||
| })); | |||
| // Randomize | |||
| menu->addChild(createMenuItem("Randomize", RACK_MOD_CTRL_NAME "+R", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->randomizeAction(); | |||
| })); | |||
| // Disconnect cables | |||
| menu->addChild(createMenuItem("Disconnect cables", RACK_MOD_CTRL_NAME "+U", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->disconnectAction(); | |||
| })); | |||
| // Bypass | |||
| std::string bypassText = RACK_MOD_CTRL_NAME "+E"; | |||
| bool bypassed = module && module->isBypassed(); | |||
| if (bypassed) | |||
| bypassText += " " CHECKMARK_STRING; | |||
| menu->addChild(createMenuItem("Bypass", bypassText, [weakThis, bypassed]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->bypassAction(!bypassed); | |||
| })); | |||
| // Duplicate | |||
| menu->addChild(createMenuItem("Duplicate", RACK_MOD_CTRL_NAME "+D", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->cloneAction(false); | |||
| })); | |||
| // Duplicate with cables | |||
| menu->addChild(createMenuItem("â”” with cables", RACK_MOD_SHIFT_NAME "+" RACK_MOD_CTRL_NAME "+D", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->cloneAction(true); | |||
| })); | |||
| // Delete | |||
| menu->addChild(createMenuItem("Delete", "Backspace/Delete", [weakThis]() { | |||
| if (!weakThis) | |||
| return; | |||
| weakThis->removeAction(); | |||
| }, false, true)); | |||
| w->appendContextMenu(menu); | |||
| } | |||
| static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w) | |||
| { | |||
| std::string selectionDir = asset::user("selections"); | |||
| @@ -304,75 +110,6 @@ static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w) | |||
| }); | |||
| } | |||
| void CardinalModuleWidget::onButton(const ButtonEvent& e) | |||
| { | |||
| const bool selected = APP->scene->rack->isSelected(this); | |||
| if (selected) { | |||
| if (e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
| if (e.action == GLFW_PRESS) { | |||
| // Open selection context menu on right-click | |||
| ui::Menu* menu = createMenu(); | |||
| patchUtils::appendSelectionContextMenu(menu); | |||
| } | |||
| e.consume(this); | |||
| } | |||
| if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| if (e.action == GLFW_PRESS) { | |||
| // Toggle selection on Shift-click | |||
| if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| APP->scene->rack->select(this, false); | |||
| e.consume(NULL); | |||
| return; | |||
| } | |||
| // If module positions are locked, don't consume left-click | |||
| if (settings::lockModules) { | |||
| return; | |||
| } | |||
| internal->dragOffset = e.pos; | |||
| } | |||
| e.consume(this); | |||
| } | |||
| return; | |||
| } | |||
| // Dispatch event to children | |||
| Widget::onButton(e); | |||
| e.stopPropagating(); | |||
| if (e.isConsumed()) | |||
| return; | |||
| if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| if (e.action == GLFW_PRESS) { | |||
| // Toggle selection on Shift-click | |||
| if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| APP->scene->rack->select(this, true); | |||
| e.consume(NULL); | |||
| return; | |||
| } | |||
| // If module positions are locked, don't consume left-click | |||
| if (settings::lockModules) { | |||
| return; | |||
| } | |||
| internal->dragOffset = e.pos; | |||
| } | |||
| e.consume(this); | |||
| } | |||
| // Open context menu on right-click | |||
| if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) { | |||
| CardinalModuleWidget__createContextMenu(this, model, module); | |||
| e.consume(this); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -140,6 +140,7 @@ 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 | |||
| RACK_FILES += override/Scene.cpp | |||
| @@ -164,6 +165,7 @@ IGNORED_FILES += Rack/src/rtmidi.cpp | |||
| IGNORED_FILES += Rack/src/app/AudioDisplay.cpp | |||
| IGNORED_FILES += Rack/src/app/MenuBar.cpp | |||
| IGNORED_FILES += Rack/src/app/MidiDisplay.cpp | |||
| IGNORED_FILES += Rack/src/app/ModuleWidget.cpp | |||
| IGNORED_FILES += Rack/src/app/Scene.cpp | |||
| IGNORED_FILES += Rack/src/app/TipWindow.cpp | |||
| IGNORED_FILES += Rack/src/dsp/minblep.cpp | |||
| @@ -7,6 +7,7 @@ diff -U3 ../Rack/src/common.cpp common.cpp > diffs/common.cpp.diff | |||
| diff -U3 ../Rack/src/context.cpp context.cpp > diffs/context.cpp.diff | |||
| diff -U3 ../Rack/src/plugin.cpp plugin.cpp > diffs/plugin.cpp.diff | |||
| diff -U3 ../Rack/src/app/MenuBar.cpp MenuBar.cpp > diffs/MenuBar.cpp.diff | |||
| diff -U3 ../Rack/src/app/ModuleWidget.cpp ModuleWidget.cpp > diffs/ModuleWidget.cpp.diff | |||
| diff -U3 ../Rack/src/app/Scene.cpp Scene.cpp > diffs/Scene.cpp.diff | |||
| diff -U3 ../Rack/src/engine/Engine.cpp Engine.cpp > diffs/Engine.cpp.diff | |||
| diff -U3 ../Rack/src/dsp/minblep.cpp minblep.cpp > diffs/minblep.cpp.diff | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/engine/Engine.cpp 2022-09-21 19:49:12.200540736 +0100 | |||
| +++ Engine.cpp 2022-11-25 17:57:38.799958734 +0000 | |||
| --- ../Rack/src/engine/Engine.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ Engine.cpp 2022-11-25 22:31:29.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/app/MenuBar.cpp 2022-09-21 19:49:12.198540676 +0100 | |||
| +++ MenuBar.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/app/MenuBar.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ MenuBar.cpp 2022-11-25 23:27:58.000000000 +0000 | |||
| @@ -1,8 +1,33 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -446,7 +446,7 @@ | |||
| struct EngineButton : MenuButton { | |||
| void onAction(const ActionEvent& e) override { | |||
| ui::Menu* menu = createMenu(); | |||
| @@ -541,268 +648,40 @@ | |||
| @@ -541,268 +648,46 @@ | |||
| settings::cpuMeter ^= true; | |||
| })); | |||
| @@ -725,7 +725,13 @@ | |||
| - if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "All plugins have been downloaded. Close and re-launch Rack to load new updates.")) { | |||
| - APP->window->close(); | |||
| + if (supportsBufferSizeChanges()) { | |||
| + static const std::vector<uint32_t> bufferSizes = {256, 512, 1024, 2048, 4096, 8192, 16384}; | |||
| + static const std::vector<uint32_t> bufferSizes = { | |||
| + #ifdef DISTRHO_OS_WASM | |||
| + 256, 512, 1024, 2048, 4096, 8192, 16384 | |||
| + #else | |||
| + 128, 256, 512, 1024, 2048, 4096, 8192 | |||
| + #endif | |||
| + }; | |||
| + const uint32_t currentBufferSize = getBufferSize(); | |||
| + menu->addChild(createSubmenuItem("Buffer Size", std::to_string(currentBufferSize), [=](ui::Menu* menu) { | |||
| + for (uint32_t bufferSize : bufferSizes) { | |||
| @@ -742,7 +748,7 @@ | |||
| } | |||
| }; | |||
| @@ -813,65 +692,23 @@ | |||
| @@ -813,65 +698,23 @@ | |||
| struct HelpButton : MenuButton { | |||
| @@ -814,7 +820,7 @@ | |||
| } | |||
| }; | |||
| @@ -921,7 +758,9 @@ | |||
| @@ -921,7 +764,9 @@ | |||
| struct MenuBar : widget::OpaqueWidget { | |||
| MeterLabel* meterLabel; | |||
| @@ -825,7 +831,7 @@ | |||
| const float margin = 5; | |||
| box.size.y = BND_WIDGET_HEIGHT + 2 * margin; | |||
| @@ -930,7 +769,7 @@ | |||
| @@ -930,7 +775,7 @@ | |||
| layout->spacing = math::Vec(0, 0); | |||
| addChild(layout); | |||
| @@ -834,7 +840,7 @@ | |||
| fileButton->text = "File"; | |||
| layout->addChild(fileButton); | |||
| @@ -946,10 +785,6 @@ | |||
| @@ -946,10 +791,6 @@ | |||
| engineButton->text = "Engine"; | |||
| layout->addChild(engineButton); | |||
| @@ -845,7 +851,7 @@ | |||
| HelpButton* helpButton = new HelpButton; | |||
| helpButton->text = "Help"; | |||
| layout->addChild(helpButton); | |||
| @@ -984,7 +819,11 @@ | |||
| @@ -984,7 +825,11 @@ | |||
| widget::Widget* createMenuBar() { | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/plugin/Model.cpp 2022-09-21 19:49:12.200540736 +0100 | |||
| +++ Model.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/plugin/Model.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ Model.cpp 2022-11-23 23:06:41.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -0,0 +1,517 @@ | |||
| --- ../Rack/src/app/ModuleWidget.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ ModuleWidget.cpp 2022-11-30 20:10:06.000000000 +0000 | |||
| @@ -1,3 +1,32 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| + * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||
| + * | |||
| + * This program is free software; you can redistribute it and/or | |||
| + * modify it under the terms of the GNU General Public License as | |||
| + * published by the Free Software Foundation; either version 3 of | |||
| + * the License, or any later version. | |||
| + * | |||
| + * This program is distributed in the hope that it will be useful, | |||
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| + * GNU General Public License for more details. | |||
| + * | |||
| + * For a full copy of the GNU General Public License see the LICENSE file. | |||
| + */ | |||
| + | |||
| +/** | |||
| + * This file is an edited version of VCVRack's ModuleWidget.cpp | |||
| + * Copyright (C) 2016-2021 VCV. | |||
| + * | |||
| + * This program is free software: you can redistribute it and/or | |||
| + * modify it under the terms of the GNU General Public License as | |||
| + * published by the Free Software Foundation; either version 3 of | |||
| + * the License, or (at your option) any later version. | |||
| + */ | |||
| + | |||
| +#include "../../CardinalCommon.hpp" | |||
| + | |||
| #include <thread> | |||
| #include <regex> | |||
| @@ -368,71 +397,71 @@ | |||
| } | |||
| void ModuleWidget::onButton(const ButtonEvent& e) { | |||
| - bool selected = APP->scene->rack->isSelected(this); | |||
| - | |||
| - if (selected) { | |||
| - if (e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
| - if (e.action == GLFW_PRESS) { | |||
| - // Open selection context menu on right-click | |||
| - ui::Menu* menu = createMenu(); | |||
| - APP->scene->rack->appendSelectionContextMenu(menu); | |||
| - } | |||
| - e.consume(this); | |||
| - } | |||
| - | |||
| - if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| - if (e.action == GLFW_PRESS) { | |||
| - // Toggle selection on Shift-click | |||
| - if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| - APP->scene->rack->select(this, false); | |||
| - e.consume(NULL); | |||
| - return; | |||
| - } | |||
| - | |||
| - // If module positions are locked, don't consume left-click | |||
| - if (settings::lockModules) { | |||
| - return; | |||
| - } | |||
| + const bool selected = APP->scene->rack->isSelected(this); | |||
| - internal->dragOffset = e.pos; | |||
| - } | |||
| - | |||
| - e.consume(this); | |||
| - } | |||
| - | |||
| - return; | |||
| - } | |||
| - | |||
| - // Dispatch event to children | |||
| - Widget::onButton(e); | |||
| - e.stopPropagating(); | |||
| - if (e.isConsumed()) | |||
| - return; | |||
| - | |||
| - if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| - if (e.action == GLFW_PRESS) { | |||
| - // Toggle selection on Shift-click | |||
| - if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| - APP->scene->rack->select(this, true); | |||
| - e.consume(NULL); | |||
| - return; | |||
| - } | |||
| - | |||
| - // If module positions are locked, don't consume left-click | |||
| - if (settings::lockModules) { | |||
| - return; | |||
| - } | |||
| - | |||
| - internal->dragOffset = e.pos; | |||
| - } | |||
| - e.consume(this); | |||
| - } | |||
| - | |||
| - // Open context menu on right-click | |||
| - if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) { | |||
| - createContextMenu(); | |||
| - e.consume(this); | |||
| - } | |||
| + if (selected) { | |||
| + if (e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
| + if (e.action == GLFW_PRESS) { | |||
| + // Open selection context menu on right-click | |||
| + ui::Menu* menu = createMenu(); | |||
| + patchUtils::appendSelectionContextMenu(menu); | |||
| + } | |||
| + e.consume(this); | |||
| + } | |||
| + | |||
| + if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| + if (e.action == GLFW_PRESS) { | |||
| + // Toggle selection on Shift-click | |||
| + if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| + APP->scene->rack->select(this, false); | |||
| + e.consume(NULL); | |||
| + return; | |||
| + } | |||
| + | |||
| + // If module positions are locked, don't consume left-click | |||
| + if (settings::lockModules) { | |||
| + return; | |||
| + } | |||
| + | |||
| + internal->dragOffset = e.pos; | |||
| + } | |||
| + | |||
| + e.consume(this); | |||
| + } | |||
| + | |||
| + return; | |||
| + } | |||
| + | |||
| + // Dispatch event to children | |||
| + Widget::onButton(e); | |||
| + e.stopPropagating(); | |||
| + if (e.isConsumed()) | |||
| + return; | |||
| + | |||
| + if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | |||
| + if (e.action == GLFW_PRESS) { | |||
| + // Toggle selection on Shift-click | |||
| + if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | |||
| + APP->scene->rack->select(this, true); | |||
| + e.consume(NULL); | |||
| + return; | |||
| + } | |||
| + | |||
| + // If module positions are locked, don't consume left-click | |||
| + if (settings::lockModules) { | |||
| + return; | |||
| + } | |||
| + | |||
| + internal->dragOffset = e.pos; | |||
| + } | |||
| + e.consume(this); | |||
| + } | |||
| + | |||
| + // Open context menu on right-click | |||
| + if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) { | |||
| + createContextMenu(); | |||
| + e.consume(this); | |||
| + } | |||
| } | |||
| void ModuleWidget::onDragStart(const DragStartEvent& e) { | |||
| @@ -624,36 +653,37 @@ | |||
| } | |||
| void ModuleWidget::loadDialog() { | |||
| - std::string presetDir = model->getUserPresetDirectory(); | |||
| - system::createDirectories(presetDir); | |||
| + std::string presetDir = model->getUserPresetDirectory(); | |||
| + system::createDirectories(presetDir); | |||
| - // Delete directories if empty | |||
| - DEFER({ | |||
| - try { | |||
| - system::remove(presetDir); | |||
| - system::remove(system::getDirectory(presetDir)); | |||
| - } | |||
| - catch (Exception& e) { | |||
| - // Ignore exceptions if directory cannot be removed. | |||
| - } | |||
| - }); | |||
| + WeakPtr<ModuleWidget> weakThis = this; | |||
| - osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS); | |||
| - DEFER({osdialog_filters_free(filters);}); | |||
| + async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) { | |||
| + // Delete directories if empty | |||
| + DEFER({ | |||
| + try { | |||
| + system::remove(presetDir); | |||
| + system::remove(system::getDirectory(presetDir)); | |||
| + } | |||
| + catch (Exception& e) { | |||
| + // Ignore exceptions if directory cannot be removed. | |||
| + } | |||
| + }); | |||
| + | |||
| + if (!weakThis) | |||
| + return; | |||
| + if (!pathC) | |||
| + return; | |||
| + | |||
| + try { | |||
| + weakThis->loadAction(pathC); | |||
| + } | |||
| + catch (Exception& e) { | |||
| + async_dialog_message(e.what()); | |||
| + } | |||
| - char* pathC = osdialog_file(OSDIALOG_OPEN, presetDir.c_str(), NULL, filters); | |||
| - if (!pathC) { | |||
| - // No path selected | |||
| - return; | |||
| - } | |||
| - DEFER({std::free(pathC);}); | |||
| - | |||
| - try { | |||
| - loadAction(pathC); | |||
| - } | |||
| - catch (Exception& e) { | |||
| - osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what()); | |||
| - } | |||
| + std::free(pathC); | |||
| + }); | |||
| } | |||
| void ModuleWidget::save(std::string filename) { | |||
| @@ -712,36 +742,37 @@ | |||
| } | |||
| void ModuleWidget::saveDialog() { | |||
| - std::string presetDir = model->getUserPresetDirectory(); | |||
| - system::createDirectories(presetDir); | |||
| + const std::string presetDir = model->getUserPresetDirectory(); | |||
| + system::createDirectories(presetDir); | |||
| - // Delete directories if empty | |||
| - DEFER({ | |||
| - try { | |||
| - system::remove(presetDir); | |||
| - system::remove(system::getDirectory(presetDir)); | |||
| - } | |||
| - catch (Exception& e) { | |||
| - // Ignore exceptions if directory cannot be removed. | |||
| - } | |||
| - }); | |||
| - | |||
| - osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS); | |||
| - DEFER({osdialog_filters_free(filters);}); | |||
| - | |||
| - char* pathC = osdialog_file(OSDIALOG_SAVE, presetDir.c_str(), "Untitled.vcvm", filters); | |||
| - if (!pathC) { | |||
| - // No path selected | |||
| - return; | |||
| - } | |||
| - DEFER({std::free(pathC);}); | |||
| + WeakPtr<ModuleWidget> weakThis = this; | |||
| - std::string path = pathC; | |||
| - // Automatically append .vcvm extension | |||
| - if (system::getExtension(path) != ".vcvm") | |||
| - path += ".vcvm"; | |||
| + async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) { | |||
| + // Delete directories if empty | |||
| + DEFER({ | |||
| + try { | |||
| + system::remove(presetDir); | |||
| + system::remove(system::getDirectory(presetDir)); | |||
| + } | |||
| + catch (Exception& e) { | |||
| + // Ignore exceptions if directory cannot be removed. | |||
| + } | |||
| + }); | |||
| + | |||
| + if (!weakThis) | |||
| + return; | |||
| + if (!pathC) | |||
| + return; | |||
| + | |||
| + std::string path = pathC; | |||
| + std::free(pathC); | |||
| + | |||
| + // Automatically append .vcvm extension | |||
| + if (system::getExtension(path) != ".vcvm") | |||
| + path += ".vcvm"; | |||
| - save(path); | |||
| + weakThis->save(path); | |||
| + }); | |||
| } | |||
| void ModuleWidget::disconnect() { | |||
| @@ -981,118 +1012,108 @@ | |||
| WeakPtr<ModuleWidget> weakThis = this; | |||
| - // Brand and module name | |||
| - menu->addChild(createMenuLabel(model->name)); | |||
| - menu->addChild(createMenuLabel(model->plugin->brand)); | |||
| - | |||
| - // Info | |||
| - menu->addChild(createSubmenuItem("Info", "", [=](ui::Menu* menu) { | |||
| - model->appendContextMenu(menu); | |||
| - })); | |||
| - | |||
| - // Preset | |||
| - menu->addChild(createSubmenuItem("Preset", "", [=](ui::Menu* menu) { | |||
| - menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->copyClipboard(); | |||
| - })); | |||
| - | |||
| - menu->addChild(createMenuItem("Paste", RACK_MOD_CTRL_NAME "+V", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->pasteClipboardAction(); | |||
| - })); | |||
| - | |||
| - menu->addChild(createMenuItem("Open", "", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->loadDialog(); | |||
| - })); | |||
| - | |||
| - menu->addChild(createMenuItem("Save as", "", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->saveDialog(); | |||
| - })); | |||
| - | |||
| - menu->addChild(createMenuItem("Save default", "", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->saveTemplateDialog(); | |||
| - })); | |||
| - | |||
| - menu->addChild(createMenuItem("Clear default", "", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->clearTemplateDialog(); | |||
| - }, !weakThis->hasTemplate())); | |||
| - | |||
| - // Scan `<user dir>/presets/<plugin slug>/<module slug>` for presets. | |||
| - menu->addChild(new ui::MenuSeparator); | |||
| - menu->addChild(createMenuLabel("User presets")); | |||
| - appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory()); | |||
| - | |||
| - // Scan `<plugin dir>/presets/<module slug>` for presets. | |||
| - menu->addChild(new ui::MenuSeparator); | |||
| - menu->addChild(createMenuLabel("Factory presets")); | |||
| - appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory()); | |||
| - })); | |||
| + // Brand and module name | |||
| + menu->addChild(createMenuLabel(model->name)); | |||
| + menu->addChild(createMenuLabel(model->plugin->brand)); | |||
| - // Initialize | |||
| - menu->addChild(createMenuItem("Initialize", RACK_MOD_CTRL_NAME "+I", [=]() { | |||
| + // Info | |||
| + menu->addChild(createSubmenuItem("Info", "", [weakThis](ui::Menu* menu) { | |||
| if (!weakThis) | |||
| return; | |||
| - weakThis->resetAction(); | |||
| - })); | |||
| + weakThis->model->appendContextMenu(menu); | |||
| + })); | |||
| - // Randomize | |||
| - menu->addChild(createMenuItem("Randomize", RACK_MOD_CTRL_NAME "+R", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->randomizeAction(); | |||
| - })); | |||
| - | |||
| - // Disconnect cables | |||
| - menu->addChild(createMenuItem("Disconnect cables", RACK_MOD_CTRL_NAME "+U", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->disconnectAction(); | |||
| - })); | |||
| - | |||
| - // Bypass | |||
| - std::string bypassText = RACK_MOD_CTRL_NAME "+E"; | |||
| - bool bypassed = module && module->isBypassed(); | |||
| - if (bypassed) | |||
| - bypassText += " " CHECKMARK_STRING; | |||
| - menu->addChild(createMenuItem("Bypass", bypassText, [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->bypassAction(!bypassed); | |||
| - })); | |||
| - | |||
| - // Duplicate | |||
| - menu->addChild(createMenuItem("Duplicate", RACK_MOD_CTRL_NAME "+D", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->cloneAction(false); | |||
| - })); | |||
| - | |||
| - // Duplicate with cables | |||
| - menu->addChild(createMenuItem("â”” with cables", RACK_MOD_SHIFT_NAME "+" RACK_MOD_CTRL_NAME "+D", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->cloneAction(true); | |||
| - })); | |||
| - | |||
| - // Delete | |||
| - menu->addChild(createMenuItem("Delete", "Backspace/Delete", [=]() { | |||
| - if (!weakThis) | |||
| - return; | |||
| - weakThis->removeAction(); | |||
| - }, false, true)); | |||
| + // Preset | |||
| + menu->addChild(createSubmenuItem("Preset", "", [weakThis](ui::Menu* menu) { | |||
| + menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->copyClipboard(); | |||
| + })); | |||
| + | |||
| + menu->addChild(createMenuItem("Paste", RACK_MOD_CTRL_NAME "+V", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->pasteClipboardAction(); | |||
| + })); | |||
| + | |||
| + menu->addChild(createMenuItem("Open", "", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->loadDialog(); | |||
| + })); | |||
| + | |||
| + /* TODO requires setting up user dir | |||
| + menu->addChild(createMenuItem("Save as", "", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + CardinalModuleWidget__saveDialog(weakThis); | |||
| + })); | |||
| + | |||
| + // Scan `<user dir>/presets/<plugin slug>/<module slug>` for presets. | |||
| + menu->addChild(new ui::MenuSeparator); | |||
| + menu->addChild(createMenuLabel("User presets")); | |||
| + appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory()); | |||
| + */ | |||
| + | |||
| + // Scan `<plugin dir>/presets/<module slug>` for presets. | |||
| + appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory()); | |||
| + })); | |||
| + | |||
| + // Initialize | |||
| + menu->addChild(createMenuItem("Initialize", RACK_MOD_CTRL_NAME "+I", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->resetAction(); | |||
| + })); | |||
| + | |||
| + // Randomize | |||
| + menu->addChild(createMenuItem("Randomize", RACK_MOD_CTRL_NAME "+R", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->randomizeAction(); | |||
| + })); | |||
| + | |||
| + // Disconnect cables | |||
| + menu->addChild(createMenuItem("Disconnect cables", RACK_MOD_CTRL_NAME "+U", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->disconnectAction(); | |||
| + })); | |||
| + | |||
| + // Bypass | |||
| + std::string bypassText = RACK_MOD_CTRL_NAME "+E"; | |||
| + bool bypassed = module && module->isBypassed(); | |||
| + if (bypassed) | |||
| + bypassText += " " CHECKMARK_STRING; | |||
| + menu->addChild(createMenuItem("Bypass", bypassText, [weakThis, bypassed]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->bypassAction(!bypassed); | |||
| + })); | |||
| + | |||
| + // Duplicate | |||
| + menu->addChild(createMenuItem("Duplicate", RACK_MOD_CTRL_NAME "+D", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->cloneAction(false); | |||
| + })); | |||
| + | |||
| + // Duplicate with cables | |||
| + menu->addChild(createMenuItem("â”” with cables", RACK_MOD_SHIFT_NAME "+" RACK_MOD_CTRL_NAME "+D", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->cloneAction(true); | |||
| + })); | |||
| + | |||
| + // Delete | |||
| + menu->addChild(createMenuItem("Delete", "Backspace/Delete", [weakThis]() { | |||
| + if (!weakThis) | |||
| + return; | |||
| + weakThis->removeAction(); | |||
| + }, false, true)); | |||
| - appendContextMenu(menu); | |||
| + appendContextMenu(menu); | |||
| } | |||
| math::Vec ModuleWidget::getGridPosition() { | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/widget/OpenGlWidget.cpp 2022-09-21 19:49:12.201540766 +0100 | |||
| +++ OpenGlWidget.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/widget/OpenGlWidget.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ OpenGlWidget.cpp 2022-11-23 23:06:41.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/app/Scene.cpp 2022-09-21 19:49:12.199540706 +0100 | |||
| +++ Scene.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/app/Scene.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ Scene.cpp 2022-11-25 22:32:04.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/window/Window.cpp 2022-09-21 19:49:12.202540796 +0100 | |||
| +++ Window.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/window/Window.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ Window.cpp 2022-11-25 22:32:06.000000000 +0000 | |||
| @@ -1,33 +1,87 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/dep/oui-blendish/blendish.c 2022-09-21 19:49:29.973066921 +0100 | |||
| +++ blendish.c 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/dep/oui-blendish/blendish.c 2022-11-23 23:11:56.000000000 +0000 | |||
| +++ blendish.c 2022-11-23 23:06:41.000000000 +0000 | |||
| @@ -61,7 +61,7 @@ | |||
| } | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/common.cpp 2022-09-21 19:49:12.199540706 +0100 | |||
| +++ common.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/common.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ common.cpp 2022-11-25 22:32:13.000000000 +0000 | |||
| @@ -1,33 +1,77 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/context.cpp 2022-09-21 19:49:12.199540706 +0100 | |||
| +++ context.cpp 2022-09-21 19:41:45.883648777 +0100 | |||
| --- ../Rack/src/context.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ context.cpp 2022-11-25 22:31:32.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -31,21 +31,22 @@ | |||
| #include <context.hpp> | |||
| #include <window/Window.hpp> | |||
| #include <patch.hpp> | |||
| @@ -6,9 +33,13 @@ | |||
| @@ -6,10 +33,14 @@ | |||
| #include <history.hpp> | |||
| #include <settings.hpp> | |||
| +#ifdef NDEBUG | |||
| +# undef DEBUG | |||
| +#endif | |||
| -namespace rack { | |||
| + | |||
| +#include "DistrhoUtils.hpp" | |||
| +namespace rack { | |||
| namespace rack { | |||
| - | |||
| Context::~Context() { | |||
| // Deleting NULL is safe in C++. | |||
| @@ -44,7 +75,7 @@ | |||
| static thread_local Context* threadContext = NULL; | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/dsp/minblep.cpp 2022-09-21 19:49:12.200540736 +0100 | |||
| +++ minblep.cpp 2022-09-21 19:41:45.884648820 +0100 | |||
| --- ../Rack/src/dsp/minblep.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ minblep.cpp 2022-11-23 23:06:41.000000000 +0000 | |||
| @@ -1,3 +1,30 @@ | |||
| +/* | |||
| + * DISTRHO Cardinal Plugin | |||
| @@ -1,5 +1,5 @@ | |||
| --- ../Rack/src/plugin.cpp 2022-09-21 19:49:12.200540736 +0100 | |||
| +++ plugin.cpp 2022-09-21 19:41:45.884648820 +0100 | |||
| --- ../Rack/src/plugin.cpp 2022-11-23 23:11:38.000000000 +0000 | |||
| +++ plugin.cpp 2022-11-25 23:27:58.000000000 +0000 | |||
| @@ -1,342 +1,41 @@ | |||
| -#include <thread> | |||
| -#include <map> | |||
| @@ -372,7 +372,15 @@ | |||
| /** Given slug => fallback slug. | |||
| @@ -389,8 +88,19 @@ | |||
| @@ -348,6 +47,7 @@ | |||
| {"VultModules", "VultModulesFree"}, | |||
| {"AudibleInstrumentsPreview", "AudibleInstruments"}, | |||
| {"SequelSequencers", "DanielDavies"}, | |||
| + {"DelexanderVol1", "DelexandraVol1"}, | |||
| // {"", ""}, | |||
| }; | |||
| @@ -389,8 +89,19 @@ | |||
| */ | |||
| using PluginModuleSlug = std::tuple<std::string, std::string>; | |||
| static const std::map<PluginModuleSlug, PluginModuleSlug> moduleSlugFallbacks = { | |||
| @@ -393,7 +401,7 @@ | |||
| // {{"", ""}, {"", ""}}, | |||
| }; | |||
| @@ -478,7 +188,6 @@ | |||
| @@ -478,7 +189,6 @@ | |||
| } | |||