mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09: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:
parent
1c3a82d59e
commit
ab324c1dae
Notes:
sideshowbarker
2024-07-17 22:02:14 +09:00
Author: https://github.com/sppmacd
Commit: ab324c1dae
Pull-request: https://github.com/SerenityOS/serenity/pull/11463
3 changed files with 23 additions and 27 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue