MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / createContextMenu

Method createContextMenu

src/override/ModuleWidget.cpp:1016–1134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1014
1015
1016void ModuleWidget::createContextMenu() {
1017 ui::Menu* menu = createMenu();
1018 assert(model);
1019
1020 WeakPtr<ModuleWidget> weakThis = this;
1021
1022 // Brand and module name
1023 menu->addChild(createMenuLabel(model->name));
1024 menu->addChild(createMenuLabel(model->plugin->brand));
1025
1026 // Info
1027 menu->addChild(createSubmenuItem("Info", "", [=](ui::Menu* menu) {
1028 model->appendContextMenu(menu);
1029 }));
1030
1031 // Preset
1032 menu->addChild(createSubmenuItem("Preset", "", [=](ui::Menu* menu) {
1033 menu->addChild(createMenuItem("Copy", RACK_MOD_CTRL_NAME "+C", [=]() {
1034 if (!weakThis)
1035 return;
1036 weakThis->copyClipboard();
1037 }));
1038
1039 menu->addChild(createMenuItem("Paste", RACK_MOD_CTRL_NAME "+V", [=]() {
1040 if (!weakThis)
1041 return;
1042 weakThis->pasteClipboardAction();
1043 }));
1044
1045 menu->addChild(createMenuItem("Open", "", [=]() {
1046 if (!weakThis)
1047 return;
1048 weakThis->loadDialog();
1049 }));
1050
1051 menu->addChild(createMenuItem("Save as", "", [=]() {
1052 if (!weakThis)
1053 return;
1054 weakThis->saveDialog();
1055 }));
1056
1057 menu->addChild(createMenuItem("Save default", "", [=]() {
1058 if (!weakThis)
1059 return;
1060 weakThis->saveTemplateDialog();
1061 }));
1062
1063 menu->addChild(createMenuItem("Clear default", "", [=]() {
1064 if (!weakThis)
1065 return;
1066 weakThis->clearTemplateDialog();
1067 }, !weakThis->hasTemplate()));
1068
1069 // Scan `<user dir>/presets/<plugin slug>/<module slug>` for presets.
1070 menu->addChild(new ui::MenuSeparator);
1071 menu->addChild(createMenuLabel("User presets"));
1072 appendPresetItems(menu, weakThis, weakThis->model->getUserPresetDirectory());
1073

Callers

nothing calls this directly

Calls 15

createMenuFunction · 0.85
createMenuLabelFunction · 0.85
createSubmenuItemFunction · 0.85
createMenuItemFunction · 0.85
appendPresetItemsFunction · 0.85
addChildMethod · 0.80
appendContextMenuMethod · 0.45
copyClipboardMethod · 0.45
pasteClipboardActionMethod · 0.45
loadDialogMethod · 0.45

Tested by

no test coverage detected