diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-03-22 14:08:51 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-22 23:22:58 +0100 |
commit | d8819c2d0eef153ff98c9bc1760e612cd5ff8496 (patch) | |
tree | dd89107709074abb73587a67b759fa16c597f66d /Userland | |
parent | c574b972464553e18640b8fc6889ddd2cc4788c5 (diff) | |
download | serenity-d8819c2d0eef153ff98c9bc1760e612cd5ff8496.zip |
ImageViewer: Scale image to window on startup
We used to do the opposite, meaning that a huge images make the window
bigger than the screen. We now define a range for the window size and
scale the image if it doesn't fit un the current scope.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 86c033a7e4..ecc3ed1bd4 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -226,8 +226,6 @@ void ViewWidget::resize_window() auto absolute_bitmap_rect = content_rect(); absolute_bitmap_rect.translate_by(window()->rect().top_left()); - if (window()->rect().contains(absolute_bitmap_rect)) - return; if (!m_bitmap) return; @@ -239,8 +237,14 @@ void ViewWidget::resize_window() if (new_size.height() < 200) new_size.set_height(200); + if (new_size.width() > 500) + new_size = { 500, 500 * absolute_bitmap_rect.height() / absolute_bitmap_rect.width() }; + if (new_size.height() > 500) + new_size = { 500 * absolute_bitmap_rect.width() / absolute_bitmap_rect.height(), 500 }; + new_size.set_height(new_size.height() + m_toolbar_height); window()->resize(new_size); + scale_image_for_window(); } void ViewWidget::set_bitmap(Gfx::Bitmap const* bitmap) |