MCPcopy Create free account
hub / github.com/VCVRack/Rack / createContextMenu

Method createContextMenu

src/app/ModuleWidget.cpp:995–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993
994
995void ModuleWidget::createContextMenu() {
996 ui::Menu* menu = createMenu();
997 assert(model);
998
999 WeakPtr<ModuleWidget> weakThis = this;
1000
1001 // Brand and module name
1002 menu->addChild(createMenuLabel(model->name));
1003 menu->addChild(createMenuLabel(model->plugin->brand));
1004
1005 // Info
1006 menu->addChild(createSubmenuItem(string::translate("ModuleWidget.info"), "", [=](ui::Menu* menu) {
1007 model->appendContextMenu(menu);
1008
1009 if (!weakThis)
1010 return;
1011 menu->addChild(new ui::MenuSeparator);
1012 menu->addChild(createMenuLabel(string::translate("ModuleWidget.moduleId")));
1013 menu->addChild(createMenuLabel(string::f("%lld", (long long) weakThis->module->getId())));
1014 }));
1015
1016 // Preset
1017 menu->addChild(createSubmenuItem(string::translate("ModuleWidget.preset"), "", [=](ui::Menu* menu) {
1018 menu->addChild(createMenuItem(string::translate("ModuleWidget.copy"), widget::getKeyCommandName(GLFW_KEY_C, RACK_MOD_CTRL), [=]() {
1019 if (!weakThis)
1020 return;
1021 weakThis->copyClipboard();
1022 }));
1023
1024 menu->addChild(createMenuItem(string::translate("ModuleWidget.paste"), widget::getKeyCommandName(GLFW_KEY_V, RACK_MOD_CTRL), [=]() {
1025 if (!weakThis)
1026 return;
1027 weakThis->pasteClipboardAction();
1028 }));
1029
1030 menu->addChild(createMenuItem(string::translate("ModuleWidget.load"), "", [=]() {
1031 if (!weakThis)
1032 return;
1033 weakThis->loadDialog();
1034 }));
1035
1036 menu->addChild(createMenuItem(string::translate("ModuleWidget.saveAs"), "", [=]() {
1037 if (!weakThis)
1038 return;
1039 weakThis->saveDialog();
1040 }));
1041
1042 menu->addChild(createMenuItem(string::translate("ModuleWidget.saveTemplate"), "", [=]() {
1043 if (!weakThis)
1044 return;
1045 weakThis->saveTemplateDialog();
1046 }));
1047
1048 menu->addChild(createMenuItem(string::translate("ModuleWidget.clearTemplate"), "", [=]() {
1049 if (!weakThis)
1050 return;
1051 weakThis->clearTemplateDialog();
1052 }, !weakThis->hasTemplate()));

Callers

nothing calls this directly

Calls 15

createMenuFunction · 0.85
createMenuLabelFunction · 0.85
createSubmenuItemFunction · 0.85
translateFunction · 0.85
createMenuItemFunction · 0.85
getKeyCommandNameFunction · 0.85
appendPresetItemsFunction · 0.85
addChildMethod · 0.80
getIdMethod · 0.80
clearTemplateDialogMethod · 0.80
hasTemplateMethod · 0.80

Tested by

no test coverage detected