diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-03-22 01:16:06 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-22 23:22:58 +0100 |
commit | 5cceae821ddc9020d21d8c1caf6409d12000a8dc (patch) | |
tree | d6ed0ad215cd6957f1c0153a7dd84b83742e78f7 | |
parent | fd0b809d541fd5c02b7d602e0722c56c8fa71dff (diff) | |
download | serenity-5cceae821ddc9020d21d8c1caf6409d12000a8dc.zip |
ImageViewer: Don't resize window on image rotation or flip
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.cpp | 16 | ||||
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.h | 1 |
2 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 428aa9d18b..80cad1c7e3 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -48,19 +48,13 @@ void ViewWidget::clear() void ViewWidget::flip(Gfx::Orientation orientation) { m_bitmap = m_bitmap->flipped(orientation).release_value_but_fixme_should_propagate_errors(); - set_original_rect(m_bitmap->rect()); - set_scale(scale()); - - resize_window(); + scale_image_for_window(); } void ViewWidget::rotate(Gfx::RotationDirection rotation_direction) { m_bitmap = m_bitmap->rotated(rotation_direction).release_value_but_fixme_should_propagate_errors(); - set_original_rect(m_bitmap->rect()); - set_scale(scale()); - - resize_window(); + scale_image_for_window(); } bool ViewWidget::is_next_available() const @@ -215,6 +209,12 @@ void ViewWidget::drop_event(GUI::DropEvent& event) on_drop(event); } +void ViewWidget::scale_image_for_window() +{ + set_original_rect(m_bitmap->rect()); + fit_content_to_view(GUI::AbstractZoomPanWidget::FitType::Both); +} + void ViewWidget::resize_window() { if (window()->is_fullscreen() || window()->is_maximized()) diff --git a/Userland/Applications/ImageViewer/ViewWidget.h b/Userland/Applications/ImageViewer/ViewWidget.h index d87596cef7..c67b3c69bf 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.h +++ b/Userland/Applications/ImageViewer/ViewWidget.h @@ -37,6 +37,7 @@ public: void set_scaled_for_first_image(bool val) { m_scaled_for_first_image = val; } void set_path(DeprecatedString const& path); void resize_window(); + void scale_image_for_window(); void set_scaling_mode(Gfx::Painter::ScalingMode); bool is_next_available() const; |