From c199b0e1aa83c177ceee17db1b5d9a7401ef2273 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 11 Apr 2020 19:20:40 +0200 Subject: [PATCH] LibGUI: Fill whole TableView cells with custom background color This was easier than I expected. :^) --- Libraries/LibGUI/TableView.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index 75787305644..7d518b4e045 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -106,10 +106,9 @@ void TableView::paint_event(PaintEvent& event) const Gfx::Font& font = column_metadata.font ? *column_metadata.font : this->font(); bool is_key_column = model()->key_column() == column_index; Gfx::Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height()); - if (is_key_column) { - auto cell_rect_for_fill = cell_rect.inflated(horizontal_padding() * 2, 0); + auto cell_rect_for_fill = cell_rect.inflated(horizontal_padding() * 2, 0); + if (is_key_column) painter.fill_rect(cell_rect_for_fill, key_column_background_color); - } auto cell_index = model()->index(row_index, column_index); if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { @@ -134,7 +133,7 @@ void TableView::paint_event(PaintEvent& event) auto cell_background_color = model()->data(cell_index, Model::Role::BackgroundColor); if (cell_background_color.is_valid()) { // FIXME: If all cells on a row provide a color, we should really fill the whole row! - painter.fill_rect(cell_rect, cell_background_color.to_color(background_color)); + painter.fill_rect(cell_rect_for_fill, cell_background_color.to_color(background_color)); } painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, Gfx::TextElision::Right); }