Reduce diff vs Rack, regarding ModuleWidget.cpp file
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
da56d13cf7
commit
b98283034d
14 changed files with 368 additions and 730 deletions
|
@ -45,43 +45,6 @@
|
||||||
namespace rack {
|
namespace rack {
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
// Create ModulePresetPathItems for each patch in a directory.
|
|
||||||
static void appendPresetItems(ui::Menu* menu, WeakPtr<ModuleWidget> moduleWidget, std::string presetDir) {
|
|
||||||
bool foundPresets = false;
|
|
||||||
|
|
||||||
if (system::isDirectory(presetDir))
|
|
||||||
{
|
|
||||||
// Note: This is not cached, so opening this menu each time might have a bit of latency.
|
|
||||||
std::vector<std::string> entries = system::getEntries(presetDir);
|
|
||||||
std::sort(entries.begin(), entries.end());
|
|
||||||
for (std::string path : entries) {
|
|
||||||
std::string name = system::getStem(path);
|
|
||||||
// Remove "1_", "42_", "001_", etc at the beginning of preset filenames
|
|
||||||
std::regex r("^\\d+_");
|
|
||||||
name = std::regex_replace(name, r, "");
|
|
||||||
|
|
||||||
if (system::getExtension(path) == ".vcvm" && name != "template")
|
|
||||||
{
|
|
||||||
if (!foundPresets)
|
|
||||||
menu->addChild(new ui::MenuSeparator);
|
|
||||||
|
|
||||||
foundPresets = true;
|
|
||||||
|
|
||||||
menu->addChild(createMenuItem(name, "", [=]() {
|
|
||||||
if (!moduleWidget)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
moduleWidget->loadAction(path);
|
|
||||||
}
|
|
||||||
catch (Exception& e) {
|
|
||||||
async_dialog_message(e.what());
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w)
|
static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w)
|
||||||
{
|
{
|
||||||
std::string selectionDir = asset::user("selections");
|
std::string selectionDir = asset::user("selections");
|
||||||
|
|
|
@ -397,71 +397,71 @@ void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::onButton(const ButtonEvent& e) {
|
void ModuleWidget::onButton(const ButtonEvent& e) {
|
||||||
const bool selected = APP->scene->rack->isSelected(this);
|
bool selected = APP->scene->rack->isSelected(this);
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
if (e.button == GLFW_MOUSE_BUTTON_RIGHT) {
|
if (e.button == GLFW_MOUSE_BUTTON_RIGHT) {
|
||||||
if (e.action == GLFW_PRESS) {
|
if (e.action == GLFW_PRESS) {
|
||||||
// Open selection context menu on right-click
|
// Open selection context menu on right-click
|
||||||
ui::Menu* menu = createMenu();
|
ui::Menu* menu = createMenu();
|
||||||
patchUtils::appendSelectionContextMenu(menu);
|
patchUtils::appendSelectionContextMenu(menu);
|
||||||
}
|
}
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
|
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
if (e.action == GLFW_PRESS) {
|
if (e.action == GLFW_PRESS) {
|
||||||
// Toggle selection on Shift-click
|
// Toggle selection on Shift-click
|
||||||
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
|
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
|
||||||
APP->scene->rack->select(this, false);
|
APP->scene->rack->select(this, false);
|
||||||
e.consume(NULL);
|
e.consume(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If module positions are locked, don't consume left-click
|
// If module positions are locked, don't consume left-click
|
||||||
if (settings::lockModules) {
|
if (settings::lockModules) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal->dragOffset = e.pos;
|
internal->dragOffset = e.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch event to children
|
// Dispatch event to children
|
||||||
Widget::onButton(e);
|
Widget::onButton(e);
|
||||||
e.stopPropagating();
|
e.stopPropagating();
|
||||||
if (e.isConsumed())
|
if (e.isConsumed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
|
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
if (e.action == GLFW_PRESS) {
|
if (e.action == GLFW_PRESS) {
|
||||||
// Toggle selection on Shift-click
|
// Toggle selection on Shift-click
|
||||||
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
|
if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
|
||||||
APP->scene->rack->select(this, true);
|
APP->scene->rack->select(this, true);
|
||||||
e.consume(NULL);
|
e.consume(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If module positions are locked, don't consume left-click
|
// If module positions are locked, don't consume left-click
|
||||||
if (settings::lockModules) {
|
if (settings::lockModules) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal->dragOffset = e.pos;
|
internal->dragOffset = e.pos;
|
||||||
}
|
}
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open context menu on right-click
|
// Open context menu on right-click
|
||||||
if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) {
|
if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) {
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
e.consume(this);
|
e.consume(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::onDragStart(const DragStartEvent& e) {
|
void ModuleWidget::onDragStart(const DragStartEvent& e) {
|
||||||
|
@ -653,37 +653,39 @@ void ModuleWidget::loadTemplate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::loadDialog() {
|
void ModuleWidget::loadDialog() {
|
||||||
std::string presetDir = model->getUserPresetDirectory();
|
std::string presetDir = model->getUserPresetDirectory();
|
||||||
system::createDirectories(presetDir);
|
system::createDirectories(presetDir);
|
||||||
|
|
||||||
WeakPtr<ModuleWidget> weakThis = this;
|
WeakPtr<ModuleWidget> weakThis = this;
|
||||||
|
async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) {
|
||||||
|
|
||||||
async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) {
|
// Delete directories if empty
|
||||||
// Delete directories if empty
|
DEFER({
|
||||||
DEFER({
|
try {
|
||||||
try {
|
system::remove(presetDir);
|
||||||
system::remove(presetDir);
|
system::remove(system::getDirectory(presetDir));
|
||||||
system::remove(system::getDirectory(presetDir));
|
}
|
||||||
}
|
catch (Exception& e) {
|
||||||
catch (Exception& e) {
|
// Ignore exceptions if directory cannot be removed.
|
||||||
// Ignore exceptions if directory cannot be removed.
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (!weakThis)
|
if (!weakThis)
|
||||||
return;
|
return;
|
||||||
if (!pathC)
|
if (!pathC) {
|
||||||
return;
|
// No path selected
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEFER({std::free(pathC);});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
weakThis->loadAction(pathC);
|
weakThis->loadAction(pathC);
|
||||||
}
|
}
|
||||||
catch (Exception& e) {
|
catch (Exception& e) {
|
||||||
async_dialog_message(e.what());
|
async_dialog_message(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::free(pathC);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::save(std::string filename) {
|
void ModuleWidget::save(std::string filename) {
|
||||||
|
@ -742,37 +744,38 @@ void ModuleWidget::clearTemplateDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::saveDialog() {
|
void ModuleWidget::saveDialog() {
|
||||||
const std::string presetDir = model->getUserPresetDirectory();
|
std::string presetDir = model->getUserPresetDirectory();
|
||||||
system::createDirectories(presetDir);
|
system::createDirectories(presetDir);
|
||||||
|
|
||||||
WeakPtr<ModuleWidget> weakThis = this;
|
WeakPtr<ModuleWidget> weakThis = this;
|
||||||
|
async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) {
|
||||||
|
|
||||||
async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) {
|
// Delete directories if empty
|
||||||
// Delete directories if empty
|
DEFER({
|
||||||
DEFER({
|
try {
|
||||||
try {
|
system::remove(presetDir);
|
||||||
system::remove(presetDir);
|
system::remove(system::getDirectory(presetDir));
|
||||||
system::remove(system::getDirectory(presetDir));
|
}
|
||||||
}
|
catch (Exception& e) {
|
||||||
catch (Exception& e) {
|
// Ignore exceptions if directory cannot be removed.
|
||||||
// Ignore exceptions if directory cannot be removed.
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (!weakThis)
|
if (!weakThis)
|
||||||
return;
|
return;
|
||||||
if (!pathC)
|
if (!pathC) {
|
||||||
return;
|
// No path selected
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEFER({std::free(pathC);});
|
||||||
|
|
||||||
std::string path = pathC;
|
std::string path = pathC;
|
||||||
std::free(pathC);
|
// Automatically append .vcvm extension
|
||||||
|
if (system::getExtension(path) != ".vcvm")
|
||||||
|
path += ".vcvm";
|
||||||
|
|
||||||
// Automatically append .vcvm extension
|
weakThis->save(path);
|
||||||
if (system::getExtension(path) != ".vcvm")
|
});
|
||||||
path += ".vcvm";
|
|
||||||
|
|
||||||
weakThis->save(path);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::disconnect() {
|
void ModuleWidget::disconnect() {
|
||||||
|
@ -975,16 +978,12 @@ static void appendPresetItems(ui::Menu* menu, WeakPtr<ModuleWidget> moduleWidget
|
||||||
std::regex r("^\\d+_");
|
std::regex r("^\\d+_");
|
||||||
name = std::regex_replace(name, r, "");
|
name = std::regex_replace(name, r, "");
|
||||||
|
|
||||||
if (system::isDirectory(path)) {
|
if (false) {
|
||||||
hasPresets = true;
|
|
||||||
|
|
||||||
menu->addChild(createSubmenuItem(name, "", [=](ui::Menu* menu) {
|
|
||||||
if (!moduleWidget)
|
|
||||||
return;
|
|
||||||
appendPresetItems(menu, moduleWidget, path);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
else if (system::getExtension(path) == ".vcvm" && name != "template") {
|
else if (system::getExtension(path) == ".vcvm" && name != "template") {
|
||||||
|
if (!hasPresets)
|
||||||
|
menu->addChild(new ui::MenuSeparator);
|
||||||
|
|
||||||
hasPresets = true;
|
hasPresets = true;
|
||||||
|
|
||||||
menu->addChild(createMenuItem(name, "", [=]() {
|
menu->addChild(createMenuItem(name, "", [=]() {
|
||||||
|
@ -994,15 +993,12 @@ static void appendPresetItems(ui::Menu* menu, WeakPtr<ModuleWidget> moduleWidget
|
||||||
moduleWidget->loadAction(path);
|
moduleWidget->loadAction(path);
|
||||||
}
|
}
|
||||||
catch (Exception& e) {
|
catch (Exception& e) {
|
||||||
osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
|
async_dialog_message(e.what());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasPresets) {
|
|
||||||
menu->addChild(createMenuLabel("(None)"));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1012,108 +1008,122 @@ void ModuleWidget::createContextMenu() {
|
||||||
|
|
||||||
WeakPtr<ModuleWidget> weakThis = this;
|
WeakPtr<ModuleWidget> weakThis = this;
|
||||||
|
|
||||||
// Brand and module name
|
// Brand and module name
|
||||||
menu->addChild(createMenuLabel(model->name));
|
menu->addChild(createMenuLabel(model->name));
|
||||||
menu->addChild(createMenuLabel(model->plugin->brand));
|
menu->addChild(createMenuLabel(model->plugin->brand));
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
menu->addChild(createSubmenuItem("Info", "", [weakThis](ui::Menu* menu) {
|
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();
|
||||||
|
}));
|
||||||
|
|
||||||
|
/* TODO requires setting up user dir
|
||||||
|
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.
|
||||||
|
/* TODO enable only after setting up user dir
|
||||||
|
menu->addChild(new ui::MenuSeparator);
|
||||||
|
menu->addChild(createMenuLabel("Factory presets"));
|
||||||
|
*/
|
||||||
|
appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory());
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
menu->addChild(createMenuItem("Initialize", RACK_MOD_CTRL_NAME "+I", [=]() {
|
||||||
if (!weakThis)
|
if (!weakThis)
|
||||||
return;
|
return;
|
||||||
weakThis->model->appendContextMenu(menu);
|
weakThis->resetAction();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Preset
|
// Randomize
|
||||||
menu->addChild(createSubmenuItem("Preset", "", [weakThis](ui::Menu* menu) {
|
menu->addChild(createMenuItem("Randomize", RACK_MOD_CTRL_NAME "+R", [=]() {
|
||||||
menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [weakThis]() {
|
if (!weakThis)
|
||||||
if (!weakThis)
|
return;
|
||||||
return;
|
weakThis->randomizeAction();
|
||||||
weakThis->copyClipboard();
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
menu->addChild(createMenuItem("Paste", RACK_MOD_CTRL_NAME "+V", [weakThis]() {
|
// Disconnect cables
|
||||||
if (!weakThis)
|
menu->addChild(createMenuItem("Disconnect cables", RACK_MOD_CTRL_NAME "+U", [=]() {
|
||||||
return;
|
if (!weakThis)
|
||||||
weakThis->pasteClipboardAction();
|
return;
|
||||||
}));
|
weakThis->disconnectAction();
|
||||||
|
}));
|
||||||
|
|
||||||
menu->addChild(createMenuItem("Open", "", [weakThis]() {
|
// Bypass
|
||||||
if (!weakThis)
|
std::string bypassText = RACK_MOD_CTRL_NAME "+E";
|
||||||
return;
|
bool bypassed = module && module->isBypassed();
|
||||||
weakThis->loadDialog();
|
if (bypassed)
|
||||||
}));
|
bypassText += " " CHECKMARK_STRING;
|
||||||
|
menu->addChild(createMenuItem("Bypass", bypassText, [=]() {
|
||||||
|
if (!weakThis)
|
||||||
|
return;
|
||||||
|
weakThis->bypassAction(!bypassed);
|
||||||
|
}));
|
||||||
|
|
||||||
/* TODO requires setting up user dir
|
// Duplicate
|
||||||
menu->addChild(createMenuItem("Save as", "", [weakThis]() {
|
menu->addChild(createMenuItem("Duplicate", RACK_MOD_CTRL_NAME "+D", [=]() {
|
||||||
if (!weakThis)
|
if (!weakThis)
|
||||||
return;
|
return;
|
||||||
CardinalModuleWidget__saveDialog(weakThis);
|
weakThis->cloneAction(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Scan `<user dir>/presets/<plugin slug>/<module slug>` for presets.
|
// Duplicate with cables
|
||||||
menu->addChild(new ui::MenuSeparator);
|
menu->addChild(createMenuItem("└ with cables", RACK_MOD_SHIFT_NAME "+" RACK_MOD_CTRL_NAME "+D", [=]() {
|
||||||
menu->addChild(createMenuLabel("User presets"));
|
if (!weakThis)
|
||||||
appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory());
|
return;
|
||||||
*/
|
weakThis->cloneAction(true);
|
||||||
|
}));
|
||||||
|
|
||||||
// Scan `<plugin dir>/presets/<module slug>` for presets.
|
// Delete
|
||||||
appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory());
|
menu->addChild(createMenuItem("Delete", "Backspace/Delete", [=]() {
|
||||||
}));
|
if (!weakThis)
|
||||||
|
return;
|
||||||
|
weakThis->removeAction();
|
||||||
|
}, false, true));
|
||||||
|
|
||||||
// Initialize
|
appendContextMenu(menu);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
math::Vec ModuleWidget::getGridPosition() {
|
math::Vec ModuleWidget::getGridPosition() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/engine/Engine.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/engine/Engine.cpp 2022-09-21 20:25:53.592040301 +0100
|
||||||
+++ Engine.cpp 2022-11-25 22:31:29.000000000 +0000
|
+++ Engine.cpp 2022-11-29 19:49:19.196926572 +0000
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/app/MenuBar.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/app/MenuBar.cpp 2022-09-21 20:25:53.590040258 +0100
|
||||||
+++ MenuBar.cpp 2022-11-25 23:27:58.000000000 +0000
|
+++ MenuBar.cpp 2022-11-29 19:49:19.196926572 +0000
|
||||||
@@ -1,8 +1,33 @@
|
@@ -1,8 +1,33 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/plugin/Model.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/plugin/Model.cpp 2022-09-21 20:25:53.592040301 +0100
|
||||||
+++ Model.cpp 2022-11-23 23:06:41.000000000 +0000
|
+++ Model.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/app/ModuleWidget.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/app/ModuleWidget.cpp 2022-09-21 20:25:53.590040258 +0100
|
||||||
+++ ModuleWidget.cpp 2022-11-30 20:10:06.000000000 +0000
|
+++ ModuleWidget.cpp 2022-12-01 20:41:02.583687336 +0000
|
||||||
@@ -1,3 +1,32 @@
|
@@ -1,3 +1,32 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
@ -33,485 +33,151 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
@@ -368,71 +397,71 @@
|
@@ -375,7 +404,7 @@
|
||||||
}
|
if (e.action == GLFW_PRESS) {
|
||||||
|
// Open selection context menu on right-click
|
||||||
void ModuleWidget::onButton(const ButtonEvent& e) {
|
ui::Menu* menu = createMenu();
|
||||||
- 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);
|
- APP->scene->rack->appendSelectionContextMenu(menu);
|
||||||
- }
|
+ patchUtils::appendSelectionContextMenu(menu);
|
||||||
- e.consume(this);
|
}
|
||||||
- }
|
e.consume(this);
|
||||||
-
|
}
|
||||||
- if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
|
@@ -627,6 +656,9 @@
|
||||||
- if (e.action == GLFW_PRESS) {
|
std::string presetDir = model->getUserPresetDirectory();
|
||||||
- // Toggle selection on Shift-click
|
system::createDirectories(presetDir);
|
||||||
- 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;
|
+ WeakPtr<ModuleWidget> weakThis = this;
|
||||||
- }
|
+ async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) {
|
||||||
-
|
|
||||||
- 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) {
|
// Delete directories if empty
|
||||||
+ if (e.action == GLFW_PRESS) {
|
DEFER({
|
||||||
+ // Toggle selection on Shift-click
|
try {
|
||||||
+ if ((e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
|
@@ -638,10 +670,8 @@
|
||||||
+ 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);
|
- osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS);
|
||||||
- DEFER({osdialog_filters_free(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 {
|
- char* pathC = osdialog_file(OSDIALOG_OPEN, presetDir.c_str(), NULL, filters);
|
||||||
|
+ if (!weakThis)
|
||||||
|
+ return;
|
||||||
|
if (!pathC) {
|
||||||
|
// No path selected
|
||||||
|
return;
|
||||||
|
@@ -649,11 +679,13 @@
|
||||||
|
DEFER({std::free(pathC);});
|
||||||
|
|
||||||
|
try {
|
||||||
- loadAction(pathC);
|
- loadAction(pathC);
|
||||||
- }
|
+ weakThis->loadAction(pathC);
|
||||||
- catch (Exception& e) {
|
}
|
||||||
|
catch (Exception& e) {
|
||||||
- osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
|
- osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
|
||||||
- }
|
+ async_dialog_message(e.what());
|
||||||
+ std::free(pathC);
|
}
|
||||||
+ });
|
+
|
||||||
|
+ });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::save(std::string filename) {
|
void ModuleWidget::save(std::string filename) {
|
||||||
@@ -712,36 +742,37 @@
|
@@ -715,6 +747,9 @@
|
||||||
}
|
std::string presetDir = model->getUserPresetDirectory();
|
||||||
|
system::createDirectories(presetDir);
|
||||||
|
|
||||||
void ModuleWidget::saveDialog() {
|
+ WeakPtr<ModuleWidget> weakThis = this;
|
||||||
- std::string presetDir = model->getUserPresetDirectory();
|
+ async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) {
|
||||||
- system::createDirectories(presetDir);
|
+
|
||||||
+ const std::string presetDir = model->getUserPresetDirectory();
|
// Delete directories if empty
|
||||||
+ system::createDirectories(presetDir);
|
DEFER({
|
||||||
|
try {
|
||||||
|
@@ -726,10 +761,8 @@
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
- // 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);
|
- osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS);
|
||||||
- DEFER({osdialog_filters_free(filters);});
|
- DEFER({osdialog_filters_free(filters);});
|
||||||
-
|
-
|
||||||
- char* pathC = osdialog_file(OSDIALOG_SAVE, presetDir.c_str(), "Untitled.vcvm", filters);
|
- char* pathC = osdialog_file(OSDIALOG_SAVE, presetDir.c_str(), "Untitled.vcvm", filters);
|
||||||
- if (!pathC) {
|
+ if (!weakThis)
|
||||||
- // No path selected
|
+ return;
|
||||||
- return;
|
if (!pathC) {
|
||||||
- }
|
// No path selected
|
||||||
- DEFER({std::free(pathC);});
|
return;
|
||||||
+ WeakPtr<ModuleWidget> weakThis = this;
|
@@ -741,7 +774,8 @@
|
||||||
|
if (system::getExtension(path) != ".vcvm")
|
||||||
- std::string path = pathC;
|
path += ".vcvm";
|
||||||
- // 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);
|
- save(path);
|
||||||
+ weakThis->save(path);
|
+ weakThis->save(path);
|
||||||
+ });
|
+ });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleWidget::disconnect() {
|
void ModuleWidget::disconnect() {
|
||||||
@@ -981,118 +1012,108 @@
|
@@ -944,16 +978,12 @@
|
||||||
|
std::regex r("^\\d+_");
|
||||||
|
name = std::regex_replace(name, r, "");
|
||||||
|
|
||||||
WeakPtr<ModuleWidget> weakThis = this;
|
- if (system::isDirectory(path)) {
|
||||||
|
- hasPresets = true;
|
||||||
|
-
|
||||||
|
- menu->addChild(createSubmenuItem(name, "", [=](ui::Menu* menu) {
|
||||||
|
- if (!moduleWidget)
|
||||||
|
- return;
|
||||||
|
- appendPresetItems(menu, moduleWidget, path);
|
||||||
|
- }));
|
||||||
|
+ if (false) {
|
||||||
|
}
|
||||||
|
else if (system::getExtension(path) == ".vcvm" && name != "template") {
|
||||||
|
+ if (!hasPresets)
|
||||||
|
+ menu->addChild(new ui::MenuSeparator);
|
||||||
|
+
|
||||||
|
hasPresets = true;
|
||||||
|
|
||||||
- // Brand and module name
|
menu->addChild(createMenuItem(name, "", [=]() {
|
||||||
- menu->addChild(createMenuLabel(model->name));
|
@@ -963,15 +993,12 @@
|
||||||
- menu->addChild(createMenuLabel(model->plugin->brand));
|
moduleWidget->loadAction(path);
|
||||||
-
|
}
|
||||||
- // Info
|
catch (Exception& e) {
|
||||||
- menu->addChild(createSubmenuItem("Info", "", [=](ui::Menu* menu) {
|
- osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
|
||||||
- model->appendContextMenu(menu);
|
+ async_dialog_message(e.what());
|
||||||
- }));
|
}
|
||||||
-
|
}));
|
||||||
- // Preset
|
}
|
||||||
- menu->addChild(createSubmenuItem("Preset", "", [=](ui::Menu* menu) {
|
}
|
||||||
- menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [=]() {
|
}
|
||||||
- if (!weakThis)
|
- if (!hasPresets) {
|
||||||
- return;
|
- menu->addChild(createMenuLabel("(None)"));
|
||||||
- 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
|
@@ -1010,6 +1037,7 @@
|
||||||
- menu->addChild(createMenuItem("Randomize", RACK_MOD_CTRL_NAME "+R", [=]() {
|
weakThis->loadDialog();
|
||||||
- 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);
|
+ /* TODO requires setting up user dir
|
||||||
+ appendContextMenu(menu);
|
menu->addChild(createMenuItem("Save as", "", [=]() {
|
||||||
}
|
if (!weakThis)
|
||||||
|
return;
|
||||||
|
@@ -1032,10 +1060,13 @@
|
||||||
|
menu->addChild(new ui::MenuSeparator);
|
||||||
|
menu->addChild(createMenuLabel("User presets"));
|
||||||
|
appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory());
|
||||||
|
+ */
|
||||||
|
|
||||||
math::Vec ModuleWidget::getGridPosition() {
|
// Scan `<plugin dir>/presets/<module slug>` for presets.
|
||||||
|
+ /* TODO enable only after setting up user dir
|
||||||
|
menu->addChild(new ui::MenuSeparator);
|
||||||
|
menu->addChild(createMenuLabel("Factory presets"));
|
||||||
|
+ */
|
||||||
|
appendPresetItems(menu, weakThis, weakThis->model->getFactoryPresetDirectory());
|
||||||
|
}));
|
||||||
|
|
||||||
|
@@ -1127,4 +1158,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace app
|
||||||
|
-} // namespace rack
|
||||||
|
\ No newline at end of file
|
||||||
|
+} // namespace rack
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/widget/OpenGlWidget.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/widget/OpenGlWidget.cpp 2022-09-21 20:25:53.593040323 +0100
|
||||||
+++ OpenGlWidget.cpp 2022-11-23 23:06:41.000000000 +0000
|
+++ OpenGlWidget.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/app/Scene.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/app/Scene.cpp 2022-09-21 20:25:53.591040280 +0100
|
||||||
+++ Scene.cpp 2022-11-25 22:32:04.000000000 +0000
|
+++ Scene.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/window/Window.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/window/Window.cpp 2022-09-21 20:25:53.593040323 +0100
|
||||||
+++ Window.cpp 2022-11-25 22:32:06.000000000 +0000
|
+++ Window.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,33 +1,87 @@
|
@@ -1,33 +1,87 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/dep/oui-blendish/blendish.c 2022-11-23 23:11:56.000000000 +0000
|
--- ../Rack/dep/oui-blendish/blendish.c 2022-09-21 20:26:10.733413463 +0100
|
||||||
+++ blendish.c 2022-11-23 23:06:41.000000000 +0000
|
+++ blendish.c 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -61,7 +61,7 @@
|
@@ -61,7 +61,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/common.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/common.cpp 2022-09-21 20:25:53.591040280 +0100
|
||||||
+++ common.cpp 2022-11-25 22:32:13.000000000 +0000
|
+++ common.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,33 +1,77 @@
|
@@ -1,33 +1,77 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/context.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/context.cpp 2022-09-21 20:25:53.591040280 +0100
|
||||||
+++ context.cpp 2022-11-25 22:31:32.000000000 +0000
|
+++ context.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
@ -31,22 +31,21 @@
|
||||||
#include <context.hpp>
|
#include <context.hpp>
|
||||||
#include <window/Window.hpp>
|
#include <window/Window.hpp>
|
||||||
#include <patch.hpp>
|
#include <patch.hpp>
|
||||||
@@ -6,10 +33,14 @@
|
@@ -6,9 +33,13 @@
|
||||||
#include <history.hpp>
|
#include <history.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
+#ifdef NDEBUG
|
+#ifdef NDEBUG
|
||||||
+# undef DEBUG
|
+# undef DEBUG
|
||||||
+#endif
|
+#endif
|
||||||
+
|
|
||||||
|
-namespace rack {
|
||||||
+#include "DistrhoUtils.hpp"
|
+#include "DistrhoUtils.hpp"
|
||||||
|
|
||||||
namespace rack {
|
+namespace rack {
|
||||||
|
|
||||||
-
|
|
||||||
Context::~Context() {
|
Context::~Context() {
|
||||||
// Deleting NULL is safe in C++.
|
// Deleting NULL is safe in C++.
|
||||||
|
|
||||||
@@ -44,7 +75,7 @@
|
@@ -44,7 +75,7 @@
|
||||||
static thread_local Context* threadContext = NULL;
|
static thread_local Context* threadContext = NULL;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/dsp/minblep.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/dsp/minblep.cpp 2022-09-21 20:25:53.592040301 +0100
|
||||||
+++ minblep.cpp 2022-11-23 23:06:41.000000000 +0000
|
+++ minblep.cpp 2022-09-21 20:18:50.295557620 +0100
|
||||||
@@ -1,3 +1,30 @@
|
@@ -1,3 +1,30 @@
|
||||||
+/*
|
+/*
|
||||||
+ * DISTRHO Cardinal Plugin
|
+ * DISTRHO Cardinal Plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- ../Rack/src/plugin.cpp 2022-11-23 23:11:38.000000000 +0000
|
--- ../Rack/src/plugin.cpp 2022-09-21 20:25:53.592040301 +0100
|
||||||
+++ plugin.cpp 2022-11-25 23:27:58.000000000 +0000
|
+++ plugin.cpp 2022-11-29 19:49:19.197926669 +0000
|
||||||
@@ -1,342 +1,41 @@
|
@@ -1,342 +1,41 @@
|
||||||
-#include <thread>
|
-#include <thread>
|
||||||
-#include <map>
|
-#include <map>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue