Skip to content

Commit f8df60a

Browse files
committed
Add 150% and 250% options to "View > UI scale" menu.
1 parent 2bcff47 commit f8df60a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/app/MenuBar.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,19 @@ struct ViewButton : MenuButton {
422422
}
423423
}));
424424

425-
menu->addChild(createIndexPtrSubmenuItem(string::translate("MenuBar.view.pixelRatio"), {
426-
string::translate("MenuBar.view.pixelRatio.auto"),
427-
"100%", "200%", "300%"
428-
}, &settings::pixelRatio));
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+
}));
429438

430439
ZoomSlider* zoomSlider = new ZoomSlider;
431440
zoomSlider->box.size.x = 250.0;

0 commit comments

Comments
 (0)