mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
ImageViewer: Add "Fit Image to View" action
This is analogous to PixelPaint, it resizes the image so that it fits in the view (with some padding).
This commit is contained in:
parent
481ed1ca16
commit
4556b8e943
1 changed files with 6 additions and 0 deletions
|
@ -215,6 +215,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
|
|
||||||
|
auto fit_image_to_view_action = GUI::Action::create(
|
||||||
|
"Fit Image To &View", [&](auto&) {
|
||||||
|
widget->fit_content_to_view();
|
||||||
|
});
|
||||||
|
|
||||||
auto zoom_out_action = GUI::CommonActions::make_zoom_out_action(
|
auto zoom_out_action = GUI::CommonActions::make_zoom_out_action(
|
||||||
[&](auto&) {
|
[&](auto&) {
|
||||||
widget->set_scale(widget->scale() / 1.44f);
|
widget->set_scale(widget->scale() / 1.44f);
|
||||||
|
@ -301,6 +306,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(view_menu->try_add_separator());
|
TRY(view_menu->try_add_separator());
|
||||||
TRY(view_menu->try_add_action(zoom_in_action));
|
TRY(view_menu->try_add_action(zoom_in_action));
|
||||||
TRY(view_menu->try_add_action(reset_zoom_action));
|
TRY(view_menu->try_add_action(reset_zoom_action));
|
||||||
|
TRY(view_menu->try_add_action(fit_image_to_view_action));
|
||||||
TRY(view_menu->try_add_action(zoom_out_action));
|
TRY(view_menu->try_add_action(zoom_out_action));
|
||||||
TRY(view_menu->try_add_separator());
|
TRY(view_menu->try_add_separator());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue