Browse Source

Implement RackWidget::bypassSelectedModulesAction() so bypassing the module selection works.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
99c96c1e05
4 changed files with 47 additions and 10 deletions
  1. +2
    -1
      include/app/RackWidget.hpp
  2. +12
    -5
      src/app/ModuleWidget.cpp
  3. +30
    -2
      src/app/RackWidget.cpp
  4. +3
    -2
      src/engine/Engine.cpp

+ 2
- 1
include/app/RackWidget.hpp View File

@@ -76,7 +76,8 @@ struct RackWidget : widget::OpaqueWidget {
void resetSelectedModulesAction();
void randomizeSelectedModulesAction();
void disconnectSelectedModulesAction();
void bypassSelectedModulesAction();
void bypassSelectedModulesAction(bool bypassed);
bool areSelectedModulesBypassed();
void deleteSelectedModulesAction();
bool requestSelectedModulePos(math::Vec delta);



+ 12
- 5
src/app/ModuleWidget.cpp View File

@@ -802,13 +802,15 @@ void ModuleWidget::cloneAction() {

void ModuleWidget::bypassAction() {
assert(module);
APP->engine->bypassModule(module, !module->isBypassed());
bool bypassed = !module->isBypassed();

// history::ModuleBypass
history::ModuleBypass* h = new history::ModuleBypass;
h->moduleId = module->id;
h->bypassed = module->isBypassed();
h->bypassed = bypassed;
APP->history->push(h);

APP->engine->bypassModule(module, bypassed);
}

void ModuleWidget::removeAction() {
@@ -1085,9 +1087,14 @@ void ModuleWidget::createSelectionContextMenu() {
}));

// Bypass
menu->addChild(createMenuItem("Bypass", "", [=]() {
APP->scene->rack->bypassSelectedModulesAction();
}));
menu->addChild(createBoolMenuItem("Bypass",
[=]() {
return APP->scene->rack->areSelectedModulesBypassed();
},
[=](bool bypassed) {
APP->scene->rack->bypassSelectedModulesAction(bypassed);
}
));

// Delete
menu->addChild(createMenuItem("Delete", "", [=]() {


+ 30
- 2
src/app/RackWidget.cpp View File

@@ -731,8 +731,36 @@ void RackWidget::disconnectSelectedModulesAction() {
delete complexAction;
}

void RackWidget::bypassSelectedModulesAction() {
// TODO
void RackWidget::bypassSelectedModulesAction(bool bypassed) {
history::ComplexAction* complexAction = new history::ComplexAction;
complexAction->name = "bypass modules";

for (ModuleWidget* mw : getSelectedModules()) {
assert(mw->module);
if (mw->module->isBypassed() == bypassed)
continue;

// history::ModuleBypass
history::ModuleBypass* h = new history::ModuleBypass;
h->moduleId = mw->module->id;
h->bypassed = bypassed;
complexAction->push(h);

APP->engine->bypassModule(mw->module, bypassed);
}

if (!complexAction->isEmpty())
APP->history->push(complexAction);
else
delete complexAction;
}

bool RackWidget::areSelectedModulesBypassed() {
for (ModuleWidget* mw : getSelectedModules()) {
if (!mw->getModule()->isBypassed())
return false;
}
return true;
}

void RackWidget::deleteSelectedModulesAction() {


+ 3
- 2
src/engine/Engine.cpp View File

@@ -863,11 +863,12 @@ void Engine::randomizeModule(Module* module) {


void Engine::bypassModule(Module* module, bool bypassed) {
WriteLock lock(internal->mutex);
assert(module);

if (module->isBypassed() == bypassed)
return;

WriteLock lock(internal->mutex);

// Clear outputs and set to 1 channel
for (Output& output : module->outputs) {
// This zeros all voltages, but the channel is set to 1 if connected


Loading…
Cancel
Save