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

LibGUI: Add optional grid and cursor styles to TableView

This commit is contained in:
Andreas Kling 2020-08-28 16:52:06 +02:00
parent 6614ee703b
commit 2222fc5e08
2 changed files with 47 additions and 0 deletions

View file

@ -141,6 +141,15 @@ void TableView::paint_event(PaintEvent& event)
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
}
}
if (m_grid_style == GridStyle::Horizontal || m_grid_style == GridStyle::Both)
painter.draw_line(cell_rect_for_fill.bottom_left(), cell_rect_for_fill.bottom_right(), palette().ruler());
if (m_grid_style == GridStyle::Vertical || m_grid_style == GridStyle::Both)
painter.draw_line(cell_rect_for_fill.top_right(), cell_rect_for_fill.bottom_right(), palette().ruler());
if (m_cursor_style == CursorStyle::Item && cell_index == cursor_index())
painter.draw_rect(cell_rect_for_fill, palette().text_cursor());
x += column_width + horizontal_padding() * 2;
}
++painted_item_index;
@ -211,4 +220,20 @@ void TableView::move_cursor(CursorMovement movement, SelectionUpdate selection_u
}
}
void TableView::set_grid_style(GridStyle style)
{
if (m_grid_style == style)
return;
m_grid_style = style;
update();
}
void TableView::set_cursor_style(CursorStyle style)
{
if (m_cursor_style == style)
return;
m_cursor_style = style;
update();
}
}