diff options
author | Andreas Kling <kling@serenityos.org> | 2021-07-27 17:37:16 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-27 18:27:49 +0200 |
commit | 4a8d47edf8c5905ab6d5c35353776fe403374876 (patch) | |
tree | 11c484a9463a47de3ae1c8b35ca330bc01c94227 /Userland | |
parent | 75a41da69f7abd4eecce1f7ddcd88b67d4271437 (diff) | |
download | serenity-4a8d47edf8c5905ab6d5c35353776fe403374876.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/IconView.h | 7 |
1 files 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 |