mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-23 05:46:06 +00:00
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:
@@ -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
|
||||
|
||||
@@ -182,6 +182,8 @@ private:
|
||||
mutable bool m_item_data_cache_valid { false };
|
||||
|
||||
bool m_changing_selection { false };
|
||||
|
||||
bool m_had_valid_size { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user