mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:37:43 +00:00
LibGUI: Bring entire cell into view after auto scroll into view
On account of row and column headers, when a user navigates to a cell (for example in the spreadsheet application) that is outside of the view, the cell is not properly aligned and so is partially cut-off. This fix takes into account the row and column headers when calculating the Rect to pass to the scroll_into_view function.
This commit is contained in:
parent
e824a2da90
commit
452150c632
2 changed files with 13 additions and 1 deletions
|
@ -276,7 +276,7 @@ void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_ho
|
||||||
Gfx::IntRect rect;
|
Gfx::IntRect rect;
|
||||||
switch (selection_behavior()) {
|
switch (selection_behavior()) {
|
||||||
case SelectionBehavior::SelectItems:
|
case SelectionBehavior::SelectItems:
|
||||||
rect = content_rect(index);
|
rect = cell_rect(index.row(), index.column());
|
||||||
break;
|
break;
|
||||||
case SelectionBehavior::SelectRows:
|
case SelectionBehavior::SelectRows:
|
||||||
rect = row_rect(index.row());
|
rect = row_rect(index.row());
|
||||||
|
@ -324,6 +324,17 @@ Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const
|
||||||
return content_rect(index.row(), index.column());
|
return content_rect(index.row(), index.column());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx::IntRect AbstractTableView::cell_rect(int row, int column) const
|
||||||
|
{
|
||||||
|
auto cell_rect = this->content_rect(row, column);
|
||||||
|
if (row_header().is_visible())
|
||||||
|
cell_rect.set_left(cell_rect.left() - row_header().width());
|
||||||
|
if (column_header().is_visible())
|
||||||
|
cell_rect.set_top(cell_rect.top() - column_header().height());
|
||||||
|
|
||||||
|
return cell_rect;
|
||||||
|
}
|
||||||
|
|
||||||
Gfx::IntRect AbstractTableView::row_rect(int item_index) const
|
Gfx::IntRect AbstractTableView::row_rect(int item_index) const
|
||||||
{
|
{
|
||||||
return { row_header().is_visible() ? row_header().width() : 0,
|
return { row_header().is_visible() ? row_header().width() : 0,
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
|
|
||||||
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
||||||
Gfx::IntRect content_rect(int row, int column) const;
|
Gfx::IntRect content_rect(int row, int column) const;
|
||||||
|
Gfx::IntRect cell_rect(int row, int column) const;
|
||||||
Gfx::IntRect row_rect(int item_index) const;
|
Gfx::IntRect row_rect(int item_index) const;
|
||||||
|
|
||||||
virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override;
|
virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue