MCPcopy Create free account
hub / github.com/VCVRack/Befaco / appendContextMenu

Method appendContextMenu

src/Random8.cpp:789–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787 }
788
789 void appendContextMenu(Menu *menu) override {
790 ModuleWidget::appendContextMenu(menu);
791 auto *random8 = dynamic_cast<Random8 *>(module);
792 if (!random8) {
793 return;
794 }
795
796 menu->addChild(new MenuSeparator());
797 menu->addChild(createMenuLabel("Presets:"));
798 std::vector<std::string> presetLabels;
799 presetLabels.reserve(Random8::NUM_CHANNELS);
800 for (int i = 0; i < Random8::NUM_CHANNELS; i++) {
801 const bool used = random8->presetSlots[i] != nullptr;
802 presetLabels.push_back(string::f("Slot %d (%s)", i + 1, used ? "used" : "unused"));
803 }
804 menu->addChild(createIndexSubmenuItem(
805 "Load preset", presetLabels, [=]() { return presetLabels.size(); },
806 [=](size_t index) {
807 if (random8) {
808 random8->loadPresetSlot(static_cast<int>(index));
809 }
810 }));
811 menu->addChild(createIndexSubmenuItem(
812 "Save preset", presetLabels, [=]() { return presetLabels.size(); },
813 [=](size_t index) {
814 if (random8) {
815 random8->savePresetSlot(static_cast<int>(index));
816 }
817 }));
818
819 menu->addChild(new MenuSeparator());
820 menu->addChild(createMenuLabel("Modes:"));
821 menu->addChild(createBoolMenuItem(
822 "Performance Mode", "", [=]() { return !random8->inMenu; },
823 [=](bool val) {
824 if (val) {
825 random8->setPanelPerformanceMode();
826 }
827 }));
828 menu->addChild(new MenuSeparator());
829 for (int p = 0; p < Random8::NUM_PAGES; p++) {
830 menu->addChild(createBoolMenuItem(
831 random8->pageNames[p], "", [=]() { return (random8->currentPage == p && random8->inMenu); },
832 [=](bool val) {
833 if (val) {
834 random8->setPanelPage(p);
835 }
836 }));
837 }
838 }
839};
840
841Model *modelRandom8 = createModel<Random8, Random8Widget>("Random8");

Callers

nothing calls this directly

Calls 4

loadPresetSlotMethod · 0.80
savePresetSlotMethod · 0.80
setPanelPageMethod · 0.80

Tested by

no test coverage detected