Skip to content

Commit

Permalink
Transit - added "unbind" option for modules #268
Browse files Browse the repository at this point in the history
  • Loading branch information
stoermelder committed Jun 7, 2021
1 parent bf9f084 commit aa93e95
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## 1.11.0 (in development)
## 1.x.x (in development)

- Module [DIRT](./docs/Dirt.md)
- New module, crosstalk and noise for polyphonic cables
- Modules [FLOWER, SEEDS, OFFSPRING](./docs/Flower.md)
- New modules, pattern-driven 16-step sequencer
- Module [STRIP-BLOCK](./docs/Strip.md)
- New module, a companion module for STRIP for blocking STRIP's expander-mechanism

## 1.10.0 (in development)

Expand All @@ -17,13 +19,13 @@
- New module, a helper for generating keyboard events from MIDI CC or note messages (#245)
- Module [PRISMA](./docs/Prisma.md)
- New module, a wave multiplier/phase shifter inspired by A-137-2
- Module [STRIP-BLOCK](./docs/Strip.md)
- New module, a companion module for STRIP for blocking STRIP's expander-mechanism

### Fixes and Changes

- Module [INTERMIX](./docs/Intermix.md)
- Added context menu option "Scene lock" to prevent accidental changes
- Module [TRANSIT](./docs/Transit.md)
- Added context menu option for unbinding all bound parameters of a module (#268)

## 1.9.0

Expand Down
38 changes: 38 additions & 0 deletions src/Transit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,43 @@ struct TransitWidget : ThemedModuleWidget<TransitModule<NUM_PRESETS>> {
}
};

struct ModuleMenuItem : MenuItem {
MODULE* module;
ModuleMenuItem() {
rightText = RIGHT_ARROW;
}

Menu* createChildMenu() override {
struct UnbindItem : MenuItem {
MODULE* module;
int moduleId;
void onAction(const event::Action& e) override {
for (size_t i = 0; i < module->sourceHandles.size(); i++) {
ParamHandle* handle = module->sourceHandles[i];
if (handle->moduleId != moduleId) continue;
APP->engine->updateParamHandle(handle, -1, 0, true);
}
}
};

Menu* menu = new Menu;
std::set<int> moduleIds;
for (size_t i = 0; i < module->sourceHandles.size(); i++) {
ParamHandle* handle = module->sourceHandles[i];
if (moduleIds.find(handle->moduleId) == moduleIds.end())
moduleIds.insert(handle->moduleId);
}

for (int moduleId : moduleIds) {
ModuleWidget* moduleWidget = APP->scene->rack->getModule(moduleId);
if (!moduleWidget) continue;
std::string text = string::f("Unbind \"%s %s\"", moduleWidget->model->plugin->name.c_str(), moduleWidget->model->name.c_str());
menu->addChild(construct<UnbindItem>(&MenuItem::text, text, &UnbindItem::module, module, &UnbindItem::moduleId, moduleId));
}
return menu;
}
};

menu->addChild(new MenuSeparator());
menu->addChild(construct<MappingIndicatorHiddenItem>(&MenuItem::text, "Hide mapping indicators", &MappingIndicatorHiddenItem::module, module));
menu->addChild(construct<PrecisionMenuItem>(&MenuItem::text, "Precision", &PrecisionMenuItem::module, module));
Expand All @@ -1161,6 +1198,7 @@ struct TransitWidget : ThemedModuleWidget<TransitModule<NUM_PRESETS>> {

if (module->sourceHandles.size() > 0) {
menu->addChild(new MenuSeparator());
menu->addChild(construct<ModuleMenuItem>(&MenuItem::text, "Bound modules", &ModuleMenuItem::module, module));
menu->addChild(construct<ParameterMenuItem>(&MenuItem::text, "Bound parameters", &ParameterMenuItem::module, module));
}
}
Expand Down

0 comments on commit aa93e95

Please sign in to comment.