1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 17:35:06 +00:00

LibGUI: Update GTableView's scrollbar range in response to resize.

This commit is contained in:
Andreas Kling 2019-02-28 13:25:52 +01:00
parent 82c22a7484
commit 827ec99a8f
2 changed files with 9 additions and 2 deletions

View file

@ -32,12 +32,18 @@ void GTableView::set_model(OwnPtr<GTableModel>&& model)
void GTableView::resize_event(GResizeEvent& event)
{
m_scrollbar->set_relative_rect(event.size().width() - m_scrollbar->preferred_size().width(), 0, m_scrollbar->preferred_size().width(), event.size().height());
update_scrollbar_range();
}
void GTableView::update_scrollbar_range()
{
int excess_height = max(0, (item_count() * item_height()) - height());
m_scrollbar->set_range(0, excess_height);
}
void GTableView::did_update_model()
{
int excess_height = max(0, (item_count() * item_height()) - height());
m_scrollbar->set_range(0, excess_height);
update_scrollbar_range();
update();
}