LibGUI: Scroll selection into view when the IconView is first laid out

If we set selection before the IconView is laid out, it has no size.
So it can't correctly calculate where to scroll. Forcing scroll after
the first resize fixes that.
This commit is contained in:
speles 2021-03-01 23:32:27 +02:00 committed by Andreas Kling
commit d64d2e4d09
Notes: sideshowbarker 2024-07-18 21:39:25 +09:00
2 changed files with 8 additions and 0 deletions

View file

@ -72,6 +72,12 @@ void IconView::resize_event(ResizeEvent& event)
{
AbstractView::resize_event(event);
update_content_size();
if (!m_had_valid_size) {
m_had_valid_size = true;
if (!selection().is_empty())
scroll_into_view(selection().first());
}
}
void IconView::reinit_item_cache() const