GTableView: Tweak the look of column headers.

This commit is contained in:
Andreas Kling 2019-03-04 10:54:34 +01:00
parent 4ea7a51ecd
commit 7e955f7b60
Notes: sideshowbarker 2024-07-19 15:33:20 +09:00

View file

@ -151,6 +151,8 @@ void GTableView::paint_event(GPaintEvent& event)
// Untranslate the painter and paint the column headers.
painter.translate(0, m_vertical_scrollbar->value());
painter.fill_rect({ 0, 0, exposed_width, header_height() }, Color::LightGray);
painter.draw_line({ 0, 0 }, { exposed_width - 1, 0 }, Color::White);
painter.draw_line({ 0, header_height() - 1 }, { exposed_width - 1, header_height() - 1 }, Color::DarkGray);
int x_offset = 0;
for (int column_index = 0; column_index < m_model->column_count(); ++column_index) {
auto column_metadata = m_model->column_metadata(column_index);
@ -160,14 +162,11 @@ void GTableView::paint_event(GPaintEvent& event)
painter.draw_text(cell_rect.translated(horizontal_padding(), 0), m_model->column_name(column_index), TextAlignment::CenterLeft, Color::Black);
x_offset += column_width + horizontal_padding() * 2;
// Draw column separator.
painter.draw_line(cell_rect.top_left(), cell_rect.bottom_left(), Color::White);
painter.draw_line(cell_rect.top_right(), cell_rect.bottom_right(), Color::DarkGray);
painter.draw_line(cell_rect.top_left().translated(0, 1), cell_rect.bottom_left().translated(0, -1), Color::White);
painter.draw_line(cell_rect.top_right(), cell_rect.bottom_right().translated(0, -1), Color::DarkGray);
}
// Draw the "start" of a new column to make the last separator look right.
painter.draw_line({ x_offset, 0 }, { x_offset, header_height() - 1 }, Color::White);
painter.draw_line({ 0, 0 }, { exposed_width - 1, 0 }, Color::White);
painter.draw_line({ 0, header_height() - 1 }, { exposed_width - 1, header_height() - 1 }, Color::DarkGray);
painter.draw_line({ x_offset, 1 }, { x_offset, header_height() - 2 }, Color::White);
// Then untranslate and fill in the scroll corner. This is pretty messy, tbh.
painter.translate(m_horizontal_scrollbar->value(), 0);