From f8df60a9e661b0ed8311a1125d176fd9e18df9ec Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 23 Mar 2025 19:19:03 -0400 Subject: [PATCH] Add 150% and 250% options to "View > UI scale" menu. --- src/app/MenuBar.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 04072baf..092e1d22 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -422,10 +422,19 @@ struct ViewButton : MenuButton { } })); - menu->addChild(createIndexPtrSubmenuItem(string::translate("MenuBar.view.pixelRatio"), { - string::translate("MenuBar.view.pixelRatio.auto"), - "100%", "200%", "300%" - }, &settings::pixelRatio)); + static const std::vector pixelRatios = {0, 1, 1.5, 2, 2.5, 3}; + std::vector pixelRatioLabels; + for (float pixelRatio : pixelRatios) { + pixelRatioLabels.push_back(pixelRatio == 0.f ? string::translate("MenuBar.view.pixelRatio.auto") : string::f("%0.f%%", pixelRatio * 100.f)); + } + menu->addChild(createIndexSubmenuItem(string::translate("MenuBar.view.pixelRatio"), pixelRatioLabels, [=]() -> size_t { + auto it = std::find(pixelRatios.begin(), pixelRatios.end(), settings::pixelRatio); + if (it == pixelRatios.end()) + return -1; + return it - pixelRatios.begin(); + }, [=](size_t i) { + settings::pixelRatio = pixelRatios[i]; + })); ZoomSlider* zoomSlider = new ZoomSlider; zoomSlider->box.size.x = 250.0;