Browse Source

Refactor context menus of Frames and Plaits.

pull/114/head
Andrew Belt 3 years ago
parent
commit
b110e6eea5
2 changed files with 45 additions and 46 deletions
  1. +33
    -44
      src/Frames.cpp
  2. +12
    -2
      src/Plaits.cpp

+ 33
- 44
src/Frames.cpp View File

@@ -348,54 +348,43 @@ struct FramesWidget : ModuleWidget {
Frames* module = dynamic_cast<Frames*>(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<std::string> 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<std::string> 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<FramesChannelSettingsItem>(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", "",


+ 12
- 2
src/Plaits.cpp View File

@@ -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;}


Loading…
Cancel
Save