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

Method onAction

src/app/MenuBar.cpp:71–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69
70struct FileButton : MenuButton {
71 void onAction(const ActionEvent& e) override {
72 ui::Menu* menu = createMenu();
73 menu->cornerFlags = BND_CORNER_TOP;
74 menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
75
76 menu->addChild(createMenuItem(string::translate("MenuBar.file.new"), widget::getKeyCommandName(GLFW_KEY_N, RACK_MOD_CTRL), []() {
77 APP->patch->loadTemplateDialog();
78 }));
79
80 menu->addChild(createMenuItem(string::translate("MenuBar.file.open"), widget::getKeyCommandName(GLFW_KEY_O, RACK_MOD_CTRL), []() {
81 APP->patch->loadDialog();
82 }));
83
84 menu->addChild(createSubmenuItem(string::translate("MenuBar.file.openRecent"), "", [](ui::Menu* menu) {
85 for (const std::string& path : settings::recentPatchPaths) {
86 std::string name = system::getStem(path);
87 menu->addChild(createMenuItem(name, "", [=]() {
88 APP->patch->loadPathDialog(path);
89 }));
90 }
91 }, settings::recentPatchPaths.empty()));
92
93 menu->addChild(createMenuItem(string::translate("MenuBar.file.save"), widget::getKeyCommandName(GLFW_KEY_S, RACK_MOD_CTRL), []() {
94 APP->patch->saveDialog();
95 }));
96
97 menu->addChild(createMenuItem(string::translate("MenuBar.file.saveAs"), widget::getKeyCommandName(GLFW_KEY_S, RACK_MOD_CTRL | GLFW_MOD_SHIFT), []() {
98 APP->patch->saveAsDialog();
99 }));
100
101 menu->addChild(createMenuItem(string::translate("MenuBar.file.saveCopy"), "", []() {
102 APP->patch->saveAsDialog(false);
103 }));
104
105 menu->addChild(createMenuItem(string::translate("MenuBar.file.revert"), widget::getKeyCommandName(GLFW_KEY_O, RACK_MOD_CTRL | GLFW_MOD_SHIFT), []() {
106 APP->patch->revertDialog();
107 }, APP->patch->path == ""));
108
109 menu->addChild(createMenuItem(string::translate("MenuBar.file.overwriteTemplate"), "", []() {
110 APP->patch->saveTemplateDialog();
111 }));
112
113 menu->addChild(new ui::MenuSeparator);
114
115 // Load selection
116 menu->addChild(createMenuItem(string::translate("MenuBar.file.importSelection"), "", [=]() {
117 APP->scene->rack->loadSelectionDialog();
118 }, false, true));
119
120 menu->addChild(new ui::MenuSeparator);
121
122 menu->addChild(createMenuItem(string::translate("MenuBar.file.quit"), widget::getKeyCommandName(GLFW_KEY_Q, RACK_MOD_CTRL), []() {
123 APP->window->close();
124 }));
125 }
126};
127
128

Callers

nothing calls this directly

Calls 15

createMenuFunction · 0.85
VecClass · 0.85
createMenuItemFunction · 0.85
translateFunction · 0.85
getKeyCommandNameFunction · 0.85
createSubmenuItemFunction · 0.85
getStemFunction · 0.85
addChildMethod · 0.80
loadTemplateDialogMethod · 0.80
loadPathDialogMethod · 0.80
saveAsDialogMethod · 0.80
revertDialogMethod · 0.80

Tested by

no test coverage detected