mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +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:
parent
6e16a5cdfa
commit
d64d2e4d09
2 changed files with 8 additions and 0 deletions
|
@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue