1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

ImageViewer: Change how scaling works

- Store scale as a (float) factor (not as %)
- Make scaling exponential so that matches PixelPaint and another
image viewers/editors/etc
This commit is contained in:
Maciej 2021-12-28 11:52:15 +01:00 committed by Andreas Kling
parent 1c3a82d59e
commit ab324c1dae
3 changed files with 23 additions and 27 deletions

View file

@ -67,13 +67,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (path) {
widget.set_path(path);
}
widget.on_scale_change = [&](int scale) {
widget.on_scale_change = [&](float scale) {
if (!widget.bitmap()) {
window->set_title("Image Viewer");
return;
}
window->set_title(String::formatted("{} {} {}% - Image Viewer", widget.path(), widget.bitmap()->size().to_string(), scale));
window->set_title(String::formatted("{} {} {}% - Image Viewer", widget.path(), widget.bitmap()->size().to_string(), (int)(scale * 100)));
if (scale == 100 && !widget.scaled_for_first_image()) {
widget.set_scaled_for_first_image(true);
@ -200,19 +200,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto zoom_in_action = GUI::CommonActions::make_zoom_in_action(
[&](auto&) {
widget.set_scale(widget.scale() + 10);
widget.set_scale(widget.scale() * 1.44f);
},
window);
auto reset_zoom_action = GUI::CommonActions::make_reset_zoom_action(
[&](auto&) {
widget.set_scale(100);
widget.set_scale(1.f);
},
window);
auto zoom_out_action = GUI::CommonActions::make_zoom_out_action(
[&](auto&) {
widget.set_scale(widget.scale() - 10);
widget.set_scale(widget.scale() / 1.44f);
},
window);