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.
This commit is contained in:
Andreas Kling 2021-07-27 17:37:16 +02:00
parent 75a41da69f
commit 4a8d47edf8
Notes: sideshowbarker 2024-07-18 08:02:29 +09:00

View file

@ -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