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

Method onAction

src/app/MenuBar.cpp:400–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398
399struct ViewButton : MenuButton {
400 void onAction(const ActionEvent& e) override {
401 ui::Menu* menu = createMenu();
402 menu->cornerFlags = BND_CORNER_TOP;
403 menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
404
405 menu->addChild(createMenuLabel(string::translate("MenuBar.view.window")));
406
407 bool fullscreen = APP->window->isFullScreen();
408 std::string fullscreenText = widget::getKeyCommandName(GLFW_KEY_F11, 0);
409 if (fullscreen)
410 fullscreenText += " " CHECKMARK_STRING;
411 menu->addChild(createMenuItem(string::translate("MenuBar.view.fullscreen"), fullscreenText, [=]() {
412 APP->window->setFullScreen(!fullscreen);
413 }));
414
415 menu->addChild(createSubmenuItem(string::translate("MenuBar.view.frameRate"), string::f("%.0f Hz", settings::frameRateLimit), [=](ui::Menu* menu) {
416 for (int i = 1; i <= 6; i++) {
417 double frameRate = APP->window->getMonitorRefreshRate() / i;
418 menu->addChild(createCheckMenuItem(string::f("%.0f Hz", frameRate), "",
419 [=]() {return settings::frameRateLimit == frameRate;},
420 [=]() {settings::frameRateLimit = frameRate;}
421 ));
422 }
423 }));
424
425 static const std::vector<float> pixelRatios = {0, 1, 1.5, 2, 2.5, 3};
426 std::vector<std::string> pixelRatioLabels;
427 for (float pixelRatio : pixelRatios) {
428 pixelRatioLabels.push_back(pixelRatio == 0.f ? string::translate("MenuBar.view.pixelRatio.auto") : string::f("%0.f%%", pixelRatio * 100.f));
429 }
430 menu->addChild(createIndexSubmenuItem(string::translate("MenuBar.view.pixelRatio"), pixelRatioLabels, [=]() -> size_t {
431 auto it = std::find(pixelRatios.begin(), pixelRatios.end(), settings::pixelRatio);
432 if (it == pixelRatios.end())
433 return -1;
434 return it - pixelRatios.begin();
435 }, [=](size_t i) {
436 settings::pixelRatio = pixelRatios[i];
437 }));
438
439 ZoomSlider* zoomSlider = new ZoomSlider;
440 zoomSlider->box.size.x = 250.0;
441 menu->addChild(zoomSlider);
442
443 menu->addChild(createMenuItem(string::translate("MenuBar.view.zoomFit"), widget::getKeyCommandName(GLFW_KEY_F4, 0), [=]() {
444 APP->scene->rackScroll->zoomToModules();
445 }));
446
447 menu->addChild(createIndexPtrSubmenuItem(string::translate("MenuBar.view.mouseWheelZoom"), {
448 string::f(string::translate("MenuBar.view.mouseWheelZoom.scroll"), RACK_MOD_CTRL_NAME),
449 string::f(string::translate("MenuBar.view.mouseWheelZoom.zoom"), RACK_MOD_CTRL_NAME)
450 }, &settings::mouseWheelZoom));
451
452 menu->addChild(new ui::MenuSeparator);
453 menu->addChild(createMenuLabel(string::translate("MenuBar.view.appearance")));
454
455 static const std::vector<std::string> uiThemes = {"dark", "light", "hcdark"};
456 menu->addChild(createIndexSubmenuItem(string::translate("MenuBar.view.uiTheme"), {
457 string::translate("MenuBar.view.appearance.dark"),

Callers

nothing calls this directly

Calls 15

createMenuFunction · 0.85
VecClass · 0.85
createMenuLabelFunction · 0.85
translateFunction · 0.85
getKeyCommandNameFunction · 0.85
createMenuItemFunction · 0.85
createSubmenuItemFunction · 0.85
createCheckMenuItemFunction · 0.85
createIndexSubmenuItemFunction · 0.85
findFunction · 0.85
refreshThemeFunction · 0.85

Tested by

no test coverage detected