From cc829ed9d278570d7bc2a7b0f877238b7f416fb5 Mon Sep 17 00:00:00 2001 From: FrHun <28605587+frhun@users.noreply.github.com> Date: Fri, 16 Jul 2021 22:28:39 +0200 Subject: [PATCH] LibGui: Add bounding of rubber band to IconView This ensures the selection rubber band in icon views stays within the visible area. --- Userland/Libraries/LibGUI/IconView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 87d17b573b..f4333b2c36 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -246,9 +246,9 @@ void IconView::mouseup_event(MouseEvent& event) AbstractView::mouseup_event(event); } -bool IconView::update_rubber_banding(const Gfx::IntPoint& position) +bool IconView::update_rubber_banding(const Gfx::IntPoint& input_position) { - auto adjusted_position = to_content_position(position); + auto adjusted_position = to_content_position(input_position.constrained(widget_inner_rect())); if (m_rubber_band_current != adjusted_position) { auto prev_rect = Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_current); auto prev_rubber_band_fill_rect = prev_rect.shrunken(1, 1);