Rack 2’s API will make writing context menus as easy as possible. After writing 100+ new menu items for Rack features and module context menus, I was finding subclassing to be repetitive and usually unneccessary. In v2 plugin developers will be able to use the following helper functions.
createMenuItem
createCheckMenuItem
createBoolMenuItem
createBoolPtrMenuItem
createSubmenuItem
createIndexSubmenuItem
createIndexPtrSubmenuItem
For example, you’ll be able to add this to your appendContextMenu()
method.
menu->addChild(new MenuSeparator);
menu->addChild(createMenuItem("Load sample", "kick.wav", [=]() {module->loadSample();}));
menu->addChild(createBoolPtrMenuItem("Loop", &module->loop));
menu->addChild(createIndexPtrSubmenuItem("Mode", {"Hi-fi", "Mid-fi", "Lo-fi"}, &module->mode));
menu->addChild(createSubmenuItem("Edit",
[=](Menu* menu) {
menu->addChild(createMenuItem("Copy", "", [=]() {copy();}));
menu->addChild(createMenuItem("Paste", "", [=]() {paste();}));
}
));
This produces the following menu items at the bottom of your module’s context menu.