From b110e6eea5413eeee38b988e50fca4d3104d4ce1 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 16 Jun 2021 11:22:21 -0400 Subject: [PATCH] Refactor context menus of Frames and Plaits. --- src/Frames.cpp | 77 ++++++++++++++++++++++---------------------------- src/Plaits.cpp | 14 +++++++-- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/src/Frames.cpp b/src/Frames.cpp index cc4e5b3..34e35aa 100644 --- a/src/Frames.cpp +++ b/src/Frames.cpp @@ -348,54 +348,43 @@ struct FramesWidget : ModuleWidget { Frames* module = dynamic_cast(this->module); assert(module); - struct FramesChannelSettingsItem : MenuItem { - Frames* module; - uint8_t channel; - Menu* createChildMenu() override { - Menu* menu = new Menu(); - - menu->addChild(createMenuLabel("Interpolation curve")); - - static const std::vector curveLabels = { - "Step", - "Linear", - "Accelerating", - "Decelerating", - "Departure/arrival", - "Bouncing", - }; - for (int i = 0; i < (int) curveLabels.size(); i++) { - menu->addChild(createCheckMenuItem(curveLabels[i], - [=]() {return module->keyframer.mutable_settings(channel)->easing_curve == i;}, - [=]() {module->keyframer.mutable_settings(channel)->easing_curve = (frames::EasingCurve) i;} - )); - } - - menu->addChild(new MenuSeparator); - - menu->addChild(createMenuLabel("Response curve")); + menu->addChild(new MenuSeparator); + menu->addChild(createMenuLabel("Channel settings")); - menu->addChild(createCheckMenuItem("Linear", - [=]() {return module->keyframer.mutable_settings(channel)->response == 0;}, - [=]() {module->keyframer.mutable_settings(channel)->response = 0;} - )); - menu->addChild(createCheckMenuItem("Exponential", - [=]() {return module->keyframer.mutable_settings(channel)->response == 255;}, - [=]() {module->keyframer.mutable_settings(channel)->response = 255;} - )); + for (int c = 0; c < 4; c++) { + menu->addChild(createSubmenuItem(string::f("Channel %d", c + 1), + [=](Menu* menu) { + menu->addChild(createMenuLabel("Interpolation curve")); + + static const std::vector curveLabels = { + "Step", + "Linear", + "Accelerating", + "Decelerating", + "Departure/arrival", + "Bouncing", + }; + for (int i = 0; i < (int) curveLabels.size(); i++) { + menu->addChild(createCheckMenuItem(curveLabels[i], + [=]() {return module->keyframer.mutable_settings(c)->easing_curve == i;}, + [=]() {module->keyframer.mutable_settings(c)->easing_curve = (frames::EasingCurve) i;} + )); + } - return menu; - } - }; + menu->addChild(new MenuSeparator); - menu->addChild(new MenuSeparator); - menu->addChild(createMenuLabel("Channel settings")); + menu->addChild(createMenuLabel("Response curve")); - for (int i = 0; i < 4; i++) { - FramesChannelSettingsItem* item = createMenuItem(string::f("Channel %d", i + 1)); - item->module = module; - item->channel = i; - menu->addChild(item); + menu->addChild(createCheckMenuItem("Linear", + [=]() {return module->keyframer.mutable_settings(c)->response == 0;}, + [=]() {module->keyframer.mutable_settings(c)->response = 0;} + )); + menu->addChild(createCheckMenuItem("Exponential", + [=]() {return module->keyframer.mutable_settings(c)->response == 255;}, + [=]() {module->keyframer.mutable_settings(c)->response = 255;} + )); + } + )); } menu->addChild(createMenuItem("Clear keyframes", "", diff --git a/src/Plaits.cpp b/src/Plaits.cpp index b7fd6a5..1627a30 100644 --- a/src/Plaits.cpp +++ b/src/Plaits.cpp @@ -343,9 +343,19 @@ struct PlaitsWidget : ModuleWidget { )); menu->addChild(new MenuSeparator); - menu->addChild(createMenuLabel("Models")); + menu->addChild(createMenuLabel("Pitched models")); - for (int i = 0; i < 16; i++) { + for (int i = 0; i < 8; i++) { + menu->addChild(createCheckMenuItem(modelLabels[i], + [=]() {return module->patch.engine == i;}, + [=]() {module->patch.engine = i;} + )); + } + + menu->addChild(new MenuSeparator); + menu->addChild(createMenuLabel("Noise/percussive models")); + + for (int i = 8; i < 16; i++) { menu->addChild(createCheckMenuItem(modelLabels[i], [=]() {return module->patch.engine == i;}, [=]() {module->patch.engine = i;}