1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 08:02:13 +00:00

Spreadsheet+LibGUI: Calculate cell position given scroll position

Take into account the current scroll position when calculating the
position of cells. This way when the user scrolls either horizontally
or vertically, the calculations done to find the cell position
will be correct.
This commit is contained in:
martinfalisse 2022-03-07 16:26:21 +01:00 committed by Ali Mohammad Pur
parent 5759b25ca8
commit 11dffbd96f
3 changed files with 11 additions and 4 deletions

View file

@ -326,6 +326,12 @@ Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const
return content_rect(index.row(), index.column());
}
Gfx::IntRect AbstractTableView::content_rect_minus_scrollbars(const ModelIndex& index) const
{
auto naive_content_rect = content_rect(index.row(), index.column());
return { naive_content_rect.x() - horizontal_scrollbar().value(), naive_content_rect.y() - vertical_scrollbar().value(), naive_content_rect.width(), naive_content_rect.height() };
}
Gfx::IntRect AbstractTableView::row_rect(int item_index) const
{
return { row_header().is_visible() ? row_header().width() : 0,