From 17eb77cf55970b7b633c1758a8635b9e6d96aabf Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 22 Mar 2023 14:15:25 -0400 Subject: [PATCH] ImageViewer: Scale image to window on resize --- Userland/Applications/ImageViewer/ViewWidget.cpp | 6 ++++++ Userland/Applications/ImageViewer/ViewWidget.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index ecc3ed1bd4e..a3dca258b51 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -213,6 +213,12 @@ void ViewWidget::drop_event(GUI::DropEvent& event) on_drop(event); } +void ViewWidget::resize_event(GUI::ResizeEvent& event) +{ + event.accept(); + scale_image_for_window(); +} + void ViewWidget::scale_image_for_window() { set_original_rect(m_bitmap->rect()); diff --git a/Userland/Applications/ImageViewer/ViewWidget.h b/Userland/Applications/ImageViewer/ViewWidget.h index c67b3c69bf7..4d6d7043e61 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.h +++ b/Userland/Applications/ImageViewer/ViewWidget.h @@ -61,6 +61,7 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; virtual void drag_enter_event(GUI::DragEvent&) override; virtual void drop_event(GUI::DropEvent&) override; + virtual void resize_event(GUI::ResizeEvent&) override; void set_bitmap(Gfx::Bitmap const* bitmap); void animate();