1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibGui: Add bounding of rubber band to IconView

This ensures the selection rubber band in icon views stays within the
visible area.
This commit is contained in:
FrHun 2021-07-16 22:28:39 +02:00 committed by Andreas Kling
parent 2c0df5e7e7
commit cc829ed9d2

View file

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