From 4a8d47edf8c5905ab6d5c35353776fe403374876 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 27 Jul 2021 17:37:16 +0200 Subject: [PATCH] LibGUI: Add some "fudge factor" around IconView item rects Previously there was a dead zone between the item icon and its text in IconViews. This meant that you could click between the icon and the text label and hit nothing. This patch improves the situation by inflating both rects so that they both overlap and become a bit easier to hit. --- Userland/Libraries/LibGUI/IconView.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/IconView.h b/Userland/Libraries/LibGUI/IconView.h index 27ef3c3c1d..8157a9da34 100644 --- a/Userland/Libraries/LibGUI/IconView.h +++ b/Userland/Libraries/LibGUI/IconView.h @@ -80,16 +80,19 @@ private: text = {}; } + Gfx::IntRect hot_icon_rect() const { return icon_rect.inflated(10, 10); } + Gfx::IntRect hot_text_rect() const { return text_rect.inflated(2, 2); } + bool is_intersecting(const Gfx::IntRect& rect) const { VERIFY(valid); - return icon_rect.intersects(rect) || text_rect.intersects(rect); + return hot_icon_rect().intersects(rect) || hot_text_rect().intersects(rect); } bool is_containing(const Gfx::IntPoint& point) const { VERIFY(valid); - return icon_rect.contains(point) || text_rect.contains(point); + return hot_icon_rect().contains(point) || hot_text_rect().contains(point); } Gfx::IntRect rect(bool wrapped = false) const